-
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gumjs: Only complete load() after leaving runtime
Once load() completes, it should be safe to assume that Interceptor has activated any hooks installed by the script. Our existing tests make this assumption as well.
- Loading branch information
Showing
2 changed files
with
74 additions
and
8 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) 2013 Karl Trygve Kalleberg <[email protected]> | ||
* | ||
* Licence: wxWindows Library Licence, Version 3.1 | ||
|
@@ -151,6 +151,7 @@ static void gum_v8_script_execute_entrypoints (GumV8Script * self, | |
GumScriptTask * task); | ||
static void gum_v8_script_on_entrypoints_executed ( | ||
const FunctionCallbackInfo<Value> & info); | ||
static gboolean gum_v8_script_complete_load_task (GumScriptTask * task); | ||
static void gum_v8_script_unload (GumScript * script, | ||
GCancellable * cancellable, GAsyncReadyCallback callback, | ||
gpointer user_data); | ||
|
@@ -1287,6 +1288,7 @@ gum_v8_script_on_entrypoints_executed (const FunctionCallbackInfo<Value> & info) | |
auto task = (GumScriptTask *) info.Data ().As<External> ()->Value (); | ||
auto self = (GumV8Script *) | ||
g_async_result_get_source_object (G_ASYNC_RESULT (task)); | ||
auto core = &self->core; | ||
auto isolate = info.GetIsolate (); | ||
auto context = isolate->GetCurrentContext (); | ||
|
||
|
@@ -1298,15 +1300,40 @@ gum_v8_script_on_entrypoints_executed (const FunctionCallbackInfo<Value> & info) | |
auto value = values->Get (context, i).ToLocalChecked ().As<Object> (); | ||
auto reason = value->Get (context, reason_str).ToLocalChecked (); | ||
if (!reason->IsUndefined ()) | ||
_gum_v8_core_on_unhandled_exception (&self->core, reason); | ||
_gum_v8_core_on_unhandled_exception (core, reason); | ||
} | ||
|
||
auto source = g_idle_source_new (); | ||
g_source_set_callback (source, (GSourceFunc) gum_v8_script_complete_load_task, | ||
task, g_object_unref); | ||
g_source_attach (source, | ||
gum_script_scheduler_get_js_context (core->scheduler)); | ||
g_source_unref (source); | ||
|
||
_gum_v8_core_pin (core); | ||
|
||
g_object_unref (self); | ||
} | ||
|
||
static gboolean | ||
gum_v8_script_complete_load_task (GumScriptTask * task) | ||
{ | ||
auto self = GUM_V8_SCRIPT ( | ||
g_async_result_get_source_object (G_ASYNC_RESULT (task))); | ||
|
||
{ | ||
ScriptScope scope (self); | ||
|
||
_gum_v8_core_unpin (&self->core); | ||
} | ||
|
||
self->state = GUM_SCRIPT_STATE_LOADED; | ||
|
||
gum_script_task_return_pointer (task, NULL, NULL); | ||
|
||
g_object_unref (self); | ||
g_object_unref (task); | ||
|
||
return G_SOURCE_REMOVE; | ||
} | ||
|
||
static void | ||
|