Repository navigation
[AUTOMATED] Give an MSVC virtual call its receiver under calleereginputs - #1582
Merged
Merged
Conversation
With calleereginputs on, an indirect call takes the __thiscall model when it is MSVC's virtual dispatch: the target is loaded from a slot of a table loaded from where ECX points, with no ECX write or call between that load and the call. A COM method has the same dispatch but is __stdcall with the interface pushed last, so a call whose last push stores ECX keeps the default; a push ecx that only reserves a slot a later store fills is not that push. New fixture vcall_pe_i386.exe; kuna-calleereginputs Noelo-Lab#6-Noelo-Lab#10. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # decompiler/crates/kuna-decomp/phases.toml # decompiler/crates/kuna-decomp/src/p4_calls/kuna_calleereginputs.rs # decompiler/crates/kuna-decomp/tests/fixtures/phase_catalog.json # docs/baseline-stages.json # docs/options.md # docs/spec/04-calls-and-prototypes.md # tests/stages/kuna-calleereginputs.xml
Keep Noelo-Lab#1575's calleereginputs header, row and spec text, with the virtual-dispatch paragraph after them; move the vcall passes to the file's off/default form as Noelo-Lab#18-Noelo-Lab#22; options.md and phase_catalog.json from main (regenerated after the build); synthesize baseline-stages.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…dows x86, and type its target On main calleereginputs is on by default, so the virtual-dispatch case now runs on every x86-32 image. Gate it to x86-32 Windows like the direct case (Borland and other x86-32 specs stay inert). A call the caller cleans up after (add esp,4: a C table of __cdecl function pointers reached through ECX) keeps the default, since a __thiscall callee removes its own arguments; a COM call whose interface is pushed from the register ECX was copied from keeps it too. Lay out the target type of a __thiscall-modeled indirect call under that model, so the call prints through a function pointer instead of an uncallable void *. Fixture gains ctable/comcopy (rebuilt from its recipe); stage Noelo-Lab#23-Noelo-Lab#25. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…ve Delphi receivers alone With the virtual-call model on by default, a receiver set in an earlier block failed the upstream register trial, and the failed ECX ended the argument list: an ATL IAtlStringMgr::Allocate call lost both of its stack arguments. The chosen model is now recorded as the call's read-register model, so Noelo-Lab#1575's rules (trial active, no list cut-off) cover it. A call that also holds the object in EAX is Delphi's register convention (mov eax,ecx; mov edx,[eax]; call [edx+8]) and keeps the default; it had lost its Int64 stack argument. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
The fork branch's merge of origin/main (Noelo-Lab#1575) re-resolved the same calleereginputs files; this head already contains both of its parents and supersedes that resolution, so the tree is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…he local head Conflicts: the calleereginputs row in phases.toml keeps main's row (values off/on/custom, the custom text) with the virtual-dispatch sentence added before "Inert on every other target"; docs/options.md and phase_catalog.json take main's side and are regenerated after the build; baseline-stages.json is synthesized from both sides (main 4322 + 8 virtual-call assertions). kuna_calleereginputs.rs, spec 04 and the stage XML merged cleanly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
docs/options.md and phase_catalog.json regenerated from the merged build; counters --check reports no drift. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
custom extends on: a whole-binary run of vcall_pe_i386.exe prints the same functions under custom as under on (the virtual member gets the object in ECX as this; the C table and COM calls keep the default), and off gives no receiver. Spec 04 says the rule holds under both values. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Conflicts: kuna_calleepurge.rs takes Noelo-Lab#1581's caller_cleanup doc and body with this branch's pub(crate) (the virtual-call cleanup check reuses it); the fixtures README keeps both new sections, main's first; baseline-stages is synthesized from both sides (main 4327 + 8 virtual-call assertions). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
# Conflicts: # decompiler/crates/kuna-analysis/tests/fixtures/README.md # decompiler/crates/kuna-decomp/phases.toml # decompiler/crates/kuna-decomp/tests/fixtures/phase_catalog.json # docs/baseline-stages.json # docs/options.md
…ious call The vtable's object was followed back through copies past intervening calls, so `mov esi,ecx; call f; mov eax,[esi]; push esi; call [eax+k]` (COM calls through ESI, and a C table through ESI) took ECX as the receiver although the earlier call clobbered it; the COM push check also compared two scans of different reach and missed the pushed interface. The object, the last push and EAX are now compared as values over the run of ops since the previous call, carried forward through copies. The vcall fixture gains comesi and crosscall (stage Noelo-Lab#26, Noelo-Lab#27, the custom test). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…load Comparing values lets `mov ecx,esi; mov eax,[esi]; call [eax+k]` pass the object in ECX, since ECX holds it at the call; the vcall fixture gains ecxcopy for it (stage Noelo-Lab#28, Noelo-Lab#29, the custom test) and spec 04 says so. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
…t at [esp+4] GCC before 4.7 (MinGW) passes a member function's `this` on the stack as a __cdecl argument, second behind the hidden pointer of a returned class (`mov ecx,[ebp+0xc]; mov eax,[ecx]; mov [esp+4],ecx; mov [esp],edx; call [eax+k]`), so ECX held the object only on the way and the call printed it twice (`(a1,a0,a1,a2,a3,0,a6)` for `(a0,a1,a2,a3,0,a6)`, 36 calls in two MinGW images). A store of the object at [esp+4], the stack pointer unchanged up to the call, now keeps the default like the COM interface push. The vcall fixture gains gccsret (stage Noelo-Lab#30, the custom test). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
… code) into the reviewed head Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
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.
An MSVC virtual call prints without the object it is called on, even now that
calleereginputsis on by default:With this change:
Fix
calleereginputs, an indirect call takes the__thiscallmodel if it is MSVC's virtual dispatch. That means the target is loaded from a slot of a table that is itself loaded from where ECX points (mov eax,[ecx]; call [eax+k], through copies and a zero offset), and no write to ECX or other call comes between that load and the call. It is chosen inActionDefaultParams, next to the Swift indirect-call hook.__stdcall, with the interface as its first stack argument. A call whose last push before it stores ECX keeps the default, sop->SetVolume(7)still prints(a0,7)once. Apush ecxthat only reserves a slot a later store fills (push ecx; fstp [esp]) is not that push.calleereginputs(on by default on x86-32 Windows since [AUTOMATED] Turn calleereginputs on by default on x86-32 Windows #1575;offrestores the old output). Thephases.tomlrow and spec 04 describe the new case.Tests
tests/stages/kuna-calleereginputs.xmlgains two passes (off, on) over a new clean-room fixture,vcall_pe_i386.exe, with assertions #18–#22:push ecxdoesn't hidethis;python -m scripts.prepr.aritydiffagainstmain, over setuptoolscli-32/gui-32, distlibt32/w32,WinHelloCPP.exeand a 2,198-function MSVC game: no change on the five public binaries. On the game, 72 calls through a pointer gain exactly their receiver and none lose an argument. Before the COM rule, two DirectSound-style calls printed the interface twice; they're unchanged now.Fixes #1579
🤖 Generated with Claude Code