Last active
January 17, 2022 03:57
-
-
Save SeeFlowerX/8e8dea9dff4819a4be4b83aac9c5ef6c to your computer and use it in GitHub Desktop.
打印ArtMethod信息
This file contains hidden or 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
function readStdString(str: NativePointer) { | |
const isTiny = (str.readU8() & 1) === 0; | |
if (isTiny) { | |
return str.add(1).readUtf8String(); | |
} | |
return str.add(2 * Process.pointerSize).readPointer().readUtf8String(); | |
} | |
function get_PrettyMethod(){ | |
let PrettyMethod_ptr = Module.findExportByName("libart.so", "_ZN3art9ArtMethod12PrettyMethodEPS0_b"); | |
if (PrettyMethod_ptr == null){ | |
log(`libart.so PrettyMethod_ptr is null`); | |
return; | |
} | |
log(`PrettyMethod_ptr => ${PrettyMethod_ptr}`); | |
let PrettyMethod_func = new NativeFunction(PrettyMethod_ptr, "pointer", ["pointer", "bool"]); | |
return PrettyMethod_func; | |
} | |
let PrettyMethod_func: any = get_PrettyMethod(); | |
function print_art_method(art_method_ptr: any){ | |
if (!PrettyMethod_func){ | |
console.log(`PrettyMethod_func => ${PrettyMethod_func}`); | |
return; | |
} | |
let std_results: NativePointer = PrettyMethod_func(art_method_ptr, 1); | |
let [ptr1, ptr2, ptr3] = [ | |
std_results.readPointer(), | |
std_results.add(Process.pointerSize).readPointer(), | |
std_results.add(Process.pointerSize * 2).readPointer() | |
] | |
let std_string_ptr = Memory.alloc(Process.pointerSize * 3); | |
std_string_ptr.writePointer(ptr1); | |
std_string_ptr.add(Process.pointerSize * 1).writePointer(ptr2); | |
std_string_ptr.add(Process.pointerSize * 2).writePointer(ptr3); | |
let function_name = readStdString(std_string_ptr); | |
console.log(`function_name:${function_name}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment