WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
44.81k stars 1.95k forks source link

[Bug] `[[hidden]]` values being shown in value summary for struct #1697

Open Kein opened 5 months ago

Kein commented 5 months ago

Operating System

Windows

What's the issue you encountered?

[[hidden]] values being shown in value summary for struct

How can the issue be reproduced?

bitfield ElevatorsData {
    BlueRat : 1 [[comment("0 down, 1 up")]];
    RedRat : 1  [[comment(" 0 right, 1 left")]];
    Ostrich : 1 [[comment(" 0 right, 1 left")]];
    Dog : 1     [[comment("0 down, 1 up")]];

    pad : 4 [[hidden]];
};

struct MapData {
    // ---
    float            SimFloats[16] [[comment("Unrelated to map data")]];
    ElevatorsData    ElevatorStates;
};

ImHex Version

1.33.0

ImHex Build Type

Installation type

manual

Additional context?

The hidden pad value is being displayed, essentially ignoring [[hidden]]: image

paxcut commented 5 months ago

Hidden means that its variable will not be seen in the set of variables shown in pattern data window not that the value will be ignored if accessed. Why is it not printing for the two rats?

Kein commented 5 months ago

There is no way for me to access this value from the constructed pattern table (because it is set to hidden), so why would it display it in the value overview? It makes no logical sense. I specifically want it to be hidden so I set it to hidden.

paxcut commented 5 months ago

Again, that's not what hidden does. The attribute [[hidden]] doesn't erase the variable and its value can be displayed, but the member variable will not be listed in the contents of the pattern that contains it.

Perhaps you should use the padding data type which will be non-existent as a variable.From online docs:

Padding

It’s also possible to insert padding in between fields using the padding syntax.

bitfield Flags {
a : 1;
b : 2;
padding : 4;
c : 1;
};

This inserts a 4 bit padding between field b and c.

If this was a struct you could also leave the field anonymous, but i don't think bit-fields can have anonymous members.

Kein commented 5 months ago

I dont want to use padding, it is ImHex specific. If [[hidden]] does not do what it is logically and empirically supposed to do (or what its alternative does in 010 Editor) then it needs to be/should be/could be updated to be wider or have a modifier that can do full hide.

C3pa commented 3 months ago

To me, this looks like you are really looking for padding: https://docs.werwolv.net/pattern-language/core-language/data-types#padding.

Also, to clarify, it looks like the [[hidden]] attribute doesn't correctly hide the bitfield values, not struct members.

paxcut commented 3 months ago

the attribute works. what doesn't work is the summary value of the bitfield.

image