Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include "ezwin.h"
  2. #include "ezproc.h"
  3. #include <iostream>
  4. #include <map>
  5. #include <vector>
  6.  
  7. // Describes the hexidecimal values for assembly instructions
  8. std::map<std::string, std::vector<unsigned char>> OpcodeHex
  9. {
  10.     {"esi", {0xFF}}, // Register
  11.     {"inc", {0x6}}, // Increases register by 1
  12.     {"dec", {0xE}}, // Decreases register by 1
  13.     {"sub", {0x6B}}, // Subtract byte ptr
  14.     {"add", {0x43}}, // Add byte ptr
  15.     {"nop", {0x90}} // Do nothing
  16. };
  17.  
  18. // Describes the memory addresses whose instructions access other beneficial values, such as health and ammo
  19. std::map<std::string, DWORD*> MemoryRegions
  20. {
  21.     {"Health", (DWORD*)0x00D8A3F8},
  22.     {"DecreaseAmmo", (DWORD*)0x004637E9}
  23. };
  24.  
  25. template <typename... CombinedType> std::vector<unsigned char> CombineVectors(CombinedType... Arguments)
  26. {
  27.     std::size_t PreallocatedMemory = sizeof...(Arguments);
  28.     std::vector<unsigned char> CombinedVectors;
  29.     CombinedVectors.reserve(PreallocatedMemory);
  30.     for(auto Vector: {Arguments...}){CombinedVectors.insert(CombinedVectors.end(), Vector.begin(), Vector.end());}
  31.     return CombinedVectors;
  32. }
  33.  
  34. // Replaces the dec[esi] opcode at the adress 0x004637E9 with inc[esi] opcode, increasing the player's ammo by 1 each time they fire
  35. void InfiniteAmmo(HANDLE* HookedProcess)
  36. {
  37.     std::vector<unsigned char> IncreaseESI = CombineVectors(OpcodeHex["esi"], OpcodeHex["inc"]);
  38.     WriteToProcess(HookedProcess, MemoryRegions["DecreaseAmmo"], IncreaseESI);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement