Fix some offsets computation when using scroll
While I was working on a personal project using both goblin and scroll, I found some bugs in the way offset are computed for both DataDirectories and OptionalHeader.
Here some minor fixes without breaking changes.
While going through the code I notice that most parsing methods are present twices:
- one implementation with the scroll traits
- one using the method
parseof each structs
Is there a reason why theses two implementations cohabit? Using only one could reduce bugs and improve maintainability.
I noticed that for now, the only reason we rely on the method DataDirectories::parse is that we take the count parameters taken from the optional header. The thing is that no matter what we will construct an array of 16 (NUM_DATA_DIRECTORIES) internally. However as we don't store this count number internally, we will write the 16 entries when using TryIntoCtx.
We should either store this count if we know that PE files can have less than 16 entries or consider that it will always be 16 and transform the DataDirectories::Parse implementation a TryFromCtx without the count parameter.
CI is failing
weird this is nightly failing actually; i didn't think this voted on CI ...
can you try applying this patch?
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index badc1bd..11f24f3 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
- build: [MSRV, stable, nightly, macos, win32, win64]
+ build: [MSRV, stable, macos, win32, win64]
include:
- build: MSRV # Minimum supported Rust version
os: ubuntu-latest
to temporarily unblock you
NB: non-breaking