Skip to content

Commit dc68346

Browse files
authored
🤖 Merge PR DefinitelyTyped#72273 frida-gum: Add typings for Process.runOnThread() by @oleavr
1 parent e54718f commit dc68346

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎types/frida-gum/frida-gum-tests.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,12 @@ const threadObserver = Process.attachThreadObserver({
443443
});
444444
threadObserver.detach();
445445

446+
// $ExpectType Promise<void>
447+
Process.runOnThread(1, () => {});
448+
449+
// $ExpectType Promise<boolean>
450+
Process.runOnThread(1, () => true);
451+
446452
const moduleObserver = Process.attachModuleObserver({
447453
onAdded(module) {
448454
// $ExpectType Module

‎types/frida-gum/index.d.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,20 @@ declare namespace Process {
380380
*/
381381
function attachThreadObserver(callbacks: ThreadObserverCallbacks): ThreadObserver;
382382

383+
/**
384+
* Runs the JavaScript function `callback` on the thread specified by `id`.
385+
* Must be used with extreme caution due to the thread potentially being
386+
* interrupted in non-reentrant code. For example, you could be interrupting
387+
* it while it's in the middle of some delicate code, holding a specific
388+
* non-recursive lock, which you then try to implicitly acquire again when
389+
* you call some function.
390+
*
391+
* @param id ID of the thread to run on.
392+
* @param callback Function to run.
393+
* @returns A Promise that resolves to the value returned by `callback`.
394+
*/
395+
function runOnThread<T>(id: ThreadId, callback: () => T): Promise<T>;
396+
383397
/**
384398
* Looks up a module by address. Returns null if not found.
385399
*/

0 commit comments

Comments
 (0)