Skip to content

feat(native): decode RT_STRING and RT_VERSION payloads in PE resources - #2887

Open
thefolahan wants to merge 9 commits into
morluto:mainfrom
thefolahan:feat/pe-string-version-resources
Open

thefolahan wants to merge 9 commits into
morluto:mainfrom
thefolahan:feat/pe-string-version-resources

Conversation

@thefolahan

Copy link
Copy Markdown
Contributor

Summary

Fixes #2812. inspect_pe_resources now decodes RT_STRING and RT_VERSION payloads, which it previously returned as opaque bytes. Both formats are fixed and documented, and they answer two first questions of a Windows investigation: which build is this, and which messages does it contain.

On Microsoft's own dbghelp.dll (shipped inside WebStorm's async-profiler), the result now includes:

version_infos[0]: decoded, file 10.0.19041.685, product 10.0.19041.685, translation 1033/1200
  040904B0: CompanyName="Microsoft Corporation"  FileDescription="Windows Image Helper"
            FileVersion="10.0.19041.685 (WinBuild.160101.0800)"  InternalName="DBGHELP.DLL"
            OriginalFilename="DBGHELP.DLL"  ProductName="Microsoft® Windows® Operating System" ...

and on symsrv.dll, string blocks 63 to 66 expand to IDs such as 1002="Symbol Server" and 1022="Requests/sec".

Change and scope

Two new arrays sit next to icon_groups, both produced by a new src/native/pe/PeResourcePayloads.ts.

string_tables, one per RT_STRING resource:

  • Block N expands into its sixteen counted UTF-16LE strings, with IDs (N - 1) * 16 through (N - 1) * 16 + 15.
  • Empty slots are kept, so every ID in the block is accounted for. Each string carries its file location.
  • trailing_bytes counts padding after the sixteenth string instead of rejecting it.

version_infos, one per RT_VERSION resource:

  • fixed_file_info: the VS_FIXEDFILEINFO signature is checked. File and product versions come as text ("6.6.3.0") and as their original words, plus flags, OS, type, subtype and date.
  • string_file_info: every StringFileInfo table, with its key split into language and code page, and each value with its location.
  • translations: the VarFileInfo\Translation language and code page pairs.
  • A text value is read up to its terminator inside its own block, because some resource compilers count its length in bytes rather than UTF-16 units. There is a test for this, since Delphi output like the sample in the issue is a common source.

As the issue asks, a payload that breaks its documented layout becomes status: "malformed" with a reason and no decoded values, while the resource inventory still succeeds. Decoded text is reserved against the existing 8 MiB metadata budget before allocation, and every row goes through the same account path as icon groups.

Not included: RT_MESSAGETABLE and other payload formats, which stay opaque, and LoadString/VerQueryValue language fallback, which is not observed. Both limitations are stated in the result.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/native/pe (payload decoding after the resource tree is read). peResourcesSchema owns the contract.
  • CLI and MCP/tool-catalog contract: additive. Two new required arrays (string_tables and version_infos, empty when an image has no such resources), an updated tool description and example title, and updated limitation text.
  • Provider, bridge, target-format, or platform compatibility: portable Node parsing, with no provider or Windows SDK. PE32 and PE32+ as before.
  • Docs: docs/binary-diagnostics.md describes both decoders and the malformed status.

Verification

Node 24.21.0 on macOS (Apple silicon):

  • src/native/pe/PeResourcePayloads.test.ts (new, 10 tests) builds payloads by hand, independent of the decoder. It covers a 16-ID block with empty slots and non-ASCII text checked against its byte range, trailing padding, a truncated block, a string past its block, a named block, full version info with string tables and translations, a byte-counted text value, a bad signature, a wrong root key, and a length past the payload. Each malformed case asserts the inventory still succeeds.
  • src/native/pe (34 tests), tests/acceptance/applications/peResources.test.ts through the compiled CLI and real stdio MCP, tests/boundary/mcp/toolSchemaValidity.test.ts, tests/boundary/mcp/compactInputSchemaMcp.test.ts, src/contracts and tests/conformance/contracts: all pass.
  • npm run check:fast, npm run docs:check and npm run verify:test-discovery: pass.
  • Real binaries: dbghelp.dll and symsrv.dll (version info and string tables as above), and Ghidra's WinHelloCPP.exe training sample, whose block 7 decodes to 103="WinHello" and 109="WINHELLO", the Visual Studio template's IDS_APP_TITLE and IDC_WINHELLO. Other PE files without these resources return empty arrays.

