Need help with generating a GUID string that does not change (on each generate)

Started by Sean1337, December 05, 2009, 10:32:44 AM

Previous topic - Next topic

Sean1337

Hi,

In order to strengthen the security of the software I am developing, I require being able to uniquely identify the computers of each license holder. I have decide to generate a GUID for each user to do this. However, I am running into some trouble and I was wondering if someone could assist me in the code that is required to generate a GUID string that remains unchanged each time you generate the GUID.

I found the following code on another site:

; #################################################

    .486
    .model flat, stdcall
    option casemap :none   ; case sensitive

; #################################################

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    ;include \masm32\include\gdi32.inc
    include \masm32\include\ole32.inc

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    ;includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\ole32.lib

    main PROTO
    .data
    AppTitle db "GUID String Example",0
   .data?
   GUIDptr  dd    ?
   GUIDTextBufferW  db 78 dup(?)
   GUIDTextBufferA db 38 dup(?)

; #################################################
    .code
   
start:
    invoke CoInitializeEx,NULL,2     
    invoke CoCreateGuid,OFFSET GUIDptr
    invoke StringFromGUID2,OFFSET GUIDptr,OFFSET GUIDTextBufferW, 78       
    invoke WideCharToMultiByte,CP_ACP, 0 ,OFFSET GUIDTextBufferW,\
    38, OFFSET GUIDTextBufferA, MAX_PATH, NULL, NULL
    invoke MessageBox,0,OFFSET GUIDTextBufferA,OFFSET AppTitle,MB_OK
    invoke CoUninitialize
   
    invoke ExitProcess,0
   
; #################################################
end start


It generates the type of GUID string that I am looking for, however the string generate differs each time the code is run which is something I do not want.

For example, I ran the code twice and got:

---------------------------
GUID String Example
---------------------------
{DBAF15AF-007B-0044-4200-410046003100}
---------------------------
OK   
---------------------------

---------------------------
GUID String Example
---------------------------
{188F732A-007B-0031-3800-380046003700}
---------------------------
OK   
---------------------------

Could anyone assist me with the code necessary to generate a GUID String that is unique for each user and which does not change every time you generate the string? (unless of course the user changed significant hardware in their computer that would warrant the GUID changing).

Thanks.