about summary refs log tree commit diff stats
path: root/Source/Memory.h
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-05 08:45:44 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-05 08:45:44 -0800
commite3758a15a6430e7ab7ce9821c0d9e19bbf7a1e87 (patch)
treef1d97e6b6947d601b309d44d60b47dea8cd19ddc /Source/Memory.h
parente2c0268d4b82e170605d9cc43e26be7f38f2eb54 (diff)
downloadwitness-tutorializer-e3758a15a6430e7ab7ce9821c0d9e19bbf7a1e87.tar.gz
witness-tutorializer-e3758a15a6430e7ab7ce9821c0d9e19bbf7a1e87.tar.bz2
witness-tutorializer-e3758a15a6430e7ab7ce9821c0d9e19bbf7a1e87.zip
Memory / Main are now cleaned up
Diffstat (limited to 'Source/Memory.h')
-rw-r--r--Source/Memory.h17
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
10enum 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
14class Memory { 20class Memory {
15public: 21public:
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:
48private: 52private:
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;