Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Initialising a STRUCT with DUPs in MASM

Posted on 2003-10-25
10
Medium Priority
?
1,835 Views
Last Modified: 2012-05-04
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
Comment
Question by:MarkSteward
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
10 Comments
 
LVL 3

Expert Comment

by:y2ksw
ID: 9840621
Privileges ANYSIZE_ARRAY dup ( LUID_AND_ATTRIBUTES <?> )
0
 
LVL 2

Author Comment

by:MarkSteward
ID: 10192320
Sorry, I'll have to ask for refund.  I'll post a new question if I ever find out a solution.

Cheers,
    Mark
0
 
LVL 2

Author Comment

by:MarkSteward
ID: 10301797
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
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
LVL 1

Expert Comment

by:Computer101
ID: 10377959
PAQed - no points refunded (of 500)

Computer101
E-E Admin
0
 
LVL 2

Author Comment

by:MarkSteward
ID: 10387534
Why?  Because it was a stupid question?  Or too many points to refund?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10387630
PAQed, with points refunded (500)

Computer101
E-E Admin
0
 
LVL 2

Author Comment

by:MarkSteward
ID: 10387646
Not worried about the points, just wanted a reason.  Thanks very much.  Sorry about the confusion.

Mark
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Check out what's been happening in the Experts Exchange community.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question