At the time of initialization, the hook is as follows:Msinitialize
{
????
???? __android_log_print (Android_log_error, TAG, "substrate initialized.");
???? Msimageref image;
???? image = Msgetimagebyname ("/system/lib/libdvm.so"), loading Lib
???? if (image! = NULL)
???? {
???????? Note that this is a C + + function that can be obtained by Objdump
???????? void * dexload=msfindsymbol (image, "_z21dvmdexfileopenpartialpkvipp6dvmdex");
???????? if (dexload==null)
???????? {
???????????? LOGD ("Error Find _z21dvmdexfileopenpartialpkvipp6dvmdex");
????????}
???????? else{
???????????? mshookfunction (Dexload, (void*) &mydvmdexfileopen, (void * *) &olddexfileopen);
????????}
????}
???? else{
???????? LOGD ("ERROR FIND LIBDVM");
????}
}
?
Other functions related to:
Int (* olddexfileopen) (const void * Addr,int len,void * * dvmdex); Keep the original address
int Mydvmdexfileopen (const void * Addr,int len,void * * dvmdex) New function
{
LOGD ("Call my DVM dex!!:%d", Getpid ());
{//write to File
???? Char buf[200];
???? sprintf (buf, "/sdcard/dex.%d", Random ()); Exporting Dex Files
???? FILE * F=fopen (BUF, "WB");
???? if (!f)
???? {
???????? LOGD ("Error open SDcard file to write");
???? }
???? else{
???????? Fwrite (ADDR,1,LEN,F);
???????? Fclose (f);
???? }
?
}
Return Olddexfileopen (Addr,len,dvmdex); make the original call without affecting the program to run
}