diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-18 08:43:27 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-18 08:43:27 -0800 |
commit | 695d0e12950b9df248ea7b84f8434e32acc84f11 (patch) | |
tree | 69ac20d6a4681fe517033a8c9210d4996a91a5d1 /Source/Memory.cpp | |
parent | 133975b5a2ceca273182829f2f11042a5276c2f0 (diff) | |
download | witness-tutorializer-695d0e12950b9df248ea7b84f8434e32acc84f11.tar.gz witness-tutorializer-695d0e12950b9df248ea7b84f8434e32acc84f11.tar.bz2 witness-tutorializer-695d0e12950b9df248ea7b84f8434e32acc84f11.zip |
actually free memory
Diffstat (limited to 'Source/Memory.cpp')
-rw-r--r-- | Source/Memory.cpp | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/Source/Memory.cpp b/Source/Memory.cpp index 26ef7e4..55ef18a 100644 --- a/Source/Memory.cpp +++ b/Source/Memory.cpp | |||
@@ -192,36 +192,3 @@ void* Memory::ComputeOffset(std::vector<int> offsets) { | |||
192 | } | 192 | } |
193 | return reinterpret_cast<void*>(cumulativeAddress + final_offset); | 193 | return reinterpret_cast<void*>(cumulativeAddress + final_offset); |
194 | } | 194 | } |
195 | |||
196 | uintptr_t Memory::Allocate(size_t bytes) { | ||
197 | /* | ||
198 | uintptr_t ForeignProcessMemory::AllocateMemory(size_t Size, DWORD Flags) const { | ||
199 | if (!ProcessHandle) { | ||
200 | return 0; | ||
201 | } | ||
202 | return (uintptr_t)VirtualAllocEx(ProcessHandle, nullptr, Size, MEM_RESERVE | MEM_COMMIT, Flags); | ||
203 | } | ||
204 | |||
205 | void ForeignProcessMemory::DeallocateMemory(uintptr_t Addr) const { | ||
206 | if (!ProcessHandle || Addr == 0) { | ||
207 | return; | ||
208 | } | ||
209 | VirtualFreeEx(ProcessHandle, (void*)Addr, 0, MEM_RELEASE); | ||
210 | } | ||
211 | */ | ||
212 | uintptr_t current = _freeMem; | ||
213 | _freeMem += bytes; | ||
214 | |||
215 | if (_freeMem > _freeMemEnd) { | ||
216 | // If we don't have enough space at our current location, go allocate some more space. | ||
217 | // Note that the remaining space in our current page is unused. Oh well. | ||
218 | _freeMem = reinterpret_cast<uintptr_t>(::VirtualAllocEx(_handle, NULL, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)); | ||
219 | _freeMemEnd = _freeMem + 0x1000; | ||
220 | |||
221 | current = _freeMem; | ||
222 | _freeMem += bytes; | ||
223 | assert(_freeMem <= _freeMemEnd); // Don't allocate data > 0x1000 at a time. Duh. | ||
224 | } | ||
225 | |||
226 | return current; | ||
227 | } | ||