Jump to content
Sign in to follow this  
GarboBombo

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")

 

Share this post


Link to post
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")

 

Share this post


Link to post
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.

Share this post


Link to post
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 2020-09-05 - Version 1.5.1.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

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...