Open az55555 opened 1 year ago
We had similar issue with getDebugDir on a completely different input file. From the looks of it, IMAGE_DIRECTORY_ENTRY_DEBUG is not something required for execution, and some toolchains put there various non-conforming information they need for their own debugging purposes. In our case it was a string - a path to the project on the build machine. The resulting size of data directory wasn't even divisible by entry size.
Conceptually, it is probably better to ignore errors while parsing non-essential parts like debug data directories. Pe-parse code causing troubles is this:
replacing return false;
with break;
solves the issue. There is another return false;
few lines above. It is probably better to replace it with break;
as well.
@batuzovk I agree that it'd be fine to skip unparseable non-critical sections, as long as we're confident that no other code assumes they've been parsed correctly (since the current error state preserves that invariant). Could you send a PR for this?
In this particular case there is code that skips everything starting from unparsable entry already, so we won't change much in this regard.
I'll make PR tomorrow.
I've opened merge request https://github.com/trailofbits/pe-parse/pull/199 It should address the issue with the first file.
Thanks for the great project! I'm trying to use it for reading versions from executables. I've built it with Qt Creator, gcc, qbs (see my .qbs and .cpp files in the archive): pe-parse.zip Most EXE and DLL files I've tried were parsed fine but two of them failed:
Here is my code: