Add CCGLProgram::compileShader patches for Android and macOS ()

This commit is contained in:
Jasmine 2025-02-10 16:38:26 -05:00 committed by GitHub
parent 174296814b
commit 59cb84fd40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,4 @@
#include <Geode/Geode.hpp>
// TODO: this affects every platform :P, but i cant be bothered rn
#ifdef GEODE_IS_WINDOWS
#include <loader/LoaderImpl.hpp>
using namespace geode::prelude;
@ -15,6 +11,7 @@ $execute {
// for some reason cocos only properly returns false on winRT, everywhere
// else it just closes the whole game
#if defined(GEODE_IS_WINDOWS)
auto addr = reinterpret_cast<uintptr_t>(
GetProcAddress(
GetModuleHandle("libcocos2d.dll"), "?compileShader@CCGLProgram@cocos2d@@AEAA_NPEAIIPEBD@Z"
@ -25,9 +22,36 @@ $execute {
0x31, 0xc0, // xor eax, eax
0xeb, 0x07 // jmp +7 (to a nearby ret)
});
#elif defined(GEODE_IS_ANDROID64)
auto addr = reinterpret_cast<uintptr_t>(
dlsym(RTLD_DEFAULT, "_ZN7cocos2d11CCGLProgram13compileShaderEPjjPKc")
) + 0x74;
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
0x1f, 0x20, 0x03, 0xd5 // nop (skip if statement)
});
#elif defined(GEODE_IS_ANDROID32)
auto addr = reinterpret_cast<uintptr_t>(
dlsym(RTLD_DEFAULT, "_ZN7cocos2d11CCGLProgram13compileShaderEPjjPKc")
) + 0x43;
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
0x14, 0xe0 // b +2c (skip if statement)
});
#elif defined(GEODE_IS_ARM_MAC)
auto addr = base::get() + 0x393aa0;
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
0x1f, 0x20, 0x03, 0xd5 // nop (skip if statement)
});
#elif defined(GEODE_IS_INTEL_MAC)
auto addr = base::get() + 0x417f65;
(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
0x48, 0x90, // nop (skip if statement)
});
#endif
#else
#pragma message("Unsupported GD version!")
#endif
};
#endif