-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gumjs: Always expose thread's system error to NativeCallback
Also when Interceptor isn't involved.
- Loading branch information
Showing
4 changed files
with
130 additions
and
14 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
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) 2015 Asger Hautop Drewsen <[email protected]> | ||
* Copyright (C) 2015 Marc Hartmayer <[email protected]> | ||
* Copyright (C) 2020-2022 Francesco Tamagni <[email protected]> | ||
|
@@ -143,6 +143,7 @@ struct GumV8CallbackContext | |
{ | ||
Global<Object> * wrapper; | ||
Global<Object> * cpu_context; | ||
gint * system_error; | ||
GumAddress return_address; | ||
GumAddress raw_return_address; | ||
}; | ||
|
@@ -308,11 +309,13 @@ static void gum_v8_native_callback_invoke (ffi_cif * cif, | |
void * return_value, void ** args, void * user_data); | ||
|
||
static GumV8CallbackContext * gum_v8_callback_context_new_persistent ( | ||
GumV8Core * core, GumCpuContext * cpu_context, | ||
GumV8Core * core, GumCpuContext * cpu_context, gint * system_error, | ||
GumAddress raw_return_address); | ||
static void gum_v8_callback_context_free (GumV8CallbackContext * self); | ||
GUMJS_DECLARE_GETTER (gumjs_callback_context_get_return_address) | ||
GUMJS_DECLARE_GETTER (gumjs_callback_context_get_cpu_context) | ||
GUMJS_DECLARE_GETTER (gumjs_callback_context_get_system_error) | ||
GUMJS_DECLARE_SETTER (gumjs_callback_context_set_system_error) | ||
|
||
GUMJS_DECLARE_CONSTRUCTOR (gumjs_cpu_context_construct) | ||
GUMJS_DECLARE_GETTER (gumjs_cpu_context_get_gpr) | ||
|
@@ -482,8 +485,21 @@ static const GumV8Function gumjs_native_function_functions[] = | |
|
||
static const GumV8Property gumjs_callback_context_values[] = | ||
{ | ||
{ "returnAddress", gumjs_callback_context_get_return_address, NULL }, | ||
{ "context", gumjs_callback_context_get_cpu_context, NULL }, | ||
{ | ||
"returnAddress", | ||
gumjs_callback_context_get_return_address, | ||
NULL | ||
}, | ||
{ | ||
"context", | ||
gumjs_callback_context_get_cpu_context, | ||
NULL | ||
}, | ||
{ | ||
GUMJS_SYSTEM_ERROR_FIELD, | ||
gumjs_callback_context_get_system_error, | ||
gumjs_callback_context_set_system_error | ||
}, | ||
|
||
{ NULL, NULL, NULL } | ||
}; | ||
|
@@ -3530,7 +3546,7 @@ gum_v8_native_callback_invoke (ffi_cif * cif, | |
#endif | ||
|
||
jcc = gum_v8_callback_context_new_persistent (self->core, &cpu_context, | ||
return_address); | ||
&error_scope.saved_error, return_address); | ||
recv = Local<Object>::New (isolate, *jcc->wrapper); | ||
} | ||
|
||
|
@@ -3566,6 +3582,7 @@ gum_v8_native_callback_invoke (ffi_cif * cif, | |
static GumV8CallbackContext * | ||
gum_v8_callback_context_new_persistent (GumV8Core * core, | ||
GumCpuContext * cpu_context, | ||
gint * system_error, | ||
GumAddress raw_return_address) | ||
{ | ||
auto isolate = core->isolate; | ||
|
@@ -3576,12 +3593,13 @@ gum_v8_callback_context_new_persistent (GumV8Core * core, | |
*core->callback_context_value); | ||
auto wrapper = callback_context_value->Clone (); | ||
wrapper->SetAlignedPointerInInternalField (0, jcc); | ||
jcc->wrapper = new Global<Object> (isolate, wrapper); | ||
jcc->return_address = 0; | ||
jcc->raw_return_address = raw_return_address; | ||
|
||
jcc->wrapper = new Global<Object> (isolate, wrapper); | ||
jcc->cpu_context = new Global<Object> (isolate, | ||
_gum_v8_cpu_context_new_immutable (cpu_context, core)); | ||
jcc->system_error = system_error; | ||
jcc->return_address = 0; | ||
jcc->raw_return_address = raw_return_address; | ||
|
||
return jcc; | ||
} | ||
|
@@ -3639,6 +3657,22 @@ GUMJS_DEFINE_CLASS_GETTER (gumjs_callback_context_get_cpu_context, | |
info.GetReturnValue ().Set (Local<Object>::New (isolate, *context)); | ||
} | ||
|
||
GUMJS_DEFINE_CLASS_GETTER (gumjs_callback_context_get_system_error, | ||
GumV8CallbackContext) | ||
{ | ||
info.GetReturnValue ().Set (*self->system_error); | ||
} | ||
|
||
GUMJS_DEFINE_CLASS_SETTER (gumjs_callback_context_set_system_error, | ||
GumV8CallbackContext) | ||
{ | ||
gint system_error; | ||
if (!_gum_v8_int_get (value, &system_error, core)) | ||
return; | ||
|
||
*self->system_error = system_error; | ||
} | ||
|
||
GUMJS_DEFINE_CONSTRUCTOR (gumjs_cpu_context_construct) | ||
{ | ||
GumCpuContext * cpu_context = NULL; | ||
|
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