Skip to content

Commit

Permalink
Update vc_crt_fix...'es (add stub for InitializeSRWLock) for plugin's…
Browse files Browse the repository at this point in the history
… also
  • Loading branch information
yjh-styx committed Jan 5, 2025
1 parent fe83d2b commit a010fc7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
1 change: 1 addition & 0 deletions plugins/common/vc_crt_fix.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
52 changes: 33 additions & 19 deletions plugins/common/vc_crt_fix_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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();
}
Expand Down
3 changes: 3 additions & 0 deletions plugins/common/vc_crt_fix_ulink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit a010fc7

Please sign in to comment.