Skip to content

Commit 0340f52

Browse files
committed
add a patch to fix abort() call in CCGLProgram::compileShader
1 parent 5880db7 commit 0340f52

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

loader/src/hooks/CompileShaderFix.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <Geode/Geode.hpp>
2+
3+
// TODO: this affects every platform :P, but i cant be bothered rn
4+
#ifdef GEODE_IS_WINDOWS
5+
6+
#include <loader/LoaderImpl.hpp>
7+
8+
using namespace geode::prelude;
9+
10+
$execute {
11+
if (LoaderImpl::get()->isForwardCompatMode()) return;
12+
13+
#if GEODE_COMP_GD_VERSION == 22074
14+
// patch an abort() call to "return false;" in CCGLProgram::compileShader
15+
// for some reason cocos only properly returns false on winRT, everywhere
16+
// else it just closes the whole game
17+
18+
auto addr = reinterpret_cast<uintptr_t>(
19+
GetProcAddress(
20+
GetModuleHandle("libcocos2d.dll"), "?compileShader@CCGLProgram@cocos2d@@AEAA_NPEAIIPEBD@Z"
21+
)
22+
) + 0xbb;
23+
24+
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
25+
0x31, 0xc0, // xor eax, eax
26+
0xeb, 0x07 // jmp +7 (to a nearby ret)
27+
});
28+
#else
29+
#pragma message("Unsupported GD version!")
30+
#endif
31+
};
32+
33+
#endif

0 commit comments

Comments
 (0)