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

Source Code for Module winappdbg.win32.version

   1  #!/usr/bin/env python 
   2  # -*- coding: utf-8 -*- 
   3   
   4  # Copyright (c) 2009-2014, Mario Vilas 
   5  # All rights reserved. 
   6  # 
   7  # Redistribution and use in source and binary forms, with or without 
   8  # modification, are permitted provided that the following conditions are met: 
   9  # 
  10  #     * Redistributions of source code must retain the above copyright notice, 
  11  #       this list of conditions and the following disclaimer. 
  12  #     * Redistributions in binary form must reproduce the above copyright 
  13  #       notice,this list of conditions and the following disclaimer in the 
  14  #       documentation and/or other materials provided with the distribution. 
  15  #     * Neither the name of the copyright holder nor the names of its 
  16  #       contributors may be used to endorse or promote products derived from 
  17  #       this software without specific prior written permission. 
  18  # 
  19  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
  20  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  21  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
  22  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
  23  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
  24  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  25  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
  26  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
  27  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  28  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  29  # POSSIBILITY OF SUCH DAMAGE. 
  30   
  31  """ 
  32  Detect the current architecture and operating system. 
  33   
  34  Some functions here are really from kernel32.dll, others from version.dll. 
  35  """ 
  36   
  37  __revision__ = "$Id: version.py 1307 2013-12-20 16:51:25Z qvasimodo $" 
  38   
  39  from defines import * 
  40   
  41  #============================================================================== 
  42  # This is used later on to calculate the list of exported symbols. 
  43  _all = None 
  44  _all = set(vars().keys()) 
  45  #============================================================================== 
  46   
  47  #--- NTDDI version ------------------------------------------------------------ 
  48   
  49  NTDDI_WIN8      = 0x06020000 
  50  NTDDI_WIN7SP1   = 0x06010100 
  51  NTDDI_WIN7      = 0x06010000 
  52  NTDDI_WS08      = 0x06000100 
  53  NTDDI_VISTASP1  = 0x06000100 
  54  NTDDI_VISTA     = 0x06000000 
  55  NTDDI_LONGHORN  = NTDDI_VISTA 
  56  NTDDI_WS03SP2   = 0x05020200 
  57  NTDDI_WS03SP1   = 0x05020100 
  58  NTDDI_WS03      = 0x05020000 
  59  NTDDI_WINXPSP3  = 0x05010300 
  60  NTDDI_WINXPSP2  = 0x05010200 
  61  NTDDI_WINXPSP1  = 0x05010100 
  62  NTDDI_WINXP     = 0x05010000 
  63  NTDDI_WIN2KSP4  = 0x05000400 
  64  NTDDI_WIN2KSP3  = 0x05000300 
  65  NTDDI_WIN2KSP2  = 0x05000200 
  66  NTDDI_WIN2KSP1  = 0x05000100 
  67  NTDDI_WIN2K     = 0x05000000 
  68  NTDDI_WINNT4    = 0x04000000 
  69   
  70  OSVERSION_MASK  = 0xFFFF0000 
  71  SPVERSION_MASK  = 0x0000FF00 
  72  SUBVERSION_MASK = 0x000000FF 
  73   
  74  #--- OSVERSIONINFO and OSVERSIONINFOEX structures and constants --------------- 
  75   
  76  VER_PLATFORM_WIN32s                 = 0 
  77  VER_PLATFORM_WIN32_WINDOWS          = 1 
  78  VER_PLATFORM_WIN32_NT               = 2 
  79   
  80  VER_SUITE_BACKOFFICE                = 0x00000004 
  81  VER_SUITE_BLADE                     = 0x00000400 
  82  VER_SUITE_COMPUTE_SERVER            = 0x00004000 
  83  VER_SUITE_DATACENTER                = 0x00000080 
  84  VER_SUITE_ENTERPRISE                = 0x00000002 
  85  VER_SUITE_EMBEDDEDNT                = 0x00000040 
  86  VER_SUITE_PERSONAL                  = 0x00000200 
  87  VER_SUITE_SINGLEUSERTS              = 0x00000100 
  88  VER_SUITE_SMALLBUSINESS             = 0x00000001 
  89  VER_SUITE_SMALLBUSINESS_RESTRICTED  = 0x00000020 
  90  VER_SUITE_STORAGE_SERVER            = 0x00002000 
  91  VER_SUITE_TERMINAL                  = 0x00000010 
  92  VER_SUITE_WH_SERVER                 = 0x00008000 
  93   
  94  VER_NT_DOMAIN_CONTROLLER            = 0x0000002 
  95  VER_NT_SERVER                       = 0x0000003 
  96  VER_NT_WORKSTATION                  = 0x0000001 
  97   
  98  VER_BUILDNUMBER                     = 0x0000004 
  99  VER_MAJORVERSION                    = 0x0000002 
 100  VER_MINORVERSION                    = 0x0000001 
 101  VER_PLATFORMID                      = 0x0000008 
 102  VER_PRODUCT_TYPE                    = 0x0000080 
 103  VER_SERVICEPACKMAJOR                = 0x0000020 
 104  VER_SERVICEPACKMINOR                = 0x0000010 
 105  VER_SUITENAME                       = 0x0000040 
 106   
 107  VER_EQUAL                           = 1 
 108  VER_GREATER                         = 2 
 109  VER_GREATER_EQUAL                   = 3 
 110  VER_LESS                            = 4 
 111  VER_LESS_EQUAL                      = 5 
 112  VER_AND                             = 6 
 113  VER_OR                              = 7 
 114   
 115  # typedef struct _OSVERSIONINFO { 
 116  #   DWORD dwOSVersionInfoSize; 
 117  #   DWORD dwMajorVersion; 
 118  #   DWORD dwMinorVersion; 
 119  #   DWORD dwBuildNumber; 
 120  #   DWORD dwPlatformId; 
 121  #   TCHAR szCSDVersion[128]; 
 122  # }OSVERSIONINFO; 
