#pragma once #include #include #include #include // #define GLOBALS 0x5B28C0 #define GLOBALS 0x62A080 // https://github.com/erayarslan/WriteProcessMemory-Example // http://stackoverflow.com/q/32798185 // http://stackoverflow.com/q/36018838 // http://stackoverflow.com/q/1387064 class Memory { public: Memory(const std::string& processName); ~Memory(); Memory(const Memory& memory) = delete; Memory& operator=(const Memory& other) = delete; int GetCurrentFrame(); template std::vector ReadArray(int panel, int offset, int size) { return ReadData({GLOBALS, 0x18, panel*8, offset, 0}, size); } template void WriteArray(int panel, int offset, const std::vector& data) { WriteData({GLOBALS, 0x18, panel*8, offset, 0}, data); } template std::vector ReadPanelData(int panel, int offset, size_t size) { return ReadData({GLOBALS, 0x18, panel*8, offset}, size); } template void WritePanelData(int panel, int offset, const std::vector& data) { WriteData({GLOBALS, 0x18, panel*8, offset}, data); } void SigScan(std::function& data)> scanFunc); void ClearOffsets() {_computedAddresses = std::map();} private: template std::vector ReadData(const std::vector& offsets, size_t numItems) { std::vector data; data.resize(numItems); for (int i=0; i<5; i++) { if (ReadProcessMemory(_handle, ComputeOffset(offsets), &data[0], sizeof(T) * numItems, nullptr)) { return data; } } ThrowError(); return {}; } template void WriteData(const std::vector& offsets, const std::vector& data) { for (int i=0; i<5; i++) { if (WriteProcessMemory(_handle, ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), nullptr)) { return; } } ThrowError(); } void ThrowError(); void* ComputeOffset(std::vector offsets); std::map _computedAddresses; uintptr_t _baseAddress = 0; HANDLE _handle = nullptr; friend class Temp; friend class ChallengeRandomizer; friend class Randomizer; };