Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ezwin.h"
- #include "ezproc.h"
- #include <iostream>
- #include <map>
- #include <vector>
- // Describes the hexidecimal values for assembly instructions
- std::map<std::string, std::vector<unsigned char>> OpcodeHex
- {
- {"esi", {0xFF}}, // Register
- {"inc", {0x6}}, // Increases register by 1
- {"dec", {0xE}}, // Decreases register by 1
- {"sub", {0x6B}}, // Subtract byte ptr
- {"add", {0x43}}, // Add byte ptr
- {"nop", {0x90}} // Do nothing
- };
- // Describes the memory addresses whose instructions access other beneficial values, such as health and ammo
- std::map<std::string, DWORD*> MemoryRegions
- {
- {"Health", (DWORD*)0x00D8A3F8},
- {"DecreaseAmmo", (DWORD*)0x004637E9}
- };
- template <typename... CombinedType> std::vector<unsigned char> CombineVectors(CombinedType... Arguments)
- {
- std::size_t PreallocatedMemory = sizeof...(Arguments);
- std::vector<unsigned char> CombinedVectors;
- CombinedVectors.reserve(PreallocatedMemory);
- for(auto Vector: {Arguments...}){CombinedVectors.insert(CombinedVectors.end(), Vector.begin(), Vector.end());}
- return CombinedVectors;
- }
- // Replaces the dec[esi] opcode at the adress 0x004637E9 with inc[esi] opcode, increasing the player's ammo by 1 each time they fire
- void InfiniteAmmo(HANDLE* HookedProcess)
- {
- std::vector<unsigned char> IncreaseESI = CombineVectors(OpcodeHex["esi"], OpcodeHex["inc"]);
- WriteToProcess(HookedProcess, MemoryRegions["DecreaseAmmo"], IncreaseESI);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement