aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2013-10-20 17:35:30 +0000
committerPascal Quantin <pascal.quantin@gmail.com>2013-10-20 17:35:30 +0000
commitcf9bbdeceffbec1798dfc8cda6d2d1af51670770 (patch)
tree46746502c52199a8d64af666ba971dff4d4f12d4
parent33e376d180f10b32ebb66a022bbbad9bd3d68681 (diff)
From RobiOneKenobi via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9297 :
Add support for MSVC2013 svn path=/trunk/; revision=52716
-rw-r--r--capture_win_ifnames.c16
-rw-r--r--config.nmake36
-rw-r--r--epan/dissectors/Makefile.nmake4
-rw-r--r--epan/emem.c34
-rw-r--r--ui/win32/file_dlg_win32.c233
5 files changed, 149 insertions, 174 deletions
diff --git a/capture_win_ifnames.c b/capture_win_ifnames.c
index a20945cc80..8dd8d860bf 100644
--- a/capture_win_ifnames.c
+++ b/capture_win_ifnames.c
@@ -201,6 +201,21 @@ parse_as_guid(const char *guid_text, GUID *guid)
/**********************************************************************************/
gboolean IsWindowsVistaOrLater()
{
+#if (_MSC_VER >= 1800)
+ /*
+ * On VS2103, GetVersionEx is deprecated. Microsoft recommend to
+ * use VerifyVersionInfo instead
+ */
+ OSVERSIONINFOEX osvi;
+ DWORDLONG dwlConditionMask = 0;
+ int op = VER_GREATER_EQUAL;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ osvi.dwMajorVersion = 6;
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
+ return VerifyVersionInfo(&osvi, VER_MAJORVERSION, dwlConditionMask);
+#else
OSVERSIONINFO osvi;
SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
@@ -210,6 +225,7 @@ gboolean IsWindowsVistaOrLater()
return osvi.dwMajorVersion >= 6;
}
return FALSE;
+#endif
}
/**********************************************************************************/
diff --git a/config.nmake b/config.nmake
index b4f7acc5f3..0017c95903 100644
--- a/config.nmake
+++ b/config.nmake
@@ -145,6 +145,14 @@ PROCESSOR_ARCHITECTURE=amd64
# Visual C++ 11.0, _MSC_VER 1700, msvcr110.dll
#MSVC_VARIANT=MSVC2012
+# "Microsoft Visual Studio 2013"
+# Visual C++ 12.0, _MSC_VER 1800, msvcr120.dll
+#MSVC_VARIANT=MSVC2013
+
+# "Microsoft Visual Studio 2013 Express Edition"
+# Visual C++ 12.0, _MSC_VER 1800, msvcr120.dll
+#MSVC_VARIANT=MSVC2013EE
+
# The default if we haven't set a system environment variable or
# uncommented an entry above. We default to the version recommended
# in the Developer's Guide, namely MSVC++ 2010 Express Edition.
@@ -864,6 +872,8 @@ MSC_VER_REQUIRED=1500
MSC_VER_REQUIRED=1600
!ELSEIF "$(MSVC_VARIANT)" == "MSVC2012" || "$(MSVC_VARIANT)" == "MSVC2012EE"
MSC_VER_REQUIRED=1700
+!ELSEIF "$(MSVC_VARIANT)" == "MSVC2013" || "$(MSVC_VARIANT)" == "MSVC2013EE"
+MSC_VER_REQUIRED=1800
!ELSE
!ERROR MSVC_VARIANT unknown
!ENDIF
@@ -921,7 +931,9 @@ APPVER=5.02
"$(MSVC_VARIANT)" == "MSVC2010" || \
"$(MSVC_VARIANT)" == "MSVC2010EE" || \
"$(MSVC_VARIANT)" == "MSVC2012" || \
- "$(MSVC_VARIANT)" == "MSVC2012EE"
+ "$(MSVC_VARIANT)" == "MSVC2012EE" || \
+ "$(MSVC_VARIANT)" == "MSVC2013" || \
+ "$(MSVC_VARIANT)" == "MSVC2013EE"
LOCAL_CFLAGS=/Zi /W3 /MD /DWIN32_LEAN_AND_MEAN /DMSC_VER_REQUIRED=$(MSC_VER_REQUIRED) \
/D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DPSAPI_VERSION=1
@@ -956,7 +968,9 @@ WARNINGS_CFLAGS=/w34295
"$(MSVC_VARIANT)" == "MSVC2010" || \
"$(MSVC_VARIANT)" == "MSVC2010EE" || \
"$(MSVC_VARIANT)" == "MSVC2012" || \
- "$(MSVC_VARIANT)" == "MSVC2012EE"
+ "$(MSVC_VARIANT)" == "MSVC2012EE" || \
+ "$(MSVC_VARIANT)" == "MSVC2013" || \
+ "$(MSVC_VARIANT)" == "MSVC2013EE"
LOCAL_CFLAGS= $(LOCAL_CFLAGS) /MP
!ENDIF
@@ -1138,7 +1152,23 @@ MSVCR_DLL=$(PROGRAM_FILES)\Microsoft Visual Studio 10.0\VC\redist\$(TARGET_MACHI
# with Visual Studio 2010.
#
MSVCR_DLL=$(PROGRAM_FILES)\Microsoft Visual Studio 11.0\VC\redist\$(TARGET_MACHINE)\Microsoft.VC110.CRT\*.*
-
+!ELSEIF "$(MSVC_VARIANT)" == "MSVC2013" || "$(MSVC_VARIANT)" == "MSVC2013EE"
+#
+# EE version added as per bug https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9227
+#
+# For MSVC 2013, we "Install a particular Visual C++
+# assembly as a private assembly for the application", by copying
+# the contents of the Microsoft.VC120.CRT folder to the target directory.
+# This is done to reduce the size of the installer; it also makes
+# a portable version work, as the C runtime doesn't have to be
+# installed on the target machine.
+#
+# Note: for what it's worth, Microsoft recommends "Using the Visual C++
+# Redistributable Package", rather than "Installing a particular Visual
+# C++ assembly as a private assembly for the application", starting
+# with Visual Studio 2010.
+#
+MSVCR_DLL=$(PROGRAM_FILES)\Microsoft Visual Studio 12.0\VC\redist\$(TARGET_MACHINE)\Microsoft.VC120.CRT\*.*
!ELSE
!ERROR MSVC_VARIANT unknown
!ENDIF
diff --git a/epan/dissectors/Makefile.nmake b/epan/dissectors/Makefile.nmake
index b62c81a20b..6e4df3adf9 100644
--- a/epan/dissectors/Makefile.nmake
+++ b/epan/dissectors/Makefile.nmake
@@ -36,7 +36,9 @@ dissectors.lib: register.obj packet-ncp2222.c $(GENERATED_HEADER_FILES) ../../co
"$(MSVC_VARIANT)" != "MSVC2010" && \
"$(MSVC_VARIANT)" != "MSVC2010EE" && \
"$(MSVC_VARIANT)" != "MSVC2012" && \
- "$(MSVC_VARIANT)" != "MSVC2012EE"
+ "$(MSVC_VARIANT)" != "MSVC2012EE" && \
+ "$(MSVC_VARIANT)" != "MSVC2013" && \
+ "$(MSVC_VARIANT)" != "MSVC2013EE"
# Disable debug for large dissectors
packet-rrc.obj : packet-rrc.c
$(CC) $(CFLAGS) /Zd /Fd.\ -c $?
diff --git a/epan/emem.c b/epan/emem.c
index 15624e6571..d1de44565f 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -174,7 +174,7 @@ static gboolean debug_use_memory_scrubber = FALSE;
#if defined (_WIN32)
static SYSTEM_INFO sysinfo;
-static OSVERSIONINFO versinfo;
+static gboolean iswindowsplatform;
static int pagesize;
#elif defined(USE_GUARD_PAGES)
static intptr_t pagesize;
@@ -389,6 +389,23 @@ emem_init(void)
GetSystemInfo(&sysinfo);
pagesize = sysinfo.dwPageSize;
+#if (_MSC_VER >= 1800)
+ /*
+ * On VS2103, GetVersionEx is deprecated. Microsoft recommend to
+ * use VerifyVersionInfo instead
+ */
+ {
+ OSVERSIONINFOEX osvi;
+ DWORDLONG dwlConditionMask = 0;
+ int op = VER_EQUAL;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ osvi.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
+ VER_SET_CONDITION(dwlConditionMask, VER_PLATFORMID, op);
+ iswindowsplatform = VerifyVersionInfo(&osvi, VER_PLATFORMID, dwlConditionMask);
+ }
+#else
/* calling GetVersionEx using the OSVERSIONINFO structure.
* OSVERSIONINFOEX requires Win NT4 with SP6 or newer NT Versions.
* OSVERSIONINFOEX will fail on Win9x and older NT Versions.
@@ -397,8 +414,15 @@ emem_init(void)
* http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp
* http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfoex_str.asp
*/
- versinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&versinfo);
+ {
+ OSVERSIONINFO versinfo;
+
+ ZeroMemory(&versinfo, sizeof(OSVERSIONINFO));
+ versinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&versinfo);
+ iswindowsplatform = (versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
+ }
+#endif
#elif defined(USE_GUARD_PAGES)
pagesize = sysconf(_SC_PAGESIZE);
@@ -734,9 +758,9 @@ emem_create_chunk_gp(size_t size)
prot2 = (char *) ((((intptr_t) buf_end - (1 * pagesize)) / pagesize) * pagesize);
ret = VirtualProtect(prot1, pagesize, PAGE_NOACCESS, &oldprot);
- g_assert(ret != 0 || versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
+ g_assert(ret != 0 || iswindowsplatform);
ret = VirtualProtect(prot2, pagesize, PAGE_NOACCESS, &oldprot);
- g_assert(ret != 0 || versinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS);
+ g_assert(ret != 0 || iswindowsplatform);
npc->amount_free_init = (unsigned int) (prot2 - prot1 - pagesize);
npc->free_offset_init = (unsigned int) (prot1 - npc->buf) + pagesize;
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index b2d8d29128..110754fed9 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -127,6 +127,65 @@ static print_args_t print_args;
static HWND g_sf_hwnd = NULL;
static char *g_dfilter_str = NULL;
+static int
+win32_get_ofnsize()
+{
+ gboolean bVerGE5 = FALSE;
+ int ofnsize;
+ /* Remarks on OPENFILENAME_SIZE_VERSION_400:
+ *
+ * MSDN states that OPENFILENAME_SIZE_VERSION_400 should be used with
+ * WINVER and _WIN32_WINNT >= 0x0500.
+ * Unfortunately all these are compiler constants, while the underlying is a
+ * problem based is a length check of the runtime version used.
+ *
+ * Instead of using OPENFILENAME_SIZE_VERSION_400, just malloc
+ * the OPENFILENAME size plus 12 bytes.
+ * These 12 bytes are the difference between the two versions of this struct.
+ *
+ * Interestingly this fixes a bug, so the places bar e.g. "My Documents"
+ * is displayed - which wasn't the case with the former implementation.
+ *
+ * XXX - It's unclear if this length+12 works on all supported platforms,
+ * NT4 is the question here. However, even if it fails, we must calculate
+ * the length based on the runtime, not the compiler version anyway ...
+ */
+ /* This assumption does not work when compiling with MSVC2008EE as
+ * the open dialog window does not appear.
+ * Instead detect Windows version at runtime and choose size accordingly */
+#if (_MSC_VER >= 1500)
+ /*
+ * On VS2103, GetVersionEx is deprecated. Microsoft recommend to
+ * use VerifyVersionInfo instead
+ */
+#if (_MSC_VER >= 1800)
+ OSVERSIONINFOEX osvi;
+ DWORDLONG dwlConditionMask = 0;
+ int op = VER_GREATER_EQUAL;
+ /* Initialize the OSVERSIONINFOEX structure. */
+ SecureZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ osvi.dwMajorVersion = 5;
+ /* Initialize the condition mask. */
+ VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op);
+ /* Perform the test. */
+ bVerGE5=VerifyVersionInfo(
+ &osvi,
+ VER_MAJORVERSION,
+ dwlConditionMask);
+#else
+ OSVERSIONINFO osvi;
+ SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osvi);
+ bVerGE5 = (osvi.dwMajorVersion >= 5);
+#endif /* _MSC_VER >= 1800 */
+ ofnsize = (bVerGE5)?sizeof(OPENFILENAME):OPENFILENAME_SIZE_VERSION_400;
+#else
+ ofnsize = sizeof(OPENFILENAME)+12;
+#endif /* _MSC_VER >= 1500 */
+ return ofnsize;
+}
/*
* According to http://msdn.microsoft.com/en-us/library/bb776913.aspx
* we should use IFileOpenDialog and IFileSaveDialog on Windows Vista
@@ -139,9 +198,6 @@ win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
gboolean gofn_ok;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
if (!file_name || !display_filter)
return FALSE;
@@ -156,40 +212,7 @@ win32_open_file (HWND h_wnd, GString *file_name, GString *display_filter) {
g_free(g_dfilter_str);
g_dfilter_str = NULL;
}
-
- /* Remarks on OPENFILENAME_SIZE_VERSION_400:
- *
- * MSDN states that OPENFILENAME_SIZE_VERSION_400 should be used with
- * WINVER and _WIN32_WINNT >= 0x0500.
- * Unfortunately all these are compiler constants, while the underlying is a
- * problem based is a length check of the runtime version used.
- *
- * Instead of using OPENFILENAME_SIZE_VERSION_400, just malloc
- * the OPENFILENAME size plus 12 bytes.
- * These 12 bytes are the difference between the two versions of this struct.
- *
- * Interestingly this fixes a bug, so the places bar e.g. "My Documents"
- * is displayed - which wasn't the case with the former implementation.
- *
- * XXX - It's unclear if this length+12 works on all supported platforms,
- * NT4 is the question here. However, even if it fails, we must calculate
- * the length based on the runtime, not the compiler version anyway ...
- */
- /* This assumption does not work when compiling with MSVC2008EE as
- * the open dialog window does not appear.
- * Instead detect Windows version at runtime and choose size accordingly */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -331,9 +354,6 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
gboolean gsfn_ok;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
gboolean discard_comments = FALSE;
if (!file_name || !file_type || !compressed)
@@ -355,19 +375,7 @@ win32_save_as_file(HWND h_wnd, capture_file *cf, GString *file_name, int *file_t
return FALSE; /* shouldn't happen - the "Save As..." item should be disabled if we can't save the file */
g_compressed = FALSE;
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -428,9 +436,6 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
gboolean gsfn_ok;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
if (!file_name || !file_type || !compressed || !range)
return FALSE;
@@ -448,19 +453,7 @@ win32_export_specified_packets_file(HWND h_wnd, capture_file *cf,
g_cf = cf;
g_compressed = FALSE;
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -518,9 +511,6 @@ win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filter, int *
TCHAR file_name16[MAX_PATH] = _T("");
int ofnsize;
gboolean gofn_ok;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
if (!file_name || !display_filter || !merge_type)
return FALSE;
@@ -536,19 +526,7 @@ win32_merge_file (HWND h_wnd, GString *file_name, GString *display_filter, int *
g_dfilter_str = NULL;
}
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -610,25 +588,10 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
char *dirname;
cf_print_status_t status;
int ofnsize;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
g_cf = cf;
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -729,9 +692,6 @@ win32_export_raw_file(HWND h_wnd, capture_file *cf) {
char *file_name8;
int fd;
int ofnsize;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
if (!cf->finfo_selected) {
/* This shouldn't happen */
@@ -739,19 +699,7 @@ win32_export_raw_file(HWND h_wnd, capture_file *cf) {
return;
}
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -818,9 +766,6 @@ win32_export_sslkeys_file(HWND h_wnd) {
int fd;
int ofnsize;
int keylist_size;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
keylist_size = ssl_session_key_count();
if (keylist_size==0) {
@@ -829,19 +774,7 @@ win32_export_sslkeys_file(HWND h_wnd) {
return;
}
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -906,23 +839,8 @@ win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list) {
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;
@@ -967,23 +885,8 @@ win32_import_color_file(HWND h_wnd, gpointer color_filters) {
TCHAR file_name[MAX_PATH] = _T("");
gchar *dirname;
int ofnsize;
-#if (_MSC_VER >= 1500)
- OSVERSIONINFO osvi;
-#endif
- /* see OPENFILENAME comment in win32_open_file */
-#if (_MSC_VER >= 1500)
- SecureZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5) {
- ofnsize = sizeof(OPENFILENAME);
- } else {
- ofnsize = OPENFILENAME_SIZE_VERSION_400;
- }
-#else
- ofnsize = sizeof(OPENFILENAME) + 12;
-#endif
+ ofnsize = win32_get_ofnsize();
ofn = g_malloc0(ofnsize);
ofn->lStructSize = ofnsize;