h2-mod/src/client/component/patches.cpp

48 lines
883 B
C++
Raw Normal View History

2021-09-06 18:40:37 -04:00
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
2021-04-26 16:34:43 -04:00
#include "game/dvars.hpp"
#include <utils/hook.hpp>
namespace patches
{
namespace
{
2021-09-06 18:40:37 -04:00
void* sub_46148()
{
2021-12-27 22:25:14 -05:00
static uint64_t off_11C52460 = 0xAD0C58_b;
2021-09-06 18:40:37 -04:00
return &off_11C52460;
}
2021-12-27 22:25:14 -05:00
2021-12-28 11:14:47 -05:00
DECLSPEC_NORETURN void quit_stub()
2021-12-27 22:25:14 -05:00
{
component_loader::pre_destroy();
exit(0);
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
2021-12-28 11:14:47 -05:00
// Fix startup crashes
utils::hook::set(0x633080_b, 0xC301B0);
utils::hook::set(0x272F70_b, 0xC301B0);
utils::hook::jump(0x46148_b, sub_46148, true);
2021-09-06 18:40:37 -04:00
2021-12-27 22:25:14 -05:00
utils::hook::jump(0x64EF10_b, quit_stub, true);
// Unlock fps in main menu
utils::hook::set<BYTE>(0x3D8E1B_b, 0xEB);
// Disable battle net popup
utils::hook::nop(0x5F4496_b, 5);
}
};
}
REGISTER_COMPONENT(patches::component)