kernel32 + user32: implement FormatMessageA, WriteConsoleA, SendMessageA#120
Draft
HarryR wants to merge 2 commits intodecompals:mainfrom
Draft
kernel32 + user32: implement FormatMessageA, WriteConsoleA, SendMessageA#120HarryR wants to merge 2 commits intodecompals:mainfrom
HarryR wants to merge 2 commits intodecompals:mainfrom
Conversation
Three APIs needed by NT 3.5-era build tools (RC.EXE, LINK.EXE, MC.EXE) for error diagnostics: FormatMessageA: Full implementation of FROM_HMODULE, FROM_STRING, FROM_SYSTEM modes. Walks RT_MESSAGETABLE resources embedded in PE .rsrc sections (the MESSAGE_RESOURCE_DATA/BLOCK/ENTRY structures produced by MC.EXE). Handles %1..%99 argument substitution with !format! specifiers, FORMAT_MESSAGE_ALLOCATE_BUFFER, and FORMAT_MESSAGE_IGNORE_INSERTS. Previously commented out due to va_list trampoline issues; signature changed to LPVOID to avoid leaking GCC's __va_list_tag. WriteConsoleA: Mirrors the existing WriteConsoleW implementation. NT tools (RC, LINK) use WriteConsoleA to emit error messages after FormatMessageA formats them. Writes through to the FileObject's underlying fd for stdout/ stderr handles. SendMessageA: No-op stub returning 0 / ERROR_INVALID_WINDOW_HANDLE. NT's RC.EXE calls SendMessage(NULL, WM_USER+0x19, ...) as a vestigial IDE progress hook that's NULL in standalone CLI runs. Without the stub wibo aborts on the missing import. Also adds ERROR_INVALID_WINDOW_HANDLE (1400) to errors.h.
FormatMessageA: - Fix 32-bit va_list handling: dereference va_list* for non-ARGUMENT_ARRAY callers, use uint32_t indexing (not host DWORD_PTR) for guest stack args - Support !ws!/!ls! wide-string format specifiers in message inserts user32: - SendMessageW no-op stub (NULL HWND path for CLI tools) - CharUpperBuffW via towupper - CharNextA single-byte advance (non-DBCS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
APIs needed by NT 3.5-era build tools (RC.EXE, LINK.EXE, MC.EXE) for error diagnostics and string handling:
FormatMessageA (kernel32):
MESSAGE_RESOURCE_DATA/BLOCK/ENTRY structures produced by MC.EXE).
!format!specifiers,FORMAT_MESSAGE_ALLOCATE_BUFFER, and FORMAT_MESSAGE_IGNORE_INSERTS.
va_list*for non-ARGUMENT_ARRAYcallers, use
uint32_tindexing (not hostDWORD_PTR) for guest stack args.The guest is 32-bit so va_list entries are 4 bytes, not 8.
!ws!/!ls!wide-string format specifiers in message inserts.WriteConsoleA (kernel32):
use WriteConsoleA to emit error messages after FormatMessageA formats them.
user32 stubs:
calls SendMessage as a vestigial IDE progress hook (NULL HWND in CLI runs).
Also adds ERROR_INVALID_WINDOW_HANDLE (1400) to errors.h.