clean project

This commit is contained in:
quaK 2022-06-01 16:55:00 +03:00
parent 12526fa754
commit f78bb85033
17 changed files with 117 additions and 97 deletions

View File

@ -1,8 +1,10 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "game/game.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
namespace arxan
@ -103,10 +105,10 @@ namespace arxan
const utils::nt::library ntdll("ntdll.dll");
nt_close_hook.create(ntdll.get_proc<void*>("NtClose"), nt_close_stub);
const auto nt_query_information_process = ntdll.get_proc<void*>("NtQueryInformationProcess");
nt_query_information_process_hook.create(nt_query_information_process,
nt_query_information_process_stub);
nt_query_information_process_stub);
nt_query_information_process_hook.move();
AddVectoredExceptionHandler(1, exception_filter);
@ -114,7 +116,7 @@ namespace arxan
void post_unpack() override
{
}
};
}

View File

@ -1,9 +1,9 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "auth.hpp"
//#include "command.hpp"
//#include "network.hpp"
#include "game/game.hpp"
#include "steam/steam.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
@ -11,9 +11,6 @@
#include <utils/info_string.hpp>
#include <utils/cryptography.hpp>
#include "game/game.hpp"
#include "steam/steam.hpp"
namespace auth
{
namespace
@ -37,7 +34,7 @@ namespace auth
return {};
}
return std::string{info.szHwProfileGuid, sizeof(info.szHwProfileGuid)};
return std::string{ info.szHwProfileGuid, sizeof(info.szHwProfileGuid) };
}
std::string get_protected_data()
@ -53,7 +50,7 @@ namespace auth
}
const auto size = std::min(data_out.cbData, 52ul);
std::string result{reinterpret_cast<char*>(data_out.pbData), size};
std::string result{ reinterpret_cast<char*>(data_out.pbData), size };
LocalFree(data_out.pbData);
return result;
@ -98,7 +95,7 @@ namespace auth
public:
void post_unpack() override
{
}
};
}

View File

