windows 64 bit changes (apart for links and all)

This commit is contained in:
altalk23 2024-05-26 14:32:36 +03:00
parent a4c6b71ee4
commit 01020ccbd4
9 changed files with 98 additions and 11 deletions

View file

@ -243,7 +243,7 @@ if (DEFINED GEODE_TULIPHOOK_REPO_PATH)
message(STATUS "Using ${GEODE_TULIPHOOK_REPO_PATH} for TulipHook")
add_subdirectory(${GEODE_TULIPHOOK_REPO_PATH} ${GEODE_TULIPHOOK_REPO_PATH}/build)
else()
CPMAddPackage("gh:geode-sdk/TulipHook#58dc814")
CPMAddPackage("gh:geode-sdk/TulipHook#40d632d")
endif()
set(CMAKE_WARN_DEPRECATED ON CACHE BOOL "" FORCE)

View file

@ -9,16 +9,27 @@
// Set dllexport/dllimport to geode classes & functions
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) && !defined(__CYGWIN__)
#define GEODE_WINDOWS(...) __VA_ARGS__
#define GEODE_IS_WINDOWS
#define GEODE_IS_DESKTOP
#define GEODE_PLATFORM_NAME "Windows"
#define GEODE_CALL __stdcall
#define GEODE_CDECL_CALL __cdecl
#define GEODE_PLATFORM_EXTENSION ".dll"
#define GEODE_PLATFORM_SHORT_IDENTIFIER "win"
#define CC_TARGET_OS_WIN32
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#if defined(WIN64) || defined(_WIN64) || defined(__WIN64) && !defined(__CYGWIN__)
#define GEODE_IS_WINDOWS64
#define GEODE_WINDOWS64(...) __VA_ARGS__
#define GEODE_WINDOWS32(...)
#else
#define GEODE_IS_WINDOWS32
#define GEODE_WINDOWS32(...) __VA_ARGS__
#define GEODE_WINDOWS64(...)
#endif
#endif
#else
#define GEODE_WINDOWS(...)
#endif
@ -45,7 +56,6 @@
#define CC_TARGET_OS_MAC
#endif
#define GEODE_CALL
#define GEODE_CDECL_CALL
#else
#define GEODE_MACOS(...)
#define GEODE_IOS(...)
@ -57,7 +67,6 @@
#define GEODE_IS_ANDROID
#define GEODE_IS_MOBILE
#define GEODE_CALL
#define GEODE_CDECL_CALL
#define CC_TARGET_OS_ANDROID
#if defined(__arm__)

View file

@ -27,7 +27,13 @@
#define GEODE_API extern "C" __declspec(dllexport)
#define GEODE_EXPORT __declspec(dllexport)
static_assert(sizeof(void*) == 4, "Geode must be compiled in 32-bit for Windows!");
#if defined(GEODE_IS_WINDOWS64)
#define GEODE_IS_X64
#define GEODE_CDECL_CALL
#else
#define GEODE_IS_X86
#define GEODE_CDECL_CALL __cdecl
#endif
#include "windows.hpp"
@ -47,6 +53,9 @@
#define GEODE_API extern "C" __attribute__((visibility("default")))
#define GEODE_EXPORT __attribute__((visibility("default")))
#define GEODE_IS_X64
#define GEODE_CDECL_CALL
#include "macos.hpp"
#elif defined(GEODE_IS_IOS)
@ -65,6 +74,9 @@
#define GEODE_API extern "C" __attribute__((visibility("default")))
#define GEODE_EXPORT __attribute__((visibility("default")))
#define GEODE_IS_X64
#define GEODE_CDECL_CALL
#include "ios.hpp"
#elif defined(GEODE_IS_ANDROID)
@ -83,6 +95,13 @@
#define GEODE_API extern "C" __attribute__((visibility("default")))
#define GEODE_EXPORT __attribute__((visibility("default")))
#if defined(GEODE_IS_ANDROID64)
#define GEODE_IS_X64
#else
#define GEODE_IS_X86
#endif
#define GEODE_CDECL_CALL
#include "android.hpp"
#else

View file

@ -383,7 +383,7 @@ int ZipUtils::ccInflateCCZFile(char const* path, unsigned char** out) {
}
unsigned long destlen = len;
unsigned long source = (unsigned long)compressed + sizeof(*header);
uintptr_t source = (uintptr_t)compressed + sizeof(*header);
int ret = uncompress(*out, &destlen, (Bytef*)source, fileLen - sizeof(*header));
delete[] compressed;

View file

