summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--WitnessRandomizer/Memory.cpp16
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
52void Memory::ThrowError() { 52void 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