From 43e355dd21b4f0c6938d247d12bf97a409d5685d Mon Sep 17 00:00:00 2001 From: s1341 Date: Thu, 29 Feb 2024 14:23:17 +0200 Subject: [PATCH] gumjs bindings for put_chaining_return --- bindings/gumjs/gumquickstalker.c | 34 ++++++++++++++++++++++++++++++++ bindings/gumjs/gumv8stalker.cpp | 27 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/bindings/gumjs/gumquickstalker.c b/bindings/gumjs/gumquickstalker.c index 995c1aeb43..4a13f8e6ed 100644 --- a/bindings/gumjs/gumquickstalker.c +++ b/bindings/gumjs/gumquickstalker.c @@ -115,6 +115,7 @@ GUMJS_DECLARE_GETTER (gumjs_default_iterator_get_memory_access) GUMJS_DECLARE_FUNCTION (gumjs_default_iterator_next) GUMJS_DECLARE_FUNCTION (gumjs_default_iterator_keep) GUMJS_DECLARE_FUNCTION (gumjs_default_iterator_put_callout) +GUMJS_DECLARE_FUNCTION (gumjs_default_iterator_put_chaining_return) static JSValue gum_quick_special_iterator_new (GumQuickStalker * parent, GumQuickSpecialIterator ** iterator); @@ -125,6 +126,7 @@ GUMJS_DECLARE_GETTER (gumjs_special_iterator_get_memory_access) GUMJS_DECLARE_FUNCTION (gumjs_special_iterator_next) GUMJS_DECLARE_FUNCTION (gumjs_special_iterator_keep) GUMJS_DECLARE_FUNCTION (gumjs_special_iterator_put_callout) +GUMJS_DECLARE_FUNCTION (gumjs_special_iterator_put_chaining_return) static void gum_quick_callout_free (GumQuickCallout * callout); static void gum_quick_callout_on_invoke (GumCpuContext * cpu_context, @@ -200,6 +202,7 @@ static const JSCFunctionListEntry gumjs_default_iterator_entries[] = JS_CFUNC_DEF ("next", 0, gumjs_default_iterator_next), JS_CFUNC_DEF ("keep", 0, gumjs_default_iterator_keep), JS_CFUNC_DEF ("putCallout", 0, gumjs_default_iterator_put_callout), + JS_CFUNC_DEF ("putChainingReturn", 0, gumjs_default_iterator_put_chaining_return), }; static const JSClassDef gumjs_special_iterator_def = @@ -215,6 +218,7 @@ static const JSCFunctionListEntry gumjs_special_iterator_entries[] = JS_CFUNC_DEF ("next", 0, gumjs_special_iterator_next), JS_CFUNC_DEF ("keep", 0, gumjs_special_iterator_keep), JS_CFUNC_DEF ("putCallout", 0, gumjs_special_iterator_put_callout), + JS_CFUNC_DEF ("putChainingReturn", 0, gumjs_special_iterator_put_chaining_return), }; static const JSClassExoticMethods gumjs_probe_args_exotic_methods = @@ -1016,6 +1020,16 @@ gum_quick_stalker_iterator_put_callout (GumQuickIterator * self, return JS_UNDEFINED; } +static JSValue +gum_quick_stalker_iterator_put_chaining_return (GumQuickIterator * self, + JSContext * ctx, + GumQuickArgs * args) +{ + gum_stalker_iterator_put_callout (self->handle); + + return JS_UNDEFINED; +} + static JSValue gum_quick_default_iterator_new (GumQuickStalker * parent, GumQuickDefaultIterator ** iterator) @@ -1135,6 +1149,16 @@ GUMJS_DEFINE_FUNCTION (gumjs_default_iterator_put_callout) return gum_quick_stalker_iterator_put_callout (&self->iterator, ctx, args); } +GUMJS_DEFINE_FUNCTION (gumjs_default_iterator_put_chaining_return) +{ + GumQuickDefaultIterator * self; + + if (!gum_quick_default_iterator_get (ctx, this_val, core, &self)) + return JS_EXCEPTION; + + return gum_quick_stalker_iterator_put_chaining_return (&self->iterator, ctx, args); +} + static JSValue gum_quick_special_iterator_new (GumQuickStalker * parent, GumQuickSpecialIterator ** iterator) @@ -1254,6 +1278,16 @@ GUMJS_DEFINE_FUNCTION (gumjs_special_iterator_put_callout) return gum_quick_stalker_iterator_put_callout (&self->iterator, ctx, args); } +GUMJS_DEFINE_FUNCTION (gumjs_special_iterator_put_chaining_return) +{ + GumQuickSpecialIterator * self; + + if (!gum_quick_special_iterator_get (ctx, this_val, core, &self)) + return JS_EXCEPTION; + + return gum_quick_stalker_iterator_put_chaining_return (&self->iterator, ctx, args); +} + static void gum_quick_callout_free (GumQuickCallout * callout) { diff --git a/bindings/gumjs/gumv8stalker.cpp b/bindings/gumjs/gumv8stalker.cpp index 1f90f0eb0f..414fb377bf 100644 --- a/bindings/gumjs/gumv8stalker.cpp +++ b/bindings/gumjs/gumv8stalker.cpp @@ -133,6 +133,7 @@ GUMJS_DECLARE_GETTER (gumjs_stalker_default_iterator_get_memory_access) GUMJS_DECLARE_FUNCTION (gumjs_stalker_default_iterator_next) GUMJS_DECLARE_FUNCTION (gumjs_stalker_default_iterator_keep) GUMJS_DECLARE_FUNCTION (gumjs_stalker_default_iterator_put_callout) +GUMJS_DECLARE_FUNCTION (gumjs_stalker_default_iterator_put_chaining_return) static GumV8StalkerSpecialIterator * gum_v8_stalker_special_iterator_new_persistent (GumV8Stalker * parent); @@ -149,6 +150,7 @@ GUMJS_DECLARE_GETTER (gumjs_stalker_special_iterator_get_memory_access) GUMJS_DECLARE_FUNCTION (gumjs_stalker_special_iterator_next) GUMJS_DECLARE_FUNCTION (gumjs_stalker_special_iterator_keep) GUMJS_DECLARE_FUNCTION (gumjs_stalker_special_iterator_put_callout) +GUMJS_DECLARE_FUNCTION (gumjs_stalker_special_iterator_put_chaining_return) static void gum_v8_callout_free (GumV8Callout * callout); static void gum_v8_callout_on_invoke (GumCpuContext * cpu_context, @@ -227,6 +229,7 @@ static const GumV8Function gumjs_stalker_default_iterator_functions[] = { "next", gumjs_stalker_default_iterator_next }, { "keep", gumjs_stalker_default_iterator_keep }, { "putCallout", gumjs_stalker_default_iterator_put_callout }, + { "putChainingReturn", gumjs_stalker_default_iterator_put_chaining_return }, { NULL, NULL } }; @@ -243,6 +246,7 @@ static const GumV8Function gumjs_stalker_special_iterator_functions[] = { "next", gumjs_stalker_special_iterator_next }, { "keep", gumjs_stalker_special_iterator_keep }, { "putCallout", gumjs_stalker_special_iterator_put_callout }, + { "putChainingReturn", gumjs_stalker_special_iterator_put_chaining_return }, { NULL, NULL } }; @@ -1083,6 +1087,17 @@ gum_v8_stalker_iterator_put_callout (GumV8StalkerIterator * self, } } +static void +gum_v8_stalker_iterator_put_chaining_return (GumV8StalkerIterator * self, + const GumV8Args * args, + Isolate * isolate) +{ + if (!gum_v8_stalker_iterator_check_valid (self, isolate)) + return; + + gum_stalker_iterator_put_chaining_return (self->handle); +} + static GumV8StalkerDefaultIterator * gum_v8_stalker_default_iterator_new_persistent (GumV8Stalker * parent) { @@ -1170,6 +1185,12 @@ GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (gumjs_stalker_default_iterator_put_callout, gum_v8_stalker_iterator_put_callout (&self->iterator, args, isolate); } +GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (gumjs_stalker_default_iterator_put_chaining_return, + GumV8StalkerDefaultIterator) +{ + gum_v8_stalker_iterator_put_chaining_return (&self->iterator, args, isolate); +} + static GumV8StalkerSpecialIterator * gum_v8_stalker_special_iterator_new_persistent (GumV8Stalker * parent) { @@ -1257,6 +1278,12 @@ GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (gumjs_stalker_special_iterator_put_callout, gum_v8_stalker_iterator_put_callout (&self->iterator, args, isolate); } +GUMJS_DEFINE_DIRECT_SUBCLASS_METHOD (gumjs_stalker_special_iterator_put_chaining_return, + GumV8StalkerSpecialIterator) +{ + gum_v8_stalker_iterator_put_chaining_return (&self->iterator, args, isolate); +} + static void gum_v8_callout_free (GumV8Callout * callout) {