News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

GUID Routines

Started by baltoro, December 31, 2008, 10:06:10 PM

Previous topic - Next topic

baltoro

I recently wrote a program in C++, to query and override functionality in USB hardware devices, and found that I was dealing with instance and device class GUIDs (which Windows stores in the registry). There are few GUID routines in the Win32 system DLLs, and I ended up writing these ridiculously long functions to compare GUIDs and convert to readable strings (GUIDs are a portion of the Device Identifier). Speed is NOT an issue, but, I wanted reliable function performance.
So, it occurred to me that exported assembly routines would be the way to go with this type of function.

This is the syntax in C++, from the MSDN site:   

typedef struct _GUID
{  DWORD Data1; 
WORD Data2; 
WORD Data3; 
BYTE Data4[8];
} GUID;


Members
Data1
Specifies the first 8 hexadecimal digits of the GUID.
Data2
Specifies the first group of 4 hexadecimal digits.
Data3
Specifies the second group of 4 hexadecimal digits.
Data4
Array of 8 bytes. The first 2 bytes contain the third group of 4 hexadecimal digits. The remaining 6 bytes contain the final 12 hexadecimal digits.

A GUID is a 128-bit value consisting of one group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal digits each, followed by one group of 12 hexadecimal digits. GUIDs are the Microsoft implementation of the distributed computing environment (DCE) universally unique identifier ( UUID).   

So, I'm wondering, if there already existing GUID conversion assembly routines. I did a preliminary search and came up with nothing.
Thanks.
Baltoro

donkey

If speed isn't an issue, why not just use the API for this ? StringFromGUID2 and  IsEqualGUID  do a fine job and are very reliable. GUID is generally defined as follows in assembly (MASM syntax)

GUID STRUCT
  Data1 dd ?
  Data2 dw ?
  Data3 dw ?
  Data4 db 8 DUP (?)
GUID ENDSS
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

baltoro

Thanks Donkey,
Yeah, you're right about the COM APIs IsEqualGUID and related.
Baltoro

jdoe

Quote from: baltoro on December 31, 2008, 10:35:22 PM
Yeah, you're right about the COM APIs IsEqualGUID and related.

Speed does not matter in that case but for an assembly replacement of IsEqualGUID...

http://www.masm32.com/board/index.php?topic=8312.0


Tedd

Quote from: baltoro on December 31, 2008, 10:06:10 PM
There are few GUID routines in the Win32 system DLLs, and I ended up writing these ridiculously long functions to compare GUIDs and convert to readable strings (GUIDs are a portion of the Device Identifier). Speed is NOT an issue, but, I wanted reliable function performance.
They're still just binary values, so a straight compare is perfectly fine (i.e. memcmp)
And printf for converting to string ("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}") :wink
No snowflake in an avalanche feels responsible.

baltoro

Thanks for excellent replies,...
I know it's kind of a simple question. I'm just incredibly lazy.
...and, my brain has been reduced to complete dysfunction by Influenza,...
Baltoro