Repository navigation
fix(nid): preserve PE forwarders when repacking export names - #6912
Conversation
|
macOS result for the NID Python groups. The description says native Windows loading was not run; this does not cover that either. Apple M5 Pro (arm64), macOS 27.0.1, Python 3.14.7.
Not checked: native Windows loading of a repacked DLL, Windows host. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine. |
|
Windows run, covering the native loading the description lists as not run. Radeon 860M (RDNA 3.5), Ryzen AI 7 350, Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,
AI-assisted |
|
Read the diff against the PE export format: forwarder detection uses the directory bounds, direct exports are kept outside the grown range, and the patch refuses before writing when it would overlap exported data or reclassify a direct export. The new tests pin forwarder targets, ordinals and directory size; the macOS negative control (7/10 fail on main's patcher) and the Windows run cover what we can't run here; merged. |
What
Renaming PE exports can overwrite forwarded-export targets while
nid_patcherreports success. With GNU Binutils 2.42, an ordinary DLL exportinga=localandb=KERNEL32.GetCurrentProcessIdplaces a name before the forwarder string. On current main, patching leaves the forwarder RVA at0x304cbut changes its target fromKERNEL32.GetCurrentProcessIdtok3ozzWYBg, part of a replacement NID.Capture forwarded targets before repacking, deduplicate their storage and update every affected export-address entry, including unnamed exports. Preserve the DLL name, original name-to-ordinal associations and direct code/data exports. Update the directory size to cover the packed export strings while checking that every direct export remains outside that range: the PE export-address table format uses the directory bounds to distinguish direct exports from forwarders. Reclaim old string space and refuse before writing the file when new metadata would overlap exported data, change a direct export into a forwarder or exceed available space.
Tested
Linux x86_64, G++ 13.3, GNU Binutils 2.42; built the actual tool from all nine NID sources.
KERNEL32.GetCurrentProcessId, the DLL name, direct code RVA0x1000, every.textbyte and the correct sorted NID-to-ordinal mapping. GNUobjdumpdisplays both full NIDs without corrupt-offset warnings; the directory size grows from0x6bto0x7fwhile direct exports retain their classification. Native Windows loading was not run.test_pe_references.pygroup pass. Coverage includes PE32/PE32+, interleaved strings, named/ordinal/unnamed/shared forwarders, long-name space reclamation, external DLL metadata, direct-data preservation, directory growth and unchanged-file refusal when growth would overwrite exported data or reclassify a direct export. Main fails the forwarder and overlapping-growth regressions.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository