mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
The point of kernel32_vista was to provide a dll that can be used for winesyncs to still have NT6 APIs. We're now switching to an architecture where we'll have kernelbase OR a kernel32_win7 depending on NT target compile but this means that for an ANSI exe such as this, we need an alternative solution. Thankfully it's pretty much only for this but just in case i made it a library.
170 lines
3.8 KiB
C
170 lines
3.8 KiB
C
/*
|
|
* This file exists due to some apps (e.g) nfsd.exe not suporting
|
|
* UNICODE This provides all the needed ANSI NT6 support while still allowing it to build on
|
|
* NT5.x builds.
|
|
*/
|
|
#define _KERNEL32_
|
|
|
|
/* PSDK/NDK Headers */
|
|
#define WIN32_NO_STATUS
|
|
#include <windef.h>
|
|
#include <winbase.h>
|
|
|
|
/* Redefine NTDDI_VERSION to 2K3 SP1 to get correct NDK definitions */
|
|
#undef NTDDI_VERSION
|
|
#define NTDDI_VERSION NTDDI_WS03SP1
|
|
|
|
#define NTOS_MODE_USER
|
|
#include <ndk/iofuncs.h>
|
|
#include <ndk/kefuncs.h>
|
|
#include <ndk/obfuncs.h>
|
|
#include <ndk/psfuncs.h>
|
|
#include <ndk/rtlfuncs.h>
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
VOID
|
|
WINAPI
|
|
AcquireSRWLockExclusive(PSRWLOCK Lock)
|
|
{
|
|
RtlAcquireSRWLockExclusive((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
AcquireSRWLockShared(PSRWLOCK Lock)
|
|
{
|
|
RtlAcquireSRWLockShared((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
InitializeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlInitializeConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
InitializeSRWLock(PSRWLOCK Lock)
|
|
{
|
|
RtlInitializeSRWLock((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
ReleaseSRWLockExclusive(PSRWLOCK Lock)
|
|
{
|
|
RtlReleaseSRWLockExclusive((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
ReleaseSRWLockShared(PSRWLOCK Lock)
|
|
{
|
|
RtlReleaseSRWLockShared((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
FORCEINLINE
|
|
PLARGE_INTEGER
|
|
GetNtTimeout(PLARGE_INTEGER Time, DWORD Timeout)
|
|
{
|
|
if (Timeout == INFINITE) return NULL;
|
|
Time->QuadPart = (ULONGLONG)Timeout * -10000;
|
|
return Time;
|
|
}
|
|
|
|
BOOL
|
|
WINAPI
|
|
SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTION CriticalSection, DWORD Timeout)
|
|
{
|
|
NTSTATUS Status;
|
|
LARGE_INTEGER Time;
|
|
|
|
Status = RtlSleepConditionVariableCS(ConditionVariable, (PRTL_CRITICAL_SECTION)CriticalSection, GetNtTimeout(&Time, Timeout));
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT)
|
|
{
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL
|
|
WINAPI
|
|
SleepConditionVariableSRW(PCONDITION_VARIABLE ConditionVariable, PSRWLOCK Lock, DWORD Timeout, ULONG Flags)
|
|
{
|
|
NTSTATUS Status;
|
|
LARGE_INTEGER Time;
|
|
|
|
Status = RtlSleepConditionVariableSRW(ConditionVariable, Lock, GetNtTimeout(&Time, Timeout), Flags);
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT)
|
|
{
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlWakeAllConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
WakeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlWakeConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection,
|
|
IN DWORD dwSpinCount,
|
|
IN DWORD flags)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
/* FIXME: Flags ignored */
|
|
|
|
/* Initialize the critical section */
|
|
Status = RtlInitializeCriticalSectionAndSpinCount(
|
|
(PRTL_CRITICAL_SECTION)lpCriticalSection,
|
|
dwSpinCount);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
/* Set failure code */
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
|
|
/* Success */
|
|
return TRUE;
|
|
}
|
|
|
|
ULONGLONG
|
|
WINAPI
|
|
GetTickCount64(VOID)
|
|
{
|
|
ULARGE_INTEGER TickCount;
|
|
|
|
while (TRUE)
|
|
{
|
|
TickCount.HighPart = (ULONG)SharedUserData->TickCount.High1Time;
|
|
TickCount.LowPart = SharedUserData->TickCount.LowPart;
|
|
|
|
if (TickCount.HighPart == (ULONG)SharedUserData->TickCount.High2Time) break;
|
|
|
|
YieldProcessor();
|
|
}
|
|
|
|
return (UInt32x32To64(TickCount.LowPart, SharedUserData->TickCountMultiplier) >> 24) +
|
|
(UInt32x32To64(TickCount.HighPart, SharedUserData->TickCountMultiplier) << 8);
|
|
}
|