@ -25,12 +25,21 @@ namespace branding
public:
void post_unpack() override
{
if (game::environment::is_dedi())
{
return;
}
localized_strings::override("LUA_MENU_LEGAL_COPYRIGHT", "IW7-MOD");
localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "IW7-MOD: MULTIPLAYER");
localized_strings::override("LUA_MENU_ALIENS_CAPS", "IW7-MOD: ZOMBIES");
//localized_strings::override("MENU_SP_CAMPAIGN", "IW7-MOD: CAMPAIGN");
//localized_strings::override("LUA_MENU_MULTIPLAYER_CAPS", "IW7-MOD: MULTIPLAYER");
//localized_strings::override("LUA_MENU_ALIENS_CAPS", "IW7-MOD: ZOMBIES");
branding = game::Dvar_RegisterBool("branding", true, game::DvarFlags::DVAR_FLAG_SAVED, "Show branding in the top left corner");
scheduler::once([]()
{
branding = game::Dvar_RegisterBool("branding", true, game::DvarFlags::DVAR_FLAG_SAVED, "Show branding in the top left corner");
}, scheduler::pipeline::renderer);
scheduler::loop([]()
{

View File

@ -1,15 +1,14 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "command.hpp"
#include "console.hpp"
#include "game_console.hpp"
//#include "fastfiles.hpp"
#include "scheduler.hpp"
#include "game/game.hpp"
#include "game/dvars.hpp"
#include "console.hpp"
#include "game_console.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include <utils/memory.hpp>

View File

@ -19,14 +19,16 @@ namespace console
{
bool is_enabled()
{
return game::environment::is_dedi() || !utils::flags::has_flag("noconsole");
static const auto noconsole = utils::flags::has_flag("noconsole");
return game::environment::is_dedi() || !noconsole;
}
namespace native
{
bool is_enabled()
{
return utils::flags::has_flag("nativeconsole");
static const auto nativeconsole = utils::flags::has_flag("nativeconsole");
return nativeconsole;
}
static bool ingame = false;
@ -55,7 +57,7 @@ namespace console
namespace sys
{
//#define COMMAND_HISTORY 64
//#define COMMAND_HISTORY 64
struct WinConData
{
@ -127,32 +129,32 @@ namespace console
if (console::is_enabled() && s_wcd.hwndBuffer)
{
// if the message is REALLY long, use just the last portion of it
if (strlen(pMsg) > ((sizeof(s_wcd.cleanBuffer) / 2) - 1))
if (strlen(pMsg) > ((sizeof(s_wcd.cleanBuffer) / 2) - 1))
{
msg = pMsg + strlen(pMsg) - ((sizeof(s_wcd.cleanBuffer) / 2) + 1);
}
else
else
{
msg = pMsg;
}
// copy into an intermediate buffer
while (msg[i] && ((b - s_wcd.cleanBuffer) < sizeof(s_wcd.cleanBuffer) - 1))
while (msg[i] && ((b - s_wcd.cleanBuffer) < sizeof(s_wcd.cleanBuffer) - 1))
{
if (msg[i] == '\n' && msg[i + 1] == '\r')
if (msg[i] == '\n' && msg[i + 1] == '\r')
{
b[0] = '\r';
b[1] = '\n';
b += 2;
i++;
}
else if (msg[i] == '\r')
else if (msg[i] == '\r')
{
b[0] = '\r';
b[1] = '\n';
b += 2;
}
else if (msg[i] == '\n')
else if (msg[i] == '\n')
{
b[0] = '\r';
b[1] = '\n';
@ -162,7 +164,7 @@ namespace console
//{
// i++;
//}
else
else
{
*b = msg[i];
b++;
@ -174,7 +176,7 @@ namespace console
bufLen = static_cast<unsigned int>(b - s_wcd.cleanBuffer);
s_totalChars += bufLen;
if (s_totalChars <= 0x8000)
if (s_totalChars <= 0x8000)
{
SendMessageA(s_wcd.hwndBuffer, EM_SETSEL, 0xFFFF, 0xFFFF);
}
@ -393,7 +395,7 @@ namespace console
sys::Sys_Print(message.data());
}
}
game_console::print(type, message);
}

View File

@ -1,6 +0,0 @@
#pragma once
namespace demonware
{
}

View File

@ -62,8 +62,8 @@ namespace fastfiles
auto result = db_find_xasset_header_hook.invoke<game::XAssetHeader>(type, name, allow_create_default);
if (!result.data)
{
console::error("Error: Could not find %s \"%s\"\n",
game::g_assetNames[static_cast<unsigned int>(type)],
console::error("Error: Could not find %s \"%s\"\n",
game::g_assetNames[static_cast<unsigned int>(type)],
name);
}
return result;

View File

@ -533,9 +533,9 @@ namespace game_console
con.line_count = 0;
con.display_line_offset = 0;
con.output.access([](output_queue& output)
{
output.clear();
});
{
output.clear();
});
history_index = -1;
history.clear();
@ -662,23 +662,23 @@ namespace game_console
if (key == game::keyNum_t::K_MWHEELUP || key == game::keyNum_t::K_PGUP)
{
con.output.access([](output_queue& output)
{
if (output.size() > con.visible_line_count && con.display_line_offset > 0)
{
if (output.size() > con.visible_line_count && con.display_line_offset > 0)
{
con.display_line_offset--;
}
});
con.display_line_offset--;
}
});
}
else if (key == game::keyNum_t::K_MWHEELDOWN || key == game::keyNum_t::K_PGDN)
{
con.output.access([](output_queue& output)
{
if (output.size() > con.visible_line_count
&& con.display_line_offset < (output.size() - con.visible_line_count))
{
if (output.size() > con.visible_line_count
&& con.display_line_offset < (output.size() - con.visible_line_count))
{
con.display_line_offset++;
}
});
con.display_line_offset++;
}
});
}
if (key == game::keyNum_t::K_ENTER)
@ -749,9 +749,9 @@ namespace game_console
con.line_count = 0;
con.display_line_offset = 0;
con.output.access([](output_queue& output)
{
output.clear();
});
{
output.clear();
});
history_index = -1;
history.clear();
});

View File

@ -91,7 +91,7 @@ namespace game_module
utils::nt::library get_game_module()
{
static utils::nt::library game{HMODULE(game::base_address)};
static utils::nt::library game{ HMODULE(game::base_address) };
return game;
}

View File

@ -1,10 +1,12 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "localized_strings.hpp"
#include "game/game.hpp"
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include <utils/concurrency.hpp>
#include "game/game.hpp"
namespace localized_strings
{

View File

@ -16,6 +16,20 @@ namespace logger
console::info(msg);
}
void print(const char* msg, ...)
{
char buffer[2048]{ 0 };
va_list ap;
va_start(ap, msg);
vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap);
va_end(ap);
console::info(buffer);
}
void sys_print_stubs()
{
utils::hook::call(0xC6E57A_b, sys_print_stub); // SV_SpawnServer: completed\n
@ -24,7 +38,7 @@ namespace logger
utils::hook::call(0xB712BA_b, sys_print_stub); // G_SaveError
}
void R_WarnOncePerFrame_print_stub(char* buffer, size_t buffer_length, char* msg, va_list va)
void r_warn_once_per_frame_print_stub(char* buffer, size_t buffer_length, char* msg, va_list va)
{
vsnprintf(buffer, buffer_length, msg, va);
console::warn(buffer);
@ -38,9 +52,12 @@ namespace logger
{
sys_print_stubs();
// com_printf
utils::hook::jump(0x343080_b, print);
if (!game::environment::is_dedi())
{
utils::hook::call(0xE4B121_b, R_WarnOncePerFrame_print_stub);
utils::hook::call(0xE4B121_b, r_warn_once_per_frame_print_stub);
}
}
};

