Changeset - r25627:a3297d91e516
[Not reviewed]
master
0 2 0
glx22 - 3 years ago 2021-05-20 16:28:14
glx@openttd.org
Codechange: [WIN32] Reduce manual dynamic loading as WinXP is the minimum version
2 files changed with 6 insertions and 9 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -351,31 +351,33 @@ if(NOT GLOBAL_DIR STREQUAL "(not set)")
 
    )
 
endif()
 

	
 
link_package(SSE)
 

	
 
add_definitions_based_on_options()
 

	
 
if(WIN32)
 
    add_definitions(
 
        -DUNICODE
 
        -D_UNICODE
 
        -DWITH_UNISCRIBE
 
        -DPSAPI_VERSION=1
 
    )
 

	
 
    target_link_libraries(openttd
 
        ws2_32
 
        winmm
 
        imm32
 
        usp10
 
        psapi
 
    )
 
endif()
 

	
 
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
 
    add_definitions(-DPOINTER_IS_64BIT)
 
endif()
 

	
 
include(CreateRegression)
 
create_regression()
 

	
 
if(APPLE OR WIN32)
 
    find_package(Pandoc)
src/os/windows/crashlog_win.cpp
Show inline comments
 
@@ -13,24 +13,25 @@
 
#include "../../core/alloc_func.hpp"
 
#include "../../core/math_func.hpp"
 
#include "../../string_func.h"
 
#include "../../fileio_func.h"
 
#include "../../strings_func.h"
 
#include "../../gamelog.h"
 
#include "../../saveload/saveload.h"
 
#include "../../video/video_driver.hpp"
 

	
 
#include <windows.h>
 
#include <mmsystem.h>
 
#include <signal.h>
 
#include <psapi.h>
 

	
 
#include "../../safeguards.h"
 

	
 
/* printf format specification for 32/64-bit addresses. */
 
#ifdef _M_AMD64
 
#define PRINTF_PTR "0x%016IX"
 
#else
 
#define PRINTF_PTR "0x%08X"
 
#endif
 

	
 
/**
 
 * Windows implementation for the crash logger.
 
@@ -197,45 +198,39 @@ static char *PrintModuleInfo(char *outpu
 
		dfi.file_time.wMonth,
 
		dfi.file_time.wDay,
 
		dfi.file_time.wHour,
 
		dfi.file_time.wMinute,
 
		dfi.file_time.wSecond
 
	);
 
	return output;
 
}
 

	
 
/* virtual */ char *CrashLogWindows::LogModules(char *output, const char *last) const
 
{
 
	MakeCRCTable(AllocaM(uint32, 256));
 
	BOOL (WINAPI *EnumProcessModules)(HANDLE, HMODULE*, DWORD, LPDWORD);
 

	
 
	output += seprintf(output, last, "Module information:\n");
 

	
 
	if (LoadLibraryList((Function*)&EnumProcessModules, "psapi.dll\0EnumProcessModules\0\0")) {
 
		HMODULE modules[100];
 
		DWORD needed;
 
		BOOL res;
 

	
 
		HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
 
		if (proc != nullptr) {
 
			res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
 
		HMODULE modules[100];
 
		DWORD needed;
 
		BOOL res = EnumProcessModules(proc, modules, sizeof(modules), &needed);
 
			CloseHandle(proc);
 
			if (res) {
 
				size_t count = std::min<DWORD>(needed / sizeof(HMODULE), lengthof(modules));
 

	
 
				for (size_t i = 0; i != count; i++) output = PrintModuleInfo(output, last, modules[i]);
 
				return output + seprintf(output, last, "\n");
 
			}
 
		}
 
	}
 
	output = PrintModuleInfo(output, last, nullptr);
 
	return output + seprintf(output, last, "\n");
 
}
 

	
 
/* virtual */ char *CrashLogWindows::LogRegisters(char *buffer, const char *last) const
 
{
 
	buffer += seprintf(buffer, last, "Registers:\n");
 
#ifdef _M_AMD64
 
	buffer += seprintf(buffer, last,
 
		" RAX: %.16I64X RBX: %.16I64X RCX: %.16I64X RDX: %.16I64X\n"
 
		" RSI: %.16I64X RDI: %.16I64X RBP: %.16I64X RSP: %.16I64X\n"
 
		" R8:  %.16I64X R9:  %.16I64X R10: %.16I64X R11: %.16I64X\n"
0 comments (0 inline, 0 general)