Remove same version check in MSVCRT.DLL \ MSVCIRT.DLL (Visual C++ Runtime Libraries) during start-up of Windows XP/2003

msvcirt-version-unlock

Purpose/History

When Windows boots, it compares the (kernel) version of Windows, typically NT 5.2, running with the version of MSVCRT.DLL \ MSVCIRT.DLL , the (main) Visual C++ Runtime (function) Library. If it doesn't match, it shuts download Windows immedialy or will show this BSOD:
STOP: c000021a {Fatal System Error} The Windows Logon Process system process terminated unexpectedly with a status of 0x00000080 (0x00000000) 0x00000000). The system has been shut down

The comments in the header of the file we will update clearly state this happens, but doesn't say that it causes a BSOD.
Add test to preclude msvcrt.dll loading on anything other than the OS it ships with.

It is necessary to apply this when changing the Windows versions values in \public\sdk\inc\ntverp.h and not booting the same (kernel) Windows NT version as the version that MSVCRT.DLL \ MSVCIRT.DLL is reporting

Relevant information here: https://blog.enrii.com/2008/07/06/troubleshooting-window-xp-c000021a-error-blue-screen/

Requirements

A x86 version of Windows 2003 / XP SP1 with source code available: see https://rentry.co/build-win2k3

Changes

  1. In \base\crts\crtw32\dllstuff\crtlib.c look for the _CRTDLL_INIT function, below This routine does the C runtime initialization.:
BOOL WINAPI _CRTDLL_INIT(
        HANDLE  hDllHandle,
        DWORD   dwReason,
        LPVOID  lpreserved
        )
{
        if ( dwReason == DLL_PROCESS_ATTACH ) {
            OSVERSIONINFOA *posvi;
#if defined(_SYSCRT)
            // The app may have set Win32VersionValue in the PE header to change
            // GetVersionEx.  Ask NTDLL for the real version and bail if we don't match.
            DWORD NtMajorVersion;
            DWORD NtMinorVersion;

#ifdef _WIN64
            NTVERSION_INFO_FCN GetNtVersionInfo = (NTVERSION_INFO_FCN) GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetNtVersionNumbers");
            if (!GetNtVersionInfo)
                GetNtVersionInfo = (NTVERSION_INFO_FCN) GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetNtVersionInfo");

            if (!GetNtVersionInfo)
                return FALSE;

            GetNtVersionInfo(&NtMajorVersion, &NtMinorVersion, NULL);
#else
            void __declspec(dllimport) __stdcall RtlGetNtVersionNumbers(PDWORD, PDWORD, PDWORD);

            RtlGetNtVersionNumbers(&NtMajorVersion, &NtMinorVersion, NULL);
#endif
            if ((NtMajorVersion != VER_PRODUCTMAJORVERSION) || (NtMinorVersion != VER_PRODUCTMINORVERSION))
                return FALSE;

#endif
}

  1. and comment the beginning of the function body out, like so:
BOOL WINAPI _CRTDLL_INIT(
        HANDLE  hDllHandle,
        DWORD   dwReason,
        LPVOID  lpreserved
        )
{
        if ( dwReason == DLL_PROCESS_ATTACH ) {
            OSVERSIONINFOA *posvi;
#if defined(_SYSCRT)
          /*  // The app may have set Win32VersionValue in the PE header to change
            // GetVersionEx.  Ask NTDLL for the real version and bail if we don't match.
            DWORD NtMajorVersion;
            DWORD NtMinorVersion;

#ifdef _WIN64
            NTVERSION_INFO_FCN GetNtVersionInfo = (NTVERSION_INFO_FCN) GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetNtVersionNumbers");
            if (!GetNtVersionInfo)
                GetNtVersionInfo = (NTVERSION_INFO_FCN) GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetNtVersionInfo");

            if (!GetNtVersionInfo)
                return FALSE;

            GetNtVersionInfo(&NtMajorVersion, &NtMinorVersion, NULL);
#else
            void __declspec(dllimport) __stdcall RtlGetNtVersionNumbers(PDWORD, PDWORD, PDWORD);

            RtlGetNtVersionNumbers(&NtMajorVersion, &NtMinorVersion, NULL);
#endif
            if ((NtMajorVersion != VER_PRODUCTMAJORVERSION) || (NtMinorVersion != VER_PRODUCTMINORVERSION))
                return FALSE;*/

#endif
}

  1. Run bcz in \base\crts
  2. Overwrite the created \base\crts\crtw32\iostream\dll\obj\i386\MSVCIRT.DLL in the C:\WINDOWS\SYSTEM32 folder of your Windows XP installation
Edit
Pub: 19 Nov 2020 02:28 UTC
Edit: 04 Dec 2020 00:11 UTC
Views: 880