diff options
| author | jbzdarkid <jbzdarkid@gmail.com> | 2018-10-24 19:02:59 -0700 | 
|---|---|---|
| committer | jbzdarkid <jbzdarkid@gmail.com> | 2018-10-24 19:02:59 -0700 | 
| commit | 4f9229dfe609632a193ce515f8fa83b494948e48 (patch) | |
| tree | 650f18f0f088066cae7750b4c6a4628ce5db6cbf | |
| parent | 7298fedc9dc6170a47a489a7918de0f7361621dd (diff) | |
| download | witness-tutorializer-4f9229dfe609632a193ce515f8fa83b494948e48.tar.gz witness-tutorializer-4f9229dfe609632a193ce515f8fa83b494948e48.tar.bz2 witness-tutorializer-4f9229dfe609632a193ce515f8fa83b494948e48.zip | |
Better errors (?)
| -rw-r--r-- | WitnessRandomizer/Memory.cpp | 16 | 
1 files changed, 8 insertions, 8 deletions
| diff --git a/WitnessRandomizer/Memory.cpp b/WitnessRandomizer/Memory.cpp index f2bd8f1..7005455 100644 --- a/WitnessRandomizer/Memory.cpp +++ b/WitnessRandomizer/Memory.cpp | |||
| @@ -14,13 +14,13 @@ Memory::Memory(const std::string& processName) { | |||
| 14 | while (Process32Next(snapshot, &entry)) { | 14 | while (Process32Next(snapshot, &entry)) { | 
| 15 | if (processName == entry.szExeFile) { | 15 | if (processName == entry.szExeFile) { | 
| 16 | _handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); | 16 | _handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID); | 
| 17 | if (!_handle) { | ||
| 18 | std::cerr << "Couldn't find " << processName.c_str() << ". Is it open?" << std::endl; | ||
| 19 | exit(EXIT_FAILURE); | ||
| 20 | } | ||
| 21 | break; | 17 | break; | 
| 22 | } | 18 | } | 
| 23 | } | 19 | } | 
| 20 | if (!_handle) { | ||
| 21 | OutputDebugStringA("Process is not open!"); | ||
| 22 | exit(EXIT_FAILURE); | ||
| 23 | } | ||
| 24 | 24 | ||
| 25 | // Next, get the process base address | 25 | // Next, get the process base address | 
| 26 | DWORD numModules; | 26 | DWORD numModules; | 
| @@ -38,7 +38,7 @@ Memory::Memory(const std::string& processName) { | |||
| 38 | } | 38 | } | 
| 39 | } | 39 | } | 
| 40 | if (_baseAddress == 0) { | 40 | if (_baseAddress == 0) { | 
| 41 | std::cerr << "Couldn't find base address!" << std::endl; | 41 | OutputDebugStringA("Couldn't find base address!"); | 
| 42 | exit(EXIT_FAILURE); | 42 | exit(EXIT_FAILURE); | 
| 43 | } | 43 | } | 
| 44 | } | 44 | } | 
| @@ -50,9 +50,9 @@ Memory::~Memory() { | |||
| 50 | // Private methods: | 50 | // Private methods: | 
| 51 | 51 | ||
| 52 | void Memory::ThrowError() { | 52 | void Memory::ThrowError() { | 
| 53 | wchar_t message[256]; | 53 | std::string message(256, '\0'); | 
| 54 | FormatMessageW(4096, NULL, GetLastError(), 1024, message, 256, NULL); | 54 | FormatMessageA(4096, NULL, GetLastError(), 1024, &message[0], message.length(), NULL); | 
| 55 | std::cerr << message << std::endl; | 55 | OutputDebugStringA(message.c_str()); | 
| 56 | exit(EXIT_FAILURE); | 56 | exit(EXIT_FAILURE); | 
| 57 | } | 57 | } | 
| 58 | 58 | ||
