Package winappdbg :: Package win32 :: Module version
[hide private]
[frames] | no frames]

Source Code for Module winappdbg.win32.version

  1  # Copyright (c) 2009-2010, Mario Vilas 
  2  # All rights reserved. 
  3  # 
  4  # Redistribution and use in source and binary forms, with or without 
  5  # modification, are permitted provided that the following conditions are met: 
  6  # 
  7  #     * Redistributions of source code must retain the above copyright notice, 
  8  #       this list of conditions and the following disclaimer. 
  9  #     * Redistributions in binary form must reproduce the above copyright 
 10  #       notice,this list of conditions and the following disclaimer in the 
 11  #       documentation and/or other materials provided with the distribution. 
 12  #     * Neither the name of the copyright holder nor the names of its 
 13  #       contributors may be used to endorse or promote products derived from 
 14  #       this software without specific prior written permission. 
 15  # 
 16  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 17  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 18  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 19  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 20  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 21  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 22  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 23  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 24  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 25  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 26  # POSSIBILITY OF SUCH DAMAGE. 
 27   
 28  """ 
 29  Detect the current architecture and operating system. 
 30  """ 
 31   
 32  __revision__ = "$Id: version.py 618 2010-02-11 02:15:09Z qvasimodo $" 
 33   
 34  from defines import * 
 35   
 36  #--- OSVERSIONINFO and OSVERSIONINFOEX structures and constants --------------- 
 37   
 38  VER_PLATFORM_WIN32s                 = 0 
 39  VER_PLATFORM_WIN32_WINDOWS          = 1 
 40  VER_PLATFORM_WIN32_NT               = 2 
 41   
 42  VER_SUITE_BACKOFFICE                = 0x00000004 
 43  VER_SUITE_BLADE                     = 0x00000400 
 44  VER_SUITE_COMPUTE_SERVER            = 0x00004000 
 45  VER_SUITE_DATACENTER                = 0x00000080 
 46  VER_SUITE_ENTERPRISE                = 0x00000002 
 47  VER_SUITE_EMBEDDEDNT                = 0x00000040 
 48  VER_SUITE_PERSONAL                  = 0x00000200 
 49  VER_SUITE_SINGLEUSERTS              = 0x00000100 
 50  VER_SUITE_SMALLBUSINESS             = 0x00000001 
 51  VER_SUITE_SMALLBUSINESS_RESTRICTED  = 0x00000020 
 52  VER_SUITE_STORAGE_SERVER            = 0x00002000 
 53  VER_SUITE_TERMINAL                  = 0x00000010 
 54  VER_SUITE_WH_SERVER                 = 0x00008000 
 55   
 56  VER_NT_DOMAIN_CONTROLLER            = 0x0000002 
 57  VER_NT_SERVER                       = 0x0000003 
 58  VER_NT_WORKSTATION                  = 0x0000001 
 59   
 60  VER_BUILDNUMBER                     = 0x0000004 
 61  VER_MAJORVERSION                    = 0x0000002 
 62  VER_MINORVERSION                    = 0x0000001 
 63  VER_PLATFORMID                      = 0x0000008 
 64  VER_PRODUCT_TYPE                    = 0x0000080 
 65  VER_SERVICEPACKMAJOR                = 0x0000020 
 66  VER_SERVICEPACKMINOR                = 0x0000010 
 67  VER_SUITENAME                       = 0x0000040 
 68   
 69  VER_EQUAL                           = 1 
 70  VER_GREATER                         = 2 
 71  VER_GREATER_EQUAL                   = 3 
 72  VER_LESS                            = 4 
 73  VER_LESS_EQUAL                      = 5 
 74  VER_AND                             = 6 
 75  VER_OR                              = 7 
 76   
 77  # typedef struct _OSVERSIONINFO { 
 78  #   DWORD dwOSVersionInfoSize; 
 79  #   DWORD dwMajorVersion; 
 80  #   DWORD dwMinorVersion; 
 81  #   DWORD dwBuildNumber; 
 82  #   DWORD dwPlatformId; 
 83  #   TCHAR szCSDVersion[128]; 
 84  # }OSVERSIONINFO; 
