Add macOS readMtgaCards via heap signature scan#3
Open
dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
Open
Add macOS readMtgaCards via heap signature scan#3dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
dan-blanchard wants to merge 1 commit intomtgatool:mainfrom
Conversation
This was referenced Apr 13, 2026
Bypasses the broken PAPA walker by scanning Arena's heap directly for the card-collection Dictionary<int,int>. Identifies it via the hash==key invariant for DefaultEqualityComparer<int>. Returns ~4300 cards in <1s. Requires sudo for task_for_pid. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0ba87c5 to
e3d9f0d
Compare
3 tasks
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.
Adds a macOS-only
readMtgaCardsnapi export that reads the player's card collection from a running Arena process. This bypasses the existing PAPA/WrapperController walker (which returns 0 forPAPA._instanceon current macOS Arena builds) by signature-scanning the heap directly for theDictionary<int,int>that holds the collection.How it works
The scanner identifies the card-collection dictionary by its data invariant (no IL2CPP metadata walking required):
hash == key(the defining property ofDictionary<int,V>with defaultEqualityComparer<int>)[1, 200000][1, 4]MTGA_KNOWN_CARD_IDSandMTGA_VERIFY_QTYSenv vars for cross-validation when multiple dictionaries passThis uniquely identifies the live collection dictionary across 200K+ candidate heap positions.
Why the PAPA walker is broken
PAPA._instancereads as 0 on current Arena builds. The likely cause: IL2CPP has separate static field regions for value-type and reference-type statics, andCLASS_STATIC_FIELDSat offset0xA8only reaches the value-type region. The signature scan sidesteps this entirely.What's included
scan_heap_for_cards_dictionary+read_cards_dictionary_entriesinmacos_backendreadMtgaCardsnapi export (macOS-only)NOTES.mddocumenting the investigation: IL2CPP memory layout,CardPrintingRecordfield table (50 fields with offsets), approaches triedfind_class_by_direct_scan,find_papa_instance_by_field_verification,probe_card_printing_record, etc.) for future reverse-engineeringTesting
Verified against live Arena on macOS arm64 (Unity 2022.3.62f2):
readMtgaCards("MTGA")returns ~4300 unique cards in <1stask_for_pid)🤖 Generated with Claude Code