Skip to content

Commit

Permalink
Update vc_crt_fix...'es (add stub for InitializeSRWLock needed for VS…
Browse files Browse the repository at this point in the history
…2019 CRTL, checked in NetBox)
  • Loading branch information
yjh-styx committed Jan 5, 2025
1 parent 689e75f commit fe83d2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions far/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
14 changes: 14 additions & 0 deletions far/vc_crt_fix_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions far/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 fe83d2b

Please sign in to comment.