From a4c01b77362c10d4cc90de37bcbe9554a6a33763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Fri, 27 Mar 2020 16:54:09 +0100 Subject: [PATCH] Sync frida-gum typings with Frida 12.8.15 (#43358) Changelog at: https://frida.re/news/2019/12/18/frida-12-8-released/ --- types/frida-gum/frida-gum-tests.ts | 24 ++++++++++++++++++++++ types/frida-gum/index.d.ts | 33 +++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/types/frida-gum/frida-gum-tests.ts b/types/frida-gum/frida-gum-tests.ts index 51bf3450fc..7baf77d30e 100644 --- a/types/frida-gum/frida-gum-tests.ts +++ b/types/frida-gum/frida-gum-tests.ts @@ -1,5 +1,29 @@ Frida.version; // $ExpectType string +// $ExpectType NativePointer +const p = ptr(1234); + +// $ExpectType NativePointer +p.sign(); +// $ExpectType NativePointer +p.sign("ia", 42); +// $ExpectError +p.sign("invalid", 42); + +// $ExpectType NativePointer +p.strip(); +// $ExpectType NativePointer +p.strip("ia"); +// $ExpectError +p.strip("invalid"); + +// $ExpectType NativePointer +p.blend(1337); +// $ExpectError +p.blend(ptr(42)); +// $ExpectError +p.blend(); + const otherPuts = new NativeCallback(() => { return 0; }, "int", ["pointer"]); diff --git a/types/frida-gum/index.d.ts b/types/frida-gum/index.d.ts index f628f4829f..74e844bff2 100644 --- a/types/frida-gum/index.d.ts +++ b/types/frida-gum/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for non-npm package frida-gum 15.1 +// Type definitions for non-npm package frida-gum 15.2 // Project: https://github.com/frida/frida // Definitions by: Ole André Vadla Ravnås // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1420,6 +1420,35 @@ declare class NativePointer { */ not(): NativePointer; + /** + * Makes a new NativePointer by taking the bits of `this` and adding + * pointer authentication bits, creating a signed pointer. This is a + * no-op if the current process does not support pointer + * authentication, returning `this` instead of a new value. + * + * @param key The key to use. Defaults to `ia`. + * @param data The data to use. Defaults to `0`. + */ + sign(key?: PointerAuthenticationKey, data?: NativePointerValue | UInt64 | Int64 | number | string): NativePointer; + + /** + * Makes a new NativePointer by taking the bits of `this` and + * removing its pointer authentication bits, creating a raw pointer. + * This is a no-op if the current process does not support pointer + * authentication, returning `this` instead of a new value. + * + * @param key The key that was used to sign `this`. Defaults to `ia`. + */ + strip(key?: PointerAuthenticationKey): NativePointer; + + /** + * Makes a new NativePointer by taking `this` and blending it with + * a constant, which may in turn be passed to `sign()` as `data`. + * + * @param smallInteger Value to blend with. + */ + blend(smallInteger: number): NativePointer; + /** * Returns a boolean indicating whether `v` is equal to `this`; i.e. it contains the same memory address. */ @@ -1497,6 +1526,8 @@ declare class NativePointer { writeAnsiString(value: string): NativePointer; } +type PointerAuthenticationKey = "ia" | "ib" | "da" | "db"; + interface ObjectWrapper { handle: NativePointer; }