@@ -10,24 +10,27 @@ using namespace geode::prelude;
1010
1111static std::mutex mutex;
1212
13- unsigned char * getFileDataHook (CCFileUtilsAndroid* fileUtils, const char * pszFileName, const char * pszMode, unsigned long * pSize) {
13+ using Func_t = unsigned char * (*)(CCFileUtilsAndroid*, const char *, const char *, unsigned long *, bool );
14+ static Func_t g_funcAddr;
15+
16+ unsigned char * getFileDataHook (CCFileUtilsAndroid* fileUtils, const char * pszFileName, const char * pszMode, unsigned long * pSize, bool async) {
1417 std::lock_guard lock (mutex);
15- return fileUtils-> getFileData ( pszFileName, pszMode, pSize);
18+ return g_funcAddr (fileUtils, pszFileName, pszMode, pSize, false );
1619}
1720
1821$execute {
1922 void * handle = dlopen (" libcocos2dcpp.so" , RTLD_LAZY | RTLD_NOLOAD);
20- void * addr = dlsym (handle, " _ZN7cocos2d18CCFileUtilsAndroid11getFileDataEPKcS2_Pm " );
23+ g_funcAddr = (Func_t) dlsym (handle, " _ZN7cocos2d18CCFileUtilsAndroid13doGetFileDataEPKcS2_Pmb " );
2124
22- if (!addr ) {
23- log::error (" Failed to hook CCFileUtilsAndroid::getFileData , address is nullptr" );
25+ if (!g_funcAddr ) {
26+ log::error (" Failed to hook CCFileUtilsAndroid::doGetFileData , address is nullptr" );
2427 return ;
2528 }
2629
2730 auto hook = Mod::get ()->hook (
28- addr ,
31+ ( void *)g_funcAddr ,
2932 &getFileDataHook,
30- " cocos2d::CCFileUtilsAndroid::getFileData " ,
33+ " cocos2d::CCFileUtilsAndroid::doGetFileData " ,
3134 tulip::hook::TulipConvention::Default
3235 ).unwrap ();
3336 hook->setPriority (-199999999 );
0 commit comments