From 9a308dcf1b89653c865f0c7fbce8d52acc046035 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 19 Sep 2024 19:42:27 +0200 Subject: [PATCH] add timestamp to logs --- inc/utils.h | 1 + src/debug.c | 11 +++++++++++ src/dllmain.c | 1 - src/utils.c | 16 ++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/inc/utils.h b/inc/utils.h index 7f7b670e58..c7109665b0 100644 --- a/inc/utils.h +++ b/inc/utils.h @@ -7,6 +7,7 @@ HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast); void util_pull_messages(); +DWORD util_get_timestamp(HMODULE mod); FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name); BOOL util_caller_is_ddraw_wrapper(void* return_address); BOOL util_is_bad_read_ptr(void* p); diff --git a/src/debug.c b/src/debug.c index 5ee790efeb..a2f22135a5 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "ddraw.h" #include "dd.h" #include "ddsurface.h" @@ -11,6 +12,8 @@ #include "version.h" #include "git.h" #include "versionhelpers.h" +#include "utils.h" +#include "dllmain.h" double g_dbg_frame_time = 0; @@ -159,6 +162,8 @@ void dbg_init() GIT_COMMIT, GIT_BRANCH); + TRACE("cnc-ddraw = %p\n", g_ddraw_module); + HKEY hkey; LONG status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0L, KEY_READ, &hkey); @@ -196,6 +201,12 @@ void dbg_init() TRACE("Wine sysname = %s, release = %s\n", sysname, release); } + + DWORD timestamp = util_get_timestamp(GetModuleHandleA(NULL)); + if (timestamp) + { + TRACE("timestamp = %s", _ctime32((const long*)×tamp)); + } } } diff --git a/src/dllmain.c b/src/dllmain.c index d025eafb85..395608184e 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -42,7 +42,6 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) #ifdef _DEBUG dbg_init(); - TRACE("cnc-ddraw = %p\n", hDll); g_dbg_exception_filter = real_SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)dbg_exception_handler); #endif diff --git a/src/utils.c b/src/utils.c index e363c72ff2..3f22bb763c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -89,6 +89,22 @@ void util_pull_messages() } } +DWORD util_get_timestamp(HMODULE mod) +{ + if (!mod || mod == INVALID_HANDLE_VALUE) + return 0; + + PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)mod; + if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) + return 0; + + PIMAGE_NT_HEADERS nt_headers = (PIMAGE_NT_HEADERS)((DWORD)dos_header + (DWORD)dos_header->e_lfanew); + if (nt_headers->Signature != IMAGE_NT_SIGNATURE) + return 0; + + return nt_headers->FileHeader.TimeDateStamp; +} + FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name) { if (!mod || mod == INVALID_HANDLE_VALUE)