Some fixes

This commit is contained in:
Federico Cecchetto 2021-09-08 01:21:20 +02:00
parent 6282e439be
commit 07974ec88a
3 changed files with 32 additions and 19 deletions

View File

@ -1,31 +1,20 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "command.hpp"
#include "game_console.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include <utils/thread.hpp>
#include <utils/hook.hpp>
namespace console
{
namespace
{
DWORD WINAPI console(LPVOID)
{
ShowWindow(GetConsoleWindow(), SW_SHOW);
std::string cmd;
while (true)
{
std::getline(std::cin, cmd);
game_console::execute(cmd.data());
}
return 0;
}
std::thread console_thread;
}
class component final : public component_interface
@ -33,7 +22,18 @@ namespace console
public:
void post_unpack() override
{
CreateThread(0, 0, console, 0, 0, 0);
ShowWindow(GetConsoleWindow(), SW_SHOW);
SetConsoleTitle("H2-Mod");
console_thread = utils::thread::create_named_thread("Console", []()
{
std::string cmd;
while (true)
{
std::getline(std::cin, cmd);
command::execute(cmd.data(), false);
}
});
}
};
}

View File

@ -85,7 +85,7 @@ namespace exception
{
std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p.\n"
"A minidump has been written.\n\n",
exception_data.code, (uint64_t)exception_data.address - game::base_address);
exception_data.code, exception_data.address);
error_str += "Make sure to update your graphics card drivers and install operating system updates!";
@ -157,7 +157,7 @@ namespace exception
line("Environment: "s + game::environment::get_string());
line("Timestamp: "s + get_timestamp());
line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode));
line(utils::string::va("Address: 0x%llX", (uint64_t)exceptioninfo->ExceptionRecord->ExceptionAddress - game::base_address));
line(utils::string::va("Address: 0x%llX", exceptioninfo->ExceptionRecord->ExceptionAddress));
line(utils::string::va("Base: 0x%llX", game::base_address));
#pragma warning(push)

View File

@ -4,6 +4,7 @@
#include "scheduler.hpp"
#include "game/game.hpp"
#include <utils/thread.hpp>
#include <utils/hook.hpp>
#include <utils/concurrency.hpp>
@ -163,9 +164,9 @@ namespace scheduler
class component final : public component_interface
{
public:
void post_unpack() override
void post_start() override
{
thread = std::thread([]()
thread = utils::thread::create_named_thread("Async Scheduler", []()
{
while (!kill)
{
@ -173,11 +174,23 @@ namespace scheduler
std::this_thread::sleep_for(10ms);
}
});
}
void post_unpack() override
{
r_end_frame_hook.create(game::base_address + 0x76D7B0, scheduler::r_end_frame_stub);
g_run_frame_hook.create(game::base_address + 0x4CB030, scheduler::server_frame_stub);
main_frame_hook.create(game::base_address + 0x417FA0, scheduler::main_frame_stub);
}
void pre_destroy() override
{
kill = true;
if (thread.joinable())
{
thread.join();
}
}
};
}