Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions types/frida-gum/frida-gum-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
55 changes: 55 additions & 0 deletions types/frida-gum/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5733,6 +5733,11 @@ declare class X86Writer {
*/
putNop(): void;

/**
* Puts an ENDBR instruction.
*/
putEndbr(): void;

/**
* Puts an OS/architecture-specific breakpoint instruction.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -7757,6 +7810,8 @@ type Arm64ConditionCode =

type Arm64IndexMode = "post-adjust" | "signed-offset" | "pre-adjust";

type RelocationScenario = "offline" | "online";

/**
* Generates machine code for mips.
*/
Expand Down
2 changes: 1 addition & 1 deletion types/frida-gum/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/frida-gum",
"version": "19.10.9999",
"version": "19.11.9999",
"nonNpm": true,
"nonNpmDescription": "frida-gum",
"projects": [
Expand Down