Getting the System Hardware Fingerprint (XP/2003/Vista)

Share your advanced PureBasic knowledge/code with the community.
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Getting the System Hardware Fingerprint (XP/2003/Vista)

Post by citystate »

just a quick snippet...

Code: Select all

Structure HW_PROFILE_INFO
  DockInfo.l
  szHWProfileGUID.s{38}
EndStructure

getCurrentHWProfile_(hwp.HW_PROFILE_INFO)
hwGUID.s = hwp\szHWProfileGUID
MessageRequester("Info","Your Machine's FingerPrint is: "+hwGUID)

end
yeah, I know I've only used the minimum structure, but it seems to work fine. It returns a string in the format:

"{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"

The output includes the braces and hyphens. The X's appear to be simple Hex, and seem to be unique to the machine running the program (no surprising considering there are 2^256 different numbers available).
My laptop gives me the fingerprint

"{536a5cc0-645b-11d7-933e-806d6172696f}"

Once I get home, I'll test on different machines to confirm the uniqueness of the number. If anyone wants to test it out, please post your results for comparison.

Cheers,
Matt
Last edited by citystate on Tue May 08, 2007 2:24 am, edited 1 time in total.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Works fine under vista. Looks like a neat function.

didn't have time to copy the text string right now. Will update later.

cheers

vista business
{3d4e88c0-6a70-11db-b1ba-806e6f6e6963}
Last edited by rsts on Mon May 07, 2007 1:05 pm, edited 1 time in total.
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

WinXP: {9defa740-316f-11d9-9ee7-806d6172696f}
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

K - I've tested it out on a couple more machines

WinXP:
{9743fa40-f2e8-11da-9cee-806d6172696f}
{22bbe040-5f97-11db-9259-806d6172696f}

2003 Server:
{e615bcc0-49c9-11db-808d-806e6f6e6963}

with just this small sample set (thanks dige) - it looks like the last 6 bytes have something to do with the platform, I'm curious what Vista and other flavours of Windows might equate to...
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Getting the System Hardware Fingerprint (Windows)

Post by PB »

How can I make this a procedure? If I run the following, I get invalid memory
access on the ProcedureReturn line:

Code: Select all

Procedure.s HardwareFingerprint()
  Structure HW_PROFILE_INFO
    DockInfo.l
    szHWProfileGUID.s{38}
  EndStructure
  GetCurrentHwProfile_(hwp.HW_PROFILE_INFO)
  ProcedureReturn hwp\szHWProfileGUID
EndProcedure

Debug HardwareFingerprint()
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Getting the System Hardware Fingerprint (Windows)

Post by gnozal »

PB wrote:How can I make this a procedure? If I run the following, I get invalid memory
access on the ProcedureReturn line:

Code: Select all

Procedure.s HardwareFingerprint()
  Structure HW_PROFILE_INFO
    DockInfo.l
    szHWProfileGUID.s{38}
  EndStructure
  GetCurrentHwProfile_(hwp.HW_PROFILE_INFO)
  ProcedureReturn hwp\szHWProfileGUID
EndProcedure

Debug HardwareFingerprint()
The structure is wrong ...
This seems to work :

Code: Select all

;
; Get Hardware Fingerprint
;
#HW_PROFILE_GUIDLEN = $27
#MAX_PROFILE_LEN = $50

Structure HW_PROFILE_INFO 
  DockInfo.l 
  szHWProfileGUID.c[#HW_PROFILE_GUIDLEN] 
  szHwProfileName.c[#MAX_PROFILE_LEN]
EndStructure 

Procedure.s HardwareFingerprint()
  Protected hwp.HW_PROFILE_INFO
  GetCurrentHwProfile_(@hwp)
  Debug PeekS(@hwp\szHwProfileName[0]) + " -> " + PeekS(@hwp\szHWProfileGUID[0])
  ProcedureReturn PeekS(@hwp\szHWProfileGUID[0])
EndProcedure 

Debug HardwareFingerprint()
WinNT4 : {ADB18780-FC84-11DB-81B7-00A0C9E133FF}
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Getting the System Hardware Fingerprint (Windows)

Post by PB »

Thanks gnozal! :)
Last edited by PB on Mon May 07, 2007 12:55 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
eJan
Enthusiast
Enthusiast
Posts: 366
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Post by eJan »

Thanks!
Win XP: {1d70e440-b786-11db-8634-806d6172696f}

Is it possible to make it working on Win 9x?
http://msdn2.microsoft.com/en-us/library/ms724311.aspx
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Winxp sp2

{27f5e540-5bbb-11db-bf11-806d6172696f}
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

eJan wrote: Is it possible to make it working on Win 9x?
http://msdn2.microsoft.com/en-us/library/ms724311.aspx
It should run on all flavours of Windows - it's a fairly standard API call
have you tried it on Win9x? what errors are you getting?
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

In Windows ME, the output from the two Debug statements are:

Code: Select all

[Debug] ->
[Debug]
Thus nothing is returned by any of the PeekS() statements.
Anthony Jordan
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Post by citystate »

hmm

try this then

Code: Select all

Structure HW_PROFILE_INFO 
  DockInfo.w
  szHWProfileGUID.c[39]
  szHWProfileName.c[80] 
EndStructure 

getCurrentHWProfile_(hwp.HW_PROFILE_INFO) 
hwGUID.s = PeekS(@hwp\szHWProfileGUID[0])
MessageRequester("Info","Your Machine's FingerPrint is: "+hwGUID) 
end
sorry, I don't have anything earlier than XP so can't really test it
the only change is to the DockInfo variable type (making it a word instead of a long) It *might* work, but perhaps this function is only valid for XP onwards (if so maybe one of the Windows guru's could help out)...
Last edited by citystate on Tue May 08, 2007 2:34 am, edited 1 time in total.
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: Getting the System Hardware Fingerprint (Windows)

Post by citystate »

PB wrote:How can I make this a procedure? If I run the following, I get invalid memory
access on the ProcedureReturn line:

Code: Select all

Procedure.s HardwareFingerprint()
  Structure HW_PROFILE_INFO
    DockInfo.l
    szHWProfileGUID.s{38}
  EndStructure
  GetCurrentHwProfile_(hwp.HW_PROFILE_INFO)
  ProcedureReturn hwp\szHWProfileGUID
EndProcedure

Debug HardwareFingerprint()
The main problem I can see is that you have the Structure inside the Procedure - move it outside and it should work
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Is it possible to make it working on Win 9x?

No. MSDN for GetCurrentHwProfile states that it requires NT-based Windows.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Vista
{0f694440-6a70-11db-8eb3-806e6f6e6963}
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Post Reply