StackOverflow when trying to write a file after patching
Azukee opened this issue · 1 comments
Azukee commented
AsmResolver Version
5.4.0
.NET Version
.NET 7.0
Operating System
Windows
Describe the Bug
I'm writing a tool that does various patching to arbitrary files that are protected by mutation.
The tool is supposed to fix this mutation and various other obfuscation techniques using a dynamic approach.
I'm applying around 480 patches to a Segment
of a PESection
. Afterwards I'm attempting to write the file to disk, which then results in a StackOverflowException.
How To Reproduce
- Load a file using
PEFile.FromFile
- In a loop, apply all patches created, as seen in this figure:
(Please ignore the weird double loop and unnecessaryList<T>
I was merely testing around to see if I'd get it work.) - Try writing the file using
PEFile.Write(path)
Expected Behavior
The file gets properly written to disk.
Actual Behavior
A StackOverflowException has been thrown, preventing the file from being written to disk.
Additional Context
If you need any code or binary files, please let me know.
Azukee commented
Alright turns out I'm just an idiot.
Section.AsPatchedSegment()
is apparently not the same as Section.Contents.AsPatchedSegment()
.