85 -class OSVERSIONINFOA(Structure):
86 _fields_ = [ 87 ("dwOSVersionInfoSize", DWORD), 88 ("dwMajorVersion", DWORD), 89 ("dwMinorVersion", DWORD), 90 ("dwBuildNumber", DWORD), 91 ("dwPlatformId", DWORD), 92 ("szCSDVersion", CHAR * 128), 93 ]
94 -class OSVERSIONINFOW(Structure):
95 _fields_ = [ 96 ("dwOSVersionInfoSize", DWORD), 97 ("dwMajorVersion", DWORD), 98 ("dwMinorVersion", DWORD), 99 ("dwBuildNumber", DWORD), 100 ("dwPlatformId", DWORD), 101 ("szCSDVersion", WCHAR * 128), 102 ]
103 104 # typedef struct _OSVERSIONINFOEX { 105 # DWORD dwOSVersionInfoSize; 106 # DWORD dwMajorVersion; 107 # DWORD dwMinorVersion; 108 # DWORD dwBuildNumber; 109 # DWORD dwPlatformId; 110 # TCHAR szCSDVersion[128]; 111 # WORD wServicePackMajor; 112 # WORD wServicePackMinor; 113 # WORD wSuiteMask; 114 # BYTE wProductType; 115 # BYTE wReserved; 116 # }OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX;
117 -class OSVERSIONINFOEXA(Structure):
118 _fields_ = [ 119 ("dwOSVersionInfoSize", DWORD), 120 ("dwMajorVersion", DWORD), 121 ("dwMinorVersion", DWORD), 122 ("dwBuildNumber", DWORD), 123 ("dwPlatformId", DWORD), 124 ("szCSDVersion", CHAR * 128), 125 ("wServicePackMajor", WORD), 126 ("wServicePackMinor", WORD), 127 ("wSuiteMask", WORD), 128 ("wProductType", BYTE), 129 ("wReserved", BYTE), 130 ]
131 -class OSVERSIONINFOEXW(Structure):
132 _fields_ = [ 133 ("dwOSVersionInfoSize", DWORD), 134 ("dwMajorVersion", DWORD), 135 ("dwMinorVersion", DWORD), 136 ("dwBuildNumber", DWORD), 137 ("dwPlatformId", DWORD), 138 ("szCSDVersion", WCHAR * 128), 139 ("wServicePackMajor", WORD), 140 ("wServicePackMinor", WORD), 141 ("wSuiteMask", WORD), 142 ("wProductType", BYTE), 143 ("wReserved", BYTE), 144 ]
145 146 LPOSVERSIONINFOA = POINTER(OSVERSIONINFOA) 147 LPOSVERSIONINFOW = POINTER(OSVERSIONINFOW) 148 LPOSVERSIONINFOEXA = POINTER(OSVERSIONINFOEXA) 149 LPOSVERSIONINFOEXW = POINTER(OSVERSIONINFOEXW) 150 POSVERSIONINFOA = LPOSVERSIONINFOA 151 POSVERSIONINFOW = LPOSVERSIONINFOW 152 POSVERSIONINFOEXA = LPOSVERSIONINFOEXA 153 POSVERSIONINFOEXW = LPOSVERSIONINFOA 154 155 #--- GetSystemMetrics constants ----------------------------------------------- 156 157 SM_CXSCREEN = 0 158 SM_CYSCREEN = 1 159 SM_CXVSCROLL = 2 160 SM_CYHSCROLL = 3 161 SM_CYCAPTION = 4 162 SM_CXBORDER = 5 163 SM_CYBORDER = 6 164 SM_CXDLGFRAME = 7 165 SM_CYDLGFRAME = 8 166 SM_CYVTHUMB = 9 167 SM_CXHTHUMB = 10 168 SM_CXICON = 11 169 SM_CYICON = 12 170 SM_CXCURSOR = 13 171 SM_CYCURSOR = 14 172 SM_CYMENU = 15 173 SM_CXFULLSCREEN = 16 174 SM_CYFULLSCREEN = 17 175 SM_CYKANJIWINDOW = 18 176 SM_MOUSEPRESENT = 19 177 SM_CYVSCROLL = 20 178 SM_CXHSCROLL = 21 179 SM_DEBUG = 22 180 SM_SWAPBUTTON = 23 181 SM_RESERVED1 = 24 182 SM_RESERVED2 = 25 183 SM_RESERVED3 = 26 184 SM_RESERVED4 = 27 185 SM_CXMIN = 28 186 SM_CYMIN = 29 187 SM_CXSIZE = 30 188 SM_CYSIZE = 31 189 SM_CXFRAME = 32 190 SM_CYFRAME = 33 191 SM_CXMINTRACK = 34 192 SM_CYMINTRACK = 35 193 SM_CXDOUBLECLK = 36 194 SM_CYDOUBLECLK = 37 195 SM_CXICONSPACING = 38 196 SM_CYICONSPACING = 39 197 SM_MENUDROPALIGNMENT = 40 198 SM_PENWINDOWS = 41 199 SM_DBCSENABLED = 42 200 SM_CMOUSEBUTTONS = 43 201 202 SM_CXFIXEDFRAME = SM_CXDLGFRAME # ;win40 name change 203 SM_CYFIXEDFRAME = SM_CYDLGFRAME # ;win40 name change 204 SM_CXSIZEFRAME = SM_CXFRAME # ;win40 name change 205 SM_CYSIZEFRAME = SM_CYFRAME # ;win40 name change 206 207 SM_SECURE = 44 208 SM_CXEDGE = 45 209 SM_CYEDGE = 46 210 SM_CXMINSPACING = 47 211 SM_CYMINSPACING = 48 212 SM_CXSMICON = 49 213 SM_CYSMICON = 50 214 SM_CYSMCAPTION = 51 215 SM_CXSMSIZE = 52 216 SM_CYSMSIZE = 53 217 SM_CXMENUSIZE = 54 218 SM_CYMENUSIZE = 55 219 SM_ARRANGE = 56 220 SM_CXMINIMIZED = 57 221 SM_CYMINIMIZED = 58 222 SM_CXMAXTRACK = 59 223 SM_CYMAXTRACK = 60 224 SM_CXMAXIMIZED = 61 225 SM_CYMAXIMIZED = 62 226 SM_NETWORK = 63 227 SM_CLEANBOOT = 67 228 SM_CXDRAG = 68 229 SM_CYDRAG = 69 230 SM_SHOWSOUNDS = 70 231 SM_CXMENUCHECK = 71 # Use instead of GetMenuCheckMarkDimensions()! 232 SM_CYMENUCHECK = 72 233 SM_SLOWMACHINE = 73 234 SM_MIDEASTENABLED = 74 235 SM_MOUSEWHEELPRESENT = 75 236 SM_XVIRTUALSCREEN = 76 237 SM_YVIRTUALSCREEN = 77 238 SM_CXVIRTUALSCREEN = 78 239 SM_CYVIRTUALSCREEN = 79 240 SM_CMONITORS = 80 241 SM_SAMEDISPLAYFORMAT = 81 242 SM_IMMENABLED = 82 243 SM_CXFOCUSBORDER = 83 244 SM_CYFOCUSBORDER = 84 245 SM_TABLETPC = 86 246 SM_MEDIACENTER = 87 247 SM_STARTER = 88 248 SM_SERVERR2 = 89 249 SM_MOUSEHORIZONTALWHEELPRESENT = 91 250 SM_CXPADDEDBORDER = 92 251 252 SM_CMETRICS = 93 253 254 SM_REMOTESESSION = 0x1000 255 SM_SHUTTINGDOWN = 0x2000 256 SM_REMOTECONTROL = 0x2001 257 SM_CARETBLINKINGENABLED = 0x2002 258 259 #--- SYSTEM_INFO structure, GetSystemInfo() and GetNativeSystemInfo() --------- 260 261 PROCESSOR_ARCHITECTURE_INTEL = 0 262 PROCESSOR_ARCHITECTURE_IA64 = 6 263 PROCESSOR_ARCHITECTURE_AMD64 = 9 264 PROCESSOR_ARCHITECTURE_UNKNOWN = 0xffff 265 266 # typedef struct _SYSTEM_INFO { 267 # union { 268 # DWORD dwOemId; 269 # struct { 270 # WORD wProcessorArchitecture; 271 # WORD wReserved; 272 # } ; 273 # } ; 274 # DWORD dwPageSize; 275 # LPVOID lpMinimumApplicationAddress; 276 # LPVOID lpMaximumApplicationAddress; 277 # DWORD_PTR dwActiveProcessorMask; 278 # DWORD dwNumberOfProcessors; 279 # DWORD dwProcessorType; 280 # DWORD dwAllocationGranularity; 281 # WORD wProcessorLevel; 282 # WORD wProcessorRevision; 283 # } SYSTEM_INFO; 284
285 -class _SYSTEM_INFO_OEM_ID_STRUCT(Structure):
286 _fields_ = [ 287 ("wProcessorArchitecture", WORD), 288 ("wReserved", WORD), 289 ]
290
291 -class _SYSTEM_INFO_OEM_ID(Union):
292 _fields_ = [ 293 ("dwOemId", DWORD), 294 ("w", _SYSTEM_INFO_OEM_ID_STRUCT), 295 ]
296
297 -class SYSTEM_INFO(Structure):
298 _fields_ = [ 299 ("id", _SYSTEM_INFO_OEM_ID), 300 ("dwPageSize", DWORD), 301 ("lpMinimumApplicationAddress", LPVOID), 302 ("lpMaximumApplicationAddress", LPVOID), 303 ("dwActiveProcessorMask", DWORD_PTR), 304 ("dwNumberOfProcessors", DWORD), 305 ("dwProcessorType", DWORD), 306 ("dwAllocationGranularity", DWORD), 307 ("wProcessorLevel", WORD), 308 ("wProcessorRevision", WORD), 309 ] 310
311 - def __get_dwOemId(self):
312 return self.id.dwOemId
313 - def __set_dwOemId(self, value):
314 self.id.dwOemId = value
315 dwOemId = property(__get_dwOemId, __set_dwOemId) 316
318 return self.id.w.wProcessorArchitecture
319 - def __set_wProcessorArchitecture(self, value):
321 wProcessorArchitecture = property(__get_wProcessorArchitecture, __set_wProcessorArchitecture)
322 323 LPSYSTEM_INFO = ctypes.POINTER(SYSTEM_INFO) 324 325 # void WINAPI GetSystemInfo( 326 # __out LPSYSTEM_INFO lpSystemInfo 327 # );
328 -def GetSystemInfo():
329 _GetSystemInfo = windll.kernel32.GetSystemInfo 330 _GetSystemInfo.argtypes = [LPSYSTEM_INFO] 331 _GetSystemInfo.restype = None 332 333 sysinfo = SYSTEM_INFO() 334 _GetSystemInfo(ctypes.byref(sysinfo)) 335 return sysinfo
336 337 # void WINAPI GetNativeSystemInfo( 338 # __out LPSYSTEM_INFO lpSystemInfo 339 # );
340 -def GetNativeSystemInfo():
341 _GetNativeSystemInfo = windll.kernel32.GetNativeSystemInfo 342 _GetNativeSystemInfo.argtypes = [LPSYSTEM_INFO] 343 _GetNativeSystemInfo.restype = None 344 345 sysinfo = SYSTEM_INFO() 346 _GetNativeSystemInfo(ctypes.byref(sysinfo)) 347 return sysinfo
348 349 # int WINAPI GetSystemMetrics( 350 # __in int nIndex 351 # );
352 -def GetSystemMetrics(nIndex):
353 _GetSystemMetrics = windll.user32.GetSystemMetrics 354 _GetSystemMetrics.argtypes = [ctypes.c_int] 355 _GetSystemMetrics.restype = ctypes.c_int 356 return _GetSystemMetrics(nIndex)
357 358 # DWORD WINAPI GetVersion(void);
359 -def GetVersion():
360 _GetVersion = windll.kernel32.GetVersion 361 _GetVersion.argtypes = [] 362 _GetVersion.restype = DWORD 363 _GetVersion.errcheck = RaiseIfZero 364 365 # See the example code here: 366 # http://msdn.microsoft.com/en-us/library/ms724439(VS.85).aspx 367 368 dwVersion = _GetVersion() 369 dwMajorVersion = dwVersion & 0x000000FF 370 dwMinorVersion = (dwVersion & 0x0000FF00) >> 8 371 if (dwVersion & 0x80000000) == 0: 372 dwBuild = (dwVersion & 0x7FFF0000) >> 16 373 else: 374 dwBuild = None 375 return int(dwMajorVersion), int(dwMinorVersion), int(dwBuild)
376 377 # BOOL WINAPI GetVersionEx( 378 # __inout LPOSVERSIONINFO lpVersionInfo 379 # );
380 -def GetVersionExA():
381 _GetVersionExA = windll.kernel32.GetVersionExA 382 _GetVersionExA.argtypes = [LPVOID] 383 _GetVersionExA.restype = bool 384 _GetVersionExA.errcheck = RaiseIfZero 385 386 osi = OSVERSIONINFOEXA() 387 osi.dwOSVersionInfoSize = sizeof(osi) 388 try: 389 _GetVersionExA(ctypes.byref(osi)) 390 except WindowsError: 391 osi = OSVERSIONINFOA() 392 osi.dwOSVersionInfoSize = sizeof(osi) 393 _GetVersionExA(ctypes.byref(osi)) 394 return osi
395
396 -def GetVersionExW():
397 _GetVersionExW = windll.kernel32.GetVersionExW 398 _GetVersionExW.argtypes = [LPVOID] 399 _GetVersionExW.restype = bool 400 _GetVersionExW.errcheck = RaiseIfZero 401 402 osi = OSVERSIONINFOEXW() 403 osi.dwOSVersionInfoSize = sizeof(osi) 404 try: 405 _GetVersionExW(ctypes.byref(osi)) 406 except WindowsError: 407 osi = OSVERSIONINFOW() 408 osi.dwOSVersionInfoSize = sizeof(osi) 409 _GetVersionExW(ctypes.byref(osi)) 410 return osi
411 412 GetVersionEx = GuessStringType(GetVersionExA, GetVersionExW) 413 414 # BOOL WINAPI GetProductInfo( 415 # __in DWORD dwOSMajorVersion, 416 # __in DWORD dwOSMinorVersion, 417 # __in DWORD dwSpMajorVersion, 418 # __in DWORD dwSpMinorVersion, 419 # __out PDWORD pdwReturnedProductType 420 # );
421 -def GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion):
422 _GetProductInfo = windll.kernel32.GetProductInfo 423 _GetProductInfo.argtypes = [DWORD, DWORD, DWORD, DWORD, PDWORD] 424 _GetProductInfo.restype = BOOL 425 _GetProductInfo.errcheck = RaiseIfZero 426 427 dwReturnedProductType = DWORD(0) 428 _GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, byref(dwReturnedProductType)) 429 return dwReturnedProductType.value
430 431 # BOOL WINAPI VerifyVersionInfo( 432 # __in LPOSVERSIONINFOEX lpVersionInfo, 433 # __in DWORD dwTypeMask, 434 # __in DWORDLONG dwlConditionMask 435 # );
436 -def VerifyVersionInfo(lpVersionInfo, dwTypeMask, dwlConditionMask):
437 if isinstance(lpVersionInfo, OSVERSIONINFOEXA): 438 return VerifyVersionInfoA(lpVersionInfo, dwTypeMask, dwlConditionMask) 439 if isinstance(lpVersionInfo, OSVERSIONINFOEXW): 440 return VerifyVersionInfoW(lpVersionInfo, dwTypeMask, dwlConditionMask) 441 raise TypeError, "Bad OSVERSIONINFOEX structure"
442
443 -def VerifyVersionInfoA(lpVersionInfo, dwTypeMask, dwlConditionMask):
444 _VerifyVersionInfoA = windll.kernel32.VerifyVersionInfoA 445 _VerifyVersionInfoA.argtypes = [LPOSVERSIONINFOEXA, DWORD, DWORDLONG] 446 _VerifyVersionInfoA.restype = bool 447 return _VerifyVersionInfoA(ctypes.byref(lpVersionInfo), dwTypeMask, dwlConditionMask)
448
449 -def VerifyVersionInfoW(lpVersionInfo, dwTypeMask, dwlConditionMask):
450 _VerifyVersionInfoW = windll.kernel32.VerifyVersionInfoW 451 _VerifyVersionInfoW.argtypes = [LPOSVERSIONINFOEXW, DWORD, DWORDLONG] 452 _VerifyVersionInfoW.restype = bool 453 return _VerifyVersionInfoW(ctypes.byref(lpVersionInfo), dwTypeMask, dwlConditionMask)
454 455 # ULONGLONG WINAPI VerSetConditionMask( 456 # __in ULONGLONG dwlConditionMask, 457 # __in DWORD dwTypeBitMask, 458 # __in BYTE dwConditionMask 459 # );
460 -def VerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask):
461 _VerSetConditionMask = windll.kernel32.VerSetConditionMask 462 _VerSetConditionMask.argtypes = [ULONGLONG, DWORD, BYTE] 463 _VerSetConditionMask.restype = ULONGLONG 464 return _VerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask)
465 466 #--- get_bits, get_arch and get_os -------------------------------------------- 467
468 -def get_bits():
469 """ 470 Determines the current integer size in bits. 471 472 This is useful to know if we're running in a 32 bits or a 64 bits machine. 473 474 @rtype: int 475 @return: Returns the size of L{SIZE_T} in bits. 476 """ 477 return sizeof(SIZE_T) * 8
478
479 -def get_arch():
480 """ 481 Determines the current processor architecture. 482 483 @rtype: str 484 @return: 485 One of the following values: 486 - C{"unknown"} 487 - C{"i386"} for Intel 32-bit x86 processor or compatible. 488 - C{"amd64"} for Intel 64-bit x86_64 processor or compatible. 489 - C{"ia64"} for Intel Itanium processor or compatible. 490 """ 491 try: 492 si = GetNativeSystemInfo() 493 except Exception: 494 si = GetSystemInfo() 495 wProcessorArchitecture = si.id.w.wProcessorArchitecture 496 if wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL: 497 return 'i386' 498 if wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64: 499 return 'amd64' 500 if wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64: 501 return 'ia64' 502 return 'unknown'
503 504 # XXX TODO
505 -def get_os():
506 """ 507 Determines the current operating system. 508 509 This function allows you to quickly tell apart major OS differences. 510 For more detailed information call L{kernel32.GetVersionEx} instead. 511 512 @note: 513 Wine reports itself as Windows XP 32 bits (even if the Linux host is 64 bits). 514 ReactOS reports itself as Windows 2000. 515 516 @rtype: str 517 @return: 518 One of the following values: 519 - C{"Unknown"} 520 - C{"Windows NT"} 521 - C{"Windows 2000"} 522 - C{"Windows XP"} 523 - C{"Windows XP (64 bits)"} 524 - C{"Windows 2003"} 525 - C{"Windows 2003 (64 bits)"} 526 - C{"Windows 2003 R2"} 527 - C{"Windows 2003 R2 (64 bits)"} 528 - C{"Windows 2008"} 529 - C{"Windows 2008 (64 bits)"} 530 - C{"Windows 2008 R2"} 531 - C{"Windows 2008 R2 (64 bits)"} 532 - C{"Windows Vista"} 533 - C{"Windows Vista (64 bits)"} 534 - C{"Windows 7"} 535 - C{"Windows 7 (64 bits)"} 536 """ 537 # rough port of http://msdn.microsoft.com/en-us/library/ms724429%28VS.85%29.aspx 538 osvi = GetVersionEx() 539 if osvi.dwPlatformId == VER_PLATFORM_WIN32_NT and osvi.dwMajorVersion > 4: 540 if osvi.dwMajorVersion == 6: 541 if osvi.dwMinorVersion == 0: 542 if osvi.wProductType == VER_NT_WORKSTATION: 543 if sizeof(SIZE_T) == 8: 544 return 'Windows Vista (64 bits)' 545 return 'Windows Vista' 546 else: 547 if sizeof(SIZE_T) == 8: 548 return 'Windows 2008 (64 bits)' 549 return 'Windows 2008' 550 if osvi.dwMinorVersion == 1: 551 if osvi.wProductType == VER_NT_WORKSTATION: 552 if sizeof(SIZE_T) == 8: 553 return 'Windows 7 (64 bits)' 554 return 'Windows 7' 555 else: 556 if sizeof(SIZE_T) == 8: 557 return 'Windows 2008 R2 (64 bits)' 558 return 'Windows 2008 R2' 559 if osvi.dwMajorVersion == 5: 560 if osvi.dwMinorVersion == 2: 561 if GetSystemMetrics(SM_SERVERR2): 562 if sizeof(SIZE_T) == 8: 563 return 'Windows 2003 R2 (64 bits)' 564 return 'Windows 2003 R2' 565 if osvi.wSuiteMask in (VER_SUITE_STORAGE_SERVER, VER_SUITE_WH_SERVER): 566 if sizeof(SIZE_T) == 8: 567 return 'Windows 2003 (64 bits)' 568 return 'Windows 2003' 569 try: 570 si = GetNativeSystemInfo() 571 except Exception: 572 si = GetSystemInfo() 573 if osvi.wProductType == VER_NT_WORKSTATION and si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64: 574 return 'Windows XP (64 bits)' 575 else: 576 if sizeof(SIZE_T) == 8: 577 return 'Windows 2003 (64 bits)' 578 return 'Windows 2003' 579 if osvi.dwMinorVersion == 1: 580 return 'Windows XP' 581 if osvi.dwMinorVersion == 0: 582 return 'Windows 2000' 583 if osvi.dwMajorVersion == 4: 584 return 'Windows NT' 585 return 'Unknown'
586 587 # Current processor architecture. See L{get_arch} for more details. 588 arch = get_arch() 589 590 # Current integer size in bits. See L{get_bits} for more details. 591 bits = get_bits() 592 593 # Current operating system. See L{get_os} for more details. 594 os = get_os() 595