1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

add timestamp to logs

This commit is contained in:
FunkyFr3sh 2024-09-19 19:42:27 +02:00
parent 892494718a
commit 9a308dcf1b
4 changed files with 28 additions and 1 deletions

View File

@ -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);

View File

@ -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"
@ -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*)&timestamp));
}
}
}

View File

@ -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

View File

@ -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)