diff options
| author | ptitSeb <seebastien.chev@gmail.com> | 2023-09-30 20:23:37 +0200 |
|---|---|---|
| committer | ptitSeb <seebastien.chev@gmail.com> | 2023-09-30 20:23:37 +0200 |
| commit | a724725fdf31c6308934b57f8ce8b442d0b1f5d3 (patch) | |
| tree | 85f60705d53f2242a53f2b42227863b33a194554 /src | |
| parent | 84a5929645099e6d823b0395f00e63a0e2f6b38c (diff) | |
| download | box64-a724725fdf31c6308934b57f8ce8b442d0b1f5d3.tar.gz box64-a724725fdf31c6308934b57f8ce8b442d0b1f5d3.zip | |
[ANDROID] No mallochack on Android
Diffstat (limited to 'src')
| -rw-r--r-- | src/include/debug.h | 13 | ||||
| -rw-r--r-- | src/mallochook.c | 30 |
2 files changed, 14 insertions, 29 deletions
diff --git a/src/include/debug.h b/src/include/debug.h index acd842c2..5ff9e194 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -114,12 +114,11 @@ void printf_ftrace(const char* fmt, ...); void init_malloc_hook(void); #ifdef ANDROID -extern size_t(*box_malloc_usable_size)(const void*); -extern void*(*__libc_malloc)(size_t); -extern void*(*__libc_realloc)(void*, size_t); -extern void*(*__libc_calloc)(size_t, size_t); -extern void (*__libc_free)(void*); -extern void*(*__libc_memalign)(size_t, size_t); +#define box_malloc malloc +#define box_realloc realloc +#define box_calloc calloc +#define box_free free +#define box_memalign memalign #else extern size_t(*box_malloc_usable_size)(void*); extern void* __libc_malloc(size_t); @@ -127,12 +126,12 @@ extern void* __libc_realloc(void*, size_t); extern void* __libc_calloc(size_t, size_t); extern void __libc_free(void*); extern void* __libc_memalign(size_t, size_t); -#endif #define box_malloc __libc_malloc #define box_realloc __libc_realloc #define box_calloc __libc_calloc #define box_free __libc_free #define box_memalign __libc_memalign +#endif extern char* box_strdup(const char* s); extern char* box_realpath(const char* path, char* ret); diff --git a/src/mallochook.c b/src/mallochook.c index 1559c4be..bf04da95 100644 --- a/src/mallochook.c +++ b/src/mallochook.c @@ -41,7 +41,7 @@ This is the Exterminate strategy implementation */ - +#ifndef ANDROID #include "bridge.h" #include "wrapper.h" @@ -131,16 +131,7 @@ typedef void* (*pFpLp_t)(void*, size_t, void*); typedef void (*vFpLL_t)(void*, size_t, size_t); typedef void* (*pFpLLp_t)(void*, size_t, size_t, void*); -#ifdef ANDROID -void*(*__libc_malloc)(size_t) = NULL; -void*(*__libc_realloc)(void*, size_t) = NULL; -void*(*__libc_calloc)(size_t, size_t) = NULL; -void (*__libc_free)(void*) = NULL; -void*(*__libc_memalign)(size_t, size_t) = NULL; -size_t(*box_malloc_usable_size)(const void*) = NULL; -#else size_t(*box_malloc_usable_size)(void*) = NULL; -#endif int GetTID(); uint32_t getProtection(uintptr_t addr); @@ -305,11 +296,7 @@ EXPORT void cfree(void* p) box_free(p); } -#ifdef ANDROID -EXPORT size_t malloc_usable_size(const void* p) -#else EXPORT size_t malloc_usable_size(void* p) -#endif { if(malloc_hack_2 && real_malloc_usable_size) { if(getMmapped((uintptr_t)p)) @@ -881,13 +868,6 @@ EXPORT int my___RML_open_factory(void* factory, void* server_version, int client } void init_malloc_hook() { -#ifdef ANDROID - __libc_malloc = dlsym(RTLD_NEXT, "malloc"); - __libc_realloc = dlsym(RTLD_NEXT, "realloc"); - __libc_calloc = dlsym(RTLD_NEXT, "calloc"); - __libc_free = dlsym(RTLD_NEXT, "free"); - __libc_memalign = dlsym(RTLD_NEXT, "memalign"); -#endif box_malloc_usable_size = dlsym(RTLD_NEXT, "malloc_usable_size"); #if 0 #define GO(A, B) @@ -898,4 +878,10 @@ void init_malloc_hook() { #endif } -#undef SUPER \ No newline at end of file +#undef SUPER +#else//ANDROID +void init_malloc_hook() {} +void startMallocHook() {} +void endMallocHook() {} +void checkHookedSymbols(elfheader_t* h) {} +#endif //!ANDROID \ No newline at end of file |