I did not have the issue's DATASUS sample, so it was not run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T18:51:44.136323Z fc350ff New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 54ba142758

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/native/pe/PeResourcePayloads.ts Resolved
Comment thread src/native/pe/PeResourcePayloads.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Adds decoding for string and version resource payloads.

The PR should not merge until broken version-entry types produce malformed results instead of successful but misleading output.

Findings

  1. P1 Broken versions look decoded ▶
  2. P2 Location checks go untested ▶
Fix with agent prompt
### Issue 1
src/native/pe/PeResourcePayloads.ts:undefined-244
When a string entry has `type = 0`, `readStringFileInfo` replaces its value with `null` and reports the version payload as `decoded`. `readTranslations` also reads text entries as binary language/code-page pairs. Someone inspecting these broken resources gets missing text or misleading translations under a success label.

Check the required types before decoding these entries. A broken layout should return `malformed` with no decoded values, as the tool promises.

### Issue 2
src/application/binaryDiagnostics/PeResourcesService.test.ts:47-55
The new `bad-string-location` and `bad-version-location` tests never check a bad location. The string case fails because `strings` is empty. The version case fails because `resource_index` is past the resource array, and its malformed row has no decoded locations.

Both tests would still pass if the new `withinPayload` checks were removed. Build otherwise-valid decoded rows, then move one location outside its resource payload so the tests catch that regression.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds RT_STRING and RT_VERSION decoding, source locations, malformed-payload results, and matching contracts and documentation.

  • PE resource results show the messages stored in RT_STRING blocks.
  • PE resource results show file versions, text fields, and translations.

Reviews (8) · Last reviewed commit: "test(pe): share one payload range betwee..." · Reviewed by Greptile

