summary refs log tree commit diff stats
path: root/Source/Memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Memory.cpp')
-rw-r--r--Source/Memory.cpp22
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
190uintptr_t Memory::Allocate(size_t bytes) { 195uintptr_t Memory::Allocate(size_t bytes) {
196/*
197uintptr_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
204void 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