parsing - Manipulating binary C struct data off line -


i have practical problem solve. in embedded system i'm working on, have pretty large structure holding system parameters, includes int, float, , other structures. structure can saved external storage.

i'm thinking of writing pc software change values inside binary structure without changing overall layout of file. idea 1 can change 1 or 2 parameter , load memory external storage. it's special purpose hex editor.

the way figures it: if can construct table contains: - parameter name - offset of parameter in memory - type should able change want.

my problem doesn't easy figure out offset of each parameter programmatically. 1 can manually printf addresses i'd avoid that.

anybody know tool can of help?

edit system in question 32 arm based running in little endian mode. compiler isn't asked pack structure purpose it's same x86 pc. problem size of structure: contains no less 1000 parameters in total, spreading across multiple level of nested structures. it's not feasible (or rather i'm not willing to) write short piece of code dump offsets. guess key problem parsing c headers , automatically generate offsets or code dump offsets. please suggest such parsing tool.

thanks

the way done sharing header file defines struct other (pc) application well. should able load bytes , cast them kind of struct , edit away.

before doing this, need know (and possibly handle):

  1. type sizes. if 2 platforms different (16bit vs 32 bit) etc, might have differently sized ints/floats, etc.
  2. field alignment. if compiler/target different, packing rules fields won't same. can force these same compiler-specific #pragmas.
  3. endianness. careful of in cases. if embedded device different endianness pc target, you'll have byte swap each field when load on pc.

if there many differences here bother with, , you're building quicker/dirtier, don't know of tools generate struct offsets automatically, poster says, write short c code uses offsetof or equivalent (or does, suggest, pointer arithmetic) dump out table of fields , offsets.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -