Code:
void CreateBackup(DWORD dwCShell, DWORD dwWeaponMgr)
{
DWORD pWeaponMgr = *(DWORD*)(dwCShell + dwWeaponMgr );
for(int i = 0; i < 1600; i++)
{
DWORD dwWeapon = *(DWORD*)(pWeaponMgr + (4 * i));
if (dwWeapon)
{
pOldWeapons[i] = new WEAPON;
memcpy(pOldWeapons[i], (void*)(dwWeapon), sizeof(WEAPON));
}
}
}
Our custom GetWeaponByIndex function to return a pointer to the weapon backup instead of the modified one
Code:
DWORD dwBypassWeaponHack = FindPattern(dwCShellBase, 0xFFFFFF, (PBYTE)"\xE8\x00\x00\x00\x00\x83\xC4\x04\x85\xC0\x74\x48\x8B\x0D\x00\x00\x00\x00\x8B\x11", "x????xxxxxxxxx????xx");
DWORD dwOldProtect;
VirtualProtect((void*)(dwBypassWeaponHack + 0x1), sizeof(DWORD), PAGE_EXECUTE_READWRITE, &dwOldProtect);
*(DWORD*)(dwBypassWeaponHack + 0x1) = (DWORD)GetWeaponByIndex - dwBypassWeaponHack - 5;
VirtualProtect((void*)(dwBypassWeaponHack + 0x1), sizeof(DWORD), dwOldProtect, NULL);