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

add crc32 to logs

This commit is contained in:
FunkyFr3sh 2024-09-23 15:21:32 +02:00
parent 9fb97bf1ca
commit db9cfb8e29
3 changed files with 33 additions and 0 deletions

View File

@ -7,6 +7,7 @@
HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast);
void util_pull_messages();
unsigned long util_get_crc32(char* filename);
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);

View File

@ -202,6 +202,8 @@ void dbg_init()
TRACE("Wine sysname = %s, release = %s\n", sysname, release);
}
TRACE("crc32 = %08X\n", util_get_crc32(exe_path));
DWORD timestamp = util_get_timestamp(GetModuleHandleA(NULL));
if (timestamp)
{

View File

@ -1,5 +1,6 @@
#include <windows.h>
#include <intrin.h>
#include <stdio.h>
#include <math.h>
#include "ddraw.h"
#include "debug.h"
@ -11,6 +12,7 @@
#include "utils.h"
#include "config.h"
#include "versionhelpers.h"
#include "crc32.h"
/*
@ -105,6 +107,34 @@ DWORD util_get_timestamp(HMODULE mod)
return nt_headers->FileHeader.TimeDateStamp;
}
unsigned long util_get_crc32(char* filename)
{
if (!filename)
return 0;
unsigned long crc32 = 0;
FILE* fp = fopen(filename, "rb");
if (fp)
{
char buf[1024];
for (size_t s = 0; (s = fread(buf, 1, sizeof(buf), fp));)
{
if (ferror(fp))
{
crc32 = 0;
break;
}
crc32 = Crc32_ComputeBuf(crc32, buf, s);
}
fclose(fp);
}
return crc32;
}
FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
{
if (!mod || mod == INVALID_HANDLE_VALUE)