Jump to content
Deye

Faster HWID lookup

Recommended Posts

Deye

Hi,

I'm looking for a faster method then _WinAPI_UniqueHardwareID(BitOR($UHID_MB, $UHID_BIOS, $UHID_CPU)) 

Maybe something based on dll calls, not WMI nor the registry and with out needing descriptions in the returns which are out of the context for uniqueness
Simply a fast function to generate a hash which will be as much as possible Unique between machines

I don't feel like I'm capable to come up with something like this at the moment
for example this post : https://www.autoitscript.com/forum/topic/120314-getting-system-cpu-info/?do=findComment&comment=836097

TIA

Share this post


Link to post
Share on other sites
BrewManNH

Don't use the $UHID_CPU variable and it's much faster. It won't make the ID returned that much more unique than without it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Deye

From this post  :mentioning not to use "SELECT *" ,is this a valid statement that can be used to change and speed up the function a bit ?

from powershell this one too, Isn't too fast :

get-wmiobject Win32_Processor | select Architecture,Family,Level,Manufacturer,Revision,Version,ProcessorType,MaxClockSpeed

 

Share this post


Link to post
Share on other sites
BrewManNH

That link doesn't give you the same information as the UniqueHardwareID does because it's only returning the ProcessorID, while _WinAPI_UniqueHardwareID returns with a lot more options.

The powershell option isn't going to be any faster as it is still querying WMI.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Deye

For now, If you are generating a key out of HWID then you would base it on specs that aren't easily changed and have a wider variety of specs per where you are acquiring them from,  so on different computers it will not be the same return, like If you are routining free trials, for a month, you then prevent re sending a key based on the HWID you have recorded the month before,  you also want to avoid a case where other computers are prevented from receiving the free trial  ..

Share this post


Link to post
Share on other sites
Deye

hi there,

I wonder what other specs can be included, It so quick that it wont hurt to include a few more , but I think this Should be good for now

Here is a (1 minute) Oops test
If you do get an "Oops" MsgBox and can tell at what point the inconsistency occurs that will help 

Thanks

#include <Memory.au3>
Global Const $STR_STRIPALL = 8

$sTest = _GetProcHWIDSpecs()

For $C = 1 To 12
    Sleep(5000)
    If $sTest <> _GetProcHWIDSpecs() Then MsgBox(262144, "", "Oops")
Next

