Skip to content

Commit

Permalink
Update vc_crt_fix_ulink
Browse files Browse the repository at this point in the history
  • Loading branch information
yjh-styx committed Dec 27, 2024
1 parent bbf3e9b commit 6e5828a
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions far/vc_crt_fix_ulink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ static int WINAPI sim_CompareStringEx(LPCWSTR, DWORD flg, LPCWCH s1, int c1,
return CompareStringW(LOCALE_USER_DEFAULT, flg, s1, c1, s2, c2);
}

//----------------------------------------------------------------------------
static DWORD WINAPI sim_FlsAlloc(PFLS_CALLBACK_FUNCTION)
{
return TlsAlloc();
}

//----------------------------------------------------------------------------
static BOOL WINAPI sim_SleepConditionVariableSRW(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}

//----------------------------------------------------------------------------
static void WINAPI sim__unimpl_1arg(PVOID)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
}

//----------------------------------------------------------------------------
static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
PDelayLoadInfo pdli)
Expand All @@ -104,6 +123,22 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
return (FARPROC)sim_LCMapStringEx;
if(!lstrcmpA(pdli->dlp.szProcName, "CompareStringEx"))
return (FARPROC)sim_CompareStringEx;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsAlloc"))
return (FARPROC)sim_FlsAlloc;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsFree"))
return (FARPROC)TlsFree;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsGetValue"))
return (FARPROC)TlsGetValue;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsSetValue"))
return (FARPROC)TlsSetValue;
if(!lstrcmpA(pdli->dlp.szProcName, "SleepConditionVariableSRW"))
return (FARPROC)sim_SleepConditionVariableSRW;
if(!lstrcmpA(pdli->dlp.szProcName, "WakeAllConditionVariable"))
return (FARPROC)sim__unimpl_1arg;
if(!lstrcmpA(pdli->dlp.szProcName, "ReleaseSRWLockExclusive"))
return (FARPROC)sim__unimpl_1arg;
if(!lstrcmpA(pdli->dlp.szProcName, "AcquireSRWLockExclusive"))
return (FARPROC)sim__unimpl_1arg;
}
return nullptr;
}
Expand All @@ -113,6 +148,14 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
#pragma comment(linker, "/delayload:kernel32.CompareStringEx")
#pragma comment(linker, "/delayload:kernel32.LCMapStringEx")
#pragma comment(linker, "/delayload:kernel32.InitializeCriticalSectionEx")
#pragma comment(linker, "/delayload:kernel32.FlsAlloc")
#pragma comment(linker, "/delayload:kernel32.FlsFree")
#pragma comment(linker, "/delayload:kernel32.FlsGetValue")
#pragma comment(linker, "/delayload:kernel32.FlsSetValue")
#pragma comment(linker, "/delayload:kernel32.SleepConditionVariableSRW")
#pragma comment(linker, "/delayload:kernel32.WakeAllConditionVariable")
#pragma comment(linker, "/delayload:kernel32.ReleaseSRWLockExclusive")
#pragma comment(linker, "/delayload:kernel32.AcquireSRWLockExclusive")

//----------------------------------------------------------------------------
#if _MSC_FULL_VER >= 190024215 // VS2015sp3
Expand Down
43 changes: 43 additions & 0 deletions plugins/common/vc_crt_fix_ulink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ static int WINAPI sim_CompareStringEx(LPCWSTR, DWORD flg, LPCWCH s1, int c1,
return CompareStringW(LOCALE_USER_DEFAULT, flg, s1, c1, s2, c2);
}

//----------------------------------------------------------------------------
static DWORD WINAPI sim_FlsAlloc(PFLS_CALLBACK_FUNCTION)
{
return TlsAlloc();
}

//----------------------------------------------------------------------------
static BOOL WINAPI sim_SleepConditionVariableSRW(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}

//----------------------------------------------------------------------------
static void WINAPI sim__unimpl_1arg(PVOID)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
}

//----------------------------------------------------------------------------
static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
PDelayLoadInfo pdli)
Expand All @@ -104,6 +123,22 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
return (FARPROC)sim_LCMapStringEx;
if(!lstrcmpA(pdli->dlp.szProcName, "CompareStringEx"))
return (FARPROC)sim_CompareStringEx;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsAlloc"))
return (FARPROC)sim_FlsAlloc;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsFree"))
return (FARPROC)TlsFree;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsGetValue"))
return (FARPROC)TlsGetValue;
if(!lstrcmpA(pdli->dlp.szProcName, "FlsSetValue"))
return (FARPROC)TlsSetValue;
if(!lstrcmpA(pdli->dlp.szProcName, "SleepConditionVariableSRW"))
return (FARPROC)sim_SleepConditionVariableSRW;
if(!lstrcmpA(pdli->dlp.szProcName, "WakeAllConditionVariable"))
return (FARPROC)sim__unimpl_1arg;
if(!lstrcmpA(pdli->dlp.szProcName, "ReleaseSRWLockExclusive"))
return (FARPROC)sim__unimpl_1arg;
if(!lstrcmpA(pdli->dlp.szProcName, "AcquireSRWLockExclusive"))
return (FARPROC)sim__unimpl_1arg;
}
return nullptr;
}
Expand All @@ -113,6 +148,14 @@ static FARPROC WINAPI delayFailureHook(/*dliNotification*/unsigned dliNotify,
#pragma comment(linker, "/delayload:kernel32.CompareStringEx")
#pragma comment(linker, "/delayload:kernel32.LCMapStringEx")
#pragma comment(linker, "/delayload:kernel32.InitializeCriticalSectionEx")
#pragma comment(linker, "/delayload:kernel32.FlsAlloc")
#pragma comment(linker, "/delayload:kernel32.FlsFree")
#pragma comment(linker, "/delayload:kernel32.FlsGetValue")
#pragma comment(linker, "/delayload:kernel32.FlsSetValue")
#pragma comment(linker, "/delayload:kernel32.SleepConditionVariableSRW")
#pragma comment(linker, "/delayload:kernel32.WakeAllConditionVariable")
#pragma comment(linker, "/delayload:kernel32.ReleaseSRWLockExclusive")
#pragma comment(linker, "/delayload:kernel32.AcquireSRWLockExclusive")

//----------------------------------------------------------------------------
#if _MSC_FULL_VER >= 190024215 // VS2015sp3
Expand Down

0 comments on commit 6e5828a

Please sign in to comment.