Advertisement
gopro2027

RDR2 Increase Ped Pool Size

Nov 26th, 2019
3,702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.51 KB | None | 0 0
  1. //Code must be loaded before game is loaded in. I put into CScriptManager::Init() from tuxick script hook
  2.  
  3. void patchSizeOfPedPool(unsigned char newSize = 0xFF) {
  4.     //By gopro_2027
  5.     //under_gameconfigload, this stores size of ped pool read
  6.     const CMemory::Pattern PedsPoolLoadSizeFuncPattern("40 53 48 83 EC 20 48 8B 1D ? ? ? ? BA ? ? ? ? 48 8B CB 41 B8 ? ? ? ? E8 ? ? ? ? 8B C8 E8 ? ? ? ? BA ? ? ? ? 41 B8 ? ? ? ? 48 8B CB E8 ? ? ? ? 8B C8 E8 ? ? ? ? BA ? ? ? ? 41 B8 ? ? ? ? 48 8B CB E8 ? ? ? ? 8B C8 E8 ? ? ? ? E8 ? ? ? ? 89 05 ? ? ? ? 48 83 C4 20 5B C3 ");
  7.     uint64_t pedsPoolAddr = PedsPoolLoadSizeFuncPattern.Search().Get<uint64_t>();
  8.     DWORD rights;
  9.     VirtualProtect((LPVOID)pedsPoolAddr, 0x50, PAGE_EXECUTE_READWRITE, &rights);
  10.     //need to modify .text:00007FF6B4A85EFC                 call    setSizeOfPedsPool
  11.     //unsigned char maxSize = 0x95;//default: 0x96
  12.     unsigned char moveax3[] = { 0xB8, newSize,  0x00, 0x00, 0x00 };//0x97 freezes, 0x96 works, 0x95 works???, 0x90 works, 0x50 does not work...  Fixed now with patches below.   Also may support more than a max size of char, might support short or int. I have not tested exactly.
  13.     uint64_t specificInstructionAddr = pedsPoolAddr + 0x35;
  14.     for (int i = 0; i < 5; i++)
  15.         *(unsigned char*)(specificInstructionAddr + i) = moveax3[i];
  16.     //*(char*)(pedsPoolAddr + 0x2E) = 3;//lower it to 3 peds
  17.     VirtualProtect((LPVOID)pedsPoolAddr, 0x50, rights, NULL);
  18.  
  19.  
  20.     //This is a spot that reads the size of the ped pool, but I think also compares the size to our previous read from the patch above. Actually not sure if this is necessary or not. Lets patch it anyways and hard code it to return our custom value.
  21.     const CMemory::Pattern bpp("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 30 8B D9 41 8B F0 B9 ? ? ? ? E8 ? ? ? ? 48 8B F8 48 85 C0 74 3E 48 8B 0D ? ? ? ? 44 8B C3 BA 17 21 A1 8D ");
  22.     uint64_t under_createSomePools = bpp.Search().Get<uint64_t>();//0x35 is offset for call
  23.     VirtualProtect((LPVOID)under_createSomePools, 0x50, PAGE_EXECUTE_READWRITE, &rights);
  24.  
  25.     specificInstructionAddr = under_createSomePools + 0x35;
  26.     for (int i = 0; i < 5; i++)
  27.         *(unsigned char*)(specificInstructionAddr + i) = moveax3[i];
  28.  
  29.     VirtualProtect((LPVOID)under_createSomePools, 0x50, rights, NULL);
  30.  
  31.  
  32.  
  33.     //createSomePools int 3 patch
  34.     const CMemory::Pattern csp("48 89 5C 24 ? 57 48 83 EC 20 45 33 C0 48 8D 05 ? ? ? ? 48 89 01 48 8B D9 48 83 61 ? ? 8B 0D ? ? ? ? 41 8D 78 04 8B D7 E8 ? ? ? ? 33 D2 8B CF E8 ? ? ? ? 81 3D ? ? ? ? ? ? ? ? 76 01 CC 33 D2 8B CF E8 ? ? ? ? ");
  35.     csp.Search().Add(0x45).Nop(1);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement