RellHaiser

OEM Activator thus far...

Mar 10th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.83 KB | None | 0 0
  1. import windows
  2.  
  3. proc GetSystemFirmwareTable(FirmwareTableProviderSignature: DWORD,
  4.  
  5.                              FirmwareTableID: DWORD,
  6.  
  7.                              pFirmwareTableBuffer: PVOID,
  8.  
  9.                              BufferSize: DWORD): DWORD{.stdcall, dynlib: "kernel32", importc: "GetSystemFirmwareTable".}
  10.  
  11.                              
  12.  
  13. proc EnumSystemFirmwareTables(FirmwareTableProviderSignature: DWORD,
  14.  
  15.                                pFirmwareTableBuffer: PVOID,
  16.  
  17.                                BufferSize: DWORD): DWORD{.stdcall, dynlib: "kernel32", importc: "EnumSystemFirmwareTables".}
  18.  
  19. proc GetWin8Key(verbose: bool = false): cstring =
  20.       var
  21.         FirmwareTableProviderSignature, BufferSize, FirmwareTableID: DWORD
  22.         vpFirmwareTableBuffer: PVOID
  23.         BytesWritten: DWORD
  24.         pFirmwareTableID = ptr DWORD
  25.         foundTable: bool = false
  26.  
  27.       FirmwareTableProviderSignature = cast[DWORD](cstring("ACPI")) # Possibly a problematic line of code??? (YES, FOUND SOLUTION THOUGH)
  28.       # Original VC++ code: FirmwareTableProviderSignature = 'ACPI';
  29.  
  30.       # get buffer size, call with null values
  31.  
  32.       BufferSize = EnumSystemFirmwareTables(FirmwareTableProviderSignature, nil, 0)
  33.  
  34.       # alloc memory
  35.  
  36.       vpFirmwareTableBuffer = alloc0(BufferSize)
  37.  
  38.       # enum acpi tables
  39.  
  40.       BytesWritten = EnumSystemFirmwareTables(FirmwareTableProviderSignature, vpFirmwareTableBuffer, BufferSize)
  41.  
  42.       # enumerate ACPI tables, look for MSDM table
  43.  
  44.       pFirmwareTableID = cast[ptr DWORD](vpFirmwareTableBuffer) # Possibly a problematic line of code??? (DEFINITELY, NOT SURE OF A FIX YET)
  45.       # Original VC++ code: pFirmwareTableID = (DWORD*)pFirmwareTableBuffer;
  46.       var d = (BytesWritten div 4)-1
  47.       for i in countup(0, d):
  48.         FirmwareTableID = pFirmwareTableID[]
Advertisement
Add Comment
Please, Sign In to add comment