View File

@ -10,7 +10,7 @@ namespace patches
{
namespace
{
}
class component final : public component_interface
@ -18,7 +18,7 @@ namespace patches
public:
void post_unpack() override
{
}
};
}

View File

@ -1,7 +1,7 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "game/game.hpp"
#include <utils/hook.hpp>
@ -186,8 +186,8 @@ namespace scheduler
void post_unpack() override
{
r_end_frame_hook.create(0xE267B0_b, scheduler::r_end_frame_stub);
g_run_frame_hook.create(0xB8E2D0_b, scheduler::server_frame_stub);
main_frame_hook.create(0xB15E20_b, scheduler::main_frame_stub);
g_run_frame_hook.create(0xB15E20_b, scheduler::server_frame_stub);
main_frame_hook.create(0xB8E2D0_b, scheduler::main_frame_stub);
}
void pre_destroy() override

View File

@ -16,9 +16,6 @@ namespace scheduler
// The game's main thread
main,
// LUI context
lui,
count,
};

View File

@ -1,6 +1,9 @@
#include <std_include.hpp>
#include "loader/component_loader.hpp"
#include "steam_proxy.hpp"
#include "game/game.hpp"
#include "scheduler.hpp"
#include <utils/nt.hpp>
@ -8,8 +11,6 @@
#include <utils/string.hpp>
#include <utils/binary_resource.hpp>
#include "game/game.hpp"
#include "steam/interface.hpp"
#include "steam/steam.hpp"
@ -132,7 +133,7 @@ namespace steam_proxy
this->client_utils_.invoke<void>("SetAppIDForCurrentPipe", app_id, false);
char our_directory[MAX_PATH] = {0};
char our_directory[MAX_PATH] = { 0 };
GetCurrentDirectoryA(sizeof(our_directory), our_directory);
const auto path = runner_file.get_extracted_file();
@ -152,29 +153,29 @@ namespace steam_proxy
void clean_up_on_error()
{
scheduler::schedule([this]()
{
if (this->steam_client_module_
&& this->steam_pipe_
&& this->global_user_
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
this->steam_pipe_)
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
)
{
if (this->steam_client_module_
&& this->steam_pipe_
&& this->global_user_
&& this->steam_client_module_.invoke<bool>("Steam_BConnected", this->global_user_,
this->steam_pipe_)
&& this->steam_client_module_.invoke<bool>("Steam_BLoggedOn", this->global_user_, this->steam_pipe_)
)
{
return scheduler::cond_continue;
}
return scheduler::cond_continue;
}
this->client_engine_ = nullptr;
this->client_user_ = nullptr;
this->client_utils_ = nullptr;
this->client_engine_ = nullptr;
this->client_user_ = nullptr;
this->client_utils_ = nullptr;
this->steam_pipe_ = nullptr;
this->global_user_ = nullptr;
this->steam_pipe_ = nullptr;
this->global_user_ = nullptr;
this->steam_client_module_ = utils::nt::library{nullptr};
this->steam_client_module_ = utils::nt::library{ nullptr };
return scheduler::cond_end;
});
return scheduler::cond_end;
});
}
};

View File

@ -31,7 +31,7 @@ namespace game
float max, unsigned int flags, const char* description)> Dvar_RegisterFloat{ 0xCEB890 };
WEAK symbol<dvar_t* (const char* name, const char* value,
unsigned int flags, const char* description)> Dvar_RegisterString{ 0xCEBD50 };
WEAK symbol<dvar_t* (const char* name, float x, float y,
WEAK symbol<dvar_t* (const char* name, float x, float y,
float min, float max, unsigned int flags, const char* description)> Dvar_RegisterVec2{ 0xCEBF50 };
WEAK symbol<dvar_t* (const char* name, float x, float y, float z,
float min, float max, unsigned int flags, const char* description)> Dvar_RegisterVec3{ 0xCEBFE0 };

View File

@ -51,12 +51,12 @@ FARPROC load_binary(uint64_t* base_address)
"Failed to read game binary (%s)!\nPlease copy the iw7-mod.exe into your Call of Duty: Infinite Warfare installation folder and run it from there.",
binary.data()));
}
#ifdef INJECT_HOST_AS_LIB
return loader.load_library(binary, base_address);
#else
*base_address = 0x140000000;
return loader.load(self, data); // this gives memory errors
return loader.load(self, data); // not working
#endif
}
@ -67,10 +67,10 @@ void remove_crash_file()
void enable_dpi_awareness()
{
const utils::nt::library user32{"user32.dll"};
const utils::nt::library user32{ "user32.dll" };
const auto set_dpi = user32
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>("SetProcessDpiAwarenessContext")
: nullptr;
? user32.get_proc<BOOL(WINAPI*)(DPI_AWARENESS_CONTEXT)>("SetProcessDpiAwarenessContext")
: nullptr;
if (set_dpi)
{
set_dpi(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);