diff --git a/plugins/common/vc_crt_fix.asm b/plugins/common/vc_crt_fix.asm index a7eee05443..b9af5667c6 100644 --- a/plugins/common/vc_crt_fix.asm +++ b/plugins/common/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/plugins/common/vc_crt_fix_impl.cpp b/plugins/common/vc_crt_fix_impl.cpp index 7ad6fc7e72..b7e8bcdc4d 100644 --- a/plugins/common/vc_crt_fix_impl.cpp +++ b/plugins/common/vc_crt_fix_impl.cpp @@ -257,7 +257,7 @@ extern "C" BOOL WINAPI WRAPPER(GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_P { struct implementation { - static BOOL WINAPI impl(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD) + static BOOL WINAPI impl(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; @@ -272,7 +272,7 @@ extern "C" BOOL WINAPI WRAPPER(SetThreadStackGuarantee)(PULONG StackSizeInBytes) { struct implementation { - static BOOL WINAPI impl(PULONG) + static BOOL WINAPI impl(PULONG) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; @@ -317,7 +317,7 @@ extern "C" int WINAPI WRAPPER(CompareStringEx)(LPCWSTR LocaleName, DWORD CmpFlag { struct implementation { - static int WINAPI impl(LPCWSTR LocaleName, DWORD CmpFlags, LPCWCH String1, int Count1, LPCWCH String2, int Count2, LPNLSVERSIONINFO, LPVOID, LPARAM) + static int WINAPI impl(LPCWSTR LocaleName, DWORD CmpFlags, LPCWCH String1, int Count1, LPCWCH String2, int Count2, LPNLSVERSIONINFO, LPVOID, LPARAM) { return CompareStringW(locale_name_to_lcid(LocaleName), CmpFlags, String1, Count1, String2, Count2); } @@ -331,7 +331,7 @@ extern "C" int WINAPI WRAPPER(LCMapStringEx)(LPCWSTR LocaleName, DWORD MapFlags, { struct implementation { - static int WINAPI impl(LPCWSTR LocaleName, DWORD MapFlags, LPCWSTR SrcStr, int SrcCount, LPWSTR DestStr, int DestCount, LPNLSVERSIONINFO, LPVOID, LPARAM) + static int WINAPI impl(LPCWSTR LocaleName, DWORD MapFlags, LPCWSTR SrcStr, int SrcCount, LPWSTR DestStr, int DestCount, LPNLSVERSIONINFO, LPVOID, LPARAM) { return LCMapStringW(locale_name_to_lcid(LocaleName), MapFlags, SrcStr, SrcCount, DestStr, DestCount); } @@ -345,7 +345,7 @@ extern "C" BOOL WINAPI WRAPPER(SleepConditionVariableSRW)(PCONDITION_VARIABLE Co { struct implementation { - static BOOL WINAPI impl(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG) + static BOOL WINAPI impl(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; @@ -360,7 +360,7 @@ extern "C" void WINAPI WRAPPER(WakeAllConditionVariable)(PCONDITION_VARIABLE Con { struct implementation { - static void WINAPI impl(PCONDITION_VARIABLE) + static void WINAPI impl(PCONDITION_VARIABLE) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); } @@ -374,7 +374,7 @@ extern "C" void WINAPI WRAPPER(AcquireSRWLockExclusive)(PSRWLOCK SRWLock) { struct implementation { - static void WINAPI impl(PSRWLOCK) + static void WINAPI impl(PSRWLOCK) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); } @@ -388,7 +388,7 @@ extern "C" void WINAPI WRAPPER(ReleaseSRWLockExclusive)(PSRWLOCK SRWLock) { struct implementation { - static void WINAPI impl(PSRWLOCK) + static void WINAPI impl(PSRWLOCK) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); } @@ -400,23 +400,37 @@ extern "C" void WINAPI WRAPPER(ReleaseSRWLockExclusive)(PSRWLOCK SRWLock) // VC2022 extern "C" BOOLEAN WINAPI WRAPPER(TryAcquireSRWLockExclusive)(PSRWLOCK SRWLock) { - struct implementation - { - static BOOLEAN WINAPI impl(PSRWLOCK) - { - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; - } - }; - - CREATE_AND_RETURN(modules::kernel32, SRWLock); + struct implementation + { + static BOOLEAN WINAPI impl(PSRWLOCK) + { + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; + } + }; + + 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 { - static DWORD WINAPI impl(PFLS_CALLBACK_FUNCTION) + static DWORD WINAPI impl(PFLS_CALLBACK_FUNCTION) { return TlsAlloc(); } diff --git a/plugins/common/vc_crt_fix_ulink.cpp b/plugins/common/vc_crt_fix_ulink.cpp index e3af06eeda..9ca58d8cd6 100644 --- a/plugins/common/vc_crt_fix_ulink.cpp +++ b/plugins/common/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