#include #include #include #include #include #if RE_DBG_INJECTED #include 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 #endif #include #include 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(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; }