Func _GetProcHWIDSpecs()
    Local $sText = ''
    Local $pRemoteCode = _MemVirtualAlloc(0, 512, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE)
    Local $tCodeBuffer = DllStructCreate("byte[512]", $pRemoteCode)
    Local $tBuffer = DllStructCreate("char[12]")
    Local $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(0) & "0FA2" & "" & "891D" & SwapEndian($pBuffer) & "8915" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "" & "C3")
    Local $aCall = DllCall("user32.dll", "dword", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    $sText &= $aCall[0]
    $sText &= DllStructGetData($tBuffer, 1)
    $tBuffer = DllStructCreate("dword[4]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(1) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "8915" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "891D" & SwapEndian($pBuffer + 12) & "" & "C3")
    $aCall = DllCall("user32.dll", "dword", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    $sText &= DllStructGetData($tBuffer, 1, 1)
    $sText &= BitAND(BitShift(DllStructGetData($tBuffer, 1, 2), 28), 1)
    $sText &= DllStructGetData($tBuffer, 1, 3)
    Local $iEAX = DllStructGetData($tBuffer, 1, 1)
    Local $iStepping = BitAND($iEAX, 0xF)
    ;Stepping ,BaseModel ,BaseFamily,ExtendedModel, $iExtendedFamily
    For $x = 4 To 20 Step 4
        $sText &= BitAND(BitShift($iEAX, $x), 0xF)
    Next
    $sText &= BitAND(BitShift($iEAX, 28), 0xF)
    Local $iEBX = DllStructGetData($tBuffer, 1, 4)
    Local $iBrandID = BitAND($iEBX, 0xFF)
    $sText &= $iBrandID
    Local $iCLFLUSH = BitAND(BitShift($iEBX, 8), 0xFF)
    $sText &= $iCLFLUSH
    Local $iLogicalProcessorCount = BitAND(BitShift($iEBX, 16), 0xFF)
    $sText &= $iLogicalProcessorCount
    Local $LocalApicId = BitAND(BitShift($iEBX, 24), 0xFF)
    $tBuffer = DllStructCreate("dword[4]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(2) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "891D" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "8915" & SwapEndian($pBuffer + 12) & "" & "C3")
    $aCall = DllCall("user32.dll", "dword", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    For $x = 1 To 4
        $sText &= DllStructGetData($tBuffer, 1, $x)
    Next
    $tBuffer = DllStructCreate("dword[4]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(0x80000000) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "" & "C3")
    $aCall = DllCall("user32.dll", "ptr", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    $tBuffer = DllStructCreate("dword[4]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(0x80000001) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "891D" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "8915" & SwapEndian($pBuffer + 12) & "" & "C3")
    $aCall = DllCall("user32.dll", "ptr", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    For $x = 1 To 4
        $sText &= DllStructGetData($tBuffer, 1, $x)
    Next
    $tBuffer = DllStructCreate("char[48]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(0x80000002) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "891D" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "8915" & SwapEndian($pBuffer + 12) & "" & "B8" & SwapEndian(0x80000003) & "0FA2" & "" & "A3" & SwapEndian($pBuffer + 16) & "891D" & SwapEndian($pBuffer + 20) & "890D" & SwapEndian($pBuffer + 24) & "8915" & SwapEndian($pBuffer + 28) & "" & "B8" & SwapEndian(0x80000004) & "0FA2" & "" & "A3" & SwapEndian($pBuffer + 32) & "891D" & SwapEndian($pBuffer + 36) & "890D" & SwapEndian($pBuffer + 40) & "8915" & SwapEndian($pBuffer + 44) & "" & "C3")
    $aCall = DllCall("user32.dll", "int", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    $sText &= DllStructGetData($tBuffer, 1)
    $tBuffer = DllStructCreate("dword[4]")
    $pBuffer = DllStructGetPtr($tBuffer)
    DllStructSetData($tCodeBuffer, 1, "0x" & "" & "B8" & SwapEndian(0x80000008) & "0FA2" & "" & "A3" & SwapEndian($pBuffer) & "891D" & SwapEndian($pBuffer + 4) & "890D" & SwapEndian($pBuffer + 8) & "8915" & SwapEndian($pBuffer + 12) & "" & "C3")
    $aCall = DllCall("user32.dll", "dword", "CallWindowProcW", "ptr", $pRemoteCode, "int", 0, "int", 0, "int", 0, "int", 0)
    For $x = 1 To 4
        $sText &= DllStructGetData($tBuffer, 1, $x)
    Next
    Local $iApicIdCoreIdSize = BitAND(DllStructGetData($tBuffer, 1, 3), 0xF)
    $sText &= $iApicIdCoreIdSize
    If $iApicIdCoreIdSize = 0 Then
        $IMNC = 1
    Else
        $IMNC = 2 ^ $iApicIdCoreIdSize
    EndIf
    $sText &= $IMNC
    Return StringStripWS($sText, $STR_STRIPALL)
EndFunc   ;==>_GetProcessorHWIDSpecs

Func SwapEndian($iValue)
    Return Hex(BinaryMid($iValue, 1, 4))
EndFunc   ;==>SwapEndian

 

Share this post


Link to post
Share on other sites
Earthshine

 What development tools do you have available to you? You know I’m going to suggest C-sharp or C++

When I finally converted I felt like Eddie izzard in that Darth Vader skit..... stuff it I’ll get a tray 🤣

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Deye

At the moment i don't have any special abilities with C#\++
The Code you see is a touched version (@first post info ..) not mine :)

 

Edited by Deye

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.