From 0df5ac4b60a15836e53b74a290d686402fce6577 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Fri, 10 Jun 2022 02:19:23 +0200 Subject: [PATCH] Some changes --- src/component/exception.cpp | 10 +++++--- src/component/gsc.cpp | 4 +++ src/component/scripting.cpp | 50 ------------------------------------- src/game/game.cpp | 4 +-- 4 files changed, 12 insertions(+), 56 deletions(-) diff --git a/src/component/exception.cpp b/src/component/exception.cpp index 353babb..c15c277 100644 --- a/src/component/exception.cpp +++ b/src/component/exception.cpp @@ -42,7 +42,7 @@ namespace exception utils::thread::suspend_other_threads(); show_mouse_cursor(); - MessageBoxA(nullptr, error_str.data(), "Plutonium T6 ERROR", MB_ICONERROR); + MessageBoxA(nullptr, error_str.data(), "Plutonium T5 ERROR", MB_ICONERROR); TerminateProcess(GetCurrentProcess(), exception_data.code); } @@ -72,7 +72,7 @@ namespace exception info.append("\r\n"); }; - line("Plutonium T6 Crash Dump"); + line("Plutonium T5 Crash Dump"); line(""); line("Timestamp: "s + utils::string::get_timestamp()); line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode)); @@ -93,13 +93,13 @@ namespace exception void write_minidump(const LPEXCEPTION_POINTERS exceptioninfo) { - const std::string crash_name = utils::string::va("minidumps/plutonium-t6-crash-%s.zip", + const std::string crash_name = utils::string::va("minidumps/plutonium-t5-crash-%s.zip", utils::string::get_timestamp().data()); utils::compression::zip::archive zip_file{}; zip_file.add("crash.dmp", create_minidump(exceptioninfo)); zip_file.add("info.txt", generate_crash_info(exceptioninfo)); - zip_file.write(crash_name, "Plutonium T6 Crash Dump"); + zip_file.write(crash_name, "Plutonium T5 Crash Dump"); } bool is_harmless_error(const LPEXCEPTION_POINTERS exceptioninfo) @@ -136,8 +136,10 @@ namespace exception public: void post_unpack() override { +#ifdef DEBUG SetUnhandledExceptionFilter(exception_filter); utils::hook::jump(reinterpret_cast(&SetUnhandledExceptionFilter), set_unhandled_exception_filter_stub); +#endif } }; } diff --git a/src/component/gsc.cpp b/src/component/gsc.cpp index 2b5955a..0b00b2f 100644 --- a/src/component/gsc.cpp +++ b/src/component/gsc.cpp @@ -210,6 +210,10 @@ namespace gsc get_function_hook.create(SELECT_VALUE(0x0, 0x465E20), get_function_stub); get_method_hook.create(SELECT_VALUE(0x0, 0x555580), get_method_stub); + // \n******* script runtime error *******\n%s\n + utils::hook::set(0xAABA68 + 40, '\n'); + utils::hook::set(0xAABA68 + 41, '\0'); + function::add("print_", [](const scripting::variadic_args& va) { for (const auto& arg : va) diff --git a/src/component/scripting.cpp b/src/component/scripting.cpp index 1050a5b..565dc26 100644 --- a/src/component/scripting.cpp +++ b/src/component/scripting.cpp @@ -14,55 +14,10 @@ namespace scripting { - std::unordered_map> fields_table; - - std::unordered_map method_map; - std::unordered_map function_map; - - std::unordered_map> script_function_table; - std::unordered_map>> script_function_table_sort; - std::unordered_map> script_function_table_rev; - namespace { - utils::hook::detour scr_add_class_field_hook; utils::hook::detour g_shutdown_game_hook; - void scr_add_class_field_stub(game::scriptInstance_t inst, unsigned int classnum, char const* name, unsigned int offset) - { - if (fields_table[classnum].find(name) == fields_table[classnum].end()) - { - fields_table[classnum][name] = offset; - } - - scr_add_class_field_hook.invoke(inst, classnum, name, offset); - } - - game::BuiltinMethodDef get_method(const std::string& name) - { - game::BuiltinMethodDef method{}; - - auto pName = name.data(); - int arg = 0; - - const auto func = game::Scr_GetMethod(&pName, &arg, &arg, &arg); - - if (func) - { - method.actionFunc = reinterpret_cast(func); - method.actionString = pName; - } - - return method; - } - - void load_functions() - { - - } - - utils::hook::detour scr_load_script_hook; - std::vector> shutdown_callbacks; void g_shutdown_game_stub(const int free_scripts) { @@ -86,11 +41,6 @@ namespace scripting void post_unpack() override { //g_shutdown_game_hook.create(SELECT(0x60DCF0, 0x688A40), g_shutdown_game_stub); - - //scr_add_class_field_hook.create(SELECT(0x6B7620, 0x438AD0), scr_add_class_field_stub); - //scr_post_load_scripts_hook.create(SELECT(0x642EB0, 0x425F80), post_load_scripts_stub); - - //load_functions(); } }; } diff --git a/src/game/game.cpp b/src/game/game.cpp index 5e6d19a..39a033a 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -39,7 +39,7 @@ namespace game return utils::hook::invoke(func, inst); } - VariableValue Scr_GetArrayIndexValue(scriptInstance_t inst, unsigned int name) + VariableValue Scr_GetArrayIndexValue(scriptInstance_t, unsigned int name) { VariableValue value{}; @@ -65,7 +65,7 @@ namespace game return value; } - unsigned int Scr_GetSelf(scriptInstance_t inst, unsigned int threadId) + unsigned int Scr_GetSelf(scriptInstance_t, unsigned int threadId) { return game::scr_VarGlob->variableList[threadId + 1].u.o.u.self; }