Windows Server 2003 (NT 5.2.3790.0) build guide

Windows 10 Compatibility for Windows XP/2003 - extras for KERNEL32.DLL

Implementation of some KERNEL32.DLL functions, available in Windows versions released after Windows XP/2003, to get software to that is compatible with Windows 2003R2/Vista/2008/2008R2/7/8/8.1/2016/10/2019 to run in Windows XP/2003.

The current implementation of C code compiles and links fine with the existing KERNEL32.DLL code, but is a work in progress.

FunctionStatusFunctionalityLast updated
RunOnceExecuteOnceImplementedredirected to NTDLL.DLL2020/12/02
RunOnceCompleteImplementedredirected to NTDLL.DLL2020/12/02
InitializeConditionVariableImplementedredirected to NTDLL.DLL2020/12/01
AcquireSRWLockExclusiveImplementedredirected to NTDLL.DLL2020/12/01
AcquireSRWLockSharedImplementedredirected to NTDLL.DLL2020/12/01
TryAcquireSRWLockExclusiveImplementedredirected to NTDLL.DLL2020/12/01
ReleaseSRWLockExclusiveImplementedredirected to NTDLL.DLL2020/12/01
ReleaseSRWLockSharedImplementedredirected to NTDLL.DLL2020/12/01
InitializeSRWLockImplementedredirected to NTDLL.DLL2020/12/01
InitializeCriticalSectionExImplementedredirected to NTDLL.DLL2020/12/01
WakeConditionVariableImplementedredirected to NTDLL.DLL2020/12/01
WakeAllConditionVariableImplementedredirected to NTDLL.DLL2020/12/01
InitializeConditionVariableImplementedredirected to NTDLL.DLL2020/12/01
SetErrorModeImplementedMicrosoft - already available in code, just added2020/11/28
GetErrorModeImplementedMicrosoft - already available in code, just added2020/11/28
InitOnceExecuteOnceMissingNeeded by explorer.exe2020/11/24
DecodePointerTestedredirected to NTDLL.DLL, see kernel32-obfuscated-pointers2020/11/28
EncodePointerTestedredirected to in NTDLL.DLL, see kernel32-obfuscated-pointers2020/11/28
GetFinalPathNameByHandleATestedmofeyi implementation for VOLUME_NAME_NT VOLUME_NAME_DOS VOLUME_NAME_GUID VOLUME_NAME_NONE flags2020/11/28
GetFinalPathNameByHandleWTestedmofeyi implementation for VOLUME_NAME_NT VOLUME_NAME_DOS VOLUME_NAME_GUID VOLUME_NAME_NONE flags2020/11/28
GetTickCount64Testedold Wine2020/11/24
InitOnceExecuteOnceMissingNeeded by explorer.exe2020/11/24
InitOnceBeginInitializeMissingNeeded by explorer.exe2020/11/24
InitOnceExecuteOnceMissingNeeded by explorer.exe2020/11/24
InitOnceCompleteMissingNeeded by explorer.exe2020/11/24
GetSystemTimePreciseAsFileTimeMissingNeeded by explorer.exe2020/11/24
CopyFile2MissingNeeded by explorer.exe2020/11/24
GetLocaleInfoExMissingNeeded by explorer.exe2020/11/24
LCMapStringExMissingNeeded by explorer.exe2020/11/24
SubmitThreadpoolWorkMissingNeeded by explorer.exe2020/11/24
CreateThreadpoolWorkMissingNeeded by explorer.exe2020/11/24
FreeLibraryWhenCallbackReturnsMissingNeeded by explorer.exe2020/11/24
CloseThreadpoolWorkMissingNeeded by explorer.exe2020/11/24
CheckElevationEnabledMissingNeeded by explorer.exe2020/11/24
CheckElevationMissingNeeded by explorer.exe2020/11/24
CreateThreadpoolWorkMissingNeeded by explorer.exe2020/11/24
CreateThreadpoolWaitMissingNeeded by explorer.exe2020/11/24
SubmitThreadpoolWorkMissingNeeded by explorer.exe2020/11/24
WaitForThreadpoolWaitCallbacksMissingNeeded by explorer.exe2020/11/24
CloseThreadpoolWaitMissingNeeded by explorer.exe2020/11/24
SetThreadpoolWaitMissingNeeded by explorer.exe2020/11/24
GetThreadUILanguageMissingNeeded by explorer.exe2020/11/24
GetProcessMitigationPolicyMissingNeeded by explorer.exe2020/11/24
GetDateFormatExMissingNeeded by explorer.exe2020/11/24
GetTimeFormatExMissingNeeded by explorer.exe2020/11/24
SHExpandEnvironmentStringsWMissingNeeded by explorer.exe2020/11/24
GetProductInfoMissingNeeded by explorer.exe2020/11/24
GetOsSafeBootModeMissingNeeded by explorer.exe2020/11/24
GetDynamicTimeZoneInformationMissingNeeded by explorer.exe2020/11/24
SetProcessDEPPolicyMissingNeeded by explorer.exe2020/11/24
PowerCreateRequestMissingNeeded by explorer.exe2020/11/24
PowerSetRequestMissingNeeded by explorer.exe2020/11/24
CreateSymbolicLinkWImplementedRedirected to CreateHardLinkW - untested2020/11/24
InitializeProcThreadAttributeListImplementedWine - untested2020/11/24
UpdateProcThreadAttributeListImplementedWine - untested2020/11/24
DeleteProcThreadAttributeListImplementedWine - untested2020/11/24
GetActiveProcessorCountImplementedUsing GetNativeSystemInfo & dwNumberOfProcessors - suggested 4chan anon »78840134 -basic - 1 group of n processors - untested2020/11/24
GetLogicalProcessorInformationExneed implementationreturns empty structure2020/11/23
CreateMutexExAImplementedWine - untested2020/11/21
CreateMutexExWImplementedWine - untested2020/11/21
CreateEventExWImplementedWine - untested2020/11/21
CreateSemaphoreExWImplementedWine - untested2020/11/21
CreateThreadpoolTimerImplementedWine - untested2020/11/21
VirtualProtectImplementedWine - untested2020/11/22
VirtualProtectExImplementedWine - untested2020/11/22
CompareStringExImplementedWine & wcscmp - untested2020/11/22
CompareStringOrdinalImplementedWine & wcscmp - untested2020/11/22
FindNLSStringImplementedWine & wcscmp - untested2020/11/22
FindNLSStringExImplementedWine & wcscmp - untested2020/11/22
FindStringOrdinalImplementedWine & wcscmp - untested2020/11/22
LocaleNameToLCIDImplementedusing GetLcidFromRfc1766 & SysAllocString - untested, need to get rid of LoadLibrary & GetProcAddress2020/11/22
LCIDToLocaleNameImplementedusing GetLocaleInfoW - untested2020/11/22
IsValidLocaleNameImplementedWine - untested2020/11/22
QueryFullProcessImageNameAImplementedWine - untested2020/11/22
QueryFullProcessImageNameWImplementedWine - untested2020/11/22
RegisterApplicationRestartImplementedStub returning S_OK2020/11/21
ApplicationRecoveryInProgressImplementedStub returning S_OK2020/11/21
ApplicationRecoveryFinishedImplementedStub returning S_OK2020/11/21
RegisterApplicationRecoveryCallbackImplementedStub returning S_OK2020/11/21
UnregisterApplicationRecoveryCallbackImplementedStub returning S_OK2020/11/21
CreateThreadpoolTimerImplementedWine - untested2020/11/21
SetThreadpoolTimerImplementedWine - untested2020/11/21
CloseThreadpoolTimerImplementedWine - untested2020/11/21
WaitForThreadpoolTimerCallbacksImplementedWine - untested2020/11/21
ResolveDelayLoadedAPIImplementedWine - untested2020/11/21
GetFileInformationByHandleExImplementedWine - untested2020/11/21

