diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-16 14:22:39 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-16 14:22:39 -0800 |
commit | fc8649b12fc1280d81e8dd4d35736ed69c0d9909 (patch) | |
tree | 7d6686c82dd6d738bdb54eb54d9989a4549cfdb5 /Source/Memory.cpp | |
parent | 039b48fe49c31f6033a17aabab353b7b7696e11b (diff) | |
download | witness-tutorializer-fc8649b12fc1280d81e8dd4d35736ed69c0d9909.tar.gz witness-tutorializer-fc8649b12fc1280d81e8dd4d35736ed69c0d9909.tar.bz2 witness-tutorializer-fc8649b12fc1280d81e8dd4d35736ed69c0d9909.zip |
Keep WIP
Diffstat (limited to 'Source/Memory.cpp')
-rw-r--r-- | Source/Memory.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Source/Memory.cpp b/Source/Memory.cpp index bc0725b..e240b90 100644 --- a/Source/Memory.cpp +++ b/Source/Memory.cpp | |||
@@ -170,7 +170,10 @@ void* Memory::ComputeOffset(std::vector<int> offsets) { | |||
170 | cumulativeAddress += offset; | 170 | cumulativeAddress += offset; |
171 | 171 | ||
172 | const auto search = _computedAddresses.find(cumulativeAddress); | 172 | const auto search = _computedAddresses.find(cumulativeAddress); |
173 | if (search == std::end(_computedAddresses)) { | 173 | // This is an issue with re-randomization. Always. Just disable it in debug mode! |
174 | #ifdef NDEBUG | ||
175 | if (search == std::end(_computedAddresses)) { | ||
176 | #endif | ||
174 | // If the address is not yet computed, then compute it. | 177 | // If the address is not yet computed, then compute it. |
175 | uintptr_t computedAddress = 0; | 178 | uintptr_t computedAddress = 0; |
176 | if (bool result = !ReadProcessMemory(_handle, reinterpret_cast<LPVOID>(cumulativeAddress), &computedAddress, sizeof(uintptr_t), NULL)) { | 179 | if (bool result = !ReadProcessMemory(_handle, reinterpret_cast<LPVOID>(cumulativeAddress), &computedAddress, sizeof(uintptr_t), NULL)) { |
@@ -180,7 +183,9 @@ void* Memory::ComputeOffset(std::vector<int> offsets) { | |||
180 | ThrowError(); | 183 | ThrowError(); |
181 | } | 184 | } |
182 | _computedAddresses[cumulativeAddress] = computedAddress; | 185 | _computedAddresses[cumulativeAddress] = computedAddress; |
186 | #ifdef NDEBUG | ||
183 | } | 187 | } |
188 | #endif | ||
184 | 189 | ||
185 | cumulativeAddress = _computedAddresses[cumulativeAddress]; | 190 | cumulativeAddress = _computedAddresses[cumulativeAddress]; |
186 | } | 191 | } |
@@ -188,6 +193,21 @@ void* Memory::ComputeOffset(std::vector<int> offsets) { | |||
188 | } | 193 | } |
189 | 194 | ||
190 | uintptr_t Memory::Allocate(size_t bytes) { | 195 | uintptr_t Memory::Allocate(size_t bytes) { |
196 | /* | ||
197 | uintptr_t ForeignProcessMemory::AllocateMemory(size_t Size, DWORD Flags) const { | ||
198 | if (!ProcessHandle) { | ||
199 | return 0; | ||
200 | } | ||
201 | return (uintptr_t)VirtualAllocEx(ProcessHandle, nullptr, Size, MEM_RESERVE | MEM_COMMIT, Flags); | ||
202 | } | ||
203 | |||
204 | void ForeignProcessMemory::DeallocateMemory(uintptr_t Addr) const { | ||
205 | if (!ProcessHandle || Addr == 0) { | ||
206 | return; | ||
207 | } | ||
208 | VirtualFreeEx(ProcessHandle, (void*)Addr, 0, MEM_RELEASE); | ||
209 | } | ||
210 | */ | ||
191 | uintptr_t current = _freeMem; | 211 | uintptr_t current = _freeMem; |
192 | _freeMem += bytes; | 212 | _freeMem += bytes; |
193 | 213 | ||