Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1886
  • Last Modified:

Initialising a STRUCT with DUPs in MASM

I'd like to initialise a STRUCT with a DUP(<>) in it, in particular:

MyTokenPrivileges TOKEN_PRIVILEGES <>

Anyone who's done a reasonable amount of work with MASM on Windows structures should be able to provide the answer here.  In the past I've had to define these structures as bytes instead of properly, but I really want to know the correct way of doing it, as I use MASM a lot, and it's driving me mad!

Sample code (STRUCTs from Hutch's MASM32):


 ANYSIZE_ARRAY equ 1
 LUID STRUCT
   LowPart   DWORD      ?
   HighPart  DWORD      ?
 LUID ENDS
 LUID_AND_ATTRIBUTES STRUCT
   Luid LUID <>
   Attributes dd ?
 LUID_AND_ATTRIBUTES ENDS
 TOKEN_PRIVILEGES STRUCT
   PrivilegeCount DWORD      ?
   Privileges LUID_AND_ATTRIBUTES ANYSIZE_ARRAY dup(<>)
 TOKEN_PRIVILEGES ENDS

 ; Nested STRUCTs are no problem
 ASampleLuidAndAttributes LUID_AND_ATTRIBUTES <<0, 0>, 0>

 ; Nor are DUP()s with normal types:
 _GUID STRUCT
   Data1           DWORD ?
   Data2           WORD ?
   Data3           WORD ?
   Data4           BYTE 8 dup (?)
 _GUID ENDS
 InitialisedGUID _GUID <0, 0, 0, <0c0h, 0, 0, 0, 0, 0, 0, 46h>>

 ; But how do I initialise this with PrivilegeCount = 1?
 MyTokenPrivileges TOKEN_PRIVILEGES <>
 ; I think it should be:
 ;  MyTokenPrivileges TOKEN_PRIVILEGES <1, < <<0, 0>, 0> >>
 ; (i.e. one set of <> for the DUP, as in _GUID,
 ;  and then the normal syntax for a LUID_AND_ATTRIBUTES structure inside).
 ; It returns error A2177: nested structure improperly initialized


And I don't want to change the line to Privileges LUID_AND_ATTRIBUTES <> (although that works).

Thanks to anyone who knows how to do this without resorting to a byte array or initialising it at runtime,
    Mark
0
MarkSteward
Asked:
MarkSteward
  • 4
  • 2
1 Solution
 
y2kswCommented:
Privileges ANYSIZE_ARRAY dup ( LUID_AND_ATTRIBUTES <?> )
0
 
MarkStewardAuthor Commented:
Sorry, I'll have to ask for refund.  I'll post a new question if I ever find out a solution.

Cheers,
    Mark
0
 
MarkStewardAuthor Commented:
ARGggh.  Just found it.

http://support.microsoft.com/default.aspx?scid=kb;en-us;94912

inner_struct STRUCT
   w1 DW ?
inner_struct ENDS
outer_struct STRUCT
   s1 inner_struct 2 DUP ({})
outer_struct ENDS

tst1 outer_struct {{{1},{2}}}   ; This line generates an error message
; tst2 outer_struct {{}}        ; This line is allowed

Refund and PAQ, please.

Thanks all,
    Mark
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
Computer101Commented:
PAQed - no points refunded (of 500)

Computer101
E-E Admin
0
 
MarkStewardAuthor Commented:
Why?  Because it was a stupid question?  Or too many points to refund?
0
 
Computer101Commented:
PAQed, with points refunded (500)

Computer101
E-E Admin
0
 
MarkStewardAuthor Commented:
Not worried about the points, just wanted a reason.  Thanks very much.  Sorry about the confusion.

Mark
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now