summary refs log tree commit diff stats
path: root/Source/Memory.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-12-02 18:06:46 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2018-12-02 18:06:46 -0800
commitf485927337c329a4a691500a1b6c18c763863bb4 (patch)
treeb1be239617439e0283a88af0cd253620084a5c76 /Source/Memory.cpp
parent53bf008124d496c728099520dd2a9e06b6767ea1 (diff)
downloadwitness-tutorializer-f485927337c329a4a691500a1b6c18c763863bb4.tar.gz
witness-tutorializer-f485927337c329a4a691500a1b6c18c763863bb4.tar.bz2
witness-tutorializer-f485927337c329a4a691500a1b6c18c763863bb4.zip
moved sigscans & wired up hotel + wonkavator
Diffstat (limited to 'Source/Memory.cpp')
-rw-r--r--Source/Memory.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Memory.cpp b/Source/Memory.cpp index 825346a..43cb9b3 100644 --- a/Source/Memory.cpp +++ b/Source/Memory.cpp
@@ -39,6 +39,11 @@ Memory::Memory(const std::string& processName) {
39 if (_baseAddress == 0) { 39 if (_baseAddress == 0) {
40 throw std::exception("Couldn't find the base process address!"); 40 throw std::exception("Couldn't find the base process address!");
41 } 41 }
42
43 // Unprotect regions of memory
44
45 DWORD oldProtect;
46 VirtualProtectEx(_handle, (LPVOID)_baseAddress, sizeof(DWORD), PAGE_READWRITE, &oldProtect);
42} 47}
43 48
44Memory::~Memory() { 49Memory::~Memory() {
@@ -58,6 +63,14 @@ int Memory::GetCurrentFrame()
58 return ReadData<int>({SCRIPT_FRAMES}, 1)[0]; 63 return ReadData<int>({SCRIPT_FRAMES}, 1)[0];
59} 64}
60 65
66void Memory::SigScan(std::function<void(int offset, const std::vector<byte>& data)> scanFunc)
67{
68 for (int i=0; i<0x200000; i+=0x1000) {
69 std::vector<byte> data = ReadData<byte>({i}, 0x1100);
70 scanFunc(i, data);
71 }
72}
73
61void Memory::ThrowError() { 74void Memory::ThrowError() {
62 std::string message(256, '\0'); 75 std::string message(256, '\0');
63 int length = FormatMessageA(4096, nullptr, GetLastError(), 1024, &message[0], static_cast<DWORD>(message.size()), nullptr); 76 int length = FormatMessageA(4096, nullptr, GetLastError(), 1024, &message[0], static_cast<DWORD>(message.size()), nullptr);