Solved

Initialising a STRUCT with DUPs in MASM

Posted on 2003-10-25
10
1,760 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 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