Custom struct parsing depending on previously read value #2154
-
hey ho, i love this so far, have been playing around with it I got some issue, though, which I've been trying to fix for an hour, if someone knows an answer to that... we have a struct which calculates some offsets and depending on that, the struct may or may not start with a specific field. I finally have something that runs without errors but it doesn't show up in the hex or tree view. (I tried it with global variables or a function that returns the right struct, setting a Size field but it didn't work) I'm on my phone so from what I recall it looks like: struct MyStruct<auto Size> {
if (Size == 8) {
MY_ENUM bleh = MYENUM::DEFAULT_VALUE; // have a default value that's not part of the file itself
}
else {
MY_ENUM bleh; //read from bytes instead
// more fields
}
};
// some previous logic here
s32 mySize = offset1 - offset2;
MyStruct<mySize> myStruct @32; it runs, variables have the right values, even the breakpoint hits like it should, but the bytes in the hex view stay default and nothing shows. I'll try more later or tomorrow, unless I'm on the right track and I'm missing something 🤔 Have a great day :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
By assigning a value to the variable you are turning it into a local variable which by default will not be shown in the pattern data view and as you rightly implied there is no place in the hex view where it would go. To have it shown in the pattern data tree view use the [[export]] attribute. |
Beta Was this translation helpful? Give feedback.
you can write the example you wrote as the following pattern:
When File is placed it will first read data struct then check its size and compare it to the offset, If the off…