version check + small things

This commit is contained in:
Skull Merlin 2022-05-21 18:51:57 +03:00
parent 11067ceeed
commit c039d03a15
4 changed files with 108 additions and 102 deletions

View File

@ -24,7 +24,7 @@ namespace gameplay
{
if (jump_slowDownEnable->current.enabled)
{
utils::hook::invoke<void>(0x1401D5360, ps);
utils::hook::invoke<void>(0x2BD0B0_b, ps);
}
}
@ -32,10 +32,8 @@ namespace gameplay
{
if (dvars::g_playerEjection->current.enabled)
{
return utils::hook::invoke<int>(0x140326CE0, entity); // StuckInClient
return utils::hook::invoke<int>(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<void>(0x1403FF860,
utils::hook::invoke<void>(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<void>(0x1401E2D00, ps, pml);
utils::hook::invoke<void>(0x2CB070_b, ps, pml);
}
}
@ -65,7 +63,9 @@ namespace gameplay
}
}
const auto pm_bouncing_stub_mp = utils::hook::assemble([](utils::hook::assembler& a)
void* pm_bouncing_stub_mp()
{
return utils::hook::assemble([](utils::hook::assembler& a)
{
const auto no_bounce = a.newLabel();
const auto loc_1401EAF9D = a.newLabel();
@ -78,18 +78,21 @@ namespace gameplay
a.pop(rax);
a.jz(no_bounce);
a.jmp(0x1401EB000);
a.jmp(0x2D39C0_b);
a.bind(no_bounce);
a.cmp(dword_ptr(rsp, 0x70), 0);
a.jnz(loc_1401EAF9D);
a.jmp(0x1401EAFF1);
a.jmp(0x2D39B1_b);
a.bind(loc_1401EAF9D);
a.jmp(0x1401EAF9D);
a.jmp(0x2D395D_b);
});
}
const auto g_speed_stub = utils::hook::assemble([](utils::hook::assembler& a)
void* g_speed_stub()
{
return utils::hook::assemble([](utils::hook::assembler& a)
{
a.mov(rax, qword_ptr(reinterpret_cast<int64_t>(&dvars::g_speed)));
a.mov(eax, dword_ptr(rax, 0x10));
@ -98,10 +101,13 @@ namespace gameplay
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()
{
return utils::hook::assemble([](utils::hook::assembler& a)
{
a.push(rax);
@ -112,11 +118,12 @@ namespace gameplay
a.pop(rax);
// Game code hook skipped
a.mov(eax, dword_ptr(rbx, 0x494C));
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);
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);
// 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, &timescale->current.value);
utils::hook::inject(0x1400DA9D1, &timescale->current.value);
utils::hook::inject(0x1400DB7A9, &timescale->current.value);
utils::hook::inject(0x1400DB7C6, &timescale->current.value);
utils::hook::inject(0x1400DB83C, &timescale->current.value);
utils::hook::inject(0x1400DB9CC, &timescale->current.value);
utils::hook::inject(0x1400DBAF0, &timescale->current.value);
utils::hook::inject(0x1400DBE72, &timescale->current.value);
utils::hook::inject(0x1400DBE9C, &timescale->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<int>::min(), std::numeric_limits<int>::max(),
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<short>::min(),
std::numeric_limits<short>::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, &timescale->current.value); // Com_GetTimeScale
//utils::hook::inject(0x17D241_b, &timescale->current.value); // Com_Restart
//utils::hook::inject(0x17E609_b, &timescale->current.value); // Com_SetSlowMotion
//utils::hook::inject(0x17E626_b, &timescale->current.value); // Com_SetSlowMotion
//utils::hook::inject(0x17E69C_b, &timescale->current.value); // Com_SetSlowMotion
//utils::hook::inject(0x1400DB9CC, &timescale->current.value); // Com_ErrorCleanup_Shutdown (INLINED)
//utils::hook::inject(0x17EAD2_b, &timescale->current.value); // Com_TimeScaleMsec (CAUSING A CRASH)
//utils::hook::inject(0x17EFE2_b, &timescale->current.value); // Com_UpdateSlowMotion
//utils::hook::inject(0x17F00C_b, &timescale->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
}
};
}

View File

@ -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);
}
};
}

View File

@ -67,8 +67,8 @@ namespace system_check
// need to update these values
void verify_binary_version()
{
const auto value = *reinterpret_cast<DWORD*>(0x140001337);
if (value != 0xFFB8006D && value != 0xFFB80080)
const auto value = *reinterpret_cast<DWORD*>(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)

View File

@ -175,7 +175,6 @@ int main()
try
{
//apply_proper_directory();
//remove_crash_file();
if (!component_loader::post_start()) return 0;