Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@ntrrgc
Copy link

@ntrrgc ntrrgc commented Feb 4, 2023

Fixes #1014

This patch wraps the BytesIO substreams made by the following subconstructs during parsing:

  • OffsettedEnd
  • Prefixed
  • FixedSize
  • NullTerminated
  • NullStripped
  • ProcessXor

This allows the Tell construct to return offsets that are relative to the beginning of the stream, rather than relative to the last occurence of these subconstructs.

This has not been implemented for the following subconstructs:

  • Transformed: there is no guarantee that there won't be any byte swapping in the transformation, therefore we can't map offsets without knowledge of the specific transformation.

  • ProcessRotateLeft: tell() offsets would be decreasing, which could cause all sorts of problems.

In both those cases, it makes more sense for the user to use a Tell immediately before the Transformed or ProcessRotateLeft and do their own mapping.

Fixes construct#1014

This patch wraps the BytesIO substreams made by the following
subconstructs during parsing:

* OffsettedEnd
* Prefixed
* FixedSize
* NullTerminated
* NullStripped
* ProcessXor

This allows the Tell construct to return offsets that are relative to
the beginning of the stream, rather than relative to the last occurence
of these subconstructs.

This has not been implemented for the following subconstructs:

* Transformed: there is no guarantee that there won't be any byte
  swapping in the transformation, therefore we can't map offsets without
  knowledge of the specific transformation.

* ProcessRotateLeft: tell() offsets would be decreasing, which could
  cause all sorts of problems.

In both those cases, it makes more sense for the user to use a Tell
immediately before the Transformed or ProcessRotateLeft and do their own
mapping.
@ntrrgc ntrrgc force-pushed the tell-global-offsets branch from 7786978 to 5ef489b Compare February 4, 2023 01:06
@arekbulski arekbulski self-assigned this Oct 22, 2023
@arekbulski
Copy link
Member

arekbulski commented Oct 23, 2023

Merging it now. I think we could even go one step further and implement a SubBytesIO that reimplements reads instead of rereading however much data into memory. Anyway, big thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefixed and others reset offsets returned by Tell

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.