Jump to content
Sign in to follow this  

Union support For DllStruct

Recommended Posts

how about support for unions so that we could easly make structs like this:

typedef union _TYPEX_HEADER
    TYPE0_HEADER Type0Hdr;  
    TYPE1_HEADER Type1Hdr;  
    TYPE2_HEADER Type2Hdr;  
    ULONG vulConfig[64];    


Share this post

Link to post
Share on other sites

AutoIt doesn't have direct support for unions. They can be forged out of several dll structs or manual reading of data (like just make a byte array large enough to hold everything and read the bytes into your own format.

Share this post

Link to post
Share on other sites

You make e.g. raw structure in required size:

$tUNION_Raw = DllStructCreate("byte[4]")

Then depending on your needs interpret data the way you like it:

$tUNION_Dword = DllStructCreate("dword", DllStructGetPtr($tUNION_Raw))
$iDWORD = DllStructGetData($tUNION_Dword, 1)
$tUNION_Int = DllStructCreate("int", DllStructGetPtr($tUNION_Raw))
$iINT = DllStructGetData($tUNION_Int, 1)
$tUNION_Float = DllStructCreate("float", DllStructGetPtr($tUNION_Raw))
$nFLOAT = DllStructGetData($tUNION_Float, 1)




Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...