Suppose I have the following text file:
Listing 1:
Endianess=little AddressModel=32 typedef struct{ int x; int y; float f; double d; } A; instance1:0x0000000100000002000048C19A99999999993C40 instance2:0x00100257000000090000000FBA99359976992397
Where instance1 corresponds to an instance of struct A, for example:
Listing 2:
A->x = 0x00000001 = 1 A->y = 0x00000002 = 2 A->f = 0x000048C1 = -12.5 A->d = 0x9A99999999993C40 = 28.6
Task:
Write an application that takes as a text file, an arbitrary C data structure and an arbitrary memory dump, and prints in an easy-to-read format, restoring an instance of this structure (for example, see Listing 2).
Questions:
- What is the best way to do this?
- Instead of reinventing the wheel, are there (are) any open source solutions that might cause this problem?
What to consider:
Decision will be
- consider the length of the data type.
- handle different models of addresses and judgments.
- displays both hex and native screen for this particular data type.
- take the C structures that were NOT associated with the program you are writing.
Bonus question:
Handle the case with inline structures:
typedef struct{ int q; int p; A a;
Thanks in advance to everyone!
source share