diff options
Diffstat (limited to 'Source/Memory.h')
| -rw-r--r-- | Source/Memory.h | 17 |
1 files changed, 9 insertions, 8 deletions
| diff --git a/Source/Memory.h b/Source/Memory.h index f70de6a..d7552c5 100644 --- a/Source/Memory.h +++ b/Source/Memory.h | |||
| @@ -7,21 +7,25 @@ | |||
| 7 | // #define GLOBALS 0x5B28C0 | 7 | // #define GLOBALS 0x5B28C0 |
| 8 | #define GLOBALS 0x62D0A0 | 8 | #define GLOBALS 0x62D0A0 |
| 9 | 9 | ||
| 10 | enum class ProcStatus { | ||
| 11 | NotRunning, | ||
| 12 | Running, | ||
| 13 | NewGame | ||
| 14 | }; | ||
| 15 | |||
| 10 | // https://github.com/erayarslan/WriteProcessMemory-Example | 16 | // https://github.com/erayarslan/WriteProcessMemory-Example |
| 11 | // http://stackoverflow.com/q/32798185 | 17 | // http://stackoverflow.com/q/32798185 |
| 12 | // http://stackoverflow.com/q/36018838 | 18 | // http://stackoverflow.com/q/36018838 |
| 13 | // http://stackoverflow.com/q/1387064 | 19 | // http://stackoverflow.com/q/1387064 |
| 14 | class Memory { | 20 | class Memory { |
| 15 | public: | 21 | public: |
| 16 | Memory(); | 22 | Memory() = default; |
| 17 | bool Initialize(const std::wstring& processName); | 23 | ProcStatus Heartbeat(const std::wstring& processName); |
| 18 | ~Memory(); | 24 | ~Memory(); |
| 19 | 25 | ||
| 20 | Memory(const Memory& memory) = delete; | 26 | Memory(const Memory& memory) = delete; |
| 21 | Memory& operator=(const Memory& other) = delete; | 27 | Memory& operator=(const Memory& other) = delete; |
| 22 | 28 | ||
| 23 | int GetCurrentFrame(); | ||
| 24 | |||
| 25 | template <class T> | 29 | template <class T> |
| 26 | std::vector<T> ReadArray(int panel, int offset, int size) { | 30 | std::vector<T> ReadArray(int panel, int offset, int size) { |
| 27 | return ReadData<T>({GLOBALS, 0x18, panel*8, offset, 0}, size); | 31 | return ReadData<T>({GLOBALS, 0x18, panel*8, offset, 0}, size); |
| @@ -48,9 +52,6 @@ public: | |||
| 48 | private: | 52 | private: |
| 49 | template<class T> | 53 | template<class T> |
| 50 | std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) { | 54 | std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) { |
| 51 | if (GetExitCodeProcess(_process) != STILL_ACTIVE) { | ||
| 52 | // Signal error, somehow | ||
| 53 | } | ||
| 54 | std::vector<T> data; | 55 | std::vector<T> data; |
| 55 | data.resize(numItems); | 56 | data.resize(numItems); |
| 56 | for (int i=0; i<5; i++) { | 57 | for (int i=0; i<5; i++) { |
| @@ -73,8 +74,8 @@ private: | |||
| 73 | ThrowError(); | 74 | ThrowError(); |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 77 | bool Initialize(const std::wstring& processName); | ||
| 76 | void ThrowError(); | 78 | void ThrowError(); |
| 77 | |||
| 78 | void* ComputeOffset(std::vector<int> offsets); | 79 | void* ComputeOffset(std::vector<int> offsets); |
| 79 | 80 | ||
| 80 | std::map<uintptr_t, uintptr_t> _computedAddresses; | 81 | std::map<uintptr_t, uintptr_t> _computedAddresses; |
