Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dpt_hoop.cpp dexNumber函数里有一个函数看不懂,谁能给讲讲啊 #15

Closed
soibhanZhangxb opened this issue Jan 17, 2023 · 1 comment

Comments

@soibhanZhangxb
Copy link

//这个函数里的location看不懂???

void LoadMethod(void *thiz, void *self, const void *dex_file,  const void *it, const void *method, void *klass, void *dst) {
                
    //这行返回 40 ,根据api版本和是否64位来判断(64位,安卓12)
     uint32_t location_offset = getDexFileLocationOffset(); //40
     
      // location指向 dex 的 file_size位置
      std::string *location = (reinterpret_cast<std::string *>((uint8_t *)dex_file + location_offset));
     
      // 为什么会从 dex的 file_size位置开始搜索  base.apk呢,这个base.apk又是什么那里来的???
      // 【我用 010editor搜索了dex 都没有 base.apk 】
      if (location->find("base.apk") != std::string::npos) {
      }
}

// 这个函数好像是从Dex里面搜索是第几个 Dex

int dexNumber(std::string *location) {
    char buf[3] = {0};
    // 根据上面的函数,location是 dex file_size 位置,为什么要从这里搜索 .dex ??? 【我用 010editor搜索了dex 都没有 .dex 】
    if (location->find(".dex") != std::string::npos) {
        const char *chs = strchr(location->c_str(), '!'); //返回字符串从'!'开始之后的字符串
        if(nullptr != chs) {
            sscanf(chs, "%*[^0-9]%[^.]", buf);
        } else {
            const char* chs2 = strchr(location->c_str(), ':');
            if(nullptr != chs2) {
                sscanf(chs2, "%*[^0-9]%[^.]", buf);
            } else {
                sprintf(buf, "%s", "1");
            }
        }
    } else {
        sprintf(buf, "%s", "1");
    }
    int dexIndex = 0;
    sscanf(buf, "%d", &dexIndex);
    return dexIndex;
}
@luoyesiqiu
Copy link
Owner

LoadMethod是运行时就会调用的,你可以在运行时把location打印出来,看看它的格式,它里面就是会包含base.apk的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants