Update readme and rename config java

This commit is contained in:
2025-05-29 16:31:55 +08:00
parent d7de3deb59
commit 647e3668a0
28 changed files with 562 additions and 13162 deletions

View File

@@ -3,7 +3,12 @@
#ifndef B8D59B54_1674_4C0F_AA2C_611385FF5D03
#define B8D59B54_1674_4C0F_AA2C_611385FF5D03
#if RE_DBG_INJECTED
#include "dbg_mem.h"
#else
#include "static_mem.h"
#endif
#include "base.h"
#include <gh_types.h>
@@ -108,6 +113,6 @@ inline longlong r3_ftol(float a) { return (longlong)a; }
constexpr byte R3ModId_not_initialized = 0xff;
#include "stubexcept.h"
#include "stub.h"
#endif /* B8D59B54_1674_4C0F_AA2C_611385FF5D03 */

View File

@@ -0,0 +1,4 @@
#include "r3/config/static.hpp"
void gh_init_dbg_loader() {
}

View File

@@ -0,0 +1,15 @@
#ifndef BD364AE6_AD96_4DEA_9D6B_B237BC1E2C6A
#define BD364AE6_AD96_4DEA_9D6B_B237BC1E2C6A
#include <gh_datasegment.h>
template <size_t addr> inline constexpr void checkMappedMemory() {
static_assert(addr >= GH_DATA_START, "Address outside lower bound");
static_assert(addr < GH_DATA_END, "Address outside upper bound");
}
void gh_init_dbg_loader();
#define GH_MEM(addr) (checkMappedMemory<addr>(), *memoryMapSafe(addr))
#endif /* BD364AE6_AD96_4DEA_9D6B_B237BC1E2C6A */

View File

@@ -4,7 +4,11 @@
#define EDBE48FC_B879_4985_9274_B7ACF24AD024
#include "base.h"
#if RE_DBG_INJECTED
#include "dbg_mem.h"
#else
#include "static_mem.h"
#endif
#include <gh_types.h>
#endif /* EDBE48FC_B879_4985_9274_B7ACF24AD024 */

View File

@@ -0,0 +1,5 @@
#include <spdlog/spdlog.h>
GHStubException::GHStubException(const char *msg) : std::exception(msg) {
SPDLOG_ERROR("{}", msg);
}

34
game_re/r3/binders/stub.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef AE625BF8_B0F9_452E_8772_8819F311CB57
#define AE625BF8_B0F9_452E_8772_8819F311CB57
#include <stdexcept>
struct GHStubException : public std::exception {
GHStubException(const char *msg);
};
void *gh_stub_impl_ptr(void *ptr);
template <typename T, typename... Args>
T gh_stub_impl_cdecl(void *ptr, Args... args) {
#if RE_DBG_INJECTED
using Callable = __cdecl T (*)(Args...);
static Callable *ptr = (Callable *)gh_stub_impl_ptr(ptr);
return ptr(args...);
#else
throw GHStubException("Function not implemented");
#endif
}
template <typename T, typename... Args>
T gh_stub_impl_stdcall(void *ptr, Args... args) {
#if RE_DBG_INJECTED
using Callable = __stdcall T (*)(Args...);
static Callable *ptr = (Callable *)gh_stub_impl_ptr(ptr);
return ptr(args...);
#else
throw GHStubException("Function not implemented");
#endif
}
#endif /* AE625BF8_B0F9_452E_8772_8819F311CB57 */

View File

@@ -1,10 +0,0 @@
#ifndef AE625BF8_B0F9_452E_8772_8819F311CB57
#define AE625BF8_B0F9_452E_8772_8819F311CB57
#include <stdexcept>
struct GHStubException : public std::exception {
GHStubException(const char *msg);
};
#endif /* AE625BF8_B0F9_452E_8772_8819F311CB57 */

View File

@@ -2,22 +2,27 @@
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <stdio.h>
#include <r3/binders/stub.h>
#if RE_DBG_INJECTED
#include <r3/binders/dbg_mem.h>
#else
#include <r3/binders/static_mem.h>
#include <r3/binders/stubexcept.h>
#endif
// Error reporting and such
extern "C" void r3_noop(void*, void*) {}
extern "C" void r3_noop(void *, void *) {}
extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR *cmdline, int showCmd);
GHStubException::GHStubException(const char *msg) : std::exception(msg) {
SPDLOG_ERROR("{}", msg);
}
int main(int argc, char **argv) {
try {
#if RE_DBG_INJECTED
gh_init_dbg_loader();
#else
gh_init_data_segment();
#endif
r3_main(GetModuleHandle(NULL), NULL, argv, SW_SHOW);
} catch (const std::exception &e) {