Skip to content

[Feature] support for c#'s 7bit int? #2180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
sk337 opened this issue Mar 22, 2025 · 3 comments
Open
1 task done

[Feature] support for c#'s 7bit int? #2180

sk337 opened this issue Mar 22, 2025 · 3 comments

Comments

@sk337
Copy link

sk337 commented Mar 22, 2025

What feature would you like to see?

i would like to see c#'s binary reader 7 bit integer

How will this feature be useful to you and others?

i will be able to parse c# fields that use that number format

Request Type

  • I can provide a PoC for this feature or am willing to work on it myself and submit a PR

Additional context?

i am willing to work on this

@paxcut
Copy link
Collaborator

paxcut commented Mar 22, 2025

I am assuming that you mean that the pattern language a binary reader to process this type of data. The pattern language has already a bit reader in std::mem::read_bits. You can also parse 7 bit integers easily using bit-fields. What exact functionality are you trying to use that you are having trouble with? If you can provide more details maybe it will be easier to determine if extra functionality is needed or not.

@sk337
Copy link
Author

sk337 commented Mar 22, 2025

the 7 bit format is a dynamic size where the msb determines if another byte is read a related stack overflow question i am unsure on how to implement this into the Pattern editor as i am very new ImHex

@paxcut
Copy link
Collaborator

paxcut commented Mar 22, 2025

Here is a partial implementation . Use the values in pragma example to create a sample input file for testing it.

#pragma example 56 78 86 99 95 87 58 88 57 78 78 00 00 00 00 00
import std.core;
import std.mem;

bitfield SevenBitBits {
    value : 7;
   bool keepReading : 1;
   if (!keepReading || std::core::array_index() > 3 )
       break;
};

struct SevenBitBytes {
   SevenBitBits bytes[while(true)];
};

SevenBitBytes data[while(!std::mem::eof())]@0;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants