Skip to content

Fix FormatMessageA trampoline generation#139

Open
miried wants to merge 1 commit into
decompals:mainfrom
miried:codex/formatmessagea-trampoline
Open

Fix FormatMessageA trampoline generation#139
miried wants to merge 1 commit into
decompals:mainfrom
miried:codex/formatmessagea-trampoline

Conversation

@miried

@miried miried commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

FormatMessageA is needed for error diagnostics in MSVC 4.2 (and possibly other tools from that era). E.g. RC.EXE currently errors because the function is not available. Note that the existing implementation is not feature-complete - this PR focuses only on enabling the function and giving it enough functionality to verify that the va_list works.

FormatMessageA takes a va_list pointer. On 64-bit targets, Clang canonicalizes va_list as an array of __va_list_tag, so the generated helper prototype tried to spell a pointer-to-array type as a simple parameter and produced invalid C syntax. Treat array pointees as opaque in best-effort helper prototypes: the trampoline only needs the outer pointer ABI, and void * preserves that ABI without depending on the host va_list representation.

Enable the existing shim and add a fixture that exercises reordered ANSI string inserts through a real guest va_list. Implement only the minimal FORMAT_MESSAGE_FROM_STRING insert path needed by the test; broader FormatMessageA support remains out of scope.

FormatMessageA takes a va_list pointer. On 64-bit targets, Clang canonicalizes va_list as an array of __va_list_tag, so the generated helper prototype tried to spell a pointer-to-array type as a simple parameter and produced invalid C syntax. Treat array pointees as opaque in best-effort helper prototypes: the trampoline only needs the outer pointer ABI, and void * preserves that ABI without depending on the host va_list representation.

Enable the existing shim and add a fixture that exercises reordered ANSI string inserts through a real guest va_list. Implement only the minimal FORMAT_MESSAGE_FROM_STRING insert path needed by the test; broader FormatMessageA support remains out of scope.
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.

1 participant