Requirements

  1. A x86 version of Windows 2003 / XP SP1 with source code available: see build-win2k3
  2. Disable Windows File Protection when DLL’s replacing after installation, see https://www.technipages.com/enable-disable-wfp
  3. Ability to execute executables built for newer versions than Windows XP SP2 / Windows Server 2003 RTM (NT 5.2).

Changes

Changes only happen in \base\win32\client

  1. (Included in the patched files) Add to \base\win32\client\sources.inc’s SOURCES macro (typically line 113):
 \
	..\_file.c \
	..\_list.c \
	..\_loader.c \
	..\_kernelbase_debug.c \
	..\_kernelbase_locale.c \
	..\_memory.c \
	..\_process.c \
	..\_synchapi.c \
	..\_security.c \
	..\_system.c
  1. (Included in the patched files) Add to \base\win32\client\sources.inc’s SOURCES macro (typically line 1056):
	// Changes for WindowsXP+
	InitializeSRWLock = NTDLL.RtlInitializeSRWLock
    AcquireSRWLockExclusive = NTDLL.RtlAcquireSRWLockExclusive
	AcquireSRWLockShared = NTDLL.RtlAcquireSRWLockShared
	TryAcquireSRWLockExclusive = NTDLL.RtlTryAcquireSRWLockExclusive
	ReleaseSRWLockExclusive = NTDLL.RtlReleaseSRWLockExclusive
	ReleaseSRWLockShared = NTDLL.RtlReleaseSRWLockShared
	InitializeCriticalSectionEx = NTDLL.RtlInitializeCriticalSectionEx
	CreateMutexExA
	CreateMutexExW
	CreateEventExW
	CreateSemaphoreExW
	CreateThreadpoolTimer
