flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > how to define and initialize struc for GUID

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 04 May 2014, 22:21
I've been struggling with struc all the evening, but cannot make it work

I'd like to define a struc for GUID as follows:
Code:
struc GUID {
  .TimeLow dd ?
  .TimeMid dw ?
  .TimeHighAndVersion dw ?
  .ClockSeqHighAndReserved db ?
  .ClockSeqLow db ?
  .Node db 6 dup (?)
}    

the problem is that the structure is not initializable.
For example, I want to init the structure with values
Code:
MyGUID GUID 0x12345678, 0x1234, 0x5678, 0xaa, 0xbb, <0x11, 0x11, 0x11, 0x11, 0x11, 0x11>    

or I'd like to define several constants in a .inc file so I could use them like
MyGUID GUID CONSTANT_VAL

The only solution I came up with is to use
Code:
struc GUID [val] {
  align 8
 common
  . db val
}    

and initialize GUID byte by byte. But this is not the way I'd like it to be.
Thanks in advance for any suggestions.
Post 04 May 2014, 22:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20527
Location: In your JS exploiting you and your system
revolution 04 May 2014, 23:02
In the USECOM example there is this:
Code:
struc GUID def
 {
   match d1-d2-d3-d4-d5, def
    \{
      .Data1 dd 0x\#d1
      .Data2 dw 0x\#d2
      .Data3 dw 0x\#d3
      .Data4 db 0x\#d4 shr 8,0x\#d4 and 0FFh
      .Data5 db 0x\#d5 shr 40,0x\#d5 shr 32 and 0FFh,0x\#d5 shr 24 and 0FFh,0x\#d5 shr 16 and 0FFh,0x\#d5 shr 8 and 0FFh,0x\#d5 and 0FFh
    \}
 }    
Post 04 May 2014, 23:02
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.