hle(host_posix): FindResourceW, SizeofResource, LockResource and version.dll's three calls are unimplemented #625

Closed
opened 2026-11-28 16:00:57 +00:00 by AnastasisKon · 3 comments
AnastasisKon commented 2026-11-28 16:00:57 +00:00 (Migrated from github.com)
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T16:00:57Z.


Summary

The resource calls were half there: FindResourceExW and LoadResource walked the mapped image's tree, but FindResourceW, SizeofResource and LockResource were unimplemented, and so was all of version.dll — GetFileVersionInfoSizeW, GetFileVersionInfoW, VerQueryValueW. A title reading its own version info (a build check, a crash log, an "about" string) got nothing, and one loading its own art got no size to allocate.

What the change does

  • SizeofResource: the data entry's size, which is at offset 4 of the entry FindResourceExW hands out.
  • LockResource: the bytes, which are already in the mapped image; LoadResource hands out the same address, so the two agree.
  • FindResourceW: the same walk as FindResourceExW with any language, which is how a title asks for its own version resource.
  • GetFileVersionInfoSizeW / GetFileVersionInfoW: RT_VERSION/1 out of the image the path names, and its bytes copied into the title's block. version.dll's calls address a file, so they answer for an image this host has mapped (by file name) and refuse a path it has not mapped — the tree is read from the mapped image, not off disk.
  • VerQueryValueW: parses the VS_VERSIONINFO block — \ (the fixed file info), \VarFileInfo\Translation, and \StringFileInfo\<table>\<key> — with wValueLength read as characters for a string and bytes for a binary value, as Windows reports them.
  • version.dll is now served by the same table as kernel32.dll, since those three names live there.

Tests

Two new ones in system.rs: a version resource built block by block (the way a linker writes it) is queried for its fixed file info, its FileVersion string and its translation, and a missing key, table or path is not found; and the calls that cannot be answered (a null resource, an unmapped path) fail with their reasons. The builder caught a real mistake in my own test — VS_FIXEDFILEINFO is thirteen words, not twelve, and one word short put every child block four bytes off.

Why it matters

A title can read its own build number, and the version resource is parsed once, from the image the host already has mapped, with no PE re-reading.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6667840761 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/625). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T16:00:57Z. --- ## Summary The resource calls were half there: `FindResourceExW` and `LoadResource` walked the mapped image's tree, but `FindResourceW`, `SizeofResource` and `LockResource` were unimplemented, and so was all of `version.dll` — `GetFileVersionInfoSizeW`, `GetFileVersionInfoW`, `VerQueryValueW`. A title reading its own version info (a build check, a crash log, an "about" string) got nothing, and one loading its own art got no size to allocate. ## What the change does - `SizeofResource`: the data entry's size, which is at offset 4 of the entry `FindResourceExW` hands out. - `LockResource`: the bytes, which are already in the mapped image; `LoadResource` hands out the same address, so the two agree. - `FindResourceW`: the same walk as `FindResourceExW` with any language, which is how a title asks for its own version resource. - `GetFileVersionInfoSizeW` / `GetFileVersionInfoW`: `RT_VERSION`/1 out of the image the path names, and its bytes copied into the title's block. `version.dll`'s calls address a *file*, so they answer for an image this host has mapped (by file name) and refuse a path it has not mapped — the tree is read from the mapped image, not off disk. - `VerQueryValueW`: parses the `VS_VERSIONINFO` block — `\` (the fixed file info), `\VarFileInfo\Translation`, and `\StringFileInfo\<table>\<key>` — with `wValueLength` read as characters for a string and bytes for a binary value, as Windows reports them. - `version.dll` is now served by the same table as `kernel32.dll`, since those three names live there. ## Tests Two new ones in `system.rs`: a version resource built block by block (the way a linker writes it) is queried for its fixed file info, its `FileVersion` string and its translation, and a missing key, table or path is not found; and the calls that cannot be answered (a null resource, an unmapped path) fail with their reasons. The builder caught a real mistake in my own test — `VS_FIXEDFILEINFO` is thirteen words, not twelve, and one word short put every child block four bytes off. ## Why it matters A title can read its own build number, and the version resource is parsed once, from the image the host already has mapped, with no PE re-reading.
AnastasisKon commented 2026-11-28 16:00:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T16:00:58Z.


/claim

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7241908605 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/625#issuecomment-7241908605). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T16:00:58Z. --- /claim
github-actions[bot] commented 2026-11-28 16:01:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by github-actions[bot] on 2026-11-28T16:01:08Z.


Claimed by @AnastasisKon. Open a draft pull request with Refs #625 in its description within 24 hours, or the claim expires.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7241910719 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/625#issuecomment-7241910719). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T16:01:08Z. --- Claimed by @AnastasisKon. Open a draft pull request with `Refs #625` in its description within 24 hours, or the claim expires.
AnastasisKon commented 2026-11-28 16:31:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-28T16:31:56Z.


Merged with the PR that serves these calls; closing.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7242314155 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/625#issuecomment-7242314155). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-28T16:31:56Z. --- Merged with the PR that serves these calls; closing.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS#625
No description provided.