From c039d03a1559f7b03f3a39dfad0c9b3932d23384 Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Sat, 21 May 2022 18:51:57 +0300 Subject: [PATCH] version check + small things --- src/client/component/gameplay.cpp | 197 +++++++++++++------------- src/client/component/materials.cpp | 4 +- src/client/component/system_check.cpp | 8 +- src/client/main.cpp | 1 - 4 files changed, 108 insertions(+), 102 deletions(-) diff --git a/src/client/component/gameplay.cpp b/src/client/component/gameplay.cpp index aeb9ff68..48185bbf 100644 --- a/src/client/component/gameplay.cpp +++ b/src/client/component/gameplay.cpp @@ -24,7 +24,7 @@ namespace gameplay { if (jump_slowDownEnable->current.enabled) { - utils::hook::invoke(0x1401D5360, ps); + utils::hook::invoke(0x2BD0B0_b, ps); } } @@ -32,10 +32,8 @@ namespace gameplay { if (dvars::g_playerEjection->current.enabled) { - return utils::hook::invoke(0x140326CE0, entity); // StuckInClient + return utils::hook::invoke(0x4035F0_b, entity); // StuckInClient } - - return 0; } void cm_transformed_capsule_trace_stub(game::trace_t* results, const float* start, const float* end, @@ -43,7 +41,7 @@ namespace gameplay { if (dvars::g_playerCollision->current.enabled) { - utils::hook::invoke(0x1403FF860, + utils::hook::invoke(0x4D63C0_b, results, start, end, bounds, capsule, contents, origin, angles); // CM_TransformedCapsuleTrace } } @@ -52,7 +50,7 @@ namespace gameplay { if (jump_enableFallDamage->current.enabled) { - utils::hook::invoke(0x1401E2D00, ps, pml); + utils::hook::invoke(0x2CB070_b, ps, pml); } } @@ -65,58 +63,67 @@ namespace gameplay } } - const auto pm_bouncing_stub_mp = utils::hook::assemble([](utils::hook::assembler& a) + void* pm_bouncing_stub_mp() { - const auto no_bounce = a.newLabel(); - const auto loc_1401EAF9D = a.newLabel(); + return utils::hook::assemble([](utils::hook::assembler& a) + { + const auto no_bounce = a.newLabel(); + const auto loc_1401EAF9D = a.newLabel(); - a.push(rax); + a.push(rax); - a.mov(rax, qword_ptr(reinterpret_cast(&dvars::pm_bouncing))); - a.mov(al, byte_ptr(rax, 0x10)); - a.cmp(byte_ptr(rbp, -0x2D), al); + a.mov(rax, qword_ptr(reinterpret_cast(&dvars::pm_bouncing))); + a.mov(al, byte_ptr(rax, 0x10)); + a.cmp(byte_ptr(rbp, -0x2D), al); - a.pop(rax); - a.jz(no_bounce); - a.jmp(0x1401EB000); + a.pop(rax); + a.jz(no_bounce); + a.jmp(0x2D39C0_b); - a.bind(no_bounce); - a.cmp(dword_ptr(rsp, 0x70), 0); - a.jnz(loc_1401EAF9D); - a.jmp(0x1401EAFF1); + a.bind(no_bounce); + a.cmp(dword_ptr(rsp, 0x70), 0); + a.jnz(loc_1401EAF9D); + a.jmp(0x2D39B1_b); - a.bind(loc_1401EAF9D); - a.jmp(0x1401EAF9D); - }); + a.bind(loc_1401EAF9D); + a.jmp(0x2D395D_b); + }); + } - const auto g_speed_stub = utils::hook::assemble([](utils::hook::assembler& a) + void* g_speed_stub() { - a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_speed))); - a.mov(eax, dword_ptr(rax, 0x10)); + return utils::hook::assemble([](utils::hook::assembler& a) + { + a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_speed))); + a.mov(eax, dword_ptr(rax, 0x10)); - // original code - a.mov(dword_ptr(r14, 0x36), ax); - a.movzx(eax, word_ptr(r14, 0x3A)); + // original code + a.mov(dword_ptr(r14, 0x36), ax); + a.movzx(eax, word_ptr(r14, 0x3A)); - a.jmp(0x140323DBC); - }); + a.jmp(0x4006BC_b); + }); + } - const auto client_end_frame_stub = utils::hook::assemble([](utils::hook::assembler& a) + void* client_end_frame_stub() { - a.push(rax); + return utils::hook::assemble([](utils::hook::assembler& a) + { + a.push(rax); - a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_gravity))); - a.mov(eax, dword_ptr(rax, 0x10)); - a.mov(word_ptr(rbx, 0x34), ax); + a.mov(rax, qword_ptr(reinterpret_cast(&dvars::g_gravity))); + a.mov(eax, dword_ptr(rax, 0x10)); + a.mov(word_ptr(rbx, 0x34), ax); - a.pop(rax); + a.pop(rax); - // Game code hook skipped - a.mov(eax, dword_ptr(rbx, 0x494C)); - a.mov(rdi, rcx); + // Game code hook skipped + a.mov(eax, dword_ptr(rbx, 0x495C)); + a.mov(rdi, rcx); - a.jmp(0x140322F82); - }); + a.jmp(0x3FF822_b); + }); + } void pm_player_trace_stub(game::pmove_t* pm, game::trace_t* trace, const float* f3, const float* f4, const game::Bounds* bounds, int a6, int a7) @@ -135,7 +142,7 @@ namespace gameplay const auto stand = a.newLabel(); const auto allsolid = a.newLabel(); - a.call(qword_ptr(r10, r15)); // Game code + a.call(rsi); // Game code a.push(rax); @@ -151,12 +158,12 @@ namespace gameplay a.jnz(allsolid); a.bind(stand); - a.and_(dword_ptr(rbx, 0x54), 0xFFFFFFFD); - a.jmp(0x1401E1CDF); + a.and_(dword_ptr(r15, 0x54), 0xFFFFFFFD); + a.jmp(0x2C9F9D_b); a.bind(allsolid); - a.jmp(0x1401E1CE1); - } + a.jmp(0x2C9F9F_b); + }; } class component final : public component_interface @@ -164,65 +171,65 @@ namespace gameplay public: void post_unpack() override { - dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false, - game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo"); - pm_weapon_use_ammo_hook.create(SELECT_VALUE(0x14042E380, 0x1401F6B90), &pm_weapon_use_ammo_stub); - if (game::environment::is_sp()) { return; } -#ifdef DEBUG - // Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored' - pm_player_trace_hook.create(0x1401E8BE0, &pm_player_trace_stub); - - // If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state - utils::hook::jump(0x1401E1CD1, utils::hook::assemble(pm_trace_stub), true); - dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DvarFlags::DVAR_FLAG_NONE, "Enables Elevators"); -#endif - - auto* timescale = dvars::register_float("timescale", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_REPLICATED, "Changes Timescale of the game"); - utils::hook::inject(0x1400D89A4, ×cale->current.value); - utils::hook::inject(0x1400DA9D1, ×cale->current.value); - utils::hook::inject(0x1400DB7A9, ×cale->current.value); - utils::hook::inject(0x1400DB7C6, ×cale->current.value); - utils::hook::inject(0x1400DB83C, ×cale->current.value); - utils::hook::inject(0x1400DB9CC, ×cale->current.value); - utils::hook::inject(0x1400DBAF0, ×cale->current.value); - utils::hook::inject(0x1400DBE72, ×cale->current.value); - utils::hook::inject(0x1400DBE9C, ×cale->current.value); - - utils::hook::call(0x1401E8830, jump_apply_slowdown_stub); - jump_slowDownEnable = dvars::register_bool("jump_slowDownEnable", true, game::DVAR_FLAG_REPLICATED, "Slow player movement after jumping"); - - utils::hook::call(0x1401E490F, pm_crashland_stub); - jump_enableFallDamage = dvars::register_bool("jump_enableFallDamage", true, game::DVAR_FLAG_REPLICATED, "Enable fall damage"); - - dvars::g_playerEjection = dvars::register_bool("g_playerEjection", true, game::DVAR_FLAG_REPLICATED, - "Flag whether player ejection is on or off"); - utils::hook::call(0x140323333, stuck_in_client_stub); - - utils::hook::nop(0x140323DAD, 15); - utils::hook::jump(0x140323DAD, g_speed_stub, true); - dvars::g_speed = dvars::register_int("g_speed", 190, std::numeric_limits::min(), std::numeric_limits::max(), + dvars::player_sustainAmmo = dvars::register_bool("player_sustainAmmo", false, + game::DVAR_FLAG_REPLICATED, "Firing weapon will not decrease clip ammo"); + pm_weapon_use_ammo_hook.create(0x2DF830_b, &pm_weapon_use_ammo_stub); + + utils::hook::nop(0x4006AD_b, 15); + utils::hook::jump(0x4006AD_b, g_speed_stub(), true); + dvars::g_speed = dvars::register_int("g_speed", 190, 0, 1000, game::DVAR_FLAG_REPLICATED, "changes the speed of the player"); - // Implement player collision dvar - dvars::g_playerCollision = dvars::register_bool("g_playerCollision", true, game::DVAR_FLAG_REPLICATED, - "Flag whether player collision is on or off"); - utils::hook::call(0x14049D7CF, cm_transformed_capsule_trace_stub); // SV_ClipMoveToEntity - utils::hook::call(0x140240BC3, cm_transformed_capsule_trace_stub); // CG_ClipMoveToEntity - // Implement bouncing dvar dvars::pm_bouncing = dvars::register_bool("pm_bouncing", false, game::DVAR_FLAG_REPLICATED, "Enable bouncing"); - utils::hook::jump(0x1401EAFE4, pm_bouncing_stub_mp, true); + utils::hook::jump(0x2D39A4_b, pm_bouncing_stub_mp(), true); - dvars::g_gravity = dvars::register_int("g_gravity", 800, std::numeric_limits::min(), - std::numeric_limits::max(), game::DVAR_FLAG_REPLICATED, "Game gravity in inches per second squared"); - utils::hook::jump(0x140322F72, client_end_frame_stub, true); - utils::hook::nop(0x140322F68, 1); // Nop skipped opcode + dvars::g_gravity = dvars::register_int("g_gravity", 800, 0, 1000, game::DVAR_FLAG_REPLICATED, + "Game gravity in inches per second squared"); + utils::hook::jump(0x3FF812_b, client_end_frame_stub(), true); + utils::hook::nop(0x3FF808_b, 1); // Nop skipped opcode + + // NEED SOME WORK + // Influence PM_JitterPoint code flow so the trace->startsolid checks are 'ignored' + //pm_player_trace_hook.create(0x2D14C0_b, &pm_player_trace_stub); + //If g_enableElevators is 1 the 'ducked' flag will always be removed from the player state + //utils::hook::jump(0x2C9F90_b, utils::hook::assemble(pm_trace_stub), true); + + //dvars::g_enableElevators = dvars::register_bool("g_enableElevators", false, game::DvarFlags::DVAR_FLAG_NONE, "Enables Elevators"); + + // NEEDS SOME WORK & REVISION + //auto* timescale = dvars::register_float("timescale", 1.0f, 0.1f, 50.0f, game::DVAR_FLAG_REPLICATED, "Changes Timescale of the game"); + //utils::hook::inject(0x15B204_b, ×cale->current.value); // Com_GetTimeScale + //utils::hook::inject(0x17D241_b, ×cale->current.value); // Com_Restart + //utils::hook::inject(0x17E609_b, ×cale->current.value); // Com_SetSlowMotion + //utils::hook::inject(0x17E626_b, ×cale->current.value); // Com_SetSlowMotion + //utils::hook::inject(0x17E69C_b, ×cale->current.value); // Com_SetSlowMotion + //utils::hook::inject(0x1400DB9CC, ×cale->current.value); // Com_ErrorCleanup_Shutdown (INLINED) + //utils::hook::inject(0x17EAD2_b, ×cale->current.value); // Com_TimeScaleMsec (CAUSING A CRASH) + //utils::hook::inject(0x17EFE2_b, ×cale->current.value); // Com_UpdateSlowMotion + //utils::hook::inject(0x17F00C_b, ×cale->current.value); // Com_UpdateSlowMotion + + //utils::hook::call(0x2D10D0_b, jump_apply_slowdown_stub); + //jump_slowDownEnable = dvars::register_bool("jump_slowDownEnable", true, game::DVAR_FLAG_REPLICATED, "Slow player movement after jumping"); + + //utils::hook::call(0x2CCC9D_b, pm_crashland_stub); + //jump_enableFallDamage = dvars::register_bool("jump_enableFallDamage", true, game::DVAR_FLAG_REPLICATED, "Enable fall damage"); + + //dvars::g_playerEjection = dvars::register_bool("g_playerEjection", true, game::DVAR_FLAG_REPLICATED, + // "Flag whether player ejection is on or off"); + //utils::hook::call(0x3FFC00_b, stuck_in_client_stub); + + // Implement player collision dvar + dvars::g_playerCollision = dvars::register_bool("g_playerCollision", true, game::DVAR_FLAG_REPLICATED, + "Flag whether player collision is on or off"); + utils::hook::call(0x567CCF_b, cm_transformed_capsule_trace_stub); // SV_ClipMoveToEntity + utils::hook::call(0x337850_b, cm_transformed_capsule_trace_stub); // CG_ClipMoveToEntity } }; } diff --git a/src/client/component/materials.cpp b/src/client/component/materials.cpp index c870039c..eb2a7cd9 100644 --- a/src/client/component/materials.cpp +++ b/src/client/component/materials.cpp @@ -203,8 +203,8 @@ namespace materials } material_register_handle_hook.create(game::Material_RegisterHandle, material_register_handle_stub); - db_material_streaming_fail_hook.create(SELECT_VALUE(0x1401D3180, 0x1402C6260), db_material_streaming_fail_stub); - db_get_material_index_hook.create(SELECT_VALUE(0x1401CAD00, 0x1402BBB20), db_get_material_index_stub); + db_material_streaming_fail_hook.create(0x3A1600_b, db_material_streaming_fail_stub); + db_get_material_index_hook.create(0x396000_b, db_get_material_index_stub); } }; } diff --git a/src/client/component/system_check.cpp b/src/client/component/system_check.cpp index 6954de1a..794bf375 100644 --- a/src/client/component/system_check.cpp +++ b/src/client/component/system_check.cpp @@ -67,8 +67,8 @@ namespace system_check // need to update these values void verify_binary_version() { - const auto value = *reinterpret_cast(0x140001337); - if (value != 0xFFB8006D && value != 0xFFB80080) + const auto value = *reinterpret_cast(0x1337_b); + if (value != 0x60202B6A && value != 0xBC0E9FE) { throw std::runtime_error("Unsupported Call of Duty: Modern Warfare Remastered version (1.15)"); } @@ -86,7 +86,7 @@ namespace system_check public: void post_load() override { - //verify_binary_version(); + verify_binary_version(); if (!is_valid()) { @@ -98,4 +98,4 @@ namespace system_check }; } -//REGISTER_COMPONENT(system_check::component) +REGISTER_COMPONENT(system_check::component) diff --git a/src/client/main.cpp b/src/client/main.cpp index 224c93b2..5f26e699 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -175,7 +175,6 @@ int main() try { //apply_proper_directory(); - //remove_crash_file(); if (!component_loader::post_start()) return 0;