pe: pin the delay-load import pairing with a synthetic image #573
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!573
Loading…
Reference in a new issue
No description provided.
Delete branch "qnjk/Darner:pe-delay-import-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Contributor role (optional)
What it changes
The problem on main: nothing. This is a tests-only change (no production line is edited), so it needs no A/B result and no gameplay run.
What it pins:
parse_delay_importshands the descriptor'sImportNameTableRvatoentriesas the thunk list and itsImportAddressTableRvaas the IAT base (crates/darner-pe/src/image.rs:316-321), andentriestakes the symbol from the first and the slot RVA from the second (:337-340). Nothing in the workspace built an image whose delay-load directory was parsed:parses_own_test_binaryreads the rustc-linked test exe, which has no delay-load table (apps/darner/build.rslinks with/DELAYLOAD:d3d12.dll, but that is a different binary), and the synthetic helper was only used for exports, sections and TLS. The two fields are twou32s of one 32-byte descriptor read symmetrically, so swapping them, naming entries from the address table, or dropping theSizeOfImagebound would not have been caught: a swapped binding names every delay-loaded import wrongly and calls through the wrong slot, which only shows up as a wrong function in a run.This change adds
synthetic_image_with_delay_import(iat_rva), which wraps the existingsynthetic_imagehelper with a one-descriptor delay-load directory (data directory 13), and two tests. Production code is untouched.How it was tested
0b7a1bb(one commit onc8258f9).cargo test --locked -p darner-pe --lib— 41 passed, 0 failed.image::tests::delay_imports_pair_the_name_table_with_the_address_table: the image has DLLdelay.dll, a name table at 0x1040 namingFoo(hint 7) and an address table at 0x10C0 whose thunk points at a different hint/name entry,Bar(hint 9), so a crossed pairing cannot agree by accident. It asserts one module, one entry,symbol == ImportSymbol::Name { hint: 7, name: "Foo" }andiat_slot_rva == 0x10C0(the address table's RVA, not the name table's 0x1040).image::tests::rejects_a_delay_import_iat_outside_the_image: the same image with the address table at 0x3000, pastSizeOfImage(0x2000), must beErr(PeError::Malformed(_)), mirroring the existingrejects_iat_outside_imagefor the normal import table.git checkout --, nevergit stash), e.g. the crossed pair:cargo clippy --locked -p darner-pe --all-targets -- -D warningspasses.cargo clippy --workspace --all-targets --locked -- -D warnings: passes.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.cargo test --workspace --locked: not run to completion here; the pre-existingdarner-gputest deadlock (#224) and thedarner-shaderwaterfall fixture failure (#227) make the whole-workspace run non-green on this machine, and neither crate is touched.darner-pe's suite is green (41 passed).Attributesnot RVA-based, and an ordinal entry are not exercised.Checklist
main.docs/asset-policy.md. (cargo xtask policy: 576 files ok.)Checked for overlap
crates/darner-pe/src/image.rs(checked against the file list of all 189 open pull requests), and no open or closed issue mentions the delay-load import table.[pr-tests] pe: pin the delay-load import pairing with a synthetic imageto pe: pin the delay-load import pairing with a synthetic imageView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.