Skip to content

Commit

Permalink
oat适配
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyesiqiu committed Jul 1, 2022
1 parent e67d73e commit 10a2aa1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shell/src/main/cpp/dpt_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,33 @@ void* fake_GetOatDexFile(){
return nullptr;
}

void *fake_GetOatDexFile2(const char* dex_location,
const uint32_t* dex_location_checksum,
std::string* error_msg){
DLOGD("fake_GetOatDexFile2 call!");

return nullptr;
}

void hook_GetOatDexFile(){
const char *getOatDexFileSymbol = find_symbol_in_elf_file(GetArtLibPath(),2,"OatFile","GetOatDexFile");
DLOGD("getOatDexFile symbol = %s",getOatDexFileSymbol);
void *sym = DobbySymbolResolver(getArtLibName(),getOatDexFileSymbol);
if(sym != nullptr){
switch (g_sdkLevel) {
case 24:
case 25:
DobbyHook(sym,(void *)fake_GetOatDexFile,(void **)&g_GetOatDexFile);
break;
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
DobbyHook(sym,(void *)fake_GetOatDexFile2,(void **)&g_GetOatDexFile2);
break;
}
}
}
3 changes: 3 additions & 0 deletions shell/src/main/cpp/dpt_hook.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ uint32_t getDataItemCodeItemOffset();
void hook_mmap();
void hook_GetOatDexFile();
static void* (*g_GetOatDexFile)() = nullptr;
static void (*g_GetOatDexFile2)(const char* dex_location,
const uint32_t* dex_location_checksum,
std::string* error_msg) = nullptr;
#endif //DPT_DPT_HOOK_H

0 comments on commit 10a2aa1

Please sign in to comment.