Jump to content

AutoIt structure with no padding.


Recommended Posts

I think the title is self explanatory, but if not I just need a way of creating a structure has no padding if an array of bytes is less than 4. Although I know this specific and not at all efficient the task I am trying to accomplish is pretty stern when it comes to data structures. If there are any other alternatives for data structures when pertaining to specific size of variables I would be more than grateful to use that.

Just as an example I'll show a little bit of code to explain what my problem is.

#include <Misc.au3>
#include <Math.au3>
#include <WinAPI.au3>

$examplestruct = "BYTE base;"
$examplestruct&= "FLOAT s;"
$examplestruct&= "FLOAT d;"
$examplestruct&= "FLOAT a;"

$example = DllStructCreate($examplestruct)

MsgBox(1,"Structure Size Problem","Target size of structure: 13 bytes"&@CRLF&"Actual size of structure:"&DllStructGetSize($example)&" bytes")

 

Link to comment
Share on other sites

To align is divine...

#include <Misc.au3>
#include <Math.au3>
#include <WinAPI.au3>

$examplestruct = "align 1;BYTE base;"
$examplestruct&= "FLOAT s;"
$examplestruct&= "FLOAT d;"
$examplestruct&= "FLOAT a;"

$example = DllStructCreate($examplestruct)

MsgBox(1,"Structure Size Problem","Target size of structure: 13 bytes"&@CRLF&"Actual size of structure:"&DllStructGetSize($example)&" bytes")

 

Link to comment
Share on other sites

1 minute ago, RTFC said:

To align is divine...

#include <Misc.au3>
#include <Math.au3>
#include <WinAPI.au3>

$examplestruct = "align 1;BYTE base;"
$examplestruct&= "FLOAT s;"
$examplestruct&= "FLOAT d;"
$examplestruct&= "FLOAT a;"

$example = DllStructCreate($examplestruct)

MsgBox(1,"Structure Size Problem","Target size of structure: 13 bytes"&@CRLF&"Actual size of structure:"&DllStructGetSize($example)&" bytes")

 

Truly! Thank you.

Link to comment
Share on other sites

BTW GarboBombo,

do not quote the post, the posters know what they have written ;) Simply add the reply at the end of the thread and click the "Submit Reply" button.
Quoting posts only clutters the thread.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...