Templates with dword alignment? Log Out | Topics | Search
Moderators | Edit Profile

X-Ways Support Forum » Advanced Features » Templates with dword alignment? « Previous Next »

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Tony V
Username: tonyv

Registered: N/A
Posted on Sunday, Feb 4, 2007 - 4:55:   

Hey all,

I have binary files that has stuff aligned on four-byte boundaries. A typical example might be something like:
 
0x80: 07 00 // 16-bit uint String length
0x82: 46 6F 6F 62 61 72 21 // ASCII text
0x89: 00 00 00 // Padding to align on 4-byte boundary
0x8C: 00 00 A0 44 // 32-bit float (dec 1280)

...

In other words, strings in particular may have zero, one, two, or three zero bytes of padding after them so that the next field is aligned on the four-byte boundary. That final 32-bit uint can start at 0x80, 0x84, 0x88, 0x8C, 0x90, 0x94, etc., but not at 0x89, 0x8A, or 0x8B because those aren't on a four-byte boundary.

Is there any way that this can be cleverly accounted for in a template? If so, how? If not, can I put that on the list o' requested features to be added?
Top of pagePrevious messageNext messageBottom of page Link to this message

Stefan Fleischmann
Username: admin

Registered: 1-2001
Posted on Sunday, Feb 4, 2007 - 11:13:   

I think you could use the modulo operator (%) and a conditional Move command for that.

Add Your Message Here
Post:
Username: Posting Information:
Only registered users may post messages here, i.e. you need to have an account.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:
Forum operated by X-Ways Software Technology AG.