From 4653e4f00ce2c3421d59d6c2f05adbb7ae9e7bd3 Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 28 Jan 2018 18:15:38 +0100 Subject: [PATCH] Fixed ammo granting from SCM - III/VC --- SilentPatchIII/SilentPatchIII.cpp | 18 ++++++++++++++++++ SilentPatchVC/SilentPatchVC.cpp | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index f3c8672..428b079 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -354,6 +354,13 @@ void __declspec(naked) AutoPilotTimerFix_III() } } +static void (__thiscall *orgGiveWeapon)( void* ped, unsigned int weapon, unsigned int ammo ); +static void __fastcall GiveWeapon_SP( void* ped, void*, unsigned int weapon, unsigned int ammo ) +{ + if ( ammo == 0 ) ammo = 1; + orgGiveWeapon( ped, weapon, ammo ); +} + void Patch_III_10(const RECT& desktop) { using namespace Memory; @@ -841,6 +848,17 @@ void Patch_III_Common() Patch( do_processing.get(1), 0xBF ); // movzx eax, word ptr [ebx+28h] -> movsx eax, word ptr [ebx+28h] Patch( do_processing.get(7), 0x74 ); // jge -> jz } + + + // Fixed ammo from SCM + { + auto give_weapon = get_pattern( "6B C0 4F 51 8B 34", 0x13 ); + ReadCall( give_weapon, orgGiveWeapon ); + InjectHook( give_weapon, GiveWeapon_SP ); + + give_weapon = get_pattern( "89 C7 A1 ? ? ? ? 55 89 F9 50", 11 ); + InjectHook( give_weapon, GiveWeapon_SP ); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 242cd44..931d800 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -219,6 +219,13 @@ void __declspec(naked) AutoPilotTimerFix_VC() } } +static void (__thiscall *orgGiveWeapon)( void* ped, unsigned int weapon, unsigned int ammo, bool flag ); +static void __fastcall GiveWeapon_SP( void* ped, void*, unsigned int weapon, unsigned int ammo, bool flag ) +{ + if ( ammo == 0 ) ammo = 1; + orgGiveWeapon( ped, weapon, ammo, flag ); +} + void Patch_VC_10(const RECT& desktop) { using namespace Memory; @@ -654,6 +661,17 @@ void Patch_VC_Common() Patch( do_processing.get(7), 0x74 ); // jge -> jz } + + // Fixed ammo from SCM + { + auto give_weapon = get_pattern( "6B C0 2E 6A 01 56 8B 3C", 0x15 ); + ReadCall( give_weapon, orgGiveWeapon ); + InjectHook( give_weapon, GiveWeapon_SP ); + + give_weapon = get_pattern( "89 F9 6A 01 55 50 E8", 6 ); + InjectHook( give_weapon, GiveWeapon_SP ); + } + } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)