Skip to content

Commit

Permalink
add timestamp to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Sep 19, 2024
1 parent 8924947 commit 9a308dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <dbghelp.h>
#include <stdio.h>
#include <d3d9.h>
#include <time.h>
#include "ddraw.h"
#include "dd.h"
#include "ddsurface.h"
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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*)&timestamp));
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9a308dc

Please sign in to comment.