Pattern to examine frames with byte stuffing. #2063
Replies: 3 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
It is hard to tell what sort of format you want the result to have based on the description given. I made some assumptions and wrote some code: import std.mem;
struct Escape {
u8 lead[[hidden]];
if (lead==0x7D) {
u8 value[[hidden]];
u8 result = value ^ 0x02[[export]];
} else
u8 result = lead[[export]];
};
struct Frame {
Escape values[while($[$]!=0x7E && !std::mem::eof())];
u8 end;
};
struct Start {
u8 discard[while($[$]!=0x7E)];
u8 lead;
Frame frames[while(!std::mem::eof())];
};
Start start@0; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you very much. That gives me an glimpse of how to parse the outer frame and then continue examining the inner payload. Think I need to learn more about ImHex pattern programming. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a protocol that uses byte stuffing (like PPP). Single
0x7E
are used to mark boundaries between frames. Within frames special characters can be escaped by0x7D 0x..
, while this escape sequence must be replaced by the byte following to0x7D
XOR0x02
before I can examine the inner structure of the frame. The frame itself has an arbitrary length.Is there a way to put this into am ImHex pattern?
Beta Was this translation helpful? Give feedback.
All reactions