From 6c69ae0fc3ec7453bb4c0119bc23b7449526be74 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Tue, 21 Jan 2025 23:22:56 +0100 Subject: Stack walking --- src/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index e71b1b7..32e4fa8 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,9 @@ #include "types.h" #include "utils.c" +#include "hashmap.c" + +extern u32 _fltused = TRUE; static HANDLE h_input = NULL; static HANDLE h_output = NULL; @@ -15,6 +18,10 @@ static DWORD continue_status = DBG_EXCEPTION_NOT_HANDLED; static DEBUG_EVENT dbg_event; static PROCESS_INFORMATION proc_info = { 0 }; +// TODO: Perfect hashing table ? +u8* string_stack_base = NULL; +u8* string_stack_current = NULL; + /* Read debugged process memory at address */ u8 read_memory(const void* addr, void* buffer, size_t size) { size_t b_read = 0U; @@ -24,6 +31,7 @@ u8 read_memory(const void* addr, void* buffer, size_t size) { } #include "module.c" +#include "stack_walk.c" #include "parser.c" #include "pdb.c" #include "events.c" @@ -80,12 +88,14 @@ void dbg_loop() { int mainCRTStartup() { - STARTUPINFOW startup_info = { 0 }; + string_stack_current = string_stack_base = VirtualAlloc(NULL, 4096U * 16U, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + + STARTUPINFOA startup_info = { 0 }; startup_info.cb = sizeof(startup_info); - BOOL ret = CreateProcessW( + BOOL ret = CreateProcessA( NULL, - L"./test.exe", + "./test.exe", NULL, NULL, FALSE, -- cgit v1.3