Skip to content

Commit

Permalink
Almost there
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmacete committed Jan 19, 2024
1 parent ab4453d commit 66080bb
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions tests/gumjs/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -10907,37 +10907,14 @@ TESTCASE (java_api_is_embedded)
TESTCASE (cloaked_items_can_be_queried_added_and_removed)
{
void * buffer = malloc (64);

#if HAVE_ANDROID
COMPILE_AND_LOAD_SCRIPT (
"const testRange = { base: ptr('0x%" G_GINT64_MODIFIER "x'), size: 64 };"
"send(Cloak.hasRangeContaining(testRange.base) === false);"
"send(Process.findRangeByAddress(testRange.base) !== null);"
"send(Cloak.clipRange(testRange) === null);"
"Cloak.addRange(testRange);"
"send(Cloak.hasRangeContaining(testRange.base));"
"send(Process.findRangeByAddress(testRange.base) === null);"
"send(Cloak.clipRange(testRange).length === 0);"
"Cloak.removeRange(testRange);"

"send(Cloak.hasCurrentThread() === false);"
"const threadId = Process.getCurrentThreadId();"
"send(Cloak.hasThread(threadId) === false);"
"Cloak.addThread(threadId);"
"send(!Process.enumerateThreads().map(x => x.id).includes(threadId));"
"send(Cloak.hasCurrentThread() === true);"
"Cloak.removeThread(threadId);"
"send(true);"

"const fd = 1;"
"Cloak.addFileDescriptor(fd);"
"send(Cloak.hasFileDescriptor(fd));"
"Cloak.removeFileDescriptor(fd);"
"send(!Cloak.hasFileDescriptor(fd));",
GPOINTER_TO_SIZE (buffer)
);
const gchar * is_android = "true";
#else
const gchar * is_android = "false";
#endif

COMPILE_AND_LOAD_SCRIPT (
"const isAndroid = %s;"
"const testRange = { base: ptr('0x%" G_GINT64_MODIFIER "x'), size: 64 };"
"send(Cloak.hasRangeContaining(testRange.base) === false);"
"send(Process.findRangeByAddress(testRange.base) !== null);"
Expand All @@ -10955,16 +10932,20 @@ TESTCASE (cloaked_items_can_be_queried_added_and_removed)
"send(!Process.enumerateThreads().map(x => x.id).includes(threadId));"
"send(Cloak.hasCurrentThread() === true);"
"Cloak.removeThread(threadId);"
"send(Process.enumerateThreads().map(x => x.id).includes(threadId));"
"if (isAndroid) {"
" send(true);"
"} else {"
" send(Process.enumerateThreads().map(x => x.id).includes(threadId));"
"}"

"const fd = 1;"
"Cloak.addFileDescriptor(fd);"
"send(Cloak.hasFileDescriptor(fd));"
"Cloak.removeFileDescriptor(fd);"
"send(!Cloak.hasFileDescriptor(fd));",
is_android,
GPOINTER_TO_SIZE (buffer)
);
#endif
EXPECT_SEND_MESSAGE_WITH ("true");
EXPECT_SEND_MESSAGE_WITH ("true");
EXPECT_SEND_MESSAGE_WITH ("true");
Expand Down

0 comments on commit 66080bb

Please sign in to comment.