From 5914164fb7f2a34877091684592d628344d0eab5 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 5 Apr 2025 00:53:33 +0100 Subject: Remove Wer* calls that crash under Wine/Proton Wine doesn't implement these it seems. Not sure why this crashed as opposed to just failing to load sst.dll but I guess it doesn't matter. This also improves compat with very old Windows 10 builds, to the extent that we really care about those which I guess we don't really, but still, it can't hurt. I did also try dynamically loading the symbols but at that point it just started crashing on unload on Windows as well. No idea what's going on there, but whatever, it's not that important, just get rid of it. --- src/ac.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ac.c b/src/ac.c index ad0cc0e..e9864a6 100644 --- a/src/ac.c +++ b/src/ac.c @@ -19,7 +19,6 @@ #ifdef _WIN32 #include -#include #else #include #endif @@ -237,7 +236,8 @@ bool ac_enable() { inhook_start(&sig); fastspin_wait(&sig); if_cold (sig == 2) { // else 1 for success - con_warn("** sst: ERROR starting message loop, can't continue! **"); + con_warn("** sst: ERROR starting message loop, " + "can't continue! **"); CloseHandle(inhookthr); return false; } @@ -256,11 +256,9 @@ HANDLE_EVENT(Tick, bool simulating) { } void ac_disable() { - if (enabled) { #ifdef _WIN32 - inhook_stop(); + if (enabled) inhook_stop(); #endif - } enabled = false; } @@ -333,6 +331,7 @@ static bool find_Key_Event() { } errmsg_errorx("couldn't find pointer to CGame instance"); return false; + ok: insns = (const uchar *)VFUNC(cgame, DispatchAllStoredGameMessages); for (const uchar *p = insns; p - insns < 128;) { if (p[0] == X86_CALL) { @@ -343,8 +342,8 @@ ok: insns = (const uchar *)VFUNC(cgame, DispatchAllStoredGameMessages); } errmsg_errorx("couldn't find DispatchInputEvent/Key_Event function"); return false; -ok2: - insns = (const uchar *)orig_Key_Event; + +ok2:insns = (const uchar *)orig_Key_Event; // Depending on compiler inlining decisions, the function we just found can // be either DispatchInputEvent or Key_Event. If another CALL is found at // the start of this function, that means that we actually found @@ -364,7 +363,7 @@ ok2: } HANDLE_EVENT(AllowPluginLoading, bool loading) { - if_cold(enabled) if_hot(demorec_demonum() != -1) { + if_cold (enabled) if_hot (demorec_demonum() != -1) { con_warn("sst: plugins cannot be %s while recording a run\n", loading ? "loaded" : "unloaded"); return false; @@ -396,12 +395,7 @@ INIT { } if_cold (!VirtualLock(keybox, 4096)) { errmsg_errorsys("couldn't secure session state"); - goto e2; - } - if_cold (WerRegisterExcludedMemoryBlock(keybox, 4096) != S_OK) { - // FIXME: stringify errors properly here - errmsg_errorx("couldn't secure session state"); - goto e2; + goto e; } if_cold (!win32_init()) goto e; #else @@ -432,8 +426,7 @@ INIT { return FEAT_OK; #ifdef _WIN32 -e: WerUnregisterExcludedMemoryBlock(keybox); // this'd better not fail! -e2: VirtualFree(keybox, 4096, MEM_RELEASE); +e: VirtualFree(keybox, 4096, MEM_RELEASE); #else e: munmap(keybox, 4096); #endif @@ -442,10 +435,9 @@ e: munmap(keybox, 4096); } END { + // TODO(opt): *maybe* do the skip-on-quit stuff here. feels a bit scary... ac_disable(); #if defined(_WIN32) - // TODO(opt): *maybe* do the skip-on-quit stuff here. feels a bit scary... - WerUnregisterExcludedMemoryBlock(keybox); // this'd better not fail! VirtualFree(keybox, 4096, MEM_RELEASE); win32_end(); #else -- cgit v1.2.3-54-g00ecf