Repository navigation
CAPE: Fix disguised/zeroed-DOS PE recovery and relocated ImageBase fallback - #262
Open
doomedraven wants to merge 1 commit into
Open
doomedraven wants to merge 1 commit into
doomedraven wants to merge 1 commit into
Conversation
…llback * Add bounded FindDisguisedNtHeader() supporting zeroed/stomped e_lfanew with Machine+Magic+section validation, inner-DOS anti-misanchoring, and O(N) page-aligned probing in ScanForDisguisedPE(); return 0/1 (never truthy -1) from IsDisguisedPEHeader(). * Fix PeParser::getDosAndNtHeader() / isValidPeFile() / ScyllaDumpProcess() to bound headerMemorySize, populate dosStubSize/pDosStub on recovered zeroed-DOS headers, reset SlackData, restore MZ/PE signatures, and preserve ApiReader readSectionHeaders=false behavior. * Update OptionalHeader.ImageBase to moduleBaseAddress in PeParser::readPeSectionsFromProcess() when no live relocations exist, and fix IsDotNetImage() PE32/PE64 dispatch plus SEH guards around post-lookup header dereferences.
doomedraven
marked this pull request as ready for review
November 22, 2026 07:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CAPE/CAPE.{h,c},CAPE/Injection.c,CAPE/ScyllaHarness.cpp,CAPE/Scylla/PeParser.{h,cpp}):FindDisguisedNtHeader()supporting zeroed/stompede_lfanew(Machine+Magic+SizeOfOptionalHeader+TestPERequirements+ non-empty section + 4-byte-alignedHasInnerDosHeader()to avoid mis-anchoring embedded PEs or false-rejecting Rich headers).ScanForDisguisedPE()O(N)(AllowZeroedDosonly atp == 0and page boundaries) and makeIsDisguisedPEHeader()return0/1(never truthy-1).headerMemorySizeandsectionHeadersLoadedinPeParsersoisValidPeFile()enforces bounds without breakingApiReader::parseModuleWithProcess(readSectionHeaders == false) on large system DLLs.MachineProbeloops inDumpImageInCurrentProcess(),ScyllaDumpProcess(), andPeParser::getDosAndNtHeader(), populatedosStubSize/pDosStubon recovered zeroed-DOS headers, initialize/resetSlackData, and restoreMZ/PEsignatures inScyllaDumpProcess().IsDotNetImage()PE32/PE64 dispatch on x64 (DataDirectory[14]offset) and wrap post-lookup dereferences in SEH (FileOffsetFromRVA,GetEntryPoint,GetTimeStamp,DumpImageInCurrentProcess,WriteMemoryHandler).OptionalHeader.ImageBasefallback (CAPE/Scylla/PeParser.cpp):readPeSectionsFromProcess(), probe for live relocation blocks viareadMemoryPartlyFromProcess()before callingreBasePEImage(); when no live relocations exist (stripped/zeroed.reloc), updateOptionalHeader.ImageBaseto the 64 KiB-alignedmoduleBaseAddressso dumped pointers match the PE header without risking double-mismatch on partial rebases.Verification
extern "C"linkage, SEH/C2712, and/W3types.g++ -Wall -Wextra -Werror -fsanitize=address,undefined).git merge-tree:0conflicts against CAPE: Add shadow-page harvester and non-mutating sparse PE dump for on-demand paged PEs #253, Scylla: support MOV-based IAT discovery and clear stale OFT=0 imports #254, hooks: add Thread Name-Calling and TP_DIRECT.Callback hijack coverage #255, and InstrCallback: follow indirect/direct NtCreateUserProcess children and inherited targets #256; pure LF line endings across all 6 files.