forked from LSPosed/LSPosed
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hook dex2oat functions to remove LSPosed traces
We use LD_PRELOAD to hook the execution of `dex2oat`. To do so, we first overwrite the output file by `liboat_hook.so`, which is given by the parameter `--oat-location`. However, we always get permission error of opening the target `base.odex` file in function `save_fd_to_file`.
- Loading branch information
1 parent
fd25732
commit ae97def
Showing
6 changed files
with
126 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <dlfcn.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "logging.h" | ||
|
||
typedef void* (*OatHeader_GetKeyValueStore_t)(const void*); | ||
|
||
OatHeader_GetKeyValueStore_t real_OatHeader_GetKeyValueStore; | ||
|
||
void* _ZNK3art9OatHeader16GetKeyValueStoreEv(const void* header) { | ||
if (!real_OatHeader_GetKeyValueStore) { | ||
real_OatHeader_GetKeyValueStore = (OatHeader_GetKeyValueStore_t)dlsym( | ||
RTLD_NEXT, "_ZNK3art9OatHeader16GetKeyValueStoreEv"); | ||
if (!real_OatHeader_GetKeyValueStore) { | ||
fprintf(stderr, "Error resolving symbol: _ZNK3art9OatHeader16GetKeyValueStoreEv\n"); | ||
exit(1); | ||
} | ||
} | ||
|
||
// Here you can add your custom logic before calling the original function | ||
LOGD("OatHeader_GetKeyValueStore() called on object at %p\n", header); | ||
|
||
return real_OatHeader_GetKeyValueStore(header); | ||
} |
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