#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <WinAPIDiag.au3>
Local $aTables = _EnumSystemFirmwareTables("ACPI")
_ArrayDisplay($aTables)
Func _EnumSystemFirmwareTables($sSignature)
Local $MSDM_FirmwareTable = "struct;CHAR Signature[4];UINT Length;BYTE Revision;BYTE Checksum;CHAR OemId[6];CHAR OemTableId[8];UINT OemRevision;CHAR CreatorId[4];UINT CreatorRevision;CHAR ProductKey[49];endstruct"
Local $bTables[1] = [0]
Local $bRet = 0
Local $aTables[1] = [0]
Local $aRet = DllCall("Kernel32.dll", "uint", "EnumSystemFirmwareTables", "dword", _Signature($sSignature), "ptr", Null, "dword", 0)
If @error Or Not $aRet[0] Then Return SetError(@error, @extended, $aTables)
Local $iSize = $aRet[0]
Local $iBound = $iSize / 4
Local $tFirewareTable = DllStructCreate("dword[" & $iBound & "]")
$aRet = DllCall("Kernel32.dll", "uint", "EnumSystemFirmwareTables", "dword", _Signature($sSignature), "ptr", DllStructGetPtr($tFirewareTable), "dword", $iSize)
If @error Or Not $aRet[0] Then Return SetError(@error, @extended, $aTables)
ReDim $aTables[$iBound + 1]
$aTables[0] = UBound($aTables) - 1
For $i = 1 To UBound($aTables) - 1
$aTables[$i] = DllStructGetData($tFirewareTable, 1, $i)
$k = BinaryToString ($aTables[$i])
msgbox (0,"", Hex($aTables[$i]) & " : " & $k ,1)
if $k = "MSDM" Then
$bRet = DllCall("Kernel32.dll", "uint","GetSystemFirmwareTable", "dword", _Signature($sSignature), "dword", _Signature(StringReverse($k)), "ptr", Null, "dword", 0)
if @error or Not $bRet[0] Then Return SetError(@error, @extended, $aTables)
Local $jsize = $bRet[0]
Local $jBound = $jsize / 4
Local $tFirmwareTable = DllStructCreate($MSDM_FirmwareTable)
$bTables = DllCall("Kernel32.dll", "uint","GetSystemFirmwareTable", "dword", _Signature($sSignature), "dword", _Signature(StringReverse($k)), "ptr",DllStructGetptr ($tFirmwareTable), "dword", $jBound)
$ProductKey = DllStructGetData ($tFirmwareTable, "ProductKey")
MsgBox (0,"key", $ProductKey,0)
$tFirmwareTable = 0
Return ($bTables)
endif
Next
Return $aTables
EndFunc ;==>_EnumSystemFirmwareTables
Func _Signature($sString)
Return "0x" & Hex(Binary($sString))
EndFunc ;==>_Signature