Comment thread src/native/pe/PeResourcePayloads.ts Resolved
Comment thread src/native/pe/PeResourcePayloads.ts Resolved
Comment thread src/native/pe/PeResourcePayloads.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8f7af3df1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

): PeResources["version_infos"] =>
resources
.filter((resource) => isResourceType(resource, RT_VERSION))
.map((resource) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Cache or yield repeated version payload decodes

When an image has many RT_VERSION leaves pointing to the same exact payload range (a shape that rejectOverlappingRanges permits and the hash loop already deduplicates), this map reparses the whole block tree synchronously for every resource. A valid 65,535-byte root can hold about 8,000 minimal children, so the default 16,384-entry tree can force tens of millions of parses; because no yield or signal check occurs until after both decoder passes in parsePeResources, cancellation cannot be delivered while the MCP event loop is blocked. Cache by payload range as hashing does, or make this traversal cancellable.

AGENTS.md reference: AGENTS.md:L46-L50

Useful? React with 👍 / 👎.

Comment on lines +144 to +147
const declared =
type === 1 ? Math.min(valueLength * 2, blockEnd - valueAt) : valueLength;
if (valueAt + declared > blockEnd)
malformed(`Version value for ${JSON.stringify(key)} leaves its block.`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject impossible text value lengths

When a text node's wValueLength is larger than both the available byte count and the available UTF-16-unit count (for example, a short CompanyName node mutated to 0xffff), this clamp consumes the remaining block, makes the following bounds check ineffective for type 1, and reports the payload as decoded. The byte-counted compiler quirk only requires falling back to valueLength bytes when that count fits; values that fit neither interpretation should produce the promised malformed result.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

// part, and the resource inventory still succeeds.
string_tables: z.array(
z.strictObject({
resource_index: uint,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate new payload references at the Evidence boundary

Whenever a PeResourcesPort returns schema-valid but inconsistent output—for example, a string table whose resource_index points to RT_ICON or a version string location outside its associated payload—the new fields pass both peResourcesSchema and PeResourcesService.validReport: that validator currently traverses resources and icon_groups only and never examines either new array. The service then publishes unattached ownership and locations as observed Evidence, so extend the application-boundary checks and tests to cover resource types, status invariants, and every nested range for these records.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

kind: "native-provider",
description:
"Inspect one explicit local PE32/PE32+ image's complete bounded type/name/language resource tree without executing it or opening a disassembler. Returns numeric IDs versus original UTF-16 names, directory/data-entry file locations, payload RVA/file ranges, complete SHA-256 hashes and static RT_GROUP_ICON image-resource candidates. Language fallback, image decoding and actual shell/window loading remain unobserved. Reads a stable regular file; malformed or ambiguous mappings, non-identical overlapping ranges and exhausted budgets return no partial success. Portable on supported Node hosts; no Windows SDK or engine installation required.",
"Inspect one explicit local PE32/PE32+ image's complete bounded type/name/language resource tree without executing it or opening a disassembler. Returns numeric IDs versus original UTF-16 names, directory/data-entry file locations, payload RVA/file ranges, complete SHA-256 hashes, static RT_GROUP_ICON image-resource candidates, decoded RT_STRING tables (string IDs, text and locations) and RT_VERSION details (fixed file and product versions, StringFileInfo values such as CompanyName and FileVersion, and translations). A malformed string or version payload is reported with a reason instead of failing the inventory. Language fallback, image decoding and actual shell/window loading remain unobserved. Reads a stable regular file; malformed or ambiguous mappings, non-identical overlapping ranges and exhausted budgets return no partial success. Portable on supported Node hosts; no Windows SDK or engine installation required.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Advertise the new decoders in CLI and packaged skill

Although this contract now exposes RT_STRING and RT_VERSION decoding, the inspected CLI registration at src/cli/binaryDiagnosticsCommands.ts:24-26 still advertises only identities, hashes, and icons, while .agents/skills/reverse-engineer-anything/references/native-and-artifacts.md:241-248 still says the other payloads are opaque. Users and packaged agents discovering the capability through those surfaces will not know these arrays exist; update both source descriptions before regenerating the ignored skill output.

AGENTS.md reference: AGENTS.md:L71-L71

Useful? React with 👍 / 👎.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

The version decoder now requires a binary root and verifies both the declared 52-byte fixed-info length and the complete in-root value range before reading fixed fields. Malformed blocks remain per-resource malformed results. Published on the live PR branch; targeted formatting and git diff --check passed; no tests run.

review thread

readChildren now checks that two bytes remain in the parent before reading a child length, routing short tails through the existing MalformedPayload result path instead of leaking RangeError. Published on the live PR branch; targeted formatting and git diff --check passed; no tests run.

@morluto
morluto force-pushed the feat/pe-string-version-resources branch from e8f7af3 to 4d83c25 Compare October 13, 2026 18:09
ensureCapacity(textBytes(entry.location.bytes / 2));
return {
key: entry.key,
value: entry.type === 1 ? textValue(bytes, entry.value) : null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Broken versions look decoded

When a string entry has type = 0, readStringFileInfo replaces its value with null and reports the version payload as decoded. readTranslations also reads text entries as binary language/code-page pairs. Someone inspecting these broken resources gets missing text or misleading translations under a success label.

Check the required types before decoding these entries. A broken layout should return malformed with no decoded values, as the tool promises.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/native/pe/PeResourcePayloads.ts
Line: 241

Comment:
**Broken versions look decoded**

When a string entry has `type = 0`, `readStringFileInfo` replaces its value with `null` and reports the version payload as `decoded`. `readTranslations` also reads text entries as binary language/code-page pairs. Someone inspecting these broken resources gets missing text or misleading translations under a success label.

Check the required types before decoding these entries. A broken layout should return `malformed` with no decoded values, as the tool promises.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +47 to +55
report.string_tables.push({
resource_index: report.resources.length - 1,
status: "decoded",
block_id: 1,
first_string_id: 0,
strings: [],
trailing_bytes: 0,
reason: null,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Location checks go untested

The new bad-string-location and bad-version-location tests never check a bad location. The string case fails because strings is empty. The version case fails because resource_index is past the resource array, and its malformed row has no decoded locations.

Both tests would still pass if the new withinPayload checks were removed. Build otherwise-valid decoded rows, then move one location outside its resource payload so the tests catch that regression.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/binaryDiagnostics/PeResourcesService.test.ts
Line: 47-55

Comment:
**Location checks go untested**

The new `bad-string-location` and `bad-version-location` tests never check a bad location. The string case fails because `strings` is empty. The version case fails because `resource_index` is past the resource array, and its malformed row has no decoded locations.

Both tests would still pass if the new `withinPayload` checks were removed. Build otherwise-valid decoded rows, then move one location outside its resource payload so the tests catch that regression.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@morluto
morluto force-pushed the feat/pe-string-version-resources branch from 0c8c9ea to abade91 Compare October 13, 2026 18:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abade91531

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const { offset, bytes: size } = resource.payload.location;
let info: VersionInfo;
try {
const root = readBlock(bytes, offset, offset + size, offset);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject bytes outside the version root

When an RT_VERSION data entry is longer than the root's wLength—for example, a valid payload whose root length is corrupted to end after the 52-byte fixed info—readBlock returns that prefix and the decoder never checks root.location.bytes against size. It consequently publishes status: "decoded" while silently dropping trailing StringFileInfo/VarFileInfo bytes; reject or report non-padding bytes outside the root before publishing decoded facts.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Comment on lines +145 to +148
if (type === 1 && valueLength > available)
malformed(`Version value for ${JSON.stringify(key)} leaves its block.`);
const declared =
type === 1 ? Math.min(valueLength * 2, available) : valueLength;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject odd byte-counted version text values

When a type-1 child is truncated to a one-byte value with wValueLength = 1, the new greater-than guard passes and Math.min makes declared one byte; textValue then emits an empty string because no UTF-16 code unit fits, and the whole version record remains decoded. Only use the byte-count fallback for an even UTF-16 byte extent. This is fresh evidence beyond the earlier oversized-length case: the declared count equals available but is still impossible.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Comment on lines +162 to +165
table.block_id === null ||
table.block_id < 1 ||
table.block_id > 4096 ||
table.first_string_id !== (table.block_id - 1) * 16 ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match decoded string blocks to their resource names

When a provider returns a decoded table attached to an RT_STRING resource named block 1 but supplies block_id: 2 and IDs 16–31, these checks pass because the block ID is bounded but never compared with the owning resource's name, so the service publishes strings under the wrong IDs. Require a decoded table's owner name to be numeric and equal to block_id; the fresh evidence after the prior boundary fix is that its new type check still omits this ownership comparison.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

thefolahan and others added 7 commits October 14, 2026 02:42
inspect_pe_resources returned string tables and version resources as
opaque bytes, though both formats are fixed and documented. They answer
the first questions of a Windows investigation: which build this is and
which messages it shows.

string_tables expands each RT_STRING block into its sixteen string IDs,
keeping empty slots and every string's file location. version_infos
decodes VS_FIXEDFILEINFO, each StringFileInfo table and the VarFileInfo
translations. A payload that breaks its layout is reported as malformed
with a reason while the inventory still succeeds.

Fixes morluto#2812
@morluto
morluto force-pushed the feat/pe-string-version-resources branch from abade91 to fc350ff Compare October 13, 2026 18:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc350ff5ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +256 to +259
readChildren(bytes, block, base)
.filter((entry) => entry.key === "Translation")
.flatMap((entry) => {
if (entry.value.bytes % 4 !== 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate Translation as binary before decoding

When a one-pair Translation node has only its wType corrupted from 0 to 1, its unchanged wValueLength = 4 and four-byte value still pass readBlock's byte-count text fallback, and this key-only path publishes those bytes as a language/code-page pair with status: "decoded". Translation values are binary, so check entry.type === 0 before deriving observed values and report this type corruption as malformed.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Comment on lines +355 to +358
const key = `${String(offset)}:${String(size)}`;
let cached = decodedByRange.get(key);
if (cached === undefined) {
cached = decode(resource);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Yield between distinct version payload decodes

When max_file_bytes is raised to 512 MiB, about 8,000 distinct 65-KiB RT_VERSION payloads fit under the 16,384-entry cap, and each can contain roughly 8,000 minimal children that are parsed and then discarded. The new cache only covers identical offset/size keys, so this fresh distinct-range case still executes tens of millions of synchronous node parses; in the inspected parsePeResources flow, there is no signal check or yield between invoking this decoder and building the report, blocking cancellation and other MCP work. Yield/check the signal during traversal or impose a decoding work bound.

AGENTS.md reference: AGENTS.md:L46-L50

Useful? React with 👍 / 👎.

)
return false;
if (
!report.string_tables.every((table) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require one payload result per matching resource

When a PeResourcesPort omits the row for an RT_STRING resource or repeats another resource_index, this .every check still passes because it validates only supplied rows and an empty string_tables array is vacuously valid; the identical version_infos check has the same gap. The new per-row checks therefore still allow complete Evidence to lose a decoded-or-malformed result for a resource, so compare the unique reported index set with all type-6/type-16 resource indices.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Comment on lines +203 to +206
info.string_file_info.every(
(table) =>
withinPayload(table.location) &&
table.strings.every((string) => withinPayload(string.location)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep version string ranges inside their table

When a provider reports a StringFileInfo table range in one part of the payload but places a claimed child string range elsewhere in the same payload, both of these payload-level checks pass. This is fresh evidence beyond the earlier outside-payload case: the service then publishes a string under a table that does not own its source bytes, so validate each string range against its containing table.location, not only the resource payload.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request labels Oct 14, 2026
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
kaoru0822-kitauji and others added 2 commits October 14, 2026 03:37
The repeated-range test built two version resources with separate payload
copies, so their locations differed and the decode cache keyed by
(offset, size) never ran. Point the second data entry at the first payload's
RVA and size so both records come from one range and must still be
independent clones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: the shard 6 and Portable failure came from this PR's own PeResourcePayloads.test.ts › "projects repeated payload ranges as independent version records". The fixture gave each of the two version resources its own payload copy, so their locations differed (1200 vs 1544). The (offset, size) decode cache from fc350ff never ran, and the equal-except-index expectation couldn't hold. 8bcb160 points the second data entry at the first payload's RVA and size, so both records come from one range and must still be independent clones. I also merged main (no conflicts). Locally: PE and binary-diagnostics tests pass (65), and docs:check and check:fast are clean. Main is currently red for unrelated reasons; #3080 fixes that.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@CassieFox23

CassieFox23 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: The PR's own 19 tests pass on Node 22, 24 and 26 at head 8bcb160. Six of the open bot findings still reproduce on this head with PEs I built myself. One does not.

Edit: this comment first said I was testing. The results are below.

The head is 977 commits behind main (7c6c25d), but its diff applies to main with git apply --check (exit 0).

Results at 8bcb160

Check Node 22 Node 24 Node 26
PeResourcePayloads.test.ts and PeResourcesService.test.ts (19 tests) pass pass pass

Open bot findings I replayed

I built each PE or report by hand with the repo's peResourceFixture and small version-node helpers. Each run used Node 24.

Finding Result
String entry with type 0 reads as decoded (P1, :244) Reproduced. Status is decoded and the CompanyName value is null.
Translation with wType changed from 0 to 1 (:259) Reproduced. Status is decoded and 1046/1252 is published.
Root wLength shorter than the payload (:285) Reproduced. A 256-byte payload with root wLength 92 is decoded with 0 strings and 0 translations.
One-byte text value with wValueLength 1 (:148) Reproduced. Status is decoded and the value is an empty string.
Service accepts a string table whose block_id differs from its resource name (:165) Reproduced. Resource name 1 with block_id 2 returned ok.
Service accepts missing or duplicated payload rows (:139) Reproduced. Empty string_tables and version_infos, and a duplicated version row, all returned ok.
Oversized wValueLength (:150) Not reproduced. wValueLength 0xffff gives malformed.
Many distinct version payloads block the event loop (:358) Partly measured. One 63,420-byte payload with 7,900 children took 30.9 ms. 8 distinct ones took 182.4 ms. That is about 3 minutes for 8,000, an estimate from a straight multiply that I did not run. By code reading, no abort check sits between the two decoder calls.

Not run

  • :353 (same range decoded twice). The head has a cache keyed by offset and size. I only read it. The fixture builder cannot put two resources on one range.
  • :116 and :206 (nested range checks at the Evidence boundary). Code reading only. The string range is checked against the resource payload, not against its own table.
  • :55 (location tests). Code reading only. The test pushes an empty strings list, which the service already rejects for its length.
  • :33 (CLI and skill text). Code reading only. The CLI description at src/cli/binaryDiagnosticsCommands.ts:25 still names only identities, hashes and icons.
  • A 512 MiB image.
  • Real apps' version data.
  • Cancellation timing.
  • Main plus the patch, and the full suite.
  • I replayed 7 P2 threads, one over the usual 6. The :150 one was a control.

Thanks, thefolahan, for the RT_STRING and RT_VERSION decoder.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.11
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 8bcb160 / 5830088 (main at test time: 7c6c25d)
  • Other: the box was shared with other test agents, so timings are rough.
Commands
npm ci
npm run prepare
npm run build:cached
npm run test:prepare
npm run test:focused -- src/native/pe/PeResourcePayloads.test.ts src/application/binaryDiagnostics/PeResourcesService.test.ts
npm run test:focused -- src/native/pe/probe2887.test.ts

All ran with exit 0, with timeout and an 8 GB memory cap. The probe file is my own and is not part of the PR.

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@thefolahan thanks for the PR — there are 13 open review threads here:

Could you address or reply to these? Once they're resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@thefolahan also, this branch has merge conflicts with main — please resolve those along with the open threads.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Decode RT_VERSION and RT_STRING payloads in inspect-pe-resources

4 participants