@ -28,14 +28,14 @@ $execute {
reinterpret_cast<void*>(geode::addresser::getNonVirtual(&FMOD::System::init)),
&FMOD_System_init_hook,
"FMOD::System::init"
GEODE_WINDOWS(, tulip::hook::TulipConvention::Stdcall)
GEODE_WINDOWS32(, tulip::hook::TulipConvention::Stdcall)
);
(void)geode::Mod::get()->hook(
reinterpret_cast<void*>(geode::addresser::getNonVirtual(&FMOD::ChannelControl::setVolume)),
&FMOD_ChannelControl_setVolume_hook,
"FMOD::ChannelControl::setVolume"
GEODE_WINDOWS(, tulip::hook::TulipConvention::Stdcall)
GEODE_WINDOWS32(, tulip::hook::TulipConvention::Stdcall)
);
}

View file

@ -38,6 +38,7 @@ $execute {
// geode::base::getCocos() + 0x1225DC = MessageBoxW in .idata
if (LoaderImpl::get()->isForwardCompatMode()) return;
#if GEODE_COMP_GD_VERSION == 22040
const uint32_t importedMessageBoxA = geode::base::getCocos() + 0x122600;
ByteVector p = {
@ -48,6 +49,9 @@ $execute {
(void)Mod::get()->patch(reinterpret_cast<void*>(geode::base::getCocos() + 0xC75F9), p);
(void)Mod::get()->patch(reinterpret_cast<void*>(geode::base::getCocos() + 0xc7651), p);
#else
#pragma message("Unsupported GD version!")
#endif
}
#endif

View file

@ -38,11 +38,15 @@ $execute {
if (LoaderImpl::get()->isForwardCompatMode()) return;
// BitmapDC::~BitmapDC
#if GEODE_COMP_GD_VERSION == 22040
patchCall(0xC9A56, (uintptr_t)&RemoveFontResourceWHook);
// BitmapDC::setFont
patchCall(0xCB5BC, (uintptr_t)&RemoveFontResourceWHook);
patchCall(0xCB642, (uintptr_t)&AddFontResourceWHook);
#else
#pragma message("Unsupported GD version!")
#endif
};
#endif

View file

@ -151,11 +151,18 @@ static std::string getStacktrace(PCONTEXT context) {
auto process = GetCurrentProcess();
auto thread = GetCurrentThread();
#ifdef GEODE_IS_X86
stack.AddrPC.Offset = context->Eip;
stack.AddrPC.Mode = AddrModeFlat;
stack.AddrStack.Offset = context->Esp;
stack.AddrStack.Mode = AddrModeFlat;
stack.AddrFrame.Offset = context->Ebp;
#else
stack.AddrPC.Offset = context->Rip;
stack.AddrStack.Offset = context->Rsp;
stack.AddrFrame.Offset = context->Rbp;
#endif
stack.AddrPC.Mode = AddrModeFlat;
stack.AddrStack.Mode = AddrModeFlat;
stack.AddrFrame.Mode = AddrModeFlat;
// size_t frame = 0;
@ -174,6 +181,7 @@ static std::string getStacktrace(PCONTEXT context) {
}
static std::string getRegisters(PCONTEXT context) {
#ifdef GEODE_IS_X86
return fmt::format(
"EAX: {:08x}\n"
"EBX: {:08x}\n"
@ -194,6 +202,44 @@ static std::string getRegisters(PCONTEXT context) {
context->Esi,
context->Eip
);
#else
return fmt::format(
"RAX: {:016x}\n"
"RBX: {:016x}\n"
"RCX: {:016x}\n"
"RDX: {:016x}\n"
"RBP: {:016x}\n"
"RSP: {:016x}\n"
"RDI: {:016x}\n"
"RSI: {:016x}\n"
"RIP: {:016x}\n"
"R8: {:016x}\n"
"R9: {:016x}\n"
"R10: {:016x}\n"
"R11: {:016x}\n"
"R12: {:016x}\n"
"R13: {:016x}\n"
"R14: {:016x}\n"
"R15: {:016x}\n",
context->Rax,
context->Rbx,
context->Rcx,
context->Rdx,
context->Rbp,
context->Rsp,
context->Rdi,
context->Rsi,
context->Rip,
context->R8,
context->R9,
context->R10,
context->R11,
context->R12,
context->R13,
context->R14,
context->R15
);
#endif
}
template <typename T, typename U>

View file

@ -65,6 +65,8 @@ std::string loadGeode() {
gdTimestamp = ntHeader->FileHeader.TimeDateStamp;
#ifdef GEODE_IS_WINDOWS32
constexpr size_t trampolineSize = 12;
mainTrampolineAddr = VirtualAlloc(
nullptr, trampolineSize,
@ -128,6 +130,9 @@ std::string loadGeode() {
return "Geode could not hook the main function, not loading Geode.";
std::memcpy(reinterpret_cast<void*>(patchAddr), patchBytes, patchSize);
VirtualProtectEx(process, reinterpret_cast<void*>(patchAddr), patchSize, oldProtect, &oldProtect);
#else
#pragma message("64-bit entry is not implemented yet.")
#endif
return "";
}