Skip to content

fix(loader): harden image cache and TLS patching - #96

Open
cosminn1337 wants to merge 9 commits into
Zettrox:mainfrom
cosminn1337:main
Open

cosminn1337 wants to merge 9 commits into
Zettrox:mainfrom
cosminn1337:main

Conversation

@cosminn1337

@cosminn1337 cosminn1337 commented Nov 25, 2026 •

Copy link
Copy Markdown

Changes

  • Key prepared image cache files by the full hash of their prepared bytes, so different versions use separate paths.
  • Publish cache files through unique temporary files. Reuse an identical file published by another process; if the canonical path contains different bytes, preserve it and use a unique alternate path.
  • Decode x64 instructions from PE .pdata function ranges and follow direct control flow before patching TLS loads.
  • Free the mapped image if TLS redirection fails.

Checks

  • cargo check -p victory-loader — passed
  • cargo test -p victory-loader — passed
  • cargo fmt --all -- --check — reports formatting differences across the workspace

When a prepared image cache file differs from the expected bytes, Windows may
refuse to replace it if another process has mapped it. Publish the new image
under an alternate filename and load that path instead. Also clean up the
temporary file if publication fails.
Refactor file staging and recovery logic to ensure unique naming across concurrent processes. Improve error handling for file operations.
@AdyTzZz

AdyTzZz commented Nov 25, 2026

Copy link
Copy Markdown

Good job king

Added the 'iced-x86' package version 1.22.0 with its dependencies.
Added code_ranges field to store function RVA ranges and implemented parse_code_ranges function to read valid x64 RUNTIME_FUNCTION ranges from the exception directory.
@cosminn1337 cosminn1337 changed the title fix(loader): handle mapped image cache files on Windows fix(loader): harden image cache and TLS patching Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants