fix tuliphook result and windows messageboxfix

This commit is contained in:
altalk23 2022-12-14 17:25:25 +03:00
parent 1bdc8f408c
commit ac40e4c8fb
2 changed files with 3 additions and 18 deletions

View file

@ -136,7 +136,7 @@ CPMAddPackage("gh:google/re2#954656f")
target_include_directories(${PROJECT_NAME} PRIVATE ${md4c_SOURCE_DIR}/src) target_include_directories(${PROJECT_NAME} PRIVATE ${md4c_SOURCE_DIR}/src)
# Tulip hook (hooking) # Tulip hook (hooking)
CPMAddPackage("gh:altalk23/TulipHook#2a97005") CPMAddPackage("gh:altalk23/TulipHook#2347311")
target_link_libraries(${PROJECT_NAME} md4c z TulipHook geode-sdk re2) target_link_libraries(${PROJECT_NAME} md4c z TulipHook geode-sdk re2)

View file

@ -7,14 +7,11 @@
#include <Geode/loader/Mod.hpp> #include <Geode/loader/Mod.hpp>
USE_GEODE_NAMESPACE(); USE_GEODE_NAMESPACE();
using geode::core::meta::x86::Thiscall;
// for some reason RobTop uses MessageBoxW in his GLFW error handler. // for some reason RobTop uses MessageBoxW in his GLFW error handler.
// no one knows how this is possible (he passes char* to wchar_t*). // no one knows how this is possible (he passes char* to wchar_t*).
// so anyway, here's a fix for it // so anyway, here's a fix for it
static auto CCEGLVIEW_CON_ADDR = reinterpret_cast<void*>(base::getCocos() + 0xc2860);
static void __cdecl fixedErrorHandler(int code, char const* description) { static void __cdecl fixedErrorHandler(int code, char const* description) {
log::error("GLFW Error {}: {}", code, description); log::error("GLFW Error {}: {}", code, description);
MessageBoxA( MessageBoxA(
@ -28,23 +25,11 @@ static void __cdecl fixedErrorHandler(int code, char const* description) {
); );
} }
static CCEGLView* CCEGLView_CCEGLView(CCEGLView* self) { $execute {
// you will never have to make a manual hook with Geode again, they said (void)Mod::get()->patch(
// 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), reinterpret_cast<void*>(geode::base::getCocos() + 0x19feec),
toByteArray(&fixedErrorHandler) toByteArray(&fixedErrorHandler)
); );
return self;
}
$execute {
(void)Mod::get()->addHook<tulip::hook::ThiscallConvention>(
CCEGLVIEW_CON_ADDR,
&CCEGLView_CCEGLView,
"CCEGLView::CCEGLView",
);
} }
#endif #endif