-
-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gumjs: Migrate to Interceptor.get_live_replacement_invocation()
To simplify things, and also guarantee that the specific replacement function has a live call.
- Loading branch information
Showing
6 changed files
with
25 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2020 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2020-2024 Ole André Vadla Ravnås <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -706,18 +706,13 @@ gum_quick_add_replace_entry (GumQuickInterceptor * self, | |
GumQuickCore * core = self->core; | ||
JSContext * ctx = core->ctx; | ||
GumQuickReplaceEntry * entry; | ||
GumQuickNativeCallback * c; | ||
|
||
entry = g_slice_new (GumQuickReplaceEntry); | ||
entry->interceptor = self->interceptor; | ||
entry->target = target; | ||
entry->replacement = JS_DupValue (ctx, replacement_value); | ||
entry->ctx = ctx; | ||
|
||
c = JS_GetOpaque (entry->replacement, core->native_callback_class); | ||
if (c != NULL) | ||
c->interceptor_replacement_count++; | ||
|
||
g_hash_table_insert (self->replacement_by_address, target, entry); | ||
} | ||
|
||
|
@@ -771,22 +766,12 @@ GUMJS_DEFINE_FUNCTION (gumjs_interceptor_revert) | |
{ | ||
GumQuickInterceptor * self; | ||
gpointer target; | ||
GumQuickReplaceEntry * entry; | ||
|
||
self = gumjs_get_parent_module (core); | ||
|
||
if (!_gum_quick_args_parse (args, "p", &target)) | ||
return JS_EXCEPTION; | ||
|
||
entry = g_hash_table_lookup (self->replacement_by_address, target); | ||
if (entry != NULL) | ||
{ | ||
GumQuickNativeCallback * c = | ||
JS_GetOpaque (entry->replacement, core->native_callback_class); | ||
if (c != NULL) | ||
c->interceptor_replacement_count--; | ||
} | ||
|
||
g_hash_table_remove (self->replacement_by_address, target); | ||
|
||
return JS_UNDEFINED; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2010-2024 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2020-2021 Francesco Tamagni <[email protected]> | ||
* Copyright (C) 2021 Abdelrahman Eid <[email protected]> | ||
* | ||
|
@@ -14,7 +14,6 @@ | |
#include "gumv8script.h" | ||
#include "gumv8scriptbackend.h" | ||
|
||
#include <ffi.h> | ||
#include <gum/gumexceptor.h> | ||
#include <gum/gumprocess.h> | ||
#include <v8.h> | ||
|
@@ -104,7 +103,6 @@ struct GumV8Core | |
v8::Global<v8::String> * value_key; | ||
v8::Global<v8::String> * system_error_key; | ||
|
||
v8::Global<v8::FunctionTemplate> * native_callback; | ||
v8::Global<v8::FunctionTemplate> * callback_context; | ||
v8::Global<v8::Object> * callback_context_value; | ||
|
||
|
@@ -142,23 +140,6 @@ struct GumV8ByteArray | |
GumV8Core * core; | ||
}; | ||
|
||
struct GumV8NativeCallback | ||
{ | ||
gint ref_count; | ||
|
||
v8::Global<v8::Object> * wrapper; | ||
|
||
v8::Global<v8::Function> * func; | ||
ffi_closure * closure; | ||
ffi_cif cif; | ||
ffi_type ** atypes; | ||
GSList * data; | ||
|
||
gint interceptor_replacement_count; | ||
|
||
GumV8Core * core; | ||
}; | ||
|
||
class GumV8SystemErrorPreservationScope | ||
{ | ||
public: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2010-2022 Ole André Vadla Ravnås <[email protected]> | ||
* Copyright (C) 2010-2024 Ole André Vadla Ravnås <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
*/ | ||
|
@@ -746,15 +746,6 @@ gum_v8_handle_replace_ret (GumV8Interceptor * self, | |
|
||
g_hash_table_insert (self->replacement_by_address, target, entry); | ||
|
||
auto native_callback = Local<FunctionTemplate>::New (isolate, | ||
*core->native_callback); | ||
auto instance = replacement_value.As<Object> (); | ||
if (native_callback->HasInstance (instance)) | ||
{ | ||
auto callback = (GumV8NativeCallback *) | ||
instance->GetInternalField (1).As<External> ()->Value (); | ||
callback->interceptor_replacement_count++; | ||
} | ||
break; | ||
} | ||
case GUM_REPLACE_WRONG_SIGNATURE: | ||
|
@@ -794,22 +785,6 @@ GUMJS_DEFINE_FUNCTION (gumjs_interceptor_revert) | |
if (!_gum_v8_args_parse (args, "p", &target)) | ||
return; | ||
|
||
auto entry = (GumV8ReplaceEntry *) | ||
g_hash_table_lookup (module->replacement_by_address, target); | ||
if (entry != NULL) | ||
{ | ||
auto native_callback = Local<FunctionTemplate>::New (isolate, | ||
*core->native_callback); | ||
auto replacement_value (Local<Value>::New (isolate, *entry->replacement)); | ||
auto instance = replacement_value.As<Object> (); | ||
if (native_callback->HasInstance (instance)) | ||
{ | ||
auto callback = (GumV8NativeCallback *) | ||
instance->GetInternalField (1).As<External> ()->Value (); | ||
callback->interceptor_replacement_count--; | ||
} | ||
} | ||
|
||
g_hash_table_remove (module->replacement_by_address, target); | ||
} | ||
|
||
|