diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-06-12 15:30:35 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-06-13 01:27:26 +0000 |
commit | 010e55ccf42d82ea5c4e085ab58a9a9764c45582 (patch) | |
tree | 672946878addc8b38b1d4ed47c60b0f6d7ffffcc /wsutil | |
parent | d72b29c1cb6daa0510cb0e721e4dd20645aa450f (diff) |
Don't assume we can get a module handle for kernel32.dll.
A failure "shouldn't happen", but check anyway; if nothing else, that
squelches some complaining from the VS Code Analysis tool.
Change-Id: I9b06db399741176d0e9f859eb650bed8a2f96d9c
Reviewed-on: https://code.wireshark.org/review/15860
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/os_version_info.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/wsutil/os_version_info.c b/wsutil/os_version_info.c index 2eaaeff301..501379d0bc 100644 --- a/wsutil/os_version_info.c +++ b/wsutil/os_version_info.c @@ -199,6 +199,7 @@ void get_os_version_info(GString *str) { #if defined(_WIN32) + HMODULE kernel_dll_handle; OSVERSIONINFOEX info; SYSTEM_INFO system_info; nativesi_func_ptr nativesi_func; @@ -238,7 +239,15 @@ get_os_version_info(GString *str) memset(&system_info, '\0', sizeof system_info); /* Look for and use the GetNativeSystemInfo() function if available to get the correct processor * architecture even when running 32-bit Wireshark in WOW64 (x86 emulation on 64-bit Windows) */ - nativesi_func = (nativesi_func_ptr)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo"); + kernel_dll_handle = GetModuleHandle(_T("kernel32.dll"); + if (kernel_dll_handle == NULL) { + /* + * XXX - get the failure reason. + */ + g_string_append(str, "unknown Windows version"); + return; + } + nativesi_func = (nativesi_func_ptr)GetProcAddress(kernel_dll_handle), "GetNativeSystemInfo"); if(nativesi_func) nativesi_func(&system_info); else |