2022-11-28 11:32:25 -05:00
|
|
|
|
|
|
|
#include <Geode/DefaultInclude.hpp>
|
|
|
|
|
2022-07-31 15:50:49 -04:00
|
|
|
#ifdef GEODE_IS_WINDOWS
|
2022-11-28 11:32:25 -05:00
|
|
|
|
|
|
|
#include <Geode/modify/InternalMacros.hpp>
|
|
|
|
#include <Geode/loader/Mod.hpp>
|
2022-07-31 15:50:49 -04:00
|
|
|
|
|
|
|
USE_GEODE_NAMESPACE();
|
|
|
|
using geode::core::meta::x86::Thiscall;
|
|
|
|
|
|
|
|
// for some reason RobTop uses MessageBoxW in his GLFW error handler.
|
|
|
|
// no one knows how this is possible (he passes char* to wchar_t*).
|
|
|
|
// so anyway, here's a fix for it
|
|
|
|
|
|
|
|
static auto CCEGLVIEW_CON_ADDR = reinterpret_cast<void*>(base::getCocos() + 0xc2860);
|
|
|
|
|
2022-10-30 14:56:36 -04:00
|
|
|
static void __cdecl fixedErrorHandler(int code, char const* description) {
|
2022-10-08 14:35:19 -04:00
|
|
|
log::critical("GLFW Error {}: {}", code, description);
|
2022-07-31 15:50:49 -04:00
|
|
|
MessageBoxA(
|
|
|
|
nullptr,
|
2022-11-28 11:32:25 -05:00
|
|
|
fmt::format(
|
|
|
|
"GLFWError #{}: {}\nPlease contact the "
|
2022-07-31 15:50:49 -04:00
|
|
|
"Geode Development Team for more information.",
|
|
|
|
code, description
|
2022-11-28 11:32:25 -05:00
|
|
|
).c_str(),
|
2022-10-30 14:56:36 -04:00
|
|
|
"OpenGL Error", MB_ICONERROR
|
2022-07-31 15:50:49 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CCEGLView* CCEGLView_CCEGLView(CCEGLView* self) {
|
|
|
|
// you will never have to make a manual hook with Geode again, they said
|
|
|
|
// it will be fun, they said
|
|
|
|
reinterpret_cast<CCEGLView*(__thiscall*)(CCEGLView*)>(CCEGLVIEW_CON_ADDR)(self);
|
|
|
|
static auto p = Mod::get()->patch(
|
|
|
|
reinterpret_cast<void*>(geode::base::getCocos() + 0x19feec),
|
|
|
|
to_byte_array(&fixedErrorHandler)
|
|
|
|
);
|
|
|
|
return self;
|
|
|
|
}
|
2022-10-08 10:05:53 -04:00
|
|
|
|
|
|
|
$execute {
|
2022-10-30 14:56:36 -04:00
|
|
|
(void)Mod::get()->addHook<&CCEGLView_CCEGLView, Thiscall>(
|
|
|
|
"CCEGLView::CCEGLView", CCEGLVIEW_CON_ADDR
|
|
|
|
);
|
2022-10-08 10:05:53 -04:00
|
|
|
}
|
2022-07-31 15:50:49 -04:00
|
|
|
|
|
|
|
#endif
|