Jump to content
Sign in to follow this  
ernesthan

Union support For DllStruct

Recommended Posts

ernesthan

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];    

}TYPEX_HEADER, *PTYPEX_HEADER;

Share this post


Link to post
Share on other sites
trancexx

It's all the same. A line of code more or less.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Richard Robertson

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
trancexx

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)

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Richard Robertson

That was a very good example, trancexx.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.