Skip to content

Commit 59cb84f

Browse files
Add CCGLProgram::compileShader patches for Android and macOS (#1241)
1 parent 1742968 commit 59cb84f

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

loader/src/hooks/CompileShaderFix.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
#include <Geode/Geode.hpp>
2-
3-
// TODO: this affects every platform :P, but i cant be bothered rn
4-
#ifdef GEODE_IS_WINDOWS
5-
62
#include <loader/LoaderImpl.hpp>
73

84
using namespace geode::prelude;
@@ -15,6 +11,7 @@ using namespace geode::prelude;
1511
// for some reason cocos only properly returns false on winRT, everywhere
1612
// else it just closes the whole game
1713

14+
#if defined(GEODE_IS_WINDOWS)
1815
auto addr = reinterpret_cast<uintptr_t>(
1916
GetProcAddress(
2017
GetModuleHandle("libcocos2d.dll"), "?compileShader@CCGLProgram@cocos2d@@AEAA_NPEAIIPEBD@Z"
@@ -25,9 +22,36 @@ using namespace geode::prelude;
2522
0x31, 0xc0, // xor eax, eax
2623
0xeb, 0x07 // jmp +7 (to a nearby ret)
2724
});
25+
#elif defined(GEODE_IS_ANDROID64)
26+
auto addr = reinterpret_cast<uintptr_t>(
27+
dlsym(RTLD_DEFAULT, "_ZN7cocos2d11CCGLProgram13compileShaderEPjjPKc")
28+
) + 0x74;
29+
30+
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
31+
0x1f, 0x20, 0x03, 0xd5 // nop (skip if statement)
32+
});
33+
#elif defined(GEODE_IS_ANDROID32)
34+
auto addr = reinterpret_cast<uintptr_t>(
35+
dlsym(RTLD_DEFAULT, "_ZN7cocos2d11CCGLProgram13compileShaderEPjjPKc")
36+
) + 0x43;
37+
38+
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
39+
0x14, 0xe0 // b +2c (skip if statement)
40+
});
41+
#elif defined(GEODE_IS_ARM_MAC)
42+
auto addr = base::get() + 0x393aa0;
43+
44+
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
45+
0x1f, 0x20, 0x03, 0xd5 // nop (skip if statement)
46+
});
47+
#elif defined(GEODE_IS_INTEL_MAC)
48+
auto addr = base::get() + 0x417f65;
49+
50+
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
51+
0x48, 0x90, // nop (skip if statement)
52+
});
53+
#endif
2854
#else
2955
#pragma message("Unsupported GD version!")
3056
#endif
3157
};
32-
33-
#endif

0 commit comments

Comments
 (0)