//	CloseThreadpoolTimer
	DecodePointer = NTDLL.RtlDecodePointer
	EncodePointer = NTDLL.RtlEncodePointer
	VirtualProtect
	VirtualProtectEx
	CompareStringEx
	CompareStringOrdinal
	FindNLSString
	FindNLSStringEx
	FindStringOrdinal
	LocaleNameToLCID
	LCIDToLocaleName
	IsValidLocaleName
	QueryFullProcessImageNameA
	QueryFullProcessImageNameW
	RegisterApplicationRestart
	ApplicationRecoveryInProgress
	ApplicationRecoveryFinished
	RegisterApplicationRecoveryCallback
	UnregisterApplicationRecoveryCallback
	CreateThreadpoolTimer
	SetThreadpoolTimer
	CloseThreadpoolTimer
	WaitForThreadpoolTimerCallbacks
	ResolveDelayLoadedAPI
	GetFileInformationByHandleEx
	GetFinalPathNameByHandle = GetFinalPathNameByHandleW
	GetFinalPathNameByHandleA
	GetFinalPathNameByHandleW
	GetTickCount64
	GetActiveProcessorCount
	GetLogicalProcessorInformationEx
	InitializeProcThreadAttributeList
	UpdateProcThreadAttribute
	DeleteProcThreadAttributeList
	CreateSymbolicLinkW
	GetErrorMode
	SetErrorMode
	InitializeConditionVariable = NTDLL.RtlInitializeConditionVariable
	WakeByAddressAll = NTDLL.RtlWakeByAddressAll
	WakeAllConditionVariable = NTDLL.RtlWakeAllConditionVariable
	WakeConditionVariable = NTDLL.RtlWakeConditionVariable
	RunOnceExecuteOnce=NTDLL.RtlRunOnceExecuteOnce
	RunOnceComplete=NTDLL.RtlRunOnceComplete
  1. Place _*.c & _*.h files from the <date>__KERNEL32.DLL.zip archive, see Download below
  2. Launch Razzle (32-bit) command, see build-win2k3
  3. Change directory \base\win32\client and run bcz
  4. Copy the \base\win32\client\daytona\obj\i386\kernel32.dll to your c:\windows\system32\ on your Windows XP/2003 environment

Download implementations

DateFilenameLink
2020/12/0220201202__KERNEL32.DLL.v6.ziphttps://gofile.io/d/DH9dZL

Test Harness

Some functions are being tested now as Python 3.9 does crash when starting, using a small program (WIP) calling the function with an input value:

Example kernel32_test.c - complete project below:

#include <stdio.h>
#define NOMINMAX
#include <Windows.h>

typedef ULONGLONG (*_GetTickCount64)();

VOID
__cdecl main(USHORT argc, PCHAR *argv)
{
	printf("Started - loading kernel32.dll\n");
	{
		HMODULE kernel32=LoadLibrary("kernel32.dll");
		if (!kernel32) {
			printf("kernel32.dll failed to load: %d\n", GetLastError());
		}
		{
			//GetTickCount64
			_GetTickCount64 GetTickCount64 = (_GetTickCount64)GetProcAddress(kernel32,"GetTickCount64");
			if (!GetTickCount64) {
				printf("GetTickCount64 not implemented!\n");
			} else {
				ULONGLONG result = GetTickCount64();
				if (!result) {
					printf("GetTickCount64 null result!\n", GetLastError());
				} else {
					printf("GetTickCount64 SUCCESS result: %d\n", result);
				}
			}
		}
	}
    return;
}

Output of program with unmodified Windows XP/2003 KERNEL32.DLL installed:

Started - loading kernel32.dll
GetTickCount64 not implemented!

Output of program with modified KERNEL32.DLL

Started - loading kernel32.dll
GetTickCount64 SUCCESS result: 349463837

To be stored under \kernel32_test, build using Razzle and the bz command