game launching errors [skip ci]

This commit is contained in:
Skull Merlin 2022-03-18 03:28:44 +02:00
parent c05aea9bd9
commit 3d32770ed7
4 changed files with 5 additions and 155 deletions

View File

@ -153,6 +153,7 @@ namespace arxan
utils::hook::nop(0x81F0C0_b, 6); utils::hook::nop(0x81F0C0_b, 6);
utils::hook::nop(0x5813609_b, 6); utils::hook::nop(0x5813609_b, 6);
utils::hook::nop(0x8DD678_b, 0xEB); utils::hook::nop(0x8DD678_b, 0xEB);
//utils::hook::nop(0xB3D96_b, 4);
} }
}; };
} }

View File

@ -3,6 +3,7 @@
#include "game_module.hpp" #include "game_module.hpp"
#include <utils/hook.hpp> #include <utils/hook.hpp>
#include <game/game.hpp>
namespace game_module namespace game_module
{ {
@ -90,7 +91,7 @@ namespace game_module
utils::nt::library get_game_module() utils::nt::library get_game_module()
{ {
static utils::nt::library game{HMODULE(0x140000000)}; static utils::nt::library game{HMODULE(game::base_address)};
return game; return game;
} }

View File

@ -1,141 +0,0 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "game/game.hpp"
#include "game_module.hpp"
#include <utils/nt.hpp>
#include <utils/hook.hpp>
namespace splash
{
class component final : public component_interface
{
public:
void post_start() override
{
const utils::nt::library self;
image_ = LoadImageA(self, MAKEINTRESOURCE(IMAGE_SPLASH), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
}
void post_load() override
{
if (game::environment::is_dedi())
{
return;
}
this->show();
}
void post_unpack() override
{
// Disable native splash screen
//utils::hook::nop(SELECT_VALUE(0x1403E192E, 0x1405123E2), 5); // winmain doesn't even exist in 1.15? lmao
utils::hook::jump(SELECT_VALUE(0, 0x5BE1D0_b), destroy_stub); // H1-STEAM(1.15)
utils::hook::jump(SELECT_VALUE(0, 0x5BE210_b), destroy_stub); // H1-STEAM(1.15)
}
void pre_destroy() override
{
this->destroy();
MSG msg;
while (this->window_ && IsWindow(this->window_))
{
if (PeekMessageA(&msg, nullptr, NULL, NULL, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
std::this_thread::sleep_for(1ms);
}
}
this->window_ = nullptr;
}
private:
HWND window_{};
HANDLE image_{};
static void destroy_stub()
{
component_loader::get<component>()->destroy();
}
void destroy() const
{
if (this->window_ && IsWindow(this->window_))
{
ShowWindow(this->window_, SW_HIDE);
DestroyWindow(this->window_);
UnregisterClassA("H1 Splash Screen", utils::nt::library{});
}
}
void show()
{
WNDCLASSA wnd_class;
const auto self = game_module::get_host_module();
wnd_class.style = CS_DROPSHADOW;
wnd_class.cbClsExtra = 0;
wnd_class.cbWndExtra = 0;
wnd_class.lpszMenuName = nullptr;
wnd_class.lpfnWndProc = DefWindowProcA;
wnd_class.hInstance = self;
wnd_class.hIcon = LoadIconA(self, reinterpret_cast<LPCSTR>(102));
wnd_class.hCursor = LoadCursorA(nullptr, IDC_APPSTARTING);
wnd_class.hbrBackground = reinterpret_cast<HBRUSH>(6);
wnd_class.lpszClassName = "H1 Splash Screen";
if (RegisterClassA(&wnd_class))
{
const auto x_pixels = GetSystemMetrics(SM_CXFULLSCREEN);
const auto y_pixels = GetSystemMetrics(SM_CYFULLSCREEN);
if (image_)
{
this->window_ = CreateWindowExA(WS_EX_APPWINDOW, "H1 Splash Screen", "H1",
WS_POPUP | WS_SYSMENU,
(x_pixels - 320) / 2, (y_pixels - 100) / 2, 320, 100, nullptr,
nullptr,
self, nullptr);
if (this->window_)
{
auto* const image_window = CreateWindowExA(0, "Static", nullptr, WS_CHILD | WS_VISIBLE | 0xEu,
0, 0,
320, 100, this->window_, nullptr, self, nullptr);
if (image_window)
{
RECT rect;
SendMessageA(image_window, 0x172u, 0, reinterpret_cast<LPARAM>(image_));
GetWindowRect(image_window, &rect);
const int width = rect.right - rect.left;
rect.left = (x_pixels - width) / 2;
const int height = rect.bottom - rect.top;
rect.top = (y_pixels - height) / 2;
rect.right = rect.left + width;
rect.bottom = rect.top + height;
AdjustWindowRect(&rect, WS_CHILD | WS_VISIBLE | 0xEu, 0);
SetWindowPos(this->window_, nullptr, rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top, SWP_NOZORDER);
ShowWindow(this->window_, SW_SHOW);
UpdateWindow(this->window_);
}
}
}
}
}
};
}
REGISTER_COMPONENT(splash::component)

View File

@ -51,27 +51,18 @@ namespace system_check
{ {
static std::unordered_map<std::string, std::string> mp_zone_hashes = static std::unordered_map<std::string, std::string> mp_zone_hashes =
{ {
{"patch_common_mp.ff", "3F44B0CFB0B8E0FBD9687C2942204AB7F11E66E6E15C73B8B4A5EB5920115A31"}, {"patch_common_mp.ff", "E45EF5F29D12A5A47F405F89FBBEE479C0A90D02141ABF852D481689514134A1"},
}; };
static std::unordered_map<std::string, std::string> sp_zone_hashes = static std::unordered_map<std::string, std::string> sp_zone_hashes =
{ {
// Steam doesn't necessarily deliver this file :( // Steam doesn't necessarily deliver this file :(
{"patch_common.ff", "BB0617DD94AF2F511571E7184BBEDE76E64D97E5D0DAFDB457F00717F035EBF0"}, {"patch_common.ff", "1D32A9770F90ED022AA76F4859B4AB178E194A703383E61AC2CE83B1E828B18F"},
}; };
return verify_hashes(mp_zone_hashes) && (game::environment::is_dedi() || verify_hashes(sp_zone_hashes)); return verify_hashes(mp_zone_hashes) && (game::environment::is_dedi() || verify_hashes(sp_zone_hashes));
} }
void verify_binary_version()
{
const auto value = *reinterpret_cast<DWORD*>(0x140001337);
if (value != 0xFFB8006D && value != 0xFFB80080)
{
throw std::runtime_error("Unsupported Call of Duty: Modern Warfare Remastered version(1.4)");
}
}
} }
bool is_valid() bool is_valid()
@ -85,8 +76,6 @@ namespace system_check
public: public:
void post_load() override void post_load() override
{ {
verify_binary_version();
if (!is_valid()) if (!is_valid())
{ {
MessageBoxA(nullptr, "Your game files are outdated or unsupported.\n" MessageBoxA(nullptr, "Your game files are outdated or unsupported.\n"