Skip to content

Commit

Permalink
stalker: Fix compilation on Darwin/x86_64
Browse files Browse the repository at this point in the history
By porting the remaining bits to the new Gum.Module API.
  • Loading branch information
oleavr committed Jan 6, 2025
1 parent 1185a95 commit bc01ede
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gum/backend-x86/gumstalker-x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -6644,12 +6644,11 @@ gum_find_thread_exit_implementation (void)
{
#if defined (HAVE_DARWIN)
GumAddress result = 0;
const gchar * pthread_path = "/usr/lib/system/libsystem_pthread.dylib";
GumMemoryRange range;
GumModule * pthread;
GumMatchPattern * pattern;

range.base_address = gum_module_find_base_address (pthread_path);
range.size = 128 * 1024;
pthread = gum_process_find_module_by_name (
"/usr/lib/system/libsystem_pthread.dylib");

pattern = gum_match_pattern_new_from_string (
#if GLIB_SIZEOF_VOID_P == 8
Expand Down Expand Up @@ -6684,16 +6683,19 @@ gum_find_thread_exit_implementation (void)
#endif
);

gum_memory_scan (&range, pattern, gum_store_thread_exit_match, &result);
gum_memory_scan (gum_module_get_range (pthread), pattern,
gum_store_thread_exit_match, &result);

gum_match_pattern_unref (pattern);

/* Non-public symbols are all <redacted> on iOS. */
#ifndef HAVE_IOS
if (result == 0)
result = gum_module_find_symbol_by_name (pthread_path, "_pthread_exit");
result = gum_module_find_symbol_by_name (pthread, "_pthread_exit");
#endif

g_object_unref (pthread);

return GSIZE_TO_POINTER (result);
#elif defined (HAVE_GLIBC)
return GSIZE_TO_POINTER (gum_module_find_export_by_name (
Expand Down

0 comments on commit bc01ede

Please sign in to comment.