Changeset 50976 in vbox for trunk/src/VBox
- Timestamp:
- Apr 4, 2014 7:34:38 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 93145
- Location:
- trunk/src/VBox/Runtime/r3/win
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/RTSystemQueryOSInfo-win.cpp
r47596 r50976 261 261 { 262 262 /* just copy the entire string. */ 263 memcpy(szTmp, g_WinOsInfoEx.szCSDVersion, sizeof(g_WinOsInfoEx.szCSDVersion)); 264 szTmp[sizeof(g_WinOsInfoEx.szCSDVersion)] = '\0'; 263 char *pszTmp = szTmp; 264 int rc = RTUtf16ToUtf8Ex(g_WinOsInfoEx.szCSDVersion, RT_ELEMENTS(g_WinOsInfoEx.szCSDVersion), 265 &pszTmp, sizeof(szTmp), NULL); 266 if (RT_SUCCESS(rc)) 267 RTStrStripR(szTmp); 268 else 269 szTmp[0] = '\0'; 265 270 AssertCompile(sizeof(szTmp) > sizeof(g_WinOsInfoEx.szCSDVersion)); 266 271 } -
trunk/src/VBox/Runtime/r3/win/init-win.cpp
r48304 r50976 48 48 *******************************************************************************/ 49 49 /** Windows DLL loader protection level. */ 50 DECLHIDDEN(RTR3WINLDRPROT) g_enmWinLdrProt = RTR3WINLDRPROT_NONE;50 DECLHIDDEN(RTR3WINLDRPROT) g_enmWinLdrProt = RTR3WINLDRPROT_NONE; 51 51 /** Our simplified windows version. */ 52 DECLHIDDEN(RTWINOSTYPE) g_enmWinVer = kRTWinOSType_UNKNOWN;52 DECLHIDDEN(RTWINOSTYPE) g_enmWinVer = kRTWinOSType_UNKNOWN; 53 53 /** Extended windows version information. */ 54 DECLHIDDEN(OSVERSIONINFOEX )g_WinOsInfoEx;54 DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx; 55 55 /** The native kernel32.dll handle. */ 56 DECLHIDDEN(HMODULE) g_hModKernel32 = NULL;56 DECLHIDDEN(HMODULE) g_hModKernel32 = NULL; 57 57 /** The native ntdll.dll handle. */ 58 DECLHIDDEN(HMODULE) g_hModNtDll = NULL;58 DECLHIDDEN(HMODULE) g_hModNtDll = NULL; 59 59 60 60 … … 92 92 </pre> 93 93 */ 94 static RTWINOSTYPE rtR3InitWinSimplifiedVersion(OSVERSIONINFOEX const *pOSInfoEx)94 static RTWINOSTYPE rtR3InitWinSimplifiedVersion(OSVERSIONINFOEXW const *pOSInfoEx) 95 95 { 96 96 RTWINOSTYPE enmVer = kRTWinOSType_UNKNOWN; … … 169 169 170 170 171 DECLHIDDEN(int) rtR3InitNativeObtrusiveWorker(void) 171 /** 172 * Initializes the global variables related to windows version. 173 */ 174 static void rtR3InitWindowsVersion(void) 175 { 176 Assert(g_hModNtDll != NULL); 177 178 /* 179 * ASSUMES OSVERSIONINFOEX starts with the exact same layout as OSVERSIONINFO (safe). 180 */ 181 AssertCompileMembersSameSizeAndOffset(OSVERSIONINFOEX, szCSDVersion, OSVERSIONINFO, szCSDVersion); 182 AssertCompileMemberOffset(OSVERSIONINFOEX, wServicePackMajor, sizeof(OSVERSIONINFO)); 183 184 /* 185 * Use the NT version of GetVersionExW so we don't get fooled by 186 * compatability shims. 187 */ 188 RT_ZERO(g_WinOsInfoEx); 189 g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 190 191 LONG (__stdcall *pfnRtlGetVersion)(OSVERSIONINFOEXW *); 192 *(FARPROC *)&pfnRtlGetVersion = GetProcAddress(g_hModNtDll, "RtlGetVersion"); 193 LONG rcNt = -1; 194 if (pfnRtlGetVersion) 195 rcNt = pfnRtlGetVersion(&g_WinOsInfoEx); 196 if (rcNt != 0) 197 { 198 /* 199 * Couldn't find it or it failed, try the windows version of the API. 200 */ 201 RT_ZERO(g_WinOsInfoEx); 202 g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); 203 if (!GetVersionExW((POSVERSIONINFOW)&g_WinOsInfoEx)) 204 { 205 /* 206 * If that didn't work either, just get the basic version bits. 207 */ 208 RT_ZERO(g_WinOsInfoEx); 209 g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 210 if (GetVersionExA((POSVERSIONINFOA)&g_WinOsInfoEx)) 211 Assert(g_WinOsInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT || g_WinOsInfoEx.dwMajorVersion < 5); 212 else 213 { 214 AssertBreakpoint(); 215 RT_ZERO(g_WinOsInfoEx); 216 } 217 } 218 } 219 220 if (g_WinOsInfoEx.dwOSVersionInfoSize) 221 g_enmWinVer = rtR3InitWinSimplifiedVersion(&g_WinOsInfoEx); 222 } 223 224 225 static int rtR3InitNativeObtrusiveWorker(void) 172 226 { 173 227 /* … … 176 230 UINT fOldErrMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); 177 231 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX | fOldErrMode); 178 179 /*180 * Query the Windows version.181 * ASSUMES OSVERSIONINFOEX starts with the exact same layout as OSVERSIONINFO (safe).182 */183 AssertCompileMembersSameSizeAndOffset(OSVERSIONINFOEX, szCSDVersion, OSVERSIONINFO, szCSDVersion);184 AssertCompileMemberOffset(OSVERSIONINFOEX, wServicePackMajor, sizeof(OSVERSIONINFO));185 RT_ZERO(g_WinOsInfoEx);186 g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);187 if (!GetVersionExA((POSVERSIONINFOA)&g_WinOsInfoEx))188 {189 /* Fallback, just get the basic info. */190 RT_ZERO(g_WinOsInfoEx);191 g_WinOsInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);192 if (GetVersionExA((POSVERSIONINFOA)&g_WinOsInfoEx))193 Assert(g_WinOsInfoEx.dwPlatformId != VER_PLATFORM_WIN32_NT || g_WinOsInfoEx.dwMajorVersion < 5);194 else195 {196 AssertBreakpoint();197 RT_ZERO(g_WinOsInfoEx);198 }199 }200 if (g_WinOsInfoEx.dwOSVersionInfoSize)201 g_enmWinVer = rtR3InitWinSimplifiedVersion(&g_WinOsInfoEx);202 232 203 233 /* … … 252 282 return VERR_INTERNAL_ERROR_2; 253 283 284 rtR3InitWindowsVersion(); 285 254 286 int rc = VINF_SUCCESS; 255 287 if (!(fFlags & RTR3INIT_FLAGS_UNOBTRUSIVE)) -
trunk/src/VBox/Runtime/r3/win/internal-r3-win.h
r47596 r50976 60 60 * Global Variables * 61 61 *******************************************************************************/ 62 extern DECLHIDDEN(RTR3WINLDRPROT) g_enmWinLdrProt;63 extern DECLHIDDEN(RTWINOSTYPE) g_enmWinVer;62 extern DECLHIDDEN(RTR3WINLDRPROT) g_enmWinLdrProt; 63 extern DECLHIDDEN(RTWINOSTYPE) g_enmWinVer; 64 64 #ifdef _WINDEF_ 65 extern DECLHIDDEN(HMODULE) g_hModKernel32;66 extern DECLHIDDEN(HMODULE) g_hModNtDll;67 extern DECLHIDDEN(OSVERSIONINFOEX ) g_WinOsInfoEx;65 extern DECLHIDDEN(HMODULE) g_hModKernel32; 66 extern DECLHIDDEN(HMODULE) g_hModNtDll; 67 extern DECLHIDDEN(OSVERSIONINFOEXW) g_WinOsInfoEx; 68 68 #endif 69 69
Note:
See TracChangeset
for help on using the changeset viewer.