Add type definitions for frida-gum (#35911)

* Add type definitions for frida-gum

Consumed through frida-compile, e.g. like this:

    https://github.com/oleavr/frida-agent-example

* Delete redundant declare keywords
This commit is contained in:
Ole André Vadla Ravnås
2019-06-11 03:31:05 +02:00
committed by Andrew Casey
parent d689e2b616
commit fc5a3acff8
4 changed files with 6756 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
Frida.version; // $ExpectType string
const otherPuts = new NativeCallback(() => {
return 0;
}, "int", ["pointer"]);
const puts = new NativeFunction(Module.getExportByName(null, "puts"), "int", ["pointer"]);
// $ExpectType NativeFunction
puts;
const message = Memory.allocUtf8String("Hello!");
// $ExpectType NativePointer
message;
// $ExpectType NativeReturnValue
puts.call(otherPuts, message);
// $ExpectType NativeReturnValue
puts.apply(otherPuts, [message]);
// $ExpectType NativeReturnValue
puts(message);
const open = new SystemFunction(Module.getExportByName(null, "open"), "int", ["pointer", "int"]);
// $ExpectType SystemFunction
open;
const path = Memory.allocUtf8String("/etc/hosts");
const result = open(path, 0) as UnixSystemFunctionResult;
// $ExpectType NativeReturnValue
result.value;
// $ExpectType number
result.errno;
Interceptor.attach(puts, {
onEnter(args) {
// $ExpectType NativePointer[]
args;
},
onLeave(retval) {
// $ExpectType InvocationReturnValue
retval;
}
});
const obj = new ObjC.Object(ptr("0x42"));
// $ExpectType Object
obj;

6673
types/frida-gum/index.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"frida-gum-tests.ts"
]
}

View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-const-enum": false
}
}