diff options
Diffstat (limited to 'WitnessRandomizer/Memory.h')
-rw-r--r-- | WitnessRandomizer/Memory.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/WitnessRandomizer/Memory.h b/WitnessRandomizer/Memory.h index 6b50948..6882c9c 100644 --- a/WitnessRandomizer/Memory.h +++ b/WitnessRandomizer/Memory.h | |||
@@ -17,18 +17,23 @@ public: | |||
17 | std::vector<T> ReadData(const std::vector<int>& offsets, int numItems) { | 17 | std::vector<T> ReadData(const std::vector<int>& offsets, int numItems) { |
18 | std::vector<T> data; | 18 | std::vector<T> data; |
19 | data.resize(numItems); | 19 | data.resize(numItems); |
20 | if (!ReadProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * numItems, NULL)) { | 20 | for (int i=0; i<5; i++) { |
21 | ThrowError(); | 21 | if (ReadProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * numItems, NULL)) |
22 | { | ||
23 | return data; | ||
24 | } | ||
22 | } | 25 | } |
23 | return data; | 26 | ThrowError(); |
24 | } | 27 | } |
25 | 28 | ||
26 | template <class T> | 29 | template <class T> |
27 | bool WriteData(const std::vector<int>& offsets, const std::vector<T>& data) { | 30 | void WriteData(const std::vector<int>& offsets, const std::vector<T>& data) { |
28 | if (!WriteProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), NULL)) { | 31 | for (int i=0; i<5; i++) { |
29 | return false; | 32 | if (WriteProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), NULL)) { |
33 | return; | ||
34 | } | ||
30 | } | 35 | } |
31 | return true; | 36 | ThrowError(); |
32 | } | 37 | } |
33 | 38 | ||
34 | private: | 39 | private: |