diff --git a/types/frida-gum/frida-gum-tests.ts b/types/frida-gum/frida-gum-tests.ts index 6212c60843aa39..f4f107f8f38356 100644 --- a/types/frida-gum/frida-gum-tests.ts +++ b/types/frida-gum/frida-gum-tests.ts @@ -564,9 +564,19 @@ x86Writer.putVextracti64x4RegOffsetPtrZmm("rax", 0, 0, 1); x86Writer.putVinserti64x4ZmmRegOffsetPtr(0, "rax", 0, 1); x86Writer.putKmovqRegOffsetPtrKreg("rax", 0, 0); x86Writer.putKmovqKregRegOffsetPtr(0, "rax", 0); +// $ExpectType void +x86Writer.putEndbr(); x86Writer.flush(); const arm64Writer = new Arm64Writer(Memory.alloc(Process.pageSize)); arm64Writer.putMovkRegImm("x0", 0x1234, 16); arm64Writer.putPaciaRegReg("x0", "x1"); +// $ExpectType void +arm64Writer.putSvcImm(0x80); arm64Writer.flush(); + +const arm64Relocator = new Arm64Relocator(ptr("0x1234"), arm64Writer); +// $ExpectType boolean +arm64Relocator.readUntilResumable("online"); +// $ExpectType Arm64Register | null +arm64Relocator.pickExitReg(ptr("0x1234")); diff --git a/types/frida-gum/index.d.ts b/types/frida-gum/index.d.ts index 2dd6bfe3ad4d1a..e41e9532c25587 100644 --- a/types/frida-gum/index.d.ts +++ b/types/frida-gum/index.d.ts @@ -5733,6 +5733,11 @@ declare class X86Writer { */ putNop(): void; + /** + * Puts an ENDBR instruction. + */ + putEndbr(): void; + /** * Puts an OS/architecture-specific breakpoint instruction. */ @@ -7145,6 +7150,19 @@ declare class Arm64Writer { */ putBrRegNoAuth(reg: Arm64Register): void; + /** + * Puts code needed for jumping to the address in `reg`, emitting RET + * rather than BR so a BTI-guarded target needs no landing pad. Emits + * BR on arm64e, which doesn't guard pages this way. + */ + putJmpReg(reg: Arm64Register): void; + + /** + * Like `putJmpReg()`, but expecting a raw pointer without any + * authentication bits. + */ + putJmpRegNoAuth(reg: Arm64Register): void; + /** * Puts a BLR instruction. */ @@ -7440,11 +7458,21 @@ declare class Arm64Writer { */ putPaciaRegReg(dstReg: Arm64Register, modReg: Arm64Register): void; + /** + * Puts a SVC instruction. + */ + putSvcImm(imm: number): void; + /** * Puts a NOP instruction. */ putNop(): void; + /** + * Puts a BTI instruction. + */ + putBti(): void; + /** * Puts a BRK instruction. */ @@ -7542,6 +7570,31 @@ declare class Arm64Relocator { */ readOne(): number; + /** + * Sets the register that exits from the relocated code may use when + * it is still untouched by the relocated instructions. + */ + setScratchReg(reg: Arm64Register): void; + + /** + * Sets the range of code that register liveness analysis may look + * at. Branches leaving it are assumed to clobber X16 and X17. + */ + setCodeRange(range: MemoryRange): void; + + /** + * Reads further until a scratch register is available for jumping + * back to the input code, or the end of input is reached. Returns + * `false` if neither happens. + */ + readUntilResumable(scenario: RelocationScenario): boolean; + + /** + * Picks a register that an exit branching to `target` may use, or + * `null` if none is known to be free. + */ + pickExitReg(target: NativePointerValue): Arm64Register | null; + /** * Peeks at the next `Instruction` to be written or skipped. */ @@ -7757,6 +7810,8 @@ type Arm64ConditionCode = type Arm64IndexMode = "post-adjust" | "signed-offset" | "pre-adjust"; +type RelocationScenario = "offline" | "online"; + /** * Generates machine code for mips. */ diff --git a/types/frida-gum/package.json b/types/frida-gum/package.json index d7c71e950646b1..a9d750f8b3f229 100644 --- a/types/frida-gum/package.json +++ b/types/frida-gum/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/frida-gum", - "version": "19.10.9999", + "version": "19.11.9999", "nonNpm": true, "nonNpmDescription": "frida-gum", "projects": [