53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
#include <windows.h>
|
|
#include <spdlog/spdlog.h>
|
|
#include <stdexcept>
|
|
#include <stdio.h>
|
|
#include <r3/binders/stub.h>
|
|
|
|
#if RE_DBG_INJECTED
|
|
#include <r3/binders/dbg_mem.h>
|
|
extern "C" {
|
|
// This is the part of Rayman3.exe main CRT setup that runs before main, but
|
|
// doesn't call it
|
|
void gh_pre_main(void);
|
|
}
|
|
#else
|
|
#include <r3/binders/static_mem.h>
|
|
#endif
|
|
|
|
#include <CLI11.hpp>
|
|
#include <magic_enum/magic_enum.hpp>
|
|
|
|
extern "C" int r3_main(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|
LPSTR *cmdline, int showCmd);
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
CLI::App app("Reman 3: The hooded ones");
|
|
std::string log_level = "info";
|
|
app.add_option("-l,--log-level", log_level, "Log level");
|
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
auto log_level_enum = magic_enum::enum_cast<spdlog::level::level_enum>(log_level);
|
|
if (log_level_enum.has_value()) {
|
|
spdlog::set_level(log_level_enum.value());
|
|
} else {
|
|
SPDLOG_ERROR("Invalid log level: {}", log_level);
|
|
return 1;
|
|
}
|
|
|
|
try {
|
|
#if RE_DBG_INJECTED
|
|
gh_init_dbg_loader();
|
|
gh_pre_main();
|
|
#else
|
|
gh_init_data_segment();
|
|
#endif
|
|
|
|
r3_main(GetModuleHandle(NULL), NULL, argv, SW_SHOW);
|
|
} catch (const std::exception &e) {
|
|
SPDLOG_ERROR("Unhandled exception: {}", e.what());
|
|
}
|
|
return 0;
|
|
} |