Repository navigation
|
I am reverse engineering a binary dataformat written by a program. In this program you can create 8 different 2D shapes and after digging deep in the datafile I have found the records for these shapes but I would need some help how to describe them as cleanly as possible. Depending on which shape has been used, a u8 byte at position 0x44 in the record says which kind of shape it is. I have gotten this far: Using the if-case I can select which 2D shape the record is supposed to be for. Basically, each record starts with bytes What I'm having problems with is how to define / work with the different sized payloads between these markers. A lot of structures are the same for all shapes (for example, I can use a messy mix of functions and if / while to find all bits and pieces, but I have no idea how to create a clean struct depending on the u8 byte that tells me which shape it is and since the record can be of very varying size. Therefore I am asking for a sort of guidance or a ready example pattern I can study to learn how to do this. |
Replies: 3 comments
|
Hey! Thing I'd do would be some variation of this: struct Primitive {
u8 marker;
// Handle end marker
if (marker == 0xFF)
break;
padding[0x2F];
PrimitiveType type;
// Handle primitive types
match (type) {
(PrimitiveType::Line): Line data;
(PrimitiveType::Bezier): Bezier data;
}
};
Primitive primitives[while(true)] @ 0x00;That matches all primitives until it hits the 0xFF marker |
|
If I understand this correctly, there should be a separate I think that will work. I will definitely give it a try and see what I end up with. |
|
I think that solved basically everything. Code (still messy, will clean-up after thorough testing): It find and fills basically all values for a Circle shape:
Thank you @WerWolv for the help, and thank you for this awesome software! I have used it only for a week but I am amazed how powerful it is. |

Hey! Thing I'd do would be some variation of this:
struct Primitive { u8 marker; // Handle end marker if (marker == 0xFF) break; padding[0x2F]; PrimitiveType type; // Handle primitive types match (type) { (PrimitiveType::Line): Line data; (PrimitiveType::Bezier): Bezier data; } }; Primitive primitives[while(true)] @ 0x00;That matches all primitives until it hits the 0xFF marker