Skip to content

fix: use VirtualSize instead of SizeOfRawData for Windows PE .bun section#7

Closed
taocihei wants to merge 1 commit into
VoidChecksum:mainfrom
taocihei:main
Closed

fix: use VirtualSize instead of SizeOfRawData for Windows PE .bun section#7
taocihei wants to merge 1 commit into
VoidChecksum:mainfrom
taocihei:main

Conversation

@taocihei
Copy link
Copy Markdown

markdown

Problem

vpcc patch fails on Windows PE builds with:
fail [bun-inplace] Bun trailer invalid - format change
plain

Root Cause

On Windows PE builds, .bun section has:

  • VirtualSize = 131,532,925 bytes (actual data)
  • SizeOfRawData = 131,533,312 bytes (+387 bytes file-alignment padding)

Current code uses rsize or vsize, causing bun_hi to land inside trailing NUL padding. Trailer validation reads \x00 bytes instead of the real trailer and fails.

Fix

Change section size resolution to prioritize VirtualSize:

return (raw_off, vsize or rsize)
Verification
Tested on Claude Code 2.1.119 Windows build:
plain

95 ok · 0 failed · 0 skipped

…tion

On Windows PE builds, SizeOfRawData includes file-alignment padding,
causing the Bun trailer validation to read trailing NUL bytes and fail.
Prioritizes VirtualSize to read actual data boundary.
@VoidChecksum
Copy link
Copy Markdown
Owner

Thanks for the fix! The same change landed via #17 (commit 663433e on 2026-04-29) — your branch is now in conflict because both branches modified the same line. Current main has (raw_off, vsize or rsize) in _find_bun_section_pe exactly as you proposed. Closing as superseded. Appreciate the diagnosis and root-cause writeup.

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