mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 11:13:21 +00:00
fix(il2cpp): honor loader pointers and registration field layout
This commit is contained in:
1 parent
db923eba44
commit
26031bcd26
3 files changed
+64
-14
No files matched your search
@@ -76,7 +76,7 @@ export interface NativeImage {
|
||||
readonly imageBase: bigint;
|
||||
readonly unresolvedPointerSlots: ReadonlyMap<bigint, number>;
|
||||
readonly zeroFillPointers: ReadonlyMap<bigint, bigint>;
|
||||
/** Mach-O loader fixups, used when interpreting method pointer slots. */
|
||||
/** Mach-O loader fixups, owned by every pointer interpretation. */
|
||||
readonly machoPointerFixups?: PointerFixups;
|
||||
}
|
||||
|
||||
@@ -191,10 +191,7 @@ export function* openImageSteps(
|
||||
};
|
||||
}
|
||||
|
||||
export const readPointer = (
|
||||
image: NativeImage,
|
||||
address: bigint,
|
||||
): bigint | null => {
|
||||
const readRawPointer = (image: NativeImage, address: bigint): bigint | null => {
|
||||
if (hasUnresolvedPointer(image, address)) return null;
|
||||
const virtual = image.zeroFillPointers.get(address);
|
||||
if (virtual !== undefined) return virtual;
|
||||
@@ -347,7 +344,7 @@ export const readSlot = (
|
||||
let raw: bigint | null;
|
||||
if (virtual !== undefined) raw = virtual;
|
||||
else if (isZeroFilled(image, address, 8)) raw = 0n;
|
||||
else raw = readPointer(image, address);
|
||||
else raw = readRawPointer(image, address);
|
||||
if (raw === null) return null;
|
||||
if (image.machoPointerFixups !== undefined) {
|
||||
const resolution = image.machoPointerFixups.decode(address, raw);
|
||||
@@ -367,3 +364,12 @@ export const readSlot = (
|
||||
throw cause;
|
||||
}
|
||||
};
|
||||
|
||||
/** Resolve a pointer through the same loader interpretation as method slots. */
|
||||
export const readPointer = (
|
||||
image: NativeImage,
|
||||
address: bigint,
|
||||
): bigint | null => {
|
||||
const slot = readSlot(image, address);
|
||||
return typeof slot === "bigint" ? slot : null;
|
||||
};
|
||||
Reference in new issue
Block a user