Skip to content

Improve kernel32 compatibility for MSVC tools#124

Merged
encounter merged 8 commits into
decompals:mainfrom
marijnvdwerf:codex/legoland-wibo-functions
Jun 26, 2026
Merged

Improve kernel32 compatibility for MSVC tools#124
encounter merged 8 commits into
decompals:mainfrom
marijnvdwerf:codex/legoland-wibo-functions

Conversation

@marijnvdwerf

Copy link
Copy Markdown
Member

Summary

This improves Wibo's kernel32 compatibility for legacy MSVC-era tooling. The changes were found while forcing a full LEGOLAND decompilation build through Wibo, including compile, link, and cvdump/reccmp.

The branch adds or fixes:

  • lstrcpynA export and truncation/null-termination behavior.
  • GetTempPathA trailing-backslash and required-buffer behavior.
  • GetTempFileNameA prefix, fixed-unique, generated-unique, and empty-file creation behavior.
  • GetProcAddress missing-export handling so dynamic probes return NULL/ERROR_PROC_NOT_FOUND instead of routing to Wibo's missing-import trap.
  • Default activation-context DLL redirections for VC8 runtime DLL names, plus the redirection record size fix.
  • CreateFileMappingA file-backed mapping growth for writable protections, and correct zero-length file mapping failures.
  • MapViewOfFile / MapViewOfFileEx handling of FILE_MAP_ALL_ACCESS as shared read/write access instead of copy-on-write.
  • GetModuleHandleExW with name, NULL, FROM_ADDRESS, PIN, and UNCHANGED_REFCOUNT cases.

Fixture tests are included for the new and changed behavior.

Microsoft Learn references

  • lstrcpynA: iMaxLength includes space for the terminating null character, and success returns the destination buffer.
  • GetTempPathA: successful paths end with a backslash and the too-small-buffer return value is the required length.
  • GetTempFileNameA: only the first three prefix characters are used; uUnique == 0 creates and closes an empty file, while nonzero uUnique only generates the name.
  • GetProcAddress: missing names/ordinals fail with NULL and extended error information.
  • Activation Contexts and side-by-side assemblies as a resource: activation contexts carry DLL redirection information used by the loader and manifests can provide process-default/static-import side-by-side bindings.
  • CreateFileMappingA: writable file mappings larger than the backing file extend the file; zero-sized file mappings have documented failure behavior.
  • MapViewOfFile and file-mapping access rights: FILE_MAP_ALL_ACCESS is equivalent to FILE_MAP_WRITE for mapping views, while FILE_MAP_COPY creates a private copy-on-write view whose changes are not written back.
  • GetModuleHandleExW: supports loaded-module lookup by name, process module lookup with NULL, address-based lookup, and the documented refcount flags.

Validation

  • Built locally with cmake --preset debug-macos and cmake --build --preset debug-macos.
  • Ran the new Wibo binary through a full LEGOLAND compile + link using MSVC6 tools under Wibo.
  • Ran LEGOLAND tools/verify / reccmp through Wibo successfully.
  • Fork CI passed: https://github.com/marijnvdwerf/wibo/actions/runs/27059227930

@marijnvdwerf marijnvdwerf marked this pull request as ready for review June 6, 2026 22:19
@marijnvdwerf marijnvdwerf requested a review from encounter June 16, 2026 22:27
@encounter encounter merged commit af24a30 into decompals:main Jun 26, 2026
23 of 24 checks passed
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