123 -class OSVERSIONINFOA(Structure):
124 _fields_ = [ 125 ("dwOSVersionInfoSize", DWORD), 126 ("dwMajorVersion", DWORD), 127 ("dwMinorVersion", DWORD), 128 ("dwBuildNumber", DWORD), 129 ("dwPlatformId", DWORD), 130 ("szCSDVersion", CHAR * 128), 131 ]
132 -class OSVERSIONINFOW(Structure):
133 _fields_ = [ 134 ("dwOSVersionInfoSize", DWORD), 135 ("dwMajorVersion", DWORD), 136 ("dwMinorVersion", DWORD), 137 ("dwBuildNumber", DWORD), 138 ("dwPlatformId", DWORD), 139 ("szCSDVersion", WCHAR * 128), 140 ]
141 142 # typedef struct _OSVERSIONINFOEX { 143 # DWORD dwOSVersionInfoSize; 144 # DWORD dwMajorVersion; 145 # DWORD dwMinorVersion; 146 # DWORD dwBuildNumber; 147 # DWORD dwPlatformId; 148 # TCHAR szCSDVersion[128]; 149 # WORD wServicePackMajor; 150 # WORD wServicePackMinor; 151 # WORD wSuiteMask; 152 # BYTE wProductType; 153 # BYTE wReserved; 154 # }OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX;
155 -class OSVERSIONINFOEXA(Structure):
156 _fields_ = [ 157 ("dwOSVersionInfoSize", DWORD), 158 ("dwMajorVersion", DWORD), 159 ("dwMinorVersion", DWORD), 160 ("dwBuildNumber", DWORD), 161 ("dwPlatformId", DWORD), 162 ("szCSDVersion", CHAR * 128), 163 ("wServicePackMajor", WORD), 164 ("wServicePackMinor", WORD), 165 ("wSuiteMask", WORD), 166 ("wProductType", BYTE), 167 ("wReserved", BYTE), 168 ]
169 -class OSVERSIONINFOEXW(Structure):
170 _fields_ = [ 171 ("dwOSVersionInfoSize", DWORD), 172 ("dwMajorVersion", DWORD), 173 ("dwMinorVersion", DWORD), 174 ("dwBuildNumber", DWORD), 175 ("dwPlatformId", DWORD), 176 ("szCSDVersion", WCHAR * 128), 177 ("wServicePackMajor", WORD), 178 ("wServicePackMinor", WORD), 179 ("wSuiteMask", WORD), 180 ("wProductType", BYTE), 181 ("wReserved", BYTE), 182 ]
183 184 LPOSVERSIONINFOA = POINTER(OSVERSIONINFOA) 185 LPOSVERSIONINFOW = POINTER(OSVERSIONINFOW) 186 LPOSVERSIONINFOEXA = POINTER(OSVERSIONINFOEXA) 187 LPOSVERSIONINFOEXW = POINTER(OSVERSIONINFOEXW) 188 POSVERSIONINFOA = LPOSVERSIONINFOA 189 POSVERSIONINFOW = LPOSVERSIONINFOW 190 POSVERSIONINFOEXA = LPOSVERSIONINFOEXA 191 POSVERSIONINFOEXW = LPOSVERSIONINFOA 192 193 #--- GetSystemMetrics constants ----------------------------------------------- 194 195 SM_CXSCREEN = 0 196 SM_CYSCREEN = 1 197 SM_CXVSCROLL = 2 198 SM_CYHSCROLL = 3 199 SM_CYCAPTION = 4 200 SM_CXBORDER = 5 201 SM_CYBORDER = 6 202 SM_CXDLGFRAME = 7 203 SM_CYDLGFRAME = 8 204 SM_CYVTHUMB = 9 205 SM_CXHTHUMB = 10 206 SM_CXICON = 11 207 SM_CYICON = 12 208 SM_CXCURSOR = 13 209 SM_CYCURSOR = 14 210 SM_CYMENU = 15 211 SM_CXFULLSCREEN = 16 212 SM_CYFULLSCREEN = 17 213 SM_CYKANJIWINDOW = 18 214 SM_MOUSEPRESENT = 19 215 SM_CYVSCROLL = 20 216 SM_CXHSCROLL = 21 217 SM_DEBUG = 22 218 SM_SWAPBUTTON = 23 219 SM_RESERVED1 = 24 220 SM_RESERVED2 = 25 221 SM_RESERVED3 = 26 222 SM_RESERVED4 = 27 223 SM_CXMIN = 28 224 SM_CYMIN = 29 225 SM_CXSIZE = 30 226 SM_CYSIZE = 31 227 SM_CXFRAME = 32 228 SM_CYFRAME = 33 229 SM_CXMINTRACK = 34 230 SM_CYMINTRACK = 35 231 SM_CXDOUBLECLK = 36 232 SM_CYDOUBLECLK = 37 233 SM_CXICONSPACING = 38 234 SM_CYICONSPACING = 39 235 SM_MENUDROPALIGNMENT = 40 236 SM_PENWINDOWS = 41 237 SM_DBCSENABLED = 42 238 SM_CMOUSEBUTTONS = 43 239 240 SM_CXFIXEDFRAME = SM_CXDLGFRAME # ;win40 name change 241 SM_CYFIXEDFRAME = SM_CYDLGFRAME # ;win40 name change 242 SM_CXSIZEFRAME = SM_CXFRAME # ;win40 name change 243 SM_CYSIZEFRAME = SM_CYFRAME # ;win40 name change 244 245 SM_SECURE = 44 246 SM_CXEDGE = 45 247 SM_CYEDGE = 46 248 SM_CXMINSPACING = 47 249 SM_CYMINSPACING = 48 250 SM_CXSMICON = 49 251 SM_CYSMICON = 50 252 SM_CYSMCAPTION = 51 253 SM_CXSMSIZE = 52 254 SM_CYSMSIZE = 53 255 SM_CXMENUSIZE = 54 256 SM_CYMENUSIZE = 55 257 SM_ARRANGE = 56 258 SM_CXMINIMIZED = 57 259 SM_CYMINIMIZED = 58 260 SM_CXMAXTRACK = 59 261 SM_CYMAXTRACK = 60 262 SM_CXMAXIMIZED = 61 263 SM_CYMAXIMIZED = 62 264 SM_NETWORK = 63 265 SM_CLEANBOOT = 67 266 SM_CXDRAG = 68 267 SM_CYDRAG = 69 268 SM_SHOWSOUNDS = 70 269 SM_CXMENUCHECK = 71 # Use instead of GetMenuCheckMarkDimensions()! 270 SM_CYMENUCHECK = 72 271 SM_SLOWMACHINE = 73 272 SM_MIDEASTENABLED = 74 273 SM_MOUSEWHEELPRESENT = 75 274 SM_XVIRTUALSCREEN = 76 275 SM_YVIRTUALSCREEN = 77 276 SM_CXVIRTUALSCREEN = 78 277 SM_CYVIRTUALSCREEN = 79 278 SM_CMONITORS = 80 279 SM_SAMEDISPLAYFORMAT = 81 280 SM_IMMENABLED = 82 281 SM_CXFOCUSBORDER = 83 282 SM_CYFOCUSBORDER = 84 283 SM_TABLETPC = 86 284 SM_MEDIACENTER = 87 285 SM_STARTER = 88 286 SM_SERVERR2 = 89 287 SM_MOUSEHORIZONTALWHEELPRESENT = 91 288 SM_CXPADDEDBORDER = 92 289 290 SM_CMETRICS = 93 291 292 SM_REMOTESESSION = 0x1000 293 SM_SHUTTINGDOWN = 0x2000 294 SM_REMOTECONTROL = 0x2001 295 SM_CARETBLINKINGENABLED = 0x2002 296 297 #--- SYSTEM_INFO structure, GetSystemInfo() and GetNativeSystemInfo() --------- 298 299 # Values used by Wine 300 # Documented values at MSDN are marked with an asterisk 301 PROCESSOR_ARCHITECTURE_UNKNOWN = 0xFFFF; # Unknown architecture. 302 PROCESSOR_ARCHITECTURE_INTEL = 0 # x86 (AMD or Intel) * 303 PROCESSOR_ARCHITECTURE_MIPS = 1 # MIPS 304 PROCESSOR_ARCHITECTURE_ALPHA = 2 # Alpha 305 PROCESSOR_ARCHITECTURE_PPC = 3 # Power PC 306 PROCESSOR_ARCHITECTURE_SHX = 4 # SHX 307 PROCESSOR_ARCHITECTURE_ARM = 5 # ARM 308 PROCESSOR_ARCHITECTURE_IA64 = 6 # Intel Itanium * 309 PROCESSOR_ARCHITECTURE_ALPHA64 = 7 # Alpha64 310 PROCESSOR_ARCHITECTURE_MSIL = 8 # MSIL 311 PROCESSOR_ARCHITECTURE_AMD64 = 9 # x64 (AMD or Intel) * 312 PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10 # IA32 on Win64 313 PROCESSOR_ARCHITECTURE_SPARC = 20 # Sparc (Wine) 314 315 # Values used by Wine 316 # PROCESSOR_OPTIL value found at http://code.google.com/p/ddab-lib/ 317 # Documented values at MSDN are marked with an asterisk 318 PROCESSOR_INTEL_386 = 386 # Intel i386 * 319 PROCESSOR_INTEL_486 = 486 # Intel i486 * 320 PROCESSOR_INTEL_PENTIUM = 586 # Intel Pentium * 321 PROCESSOR_INTEL_IA64 = 2200 # Intel IA64 (Itanium) * 322 PROCESSOR_AMD_X8664 = 8664 # AMD X86 64 * 323 PROCESSOR_MIPS_R4000 = 4000 # MIPS R4000, R4101, R3910 324 PROCESSOR_ALPHA_21064 = 21064 # Alpha 210 64 325 PROCESSOR_PPC_601 = 601 # PPC 601 326 PROCESSOR_PPC_603 = 603 # PPC 603 327 PROCESSOR_PPC_604 = 604 # PPC 604 328 PROCESSOR_PPC_620 = 620 # PPC 620 329 PROCESSOR_HITACHI_SH3 = 10003 # Hitachi SH3 (Windows CE) 330 PROCESSOR_HITACHI_SH3E = 10004 # Hitachi SH3E (Windows CE) 331 PROCESSOR_HITACHI_SH4 = 10005 # Hitachi SH4 (Windows CE) 332 PROCESSOR_MOTOROLA_821 = 821 # Motorola 821 (Windows CE) 333 PROCESSOR_SHx_SH3 = 103 # SHx SH3 (Windows CE) 334 PROCESSOR_SHx_SH4 = 104 # SHx SH4 (Windows CE) 335 PROCESSOR_STRONGARM = 2577 # StrongARM (Windows CE) 336 PROCESSOR_ARM720 = 1824 # ARM 720 (Windows CE) 337 PROCESSOR_ARM820 = 2080 # ARM 820 (Windows CE) 338 PROCESSOR_ARM920 = 2336 # ARM 920 (Windows CE) 339 PROCESSOR_ARM_7TDMI = 70001 # ARM 7TDMI (Windows CE) 340 PROCESSOR_OPTIL = 0x494F # MSIL 341 342 # typedef struct _SYSTEM_INFO { 343 # union { 344 # DWORD dwOemId; 345 # struct { 346 # WORD wProcessorArchitecture; 347 # WORD wReserved; 348 # } ; 349 # } ; 350 # DWORD dwPageSize; 351 # LPVOID lpMinimumApplicationAddress; 352 # LPVOID lpMaximumApplicationAddress; 353 # DWORD_PTR dwActiveProcessorMask; 354 # DWORD dwNumberOfProcessors; 355 # DWORD dwProcessorType; 356 # DWORD dwAllocationGranularity; 357 # WORD wProcessorLevel; 358 # WORD wProcessorRevision; 359 # } SYSTEM_INFO; 360
361 -class _SYSTEM_INFO_OEM_ID_STRUCT(Structure):
362 _fields_ = [ 363 ("wProcessorArchitecture", WORD), 364 ("wReserved", WORD), 365 ]
366
367 -class _SYSTEM_INFO_OEM_ID(Union):
368 _fields_ = [ 369 ("dwOemId", DWORD), 370 ("w", _SYSTEM_INFO_OEM_ID_STRUCT), 371 ]
372
373 -class SYSTEM_INFO(Structure):
374 _fields_ = [ 375 ("id", _SYSTEM_INFO_OEM_ID), 376 ("dwPageSize", DWORD), 377 ("lpMinimumApplicationAddress", LPVOID), 378 ("lpMaximumApplicationAddress", LPVOID), 379 ("dwActiveProcessorMask", DWORD_PTR), 380 ("dwNumberOfProcessors", DWORD), 381 ("dwProcessorType", DWORD), 382 ("dwAllocationGranularity", DWORD), 383 ("wProcessorLevel", WORD), 384 ("wProcessorRevision", WORD), 385 ] 386
387 - def __get_dwOemId(self):
388 return self.id.dwOemId
389 - def __set_dwOemId(self, value):
390 self.id.dwOemId = value
391 dwOemId = property(__get_dwOemId, __set_dwOemId) 392
394 return self.id.w.wProcessorArchitecture
395 - def __set_wProcessorArchitecture(self, value):
397 wProcessorArchitecture = property(__get_wProcessorArchitecture, __set_wProcessorArchitecture)
398 399 LPSYSTEM_INFO = ctypes.POINTER(SYSTEM_INFO) 400 401 # void WINAPI GetSystemInfo( 402 # __out LPSYSTEM_INFO lpSystemInfo 403 # );
404 -def GetSystemInfo():
405 _GetSystemInfo = windll.kernel32.GetSystemInfo 406 _GetSystemInfo.argtypes = [LPSYSTEM_INFO] 407 _GetSystemInfo.restype = None 408 409 sysinfo = SYSTEM_INFO() 410 _GetSystemInfo(byref(sysinfo)) 411 return sysinfo
412 413 # void WINAPI GetNativeSystemInfo( 414 # __out LPSYSTEM_INFO lpSystemInfo 415 # );
416 -def GetNativeSystemInfo():
417 _GetNativeSystemInfo = windll.kernel32.GetNativeSystemInfo 418 _GetNativeSystemInfo.argtypes = [LPSYSTEM_INFO] 419 _GetNativeSystemInfo.restype = None 420 421 sysinfo = SYSTEM_INFO() 422 _GetNativeSystemInfo(byref(sysinfo)) 423 return sysinfo
424 425 # int WINAPI GetSystemMetrics( 426 # __in int nIndex 427 # );
428 -def GetSystemMetrics(nIndex):
429 _GetSystemMetrics = windll.user32.GetSystemMetrics 430 _GetSystemMetrics.argtypes = [ctypes.c_int] 431 _GetSystemMetrics.restype = ctypes.c_int 432 return _GetSystemMetrics(nIndex)
433 434 # SIZE_T WINAPI GetLargePageMinimum(void);
435 -def GetLargePageMinimum():
436 _GetLargePageMinimum = windll.user32.GetLargePageMinimum 437 _GetLargePageMinimum.argtypes = [] 438 _GetLargePageMinimum.restype = SIZE_T 439 return _GetLargePageMinimum()
440 441 # HANDLE WINAPI GetCurrentProcess(void);
442 -def GetCurrentProcess():
443 ## return 0xFFFFFFFFFFFFFFFFL 444 _GetCurrentProcess = windll.kernel32.GetCurrentProcess 445 _GetCurrentProcess.argtypes = [] 446 _GetCurrentProcess.restype = HANDLE 447 return _GetCurrentProcess()
448 449 # HANDLE WINAPI GetCurrentThread(void);
450 -def GetCurrentThread():
451 ## return 0xFFFFFFFFFFFFFFFEL 452 _GetCurrentThread = windll.kernel32.GetCurrentThread 453 _GetCurrentThread.argtypes = [] 454 _GetCurrentThread.restype = HANDLE 455 return _GetCurrentThread()
456 457 # BOOL WINAPI IsWow64Process( 458 # __in HANDLE hProcess, 459 # __out PBOOL Wow64Process 460 # );
461 -def IsWow64Process(hProcess):
462 _IsWow64Process = windll.kernel32.IsWow64Process 463 _IsWow64Process.argtypes = [HANDLE, PBOOL] 464 _IsWow64Process.restype = bool 465 _IsWow64Process.errcheck = RaiseIfZero 466 467 Wow64Process = BOOL(FALSE) 468 _IsWow64Process(hProcess, byref(Wow64Process)) 469 return bool(Wow64Process)
470 471 # DWORD WINAPI GetVersion(void);
472 -def GetVersion():
473 _GetVersion = windll.kernel32.GetVersion 474 _GetVersion.argtypes = [] 475 _GetVersion.restype = DWORD 476 _GetVersion.errcheck = RaiseIfZero 477 478 # See the example code here: 479 # http://msdn.microsoft.com/en-us/library/ms724439(VS.85).aspx 480 481 dwVersion = _GetVersion() 482 dwMajorVersion = dwVersion & 0x000000FF 483 dwMinorVersion = (dwVersion & 0x0000FF00) >> 8 484 if (dwVersion & 0x80000000) == 0: 485 dwBuild = (dwVersion & 0x7FFF0000) >> 16 486 else: 487 dwBuild = None 488 return int(dwMajorVersion), int(dwMinorVersion), int(dwBuild)
489 490 # BOOL WINAPI GetVersionEx( 491 # __inout LPOSVERSIONINFO lpVersionInfo 492 # );
493 -def GetVersionExA():
494 _GetVersionExA = windll.kernel32.GetVersionExA 495 _GetVersionExA.argtypes = [POINTER(OSVERSIONINFOEXA)] 496 _GetVersionExA.restype = bool 497 _GetVersionExA.errcheck = RaiseIfZero 498 499 osi = OSVERSIONINFOEXA() 500 osi.dwOSVersionInfoSize = sizeof(osi) 501 try: 502 _GetVersionExA(byref(osi)) 503 except WindowsError: 504 osi = OSVERSIONINFOA() 505 osi.dwOSVersionInfoSize = sizeof(osi) 506 _GetVersionExA.argtypes = [POINTER(OSVERSIONINFOA)] 507 _GetVersionExA(byref(osi)) 508 return osi
509
510 -def GetVersionExW():
511 _GetVersionExW = windll.kernel32.GetVersionExW 512 _GetVersionExW.argtypes = [POINTER(OSVERSIONINFOEXW)] 513 _GetVersionExW.restype = bool 514 _GetVersionExW.errcheck = RaiseIfZero 515 516 osi = OSVERSIONINFOEXW() 517 osi.dwOSVersionInfoSize = sizeof(osi) 518 try: 519 _GetVersionExW(byref(osi)) 520 except WindowsError: 521 osi = OSVERSIONINFOW() 522 osi.dwOSVersionInfoSize = sizeof(osi) 523 _GetVersionExW.argtypes = [POINTER(OSVERSIONINFOW)] 524 _GetVersionExW(byref(osi)) 525 return osi
526 527 GetVersionEx = GuessStringType(GetVersionExA, GetVersionExW) 528 529 # BOOL WINAPI GetProductInfo( 530 # __in DWORD dwOSMajorVersion, 531 # __in DWORD dwOSMinorVersion, 532 # __in DWORD dwSpMajorVersion, 533 # __in DWORD dwSpMinorVersion, 534 # __out PDWORD pdwReturnedProductType 535 # );
536 -def GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion):
537 _GetProductInfo = windll.kernel32.GetProductInfo 538 _GetProductInfo.argtypes = [DWORD, DWORD, DWORD, DWORD, PDWORD] 539 _GetProductInfo.restype = BOOL 540 _GetProductInfo.errcheck = RaiseIfZero 541 542 dwReturnedProductType = DWORD(0) 543 _GetProductInfo(dwOSMajorVersion, dwOSMinorVersion, dwSpMajorVersion, dwSpMinorVersion, byref(dwReturnedProductType)) 544 return dwReturnedProductType.value
545 546 # BOOL WINAPI VerifyVersionInfo( 547 # __in LPOSVERSIONINFOEX lpVersionInfo, 548 # __in DWORD dwTypeMask, 549 # __in DWORDLONG dwlConditionMask 550 # );
551 -def VerifyVersionInfo(lpVersionInfo, dwTypeMask, dwlConditionMask):
552 if isinstance(lpVersionInfo, OSVERSIONINFOEXA): 553 return VerifyVersionInfoA(lpVersionInfo, dwTypeMask, dwlConditionMask) 554 if isinstance(lpVersionInfo, OSVERSIONINFOEXW): 555 return VerifyVersionInfoW(lpVersionInfo, dwTypeMask, dwlConditionMask) 556 raise TypeError("Bad OSVERSIONINFOEX structure")
557
558 -def VerifyVersionInfoA(lpVersionInfo, dwTypeMask, dwlConditionMask):
559 _VerifyVersionInfoA = windll.kernel32.VerifyVersionInfoA 560 _VerifyVersionInfoA.argtypes = [LPOSVERSIONINFOEXA, DWORD, DWORDLONG] 561 _VerifyVersionInfoA.restype = bool 562 return _VerifyVersionInfoA(byref(lpVersionInfo), dwTypeMask, dwlConditionMask)
563
564 -def VerifyVersionInfoW(lpVersionInfo, dwTypeMask, dwlConditionMask):
565 _VerifyVersionInfoW = windll.kernel32.VerifyVersionInfoW 566 _VerifyVersionInfoW.argtypes = [LPOSVERSIONINFOEXW, DWORD, DWORDLONG] 567 _VerifyVersionInfoW.restype = bool 568 return _VerifyVersionInfoW(byref(lpVersionInfo), dwTypeMask, dwlConditionMask)
569 570 # ULONGLONG WINAPI VerSetConditionMask( 571 # __in ULONGLONG dwlConditionMask, 572 # __in DWORD dwTypeBitMask, 573 # __in BYTE dwConditionMask 574 # );
575 -def VerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask):
576 _VerSetConditionMask = windll.kernel32.VerSetConditionMask 577 _VerSetConditionMask.argtypes = [ULONGLONG, DWORD, BYTE] 578 _VerSetConditionMask.restype = ULONGLONG 579 return _VerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask)
580 581 #--- get_bits, get_arch and get_os -------------------------------------------- 582 583 ARCH_UNKNOWN = "unknown" 584 ARCH_I386 = "i386" 585 ARCH_MIPS = "mips" 586 ARCH_ALPHA = "alpha" 587 ARCH_PPC = "ppc" 588 ARCH_SHX = "shx" 589 ARCH_ARM = "arm" 590 ARCH_ARM64 = "arm64" 591 ARCH_THUMB = "thumb" 592 ARCH_IA64 = "ia64" 593 ARCH_ALPHA64 = "alpha64" 594 ARCH_MSIL = "msil" 595 ARCH_AMD64 = "amd64" 596 ARCH_SPARC = "sparc" 597 598 # aliases 599 ARCH_IA32 = ARCH_I386 600 ARCH_X86 = ARCH_I386 601 ARCH_X64 = ARCH_AMD64 602 ARCH_ARM7 = ARCH_ARM 603 ARCH_ARM8 = ARCH_ARM64 604 ARCH_T32 = ARCH_THUMB 605 ARCH_AARCH32 = ARCH_ARM7 606 ARCH_AARCH64 = ARCH_ARM8 607 ARCH_POWERPC = ARCH_PPC 608 ARCH_HITACHI = ARCH_SHX 609 ARCH_ITANIUM = ARCH_IA64 610 611 # win32 constants -> our constants 612 _arch_map = { 613 PROCESSOR_ARCHITECTURE_INTEL : ARCH_I386, 614 PROCESSOR_ARCHITECTURE_MIPS : ARCH_MIPS, 615 PROCESSOR_ARCHITECTURE_ALPHA : ARCH_ALPHA, 616 PROCESSOR_ARCHITECTURE_PPC : ARCH_PPC, 617 PROCESSOR_ARCHITECTURE_SHX : ARCH_SHX, 618 PROCESSOR_ARCHITECTURE_ARM : ARCH_ARM, 619 PROCESSOR_ARCHITECTURE_IA64 : ARCH_IA64, 620 PROCESSOR_ARCHITECTURE_ALPHA64 : ARCH_ALPHA64, 621 PROCESSOR_ARCHITECTURE_MSIL : ARCH_MSIL, 622 PROCESSOR_ARCHITECTURE_AMD64 : ARCH_AMD64, 623 PROCESSOR_ARCHITECTURE_SPARC : ARCH_SPARC, 624 } 625 626 OS_UNKNOWN = "Unknown" 627 OS_NT = "Windows NT" 628 OS_W2K = "Windows 2000" 629 OS_XP = "Windows XP" 630 OS_XP_64 = "Windows XP (64 bits)" 631 OS_W2K3 = "Windows 2003" 632 OS_W2K3_64 = "Windows 2003 (64 bits)" 633 OS_W2K3R2 = "Windows 2003 R2" 634 OS_W2K3R2_64 = "Windows 2003 R2 (64 bits)" 635 OS_W2K8 = "Windows 2008" 636 OS_W2K8_64 = "Windows 2008 (64 bits)" 637 OS_W2K8R2 = "Windows 2008 R2" 638 OS_W2K8R2_64 = "Windows 2008 R2 (64 bits)" 639 OS_VISTA = "Windows Vista" 640 OS_VISTA_64 = "Windows Vista (64 bits)" 641 OS_W7 = "Windows 7" 642 OS_W7_64 = "Windows 7 (64 bits)" 643 644 OS_SEVEN = OS_W7 645 OS_SEVEN_64 = OS_W7_64 646 647 OS_WINDOWS_NT = OS_NT 648 OS_WINDOWS_2000 = OS_W2K 649 OS_WINDOWS_XP = OS_XP 650 OS_WINDOWS_XP_64 = OS_XP_64 651 OS_WINDOWS_2003 = OS_W2K3 652 OS_WINDOWS_2003_64 = OS_W2K3_64 653 OS_WINDOWS_2003_R2 = OS_W2K3R2 654 OS_WINDOWS_2003_R2_64 = OS_W2K3R2_64 655 OS_WINDOWS_2008 = OS_W2K8 656 OS_WINDOWS_2008_64 = OS_W2K8_64 657 OS_WINDOWS_2008_R2 = OS_W2K8R2 658 OS_WINDOWS_2008_R2_64 = OS_W2K8R2_64 659 OS_WINDOWS_VISTA = OS_VISTA 660 OS_WINDOWS_VISTA_64 = OS_VISTA_64 661 OS_WINDOWS_SEVEN = OS_W7 662 OS_WINDOWS_SEVEN_64 = OS_W7_64 663
664 -def _get_bits():
665 """ 666 Determines the current integer size in bits. 667 668 This is useful to know if we're running in a 32 bits or a 64 bits machine. 669 670 @rtype: int 671 @return: Returns the size of L{SIZE_T} in bits. 672 """ 673 return sizeof(SIZE_T) * 8
674
675 -def _get_arch():
676 """ 677 Determines the current processor architecture. 678 679 @rtype: str 680 @return: 681 On error, returns: 682 683 - L{ARCH_UNKNOWN} (C{"unknown"}) meaning the architecture could not be detected or is not known to WinAppDbg. 684 685 On success, returns one of the following values: 686 687 - L{ARCH_I386} (C{"i386"}) for Intel 32-bit x86 processor or compatible. 688 - L{ARCH_AMD64} (C{"amd64"}) for Intel 64-bit x86_64 processor or compatible. 689 690 May also return one of the following values if you get both Python and 691 WinAppDbg to work in such machines... let me know if you do! :) 692 693 - L{ARCH_MIPS} (C{"mips"}) for MIPS compatible processors. 694 - L{ARCH_ALPHA} (C{"alpha"}) for Alpha processors. 695 - L{ARCH_PPC} (C{"ppc"}) for PowerPC compatible processors. 696 - L{ARCH_SHX} (C{"shx"}) for Hitachi SH processors. 697 - L{ARCH_ARM} (C{"arm"}) for ARM compatible processors. 698 - L{ARCH_IA64} (C{"ia64"}) for Intel Itanium processor or compatible. 699 - L{ARCH_ALPHA64} (C{"alpha64"}) for Alpha64 processors. 700 - L{ARCH_MSIL} (C{"msil"}) for the .NET virtual machine. 701 - L{ARCH_SPARC} (C{"sparc"}) for Sun Sparc processors. 702 703 Probably IronPython returns C{ARCH_MSIL} but I haven't tried it. Python 704 on Windows CE and Windows Mobile should return C{ARCH_ARM}. Python on 705 Solaris using Wine would return C{ARCH_SPARC}. Python in an Itanium 706 machine should return C{ARCH_IA64} both on Wine and proper Windows. 707 All other values should only be returned on Linux using Wine. 708 """ 709 try: 710 si = GetNativeSystemInfo() 711 except Exception: 712 si = GetSystemInfo() 713 try: 714 return _arch_map[si.id.w.wProcessorArchitecture] 715 except KeyError: 716 return ARCH_UNKNOWN
717
718 -def _get_wow64():
719 """ 720 Determines if the current process is running in Windows-On-Windows 64 bits. 721 722 @rtype: bool 723 @return: C{True} of the current process is a 32 bit program running in a 724 64 bit version of Windows, C{False} if it's either a 32 bit program 725 in a 32 bit Windows or a 64 bit program in a 64 bit Windows. 726 """ 727 # Try to determine if the debugger itself is running on WOW64. 728 # On error assume False. 729 if bits == 64: 730 wow64 = False 731 else: 732 try: 733 wow64 = IsWow64Process( GetCurrentProcess() ) 734 except Exception: 735 wow64 = False 736 return wow64
737
738 -def _get_os(osvi = None):
739 """ 740 Determines the current operating system. 741 742 This function allows you to quickly tell apart major OS differences. 743 For more detailed information call L{GetVersionEx} instead. 744 745 @note: 746 Wine reports itself as Windows XP 32 bits 747 (even if the Linux host is 64 bits). 748 ReactOS may report itself as Windows 2000 or Windows XP, 749 depending on the version of ReactOS. 750 751 @type osvi: L{OSVERSIONINFOEXA} 752 @param osvi: Optional. The return value from L{GetVersionEx}. 753 754 @rtype: str 755 @return: 756 One of the following values: 757 - L{OS_UNKNOWN} (C{"Unknown"}) 758 - L{OS_NT} (C{"Windows NT"}) 759 - L{OS_W2K} (C{"Windows 2000"}) 760 - L{OS_XP} (C{"Windows XP"}) 761 - L{OS_XP_64} (C{"Windows XP (64 bits)"}) 762 - L{OS_W2K3} (C{"Windows 2003"}) 763 - L{OS_W2K3_64} (C{"Windows 2003 (64 bits)"}) 764 - L{OS_W2K3R2} (C{"Windows 2003 R2"}) 765 - L{OS_W2K3R2_64} (C{"Windows 2003 R2 (64 bits)"}) 766 - L{OS_W2K8} (C{"Windows 2008"}) 767 - L{OS_W2K8_64} (C{"Windows 2008 (64 bits)"}) 768 - L{OS_W2K8R2} (C{"Windows 2008 R2"}) 769 - L{OS_W2K8R2_64} (C{"Windows 2008 R2 (64 bits)"}) 770 - L{OS_VISTA} (C{"Windows Vista"}) 771 - L{OS_VISTA_64} (C{"Windows Vista (64 bits)"}) 772 - L{OS_W7} (C{"Windows 7"}) 773 - L{OS_W7_64} (C{"Windows 7 (64 bits)"}) 774 """ 775 # rough port of http://msdn.microsoft.com/en-us/library/ms724429%28VS.85%29.aspx 776 if not osvi: 777 osvi = GetVersionEx() 778 if osvi.dwPlatformId == VER_PLATFORM_WIN32_NT and osvi.dwMajorVersion > 4: 779 if osvi.dwMajorVersion == 6: 780 if osvi.dwMinorVersion == 0: 781 if osvi.wProductType == VER_NT_WORKSTATION: 782 if bits == 64 or wow64: 783 return 'Windows Vista (64 bits)' 784 return 'Windows Vista' 785 else: 786 if bits == 64 or wow64: 787 return 'Windows 2008 (64 bits)' 788 return 'Windows 2008' 789 if osvi.dwMinorVersion == 1: 790 if osvi.wProductType == VER_NT_WORKSTATION: 791 if bits == 64 or wow64: 792 return 'Windows 7 (64 bits)' 793 return 'Windows 7' 794 else: 795 if bits == 64 or wow64: 796 return 'Windows 2008 R2 (64 bits)' 797 return 'Windows 2008 R2' 798 if osvi.dwMajorVersion == 5: 799 if osvi.dwMinorVersion == 2: 800 if GetSystemMetrics(SM_SERVERR2): 801 if bits == 64 or wow64: 802 return 'Windows 2003 R2 (64 bits)' 803 return 'Windows 2003 R2' 804 if osvi.wSuiteMask in (VER_SUITE_STORAGE_SERVER, VER_SUITE_WH_SERVER): 805 if bits == 64 or wow64: 806 return 'Windows 2003 (64 bits)' 807 return 'Windows 2003' 808 if osvi.wProductType == VER_NT_WORKSTATION and arch == ARCH_AMD64: 809 return 'Windows XP (64 bits)' 810 else: 811 if bits == 64 or wow64: 812 return 'Windows 2003 (64 bits)' 813 return 'Windows 2003' 814 if osvi.dwMinorVersion == 1: 815 return 'Windows XP' 816 if osvi.dwMinorVersion == 0: 817 return 'Windows 2000' 818 if osvi.dwMajorVersion == 4: 819 return 'Windows NT' 820 return 'Unknown'
821
822 -def _get_ntddi(osvi):
823 """ 824 Determines the current operating system. 825 826 This function allows you to quickly tell apart major OS differences. 827 For more detailed information call L{kernel32.GetVersionEx} instead. 828 829 @note: 830 Wine reports itself as Windows XP 32 bits 831 (even if the Linux host is 64 bits). 832 ReactOS may report itself as Windows 2000 or Windows XP, 833 depending on the version of ReactOS. 834 835 @type osvi: L{OSVERSIONINFOEXA} 836 @param osvi: Optional. The return value from L{kernel32.GetVersionEx}. 837 838 @rtype: int 839 @return: NTDDI version number. 840 """ 841 if not osvi: 842 osvi = GetVersionEx() 843 ntddi = 0 844 ntddi += (osvi.dwMajorVersion & 0xFF) << 24 845 ntddi += (osvi.dwMinorVersion & 0xFF) << 16 846 ntddi += (osvi.wServicePackMajor & 0xFF) << 8 847 ntddi += (osvi.wServicePackMinor & 0xFF) 848 return ntddi
849 850 # The order of the following definitions DOES matter! 851 852 # Current integer size in bits. See L{_get_bits} for more details. 853 bits = _get_bits() 854 855 # Current processor architecture. See L{_get_arch} for more details. 856 arch = _get_arch() 857 858 # Set to C{True} if the current process is running in WOW64. See L{_get_wow64} for more details. 859 wow64 = _get_wow64() 860 861 _osvi = GetVersionEx() 862 863 # Current operating system. See L{_get_os} for more details. 864 os = _get_os(_osvi) 865 866 # Current operating system as an NTDDI constant. See L{_get_ntddi} for more details. 867 NTDDI_VERSION = _get_ntddi(_osvi) 868 869 # Upper word of L{NTDDI_VERSION}, contains the OS major and minor version number. 870 WINVER = NTDDI_VERSION >> 16 871 872 #--- version.dll -------------------------------------------------------------- 873 874 VS_FF_DEBUG = 0x00000001 875 VS_FF_PRERELEASE = 0x00000002 876 VS_FF_PATCHED = 0x00000004 877 VS_FF_PRIVATEBUILD = 0x00000008 878 VS_FF_INFOINFERRED = 0x00000010 879 VS_FF_SPECIALBUILD = 0x00000020 880 881 VOS_UNKNOWN = 0x00000000 882 VOS__WINDOWS16 = 0x00000001 883 VOS__PM16 = 0x00000002 884 VOS__PM32 = 0x00000003 885 VOS__WINDOWS32 = 0x00000004 886 VOS_DOS = 0x00010000 887 VOS_OS216 = 0x00020000 888 VOS_OS232 = 0x00030000 889 VOS_NT = 0x00040000 890 891 VOS_DOS_WINDOWS16 = 0x00010001 892 VOS_DOS_WINDOWS32 = 0x00010004 893 VOS_NT_WINDOWS32 = 0x00040004 894 VOS_OS216_PM16 = 0x00020002 895 VOS_OS232_PM32 = 0x00030003 896 897 VFT_UNKNOWN = 0x00000000 898 VFT_APP = 0x00000001 899 VFT_DLL = 0x00000002 900 VFT_DRV = 0x00000003 901 VFT_FONT = 0x00000004 902 VFT_VXD = 0x00000005 903 VFT_RESERVED = 0x00000006 # undocumented 904 VFT_STATIC_LIB = 0x00000007 905 906 VFT2_UNKNOWN = 0x00000000 907 908 VFT2_DRV_PRINTER = 0x00000001 909 VFT2_DRV_KEYBOARD = 0x00000002 910 VFT2_DRV_LANGUAGE = 0x00000003 911 VFT2_DRV_DISPLAY = 0x00000004 912 VFT2_DRV_MOUSE = 0x00000005 913 VFT2_DRV_NETWORK = 0x00000006 914 VFT2_DRV_SYSTEM = 0x00000007 915 VFT2_DRV_INSTALLABLE = 0x00000008 916 VFT2_DRV_SOUND = 0x00000009 917 VFT2_DRV_COMM = 0x0000000A 918 VFT2_DRV_RESERVED = 0x0000000B # undocumented 919 VFT2_DRV_VERSIONED_PRINTER = 0x0000000C 920 921 VFT2_FONT_RASTER = 0x00000001 922 VFT2_FONT_VECTOR = 0x00000002 923 VFT2_FONT_TRUETYPE = 0x00000003 924 925 # typedef struct tagVS_FIXEDFILEINFO { 926 # DWORD dwSignature; 927 # DWORD dwStrucVersion; 928 # DWORD dwFileVersionMS; 929 # DWORD dwFileVersionLS; 930 # DWORD dwProductVersionMS; 931 # DWORD dwProductVersionLS; 932 # DWORD dwFileFlagsMask; 933 # DWORD dwFileFlags; 934 # DWORD dwFileOS; 935 # DWORD dwFileType; 936 # DWORD dwFileSubtype; 937 # DWORD dwFileDateMS; 938 # DWORD dwFileDateLS; 939 # } VS_FIXEDFILEINFO;
940 -class VS_FIXEDFILEINFO(Structure):
941 _fields_ = [ 942 ("dwSignature", DWORD), 943 ("dwStrucVersion", DWORD), 944 ("dwFileVersionMS", DWORD), 945 ("dwFileVersionLS", DWORD), 946 ("dwProductVersionMS", DWORD), 947 ("dwProductVersionLS", DWORD), 948 ("dwFileFlagsMask", DWORD), 949 ("dwFileFlags", DWORD), 950 ("dwFileOS", DWORD), 951 ("dwFileType", DWORD), 952 ("dwFileSubtype", DWORD), 953 ("dwFileDateMS", DWORD), 954 ("dwFileDateLS", DWORD), 955 ]
956 PVS_FIXEDFILEINFO = POINTER(VS_FIXEDFILEINFO) 957 LPVS_FIXEDFILEINFO = PVS_FIXEDFILEINFO 958 959 # BOOL WINAPI GetFileVersionInfo( 960 # _In_ LPCTSTR lptstrFilename, 961 # _Reserved_ DWORD dwHandle, 962 # _In_ DWORD dwLen, 963 # _Out_ LPVOID lpData 964 # ); 965 # DWORD WINAPI GetFileVersionInfoSize( 966 # _In_ LPCTSTR lptstrFilename, 967 # _Out_opt_ LPDWORD lpdwHandle 968 # );
969 -def GetFileVersionInfoA(lptstrFilename):
970 _GetFileVersionInfoA = windll.version.GetFileVersionInfoA 971 _GetFileVersionInfoA.argtypes = [LPSTR, DWORD, DWORD, LPVOID] 972 _GetFileVersionInfoA.restype = bool 973 _GetFileVersionInfoA.errcheck = RaiseIfZero 974 975 _GetFileVersionInfoSizeA = windll.version.GetFileVersionInfoSizeA 976 _GetFileVersionInfoSizeA.argtypes = [LPSTR, LPVOID] 977 _GetFileVersionInfoSizeA.restype = DWORD 978 _GetFileVersionInfoSizeA.errcheck = RaiseIfZero 979 980 dwLen = _GetFileVersionInfoSizeA(lptstrFilename, None) 981 lpData = ctypes.create_string_buffer(dwLen) 982 _GetFileVersionInfoA(lptstrFilename, 0, dwLen, byref(lpData)) 983 return lpData
984
985 -def GetFileVersionInfoW(lptstrFilename):
986 _GetFileVersionInfoW = windll.version.GetFileVersionInfoW 987 _GetFileVersionInfoW.argtypes = [LPWSTR, DWORD, DWORD, LPVOID] 988 _GetFileVersionInfoW.restype = bool 989 _GetFileVersionInfoW.errcheck = RaiseIfZero 990 991 _GetFileVersionInfoSizeW = windll.version.GetFileVersionInfoSizeW 992 _GetFileVersionInfoSizeW.argtypes = [LPWSTR, LPVOID] 993 _GetFileVersionInfoSizeW.restype = DWORD 994 _GetFileVersionInfoSizeW.errcheck = RaiseIfZero 995 996 dwLen = _GetFileVersionInfoSizeW(lptstrFilename, None) 997 lpData = ctypes.create_string_buffer(dwLen) # not a string! 998 _GetFileVersionInfoW(lptstrFilename, 0, dwLen, byref(lpData)) 999 return lpData
1000 1001 GetFileVersionInfo = GuessStringType(GetFileVersionInfoA, GetFileVersionInfoW) 1002 1003 # BOOL WINAPI VerQueryValue( 1004 # _In_ LPCVOID pBlock, 1005 # _In_ LPCTSTR lpSubBlock, 1006 # _Out_ LPVOID *lplpBuffer, 1007 # _Out_ PUINT puLen 1008 # );
1009 -def VerQueryValueA(pBlock, lpSubBlock):
1010 _VerQueryValueA = windll.version.VerQueryValueA 1011 _VerQueryValueA.argtypes = [LPVOID, LPSTR, LPVOID, POINTER(UINT)] 1012 _VerQueryValueA.restype = bool 1013 _VerQueryValueA.errcheck = RaiseIfZero 1014 1015 lpBuffer = LPVOID(0) 1016 uLen = UINT(0) 1017 _VerQueryValueA(pBlock, lpSubBlock, byref(lpBuffer), byref(uLen)) 1018 return lpBuffer, uLen.value
1019
1020 -def VerQueryValueW(pBlock, lpSubBlock):
1021 _VerQueryValueW = windll.version.VerQueryValueW 1022 _VerQueryValueW.argtypes = [LPVOID, LPWSTR, LPVOID, POINTER(UINT)] 1023 _VerQueryValueW.restype = bool 1024 _VerQueryValueW.errcheck = RaiseIfZero 1025 1026 lpBuffer = LPVOID(0) 1027 uLen = UINT(0) 1028 _VerQueryValueW(pBlock, lpSubBlock, byref(lpBuffer), byref(uLen)) 1029 return lpBuffer, uLen.value
1030 1031 VerQueryValue = GuessStringType(VerQueryValueA, VerQueryValueW) 1032 1033 #============================================================================== 1034 # This calculates the list of exported symbols. 1035 _all = set(vars().keys()).difference(_all) 1036 __all__ = [_x for _x in _all if not _x.startswith('_')] 1037 __all__.sort() 1038 #============================================================================== 1039