From fe83d2bfb437a6727ca7265aca91e3b5219b2d83 Mon Sep 17 00:00:00 2001 From: Iouri Kharon Date: Sun, 5 Jan 2025 10:38:25 +0300 Subject: [PATCH] Update vc_crt_fix...'es (add stub for InitializeSRWLock needed for VS2019 CRTL, checked in NetBox) --- far/vc_crt_fix.asm | 1 + far/vc_crt_fix_impl.cpp | 14 ++++++++++++++ far/vc_crt_fix_ulink.cpp | 3 +++ 3 files changed, 18 insertions(+) diff --git a/far/vc_crt_fix.asm b/far/vc_crt_fix.asm index a7eee05443..b9af5667c6 100644 --- a/far/vc_crt_fix.asm +++ b/far/vc_crt_fix.asm @@ -71,5 +71,6 @@ HOOK ReleaseSRWLockExclusive , 4, :dword HOOK SleepConditionVariableSRW , 16, :dword, :dword, :dword, :dword HOOK WakeAllConditionVariable , 4, :dword HOOK TryAcquireSRWLockExclusive , 4, :dword +HOOK InitializeSRWLock , 4, :dword end diff --git a/far/vc_crt_fix_impl.cpp b/far/vc_crt_fix_impl.cpp index 3825f50dac..b7e8bcdc4d 100644 --- a/far/vc_crt_fix_impl.cpp +++ b/far/vc_crt_fix_impl.cpp @@ -412,6 +412,20 @@ extern "C" BOOLEAN WINAPI WRAPPER(TryAcquireSRWLockExclusive)(PSRWLOCK SRWLock) CREATE_AND_RETURN(modules::kernel32, SRWLock); } +// VC2019 +extern "C" void WINAPI WRAPPER(InitializeSRWLock)(PSRWLOCK SRWLock) +{ + struct implementation + { + static void WINAPI impl(PSRWLOCK SRWLock) + { + *(void**)SRWLock = 0; + } + }; + + CREATE_AND_RETURN(modules::kernel32, SRWLock); +} + extern "C" DWORD WINAPI WRAPPER(FlsAlloc)(PFLS_CALLBACK_FUNCTION Callback) { struct implementation diff --git a/far/vc_crt_fix_ulink.cpp b/far/vc_crt_fix_ulink.cpp index e3af06eeda..9ca58d8cd6 100644 --- a/far/vc_crt_fix_ulink.cpp +++ b/far/vc_crt_fix_ulink.cpp @@ -146,6 +146,8 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify, return (FARPROC)sim__unimpl_1arg; if(!lstrcmpA(pdli->dlp.szProcName, "TryAcquireSRWLockExclusive")) return (FARPROC)sim__unimpl_1arg; + if(!lstrcmpA(pdli->dlp.szProcName, "InitializeSRWLock")) + return (FARPROC)sim__unimpl_1arg; } return nullptr; } @@ -166,6 +168,7 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify, #pragma comment(linker, "/delayload:kernel32.ReleaseSRWLockExclusive") #pragma comment(linker, "/delayload:kernel32.AcquireSRWLockExclusive") #pragma comment(linker, "/delayload:kernel32.TryAcquireSRWLockExclusive") +#pragma comment(linker, "/delayload:kernel32.InitializeSRWLock") //---------------------------------------------------------------------------- #if _MSC_FULL_VER >= 190024215 // VS2015sp3