News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

A GUID getter for assembly language

Started by NoCforMe, June 30, 2024, 04:45:17 PM

Previous topic - Next topic

sinsi

Quote from: NoCforMe on June 30, 2024, 08:58:42 PMHow about this: let's take a completely empirical approach:
  • Use UuidCreate() to get a GUID
  • Look at the data in the GUID structure, byte by byte
  • Use UuidToString() to create the string
  • Compare the data layout to the byte order in the string
That should show us the correct order of things.
Already did that.
e4 4c 54 8a 70 77 18 4d-83 70 0a e4 8a 29 78 52
8a544ce4-7770-4d18-8370-0ae48a297852
The top line is the buffer from UuidCreate
The next line is from UuidToString


TimoVJL

Quote from: NoCforMe on June 30, 2024, 06:55:39 PM
Quote from: TimoVJL on June 30, 2024, 06:22:38 PMAlso a string for register would be useful, as it might be needed for later usage.
You mean for the registry? I thought that was the XXXXXXXX-XXXX-XXXX ... form. What format exactly is it?
string like "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"
May the source be with you

NoCforMe

So all I need to do is enclose it in {}. Easy peasy.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: sinsi on June 30, 2024, 09:32:12 PM
Quote from: NoCforMe on June 30, 2024, 08:58:42 PMHow about this: let's take a completely empirical approach:
  • Use UuidCreate() to get a GUID
  • Look at the data in the GUID structure, byte by byte
  • Use UuidToString() to create the string
  • Compare the data layout to the byte order in the string
That should show us the correct order of things.
Already did that.
e4 4c 54 8a 70 77 18 4d-83 70 0a e4 8a 29 78 52
8a544ce4-7770-4d18-8370-0ae48a297852
The top line is the buffer from UuidCreate
The next line is from UuidToString
This is my guide, then, to fixing my utility so it shows the value properly. Probably be done later today ...
Assembly language programming should be fun. That's why I do it.

TimoVJL

Quote from: NoCforMe on July 01, 2024, 06:38:36 AMSo all I need to do is enclose it in {}. Easy peasy.
Windows API function StringFromGUID2() make it in UNICODE form for reference.
May the source be with you

NoCforMe

Quote from: TimoVJL on July 01, 2024, 07:47:29 AM
Quote from: NoCforMe on July 01, 2024, 06:38:36 AMSo all I need to do is enclose it in {}. Easy peasy.
Windows API function StringFromGUID2() make it in UNICODE form for reference.
Unicode, schmunicode; all that's needed are plain ASCII characters here.
Assembly language programming should be fun. That's why I do it.

NoCforMe

OK, new version attached. It puts the GUID in the same format (byte-order wise) as UuidToString(), as shown in the status bar).

Timo, I added "{}" to the GUID string shown at the top: happy? It ain't Unicode, but you can certainly copy and paste into anything.

So it turns out that the GUID format is:
  • First 4 bytes (8 hex chars.) in DWORD order (little-endian)
  • Next 2 sets of 2 bytes each (4 hex chars.) in WORD order
  • Next set of 2 bytes in non-byte-swapped order (?????)
  • Last set of 6 bytes (12 hex chars.) in non-byte-swapped order

Weird.

Last question: I'm using uppercase hex characters here, but UuidToString() renders them in lowercase. Probly doesn't matter, but I could put in an option for case here; anyone think that would be a good thing?
Assembly language programming should be fun. That's why I do it.

TimoVJL

In windows register GUIDs are mostly uppercase, like CLSIDs, but not necessarily.
May the source be with you

NoCforMe

Quote from: TimoVJL on July 01, 2024, 08:15:45 AMIn windows register registry GUIDs are mostly uppercase, like CLSIDs, but not necessarily.
Assembly language programming should be fun. That's why I do it.

NoCforMe

New version gives you the choice of uppercase or not.
Assembly language programming should be fun. That's why I do it.