-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a patch to fix abort() call in CCGLProgram::compileShader
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |