-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
I dont know how to get the current offset of file. #27
Comments
Hi |
current byte offset of file when used in a hex pattern |
I was having the same usability issue I think: there doesn't seem to be a good way to get the current byte offset under the cursor in various views. For example, in the hex editor if I'm looking at a byte I literally counted the byte columns from the start of the row to manually type it in the pattern editor. Having every single byte offset be easily accessible would be super useful (imgui makes this nice - a byteOffsetText() fn that handled right clicking/shift+clicking/etc on the text to copy to clipboard would be easy to slot in, etc). |
That is correct ^ |
This is possible now using the |
can you be more specific on how to use the $ operator? |
To copy the offset on the hex editor view place the cursor on the data whose offset you want and right click Copy As > Address. That will copy the offset to the clipboard. The $ operator in the pattern language is the operator that returns the current offset that the pattern is processing. When you place a pattern in the data using the @ operator, the value of $ is updated automatically. $ can be read, assigned to variables, written to using values or variables like for example: std::print("{:#x}",$); //prints offset in hex
u32 offset = $; // assigns offset to variable 'offset'
$ = a==0 ? 0x25 : a; // if a is zero set offset to 37 else set it to the value of a |
Im trying to use your patterns and I dont know how to get the current offset of the file.
The text was updated successfully, but these errors were encountered: