Solved

Initialising a STRUCT with DUPs in MASM

Posted on 2003-10-25
10
1,665 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
  • 4
  • 2
10 Comments
 
LVL 3

Expert Comment

by:y2ksw
Comment Utility
Privileges ANYSIZE_ARRAY dup ( LUID_AND_ATTRIBUTES <?> )
0
 
LVL 2

Author Comment

by:MarkSteward
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Expert Comment

by:Computer101
Comment Utility
PAQed - no points refunded (of 500)

Computer101
E-E Admin
0
 
LVL 2

Author Comment

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

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed, with points refunded (500)

Computer101
E-E Admin
0
 
LVL 2

Author Comment

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

Mark
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
False Theorem 27 909
Assembly Language 5 380
port mapped I/o query 10 136
Integrating PowerShell Script in C# Assembly Code 4 598
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now