diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2018-12-02 18:06:46 -0800 |
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-12-02 18:06:46 -0800 |
| commit | f485927337c329a4a691500a1b6c18c763863bb4 (patch) | |
| tree | b1be239617439e0283a88af0cd253620084a5c76 /Source/Memory.cpp | |
| parent | 53bf008124d496c728099520dd2a9e06b6767ea1 (diff) | |
| download | witness-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.cpp | 13 |
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 | ||
| 44 | Memory::~Memory() { | 49 | Memory::~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 | ||
| 66 | void 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 | |||
| 61 | void Memory::ThrowError() { | 74 | void 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); |
