Update readme and rename config java
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
function(setup_target TARGET)
|
||||
function(setup_target TARGET DBG_MODE)
|
||||
add_executable(${TARGET}
|
||||
r3/main.cpp
|
||||
r3/binders/static_mem.cxx
|
||||
r3/main.cxx
|
||||
gh_global.cxx
|
||||
)
|
||||
|
||||
@@ -63,9 +62,18 @@ function(setup_target TARGET)
|
||||
target_precompile_headers(${TARGET} PRIVATE
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/r3/binders/auto_pch.cxx>"
|
||||
)
|
||||
|
||||
if(DBG_MODE)
|
||||
target_sources(${TARGET} PRIVATE
|
||||
r3/binders/dbg_mem.cxx
|
||||
)
|
||||
target_compile_definitions(game_dbg PRIVATE RE_DBG_INJECTED=1)
|
||||
else()
|
||||
target_sources(${TARGET} PRIVATE
|
||||
r3/binders/static_mem.cxx
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
setup_target(game_re)
|
||||
|
||||
setup_target(game_dbg)
|
||||
target_compile_definitions(game_dbg PRIVATE RE_DBG_INJECTED=1)
|
||||
setup_target(game_re OFF)
|
||||
setup_target(game_dbg ON)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1759
game_re/gh_global.h
1759
game_re/gh_global.h
File diff suppressed because it is too large
Load Diff
9458
game_re/gh_types.h
9458
game_re/gh_types.h
File diff suppressed because it is too large
Load Diff
@@ -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 */
|
||||
|
||||
4
game_re/r3/binders/dbg_mem.cxx
Normal file
4
game_re/r3/binders/dbg_mem.cxx
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "r3/config/static.hpp"
|
||||
|
||||
void gh_init_dbg_loader() {
|
||||
}
|
||||
15
game_re/r3/binders/dbg_mem.h
Normal file
15
game_re/r3/binders/dbg_mem.h
Normal 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 */
|
||||
@@ -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 */
|
||||
|
||||
5
game_re/r3/binders/stub.cxx
Normal file
5
game_re/r3/binders/stub.cxx
Normal 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
34
game_re/r3/binders/stub.h
Normal 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 */
|
||||
@@ -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 */
|
||||
@@ -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) {
|
||||
Reference in New Issue
Block a user