#pragma once
#include <Includes/Includes.hpp>
#include <Includes/Utils.hpp>
#include <Core/Offsets.hpp>
#include <Core/Core.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <regex>
namespace Core
{
namespace Features
{
namespace Exploits
{
class cWeaponSpawn
{
private:
bool Bypassed = false;
private:
void Bypass( )
{
uintptr_t HasPedGotWeapon = Mem.FindSignature(
{ 0x48, 0x8b, 0xc4, 0x48, 0x89, 0x58,0x00 , 0x48, 0x89, 0x68,0x00 , 0x48, 0x89, 0x70,0x00 , 0x48, 0x89, 0x78,0x00 , 0x41, 0x56, 0x48, 0x83, 0xec,0x00 , 0x41, 0x8b, 0xf8, 0x8b, 0xea }
);
uintptr_t GetSelectedPedWeapon = Mem.FindSignature(
{ 0x48, 0x83, 0xec,0x00 , 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x48, 0x8b, 0x80,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x8b, 0x40 }
);
uintptr_t IsPedArmed = Mem.FindSignature(
{ 0x48, 0x89, 0x5c, 0x24,0x00 , 0x48, 0x89, 0x6c, 0x24,0x00 , 0x48, 0x89, 0x74, 0x24,0x00 , 0x57, 0x48, 0x83, 0xec,0x00 , 0x8b, 0xea, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x33, 0xdb }
);
uintptr_t GetBestPedWeapon = Mem.FindSignature(
{ 0x40, 0x53, 0x48, 0x83, 0xec,0x00 , 0x8a, 0xda, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x48, 0x8b, 0x88,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc9, 0x74,0x00 , 0x44, 0x8a, 0xc3 }
);
uintptr_t GetCurrentPedWeapon = Mem.FindSignature(
{ 0x48, 0x89, 0xe2, 0x48, 0x81, 0xc2,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x89, 0xd4, 0x48, 0x89, 0x1c, 0x24, 0x48, 0x83, 0xec,0x00 , 0x48, 0x8b, 0x41,0x00 , 0x48, 0x89, 0x4c, 0x24 }
);
uintptr_t GetPedAmmoByType = Mem.FindSignature(
{ 0x40, 0x53, 0x48, 0x83, 0xec,0x00 , 0x8b, 0xda, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x48, 0x8b, 0x88,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc9, 0x74,0x00 , 0x48, 0x83, 0xc1,0x00 , 0x8b, 0xd3, 0x48, 0x83, 0xc4 }
);
uintptr_t GetAmmoInPedWeapon = Mem.FindSignature(
{ 0x48, 0x89, 0x5c, 0x24,0x00 , 0x57, 0x48, 0x83, 0xec,0x00 , 0x8b, 0xfa, 0x33, 0xdb, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x4c, 0x8b, 0x80 }
);
uintptr_t GetPedAmmoTypeFromWeapon = Mem.FindSignature(
{ 0x48, 0x89, 0x5c, 0x24,0x00 , 0x57, 0x48, 0x83, 0xec,0x00 , 0x8b, 0xda, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x8b, 0xf8, 0x48, 0x85, 0xc0, 0x74,0x00 , 0x48, 0x83, 0xb8 }
);
uintptr_t GetPedAmmoTypeFromWeapon_2 = Mem.FindSignature(
{ 0x40, 0x53, 0x48, 0x83, 0xec,0x00 , 0x8b, 0xda, 0xe8,0x00 ,0x00 ,0x00 ,0x00 , 0x48, 0x85, 0xc0, 0x74,0x00 , 0x48, 0x83, 0xb8 }
);
uintptr_t IsPedShooting = Mem.FindSignature(
{ 0x40, 0x53, 0x48, 0x83, 0xec, 0x00 , 0x8b, 0xd9, 0xe8, 0x00 , 0x00 , 0x00 , 0x00 , 0x8b, 0xcb, 0xe8, 0x00 , 0x00 , 0x00 , 0x00 , 0x48, 0x8b, 0xd8, 0x48, 0x85, 0xc0, 0x74, 0x00 , 0x8b, 0x0d, 0x00 , 0x00 , 0x00 , 0x00 , 0x4c, 0x8b, 0x00, 0x48, 0x8d, 0x54, 0x24, 0x00 , 0x89, 0x4c, 0x24, 0x00 , 0x48, 0x8b, 0xc8, 0x41, 0xff, 0x50, 0x00 , 0x84, 0xc0, 0x74, 0x00 , 0x48, 0x8b, 0xc3, 0xeb, 0x00 , 0x33, 0xc0, 0x48, 0x83, 0xc4, 0x00 , 0x5b, 0xc3, 0xcc, 0x0f, 0x48, 0x89 }
);
Mem.WriteBytes( IsPedShooting, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( HasPedGotWeapon, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( IsPedArmed, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( GetPedAmmoByType, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( GetPedAmmoTypeFromWeapon, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( GetPedAmmoTypeFromWeapon_2, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( GetAmmoInPedWeapon, { 0x31, 0xC0, 0xC3 } );
Mem.WriteBytes( GetSelectedPedWeapon, { 0xB8, 0x63, 0x92, 0x71, 0xA2, 0xC3 } );
Mem.WriteBytes( GetBestPedWeapon, { 0xB8, 0x63, 0x92, 0x71, 0xA2, 0xC3 } );
Mem.WriteBytes( GetCurrentPedWeapon, { 0xB8, 0x63, 0x92, 0x71, 0xA2, 0xC3 } );
}
public:
bool Spawn( unsigned int WeaponHash, unsigned int Ammo )
{
if ( !Core::SDK::Pointers::pLocalPlayer )
return false;
if ( !Bypassed )
{
Bypass( );
Bypassed = true;
}
std::vector<uint8_t> ShellCode =
{
0x51, // push rcx
0x41,0x50, // push r8
0x52, // push rdx
0x48, 0xB9, // mov rcx, CPedInventory
0x00, 0x00, 0x00, 0x00,0x00,0x00,0x00,0x00, // CPedInventory @ 6
0x49, 0xB8, // mov r8, Ammo
0x00, 0x00, 0x00, 0x00, 0x00,0x00,0x00,0x00, // Ammo @ 16
0xBA, // mov edx, WeaponHash
0x00,0x00,0x00,0x00, // WeaponHash @ 25
0xFF,0x15, 0x02,0x00,0x00,0x00, 0xEB,0x08, // call qword ptr Func @ 37
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // Func
0x5A,// pop rdx
0x41,0x58, // pop r8
0x59, // pop rcx
0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 // mov eax,0x1 | ret
};
uintptr_t Cave = Mem.CreateCodeCave( ShellCode.size( ) );
uintptr_t CPedInventory = Core::SDK::Pointers::pLocalPlayer->GetCPedInventory( );
uintptr_t GiveWeaponFunc = g_Offsets.m_GiveWeapon;
memcpy( ShellCode.data( ) + 6, &CPedInventory, sizeof( CPedInventory ) );
memcpy( ShellCode.data( ) + 16, &Ammo, sizeof( Ammo ) );
memcpy( ShellCode.data( ) + 25, &WeaponHash, sizeof( WeaponHash ) );
memcpy( ShellCode.data( ) + 37, &GiveWeaponFunc, sizeof( GiveWeaponFunc ) );
Mem.WriteBytes( Cave, ShellCode );
HANDLE RemoteThread = CreateRemoteThread( Mem.ProcHandle, NULL, 0, ( LPTHREAD_START_ROUTINE ) Cave, NULL, 0, NULL );
Sleep( 1000 );
Mem.FreeCave( Cave );
return true;
}
};
inline cWeaponSpawn g_WeaponSpawn;
}
}
}