Skip to content

Commit

Permalink
add a patch to fix abort() call in CCGLProgram::compileShader
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Jan 17, 2025
1 parent 5880db7 commit 0340f52
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions loader/src/hooks/CompileShaderFix.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#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;

$execute {
if (LoaderImpl::get()->isForwardCompatMode()) return;

#if GEODE_COMP_GD_VERSION == 22074
// patch an abort() call to "return false;" in CCGLProgram::compileShader
// for some reason cocos only properly returns false on winRT, everywhere
// else it just closes the whole game

auto addr = reinterpret_cast<uintptr_t>(
GetProcAddress(
GetModuleHandle("libcocos2d.dll"), "?compileShader@CCGLProgram@cocos2d@@AEAA_NPEAIIPEBD@Z"
)
) + 0xbb;

(void) Mod::get()->patch(reinterpret_cast<void*>(addr), {
0x31, 0xc0, // xor eax, eax
0xeb, 0x07 // jmp +7 (to a nearby ret)
});
#else
#pragma message("Unsupported GD version!")
#endif
};

#endif

0 comments on commit 0340f52

Please sign in to comment.