README
frida-typed-extensions
Extension module for Frida NativeFunction
and NativeCallback
with type checking
and string support.
Installation
npm install --save-dev frida-typed-extensions
You may need to include "moduleResolution": "node"
in your tsconfig.json
.
Usage
// native-functions.ts
import { createNF } from "frida-typed-extensions";
// Without type checking and string support
const old_nf0 = new NativeFunction(ptr, "pointer", ["int32"]);
const old_r0 = (nf0(false, false, false) as NativePointer).readUtf8String();
// (args_0: number) => (string | null)
const nf0 = createNF(ptr, "utf8string", ["int32"]);
const r0 = nf0(34); // string | null
// const nf1: (args_0: boolean, args_1: Int64) => undefined
const nf1 = createNF(ptr, "void", ["bool", "int64"]);
// const nf2: (args_0: string) => NativePointer
const nf2 = createNF(ptr, "pointer", ["utf16string"], { scheduling: "exclusive" });
// native-callbacks.ts
import { createNC } from "frida-typed-extensions";
// Without type checking and string support
const old_nc0 = new NativeCallback((args_0: string, args_1: boolean) => {
return Memory.allocUtf8String("hello");
}, "pointer", ["int32"]);
const nc0 = createNC((args_0: number) => {
return "hello";
}, "utf8string", ["int32"]);
const nc1 = createNC((args_0: boolean, args_1: UInt64) => {
console.log(args_0, args_1);
}, "void", ["bool", "uint64"]);
const nc2 = createNC((args_0: string | null) => {
return ptr(0x786ae800);
}, "pointer", ["utf16string"], "default");
Limitations
- No support for structs passed by value yet.