diff options
Diffstat (limited to 'src/utils.c')
| -rw-r--r-- | src/utils.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/utils.c b/src/utils.c index de719e9..440b9fb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,9 +1,7 @@ -#if defined (_DEBUG) -#define assert(x) if (!(x)) __debugbreak(); -#else -#define assert(x) (x) -#endif -void print(const char* format, ...); +#include "utils.h" + +#include <Windows.h> +#include <strsafe.h> u8 is_alpha(char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); @@ -155,3 +153,13 @@ void print(const char* format, ...) { StringCchLengthA(formatted_str, sizeof(formatted_str), &length); SUCCEEDED(WriteFile(standard_err, formatted_str, (DWORD)length, NULL, NULL)); } + +/* Read debugged process memory at address */ +u8 read_memory(const void* addr, void* buffer, size_t size) { + extern PROCESS_INFORMATION proc_info; + + size_t b_read = 0U; + HRESULT hr = ReadProcessMemory(proc_info.hProcess, addr, buffer, size, &b_read); + + return hr > 0 && b_read == size; +} |
