Runs .NET Framework 4.8 managed executables on Windows 98 SE (with
KernelEx 4.5.2+ and an SSE2-capable CPU), using a set of
wrapper DLLs, small binary patches to clr.dll and clrjit.dll, and Microsoft's official
redistributable for everything else. Managed programs start by double-click, as on any other
Windows.
- On Windows 98 SE, install KernelEx 4.5.2 (included in the release) and restart.
- Download the latest release and extract it on the Windows 98 machine with 7-Zip 9.20.
- Copy
mscoree.dllfrom a Windows 10/11 PC (C:\Windows\SysWOW64\mscoree.dll) into the extracted folder. - With the Windows 98 machine online, run
WIN98SETUP.BATfrom an MS-DOS Prompt. - Restart. Notepad opens with the result of a quick check:
HELLO48 OKmeans it works.
The details, and how to install without an internet connection, are under Install.
What works:
- Console and WinForms applications, including common and complex controls, dialogs, the clipboard and GDI+ drawing.
- The base class library: threads, the thread pool, timers,
Task/async, file I/O,FileSystemWatcher, memory-mapped files, compression, the registry, processes, reflection andReflection.Emit,dynamic, LINQ/PLINQ, XML/XSLT, serialization (binary, XML, DataContract, JSON),DataTable, cultures and time zones, regular expressions. - Networking: DNS, TCP/UDP sockets, ping, HTTP, and HTTPS/
SslStreamover TLS 1.0-1.2 (see TLS). - Hashing, random numbers, PBKDF2, managed AES, X.509 parsing and DPAPI (
ProtectedData). - Real applications: the XNA-based CnCNet clients for Dawn of the Tiberium Age and Red Alert 2 / Yuri's Revenge - main menu, CnCNet lobby and chat, the updater, and launching games (RA2/YR with Ares and Phobos needs a patched Syringe). They need some extra DLLs beside the client, which a separate project sets up: cncnet-win98.
The test suite in tests/DN48Test (115 tests) passes 100 on Windows 98 SE and all of them on
Windows 10.
Known gaps (the remaining test failures):
- Cryptography through Windows' crypto providers:
AesCryptoServiceProvider,TripleDES,SHA256CryptoServiceProvider,RSACryptoServiceProviderkey generation and SHA-256 signatures, and CNG (ECDsaCng). Win98 only has the old base provider. The managed implementations (AesManaged,SHA256Managed, ...) work. - Not available on Win98: named pipes,
HttpListener(httpapi.dll), WMI (System.Management), WPF (needs DirectWrite). - Not yet investigated: isolated storage,
Icon.ExtractAssociatedIcon/metafiles, the WinFormsWebBrowsercontrol, OLE DB/Jet and late-bound COM automation (both hang).
If you hit a managed API that doesn't work, it is very likely an unimplemented or stubbed KERNEL32 or ADVAPI32 function - see How it works for where to look.
- Windows 98 SE with KernelEx 4.5.2 or later installed first
(the 4.5.2 installer is included in the release, in
third_party\kernelex-4.5.2). - An SSE2-capable CPU.
- About 1GB of free disk space on the drive you run the installer from, plus roughly 300MB on
C:for the installed Framework. The payload cabinets and the_DN48scratch directory can live on another drive - runWIN98SETUP.BATfrom there, or setWORKat the top of it. - A 32-bit .NET 4.x-era
mscoree.dllfrom another Windows computer. Microsoft's .NET 4.8 package does not include it (Windows 10 has it built in). On 64-bit Windows 10/11, copyC:\Windows\SysWOW64\mscoree.dll; on 32-bit Windows,C:\Windows\System32\mscoree.dll. - An internet connection on the Windows 98 machine, so the installer can download Microsoft's
.NET Framework 4.8 package and GDI+ (both are checked against known SHA-1 hashes). Without
one, download these on another computer and put them beside
WIN98SETUP.BAT:NDP48-x86-x64-AllOS-ENU.exe, the .NET Framework 4.8 offline installer.gdiplus.dll, whichSystem.Drawingand WinForms images need. It is in Microsoft's old GDI+ redistributable,gdiplus_dnld.exe(archived by the Internet Archive; open it with 7-Zip, then thegdiplus.exeinside). Version 5.1.3102.1360 was used for testing.
- Install KernelEx 4.5.2+ on the Windows 98 SE machine (the installer is in the release, in
third_party\kernelex-4.5.2), and restart. - Download the latest release,
dotnet48-win98-<version>.zip, from the Releases page. - Extract it on the Windows 98 machine, keeping its long file names. The simplest way is to
copy the
.zipacross and extract it there with a tool that supports long file names, such as 7-Zip 9.20 (the last version that runs on Windows 98). You can also extract it on another computer and copy the folder across a network share, or on a CD (with Joliet), a USB stick or a disk that keeps long file names. - Put the 32-bit
mscoree.dlldescribed above besideWIN98SETUP.BAT. - Without an internet connection: put
NDP48-x86-x64-AllOS-ENU.exeandgdiplus.dllbesideWIN98SETUP.BATtoo. - Open an MS-DOS Prompt, change to the extracted folder and run
WIN98SETUP.BAT. - Restart.
- After the restart a quick check runs once and opens its results in Notepad: they should
show
HELLO48 OKand the CLR version. RunC:\DOTNET48\VERIFY.BATto check again later.
WIN98SETUP.BAT copies wrapper DLLs and the supplied mscoree.dll into C:\WINDOWS\SYSTEM,
extracts Microsoft payload files with the bundled bin\7za.exe, copies the Framework files into
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319, imports the .NET registration keys, and sets
the KernelEx compatibility mode for mscoree.dll to WINXP. It also adds the DN98FX API
library to KernelEx's CORE.INI (the original is kept as CORE.INI.DN98), and leaves
DN98INST.EXE and 7ZA.EXE in C:\DOTNET48 for other packages to use, such as
cncnet-win98.
Before replacing them, setup saves the mscoree.dll and mscorees.dll already in
C:\WINDOWS\SYSTEM (and any existing registration of the taskbar object it registers) in
C:\DOTNET48\BACKUP; UNINSTALL.BAT puts them back.
dotnet9x (.NET 2.0-3.5 for Windows 9x) can be installed
on the same machine. The two keep their files apart - dotnet9x uses Microsoft.NET\Framework\v2.0.50727,
v3.5, the C:\WINDOWS\assembly GAC and the wrappers CORKEL32, CORNT, CORUSR and
CORSHLW; this project uses v4.0.30319, Microsoft.NET\assembly and DNKERNEL/DNADVAPI -
but there is only one mscoree.dll, the loader every .NET program starts through:
- Install dotnet9x first, then this. Setup saves dotnet9x's
mscoree.dlland replaces it with the .NET 4 one; from then on every .NET program, including .NET 2.0-3.5 ones, runs on .NET 4.8. .NET 4 is meant to run most older programs, but this has not been tested with dotnet9x. - Installing or repairing dotnet9x afterwards puts its own
mscoree.dllback, and .NET 4.8 programs stop starting. RunWIN98SETUP.BATagain (with the .NET 4mscoree.dllbeside it). UNINSTALL.BATrestores dotnet9x'smscoree.dll, so .NET 2.0-3.5 programs run on dotnet9x again.- Setup refuses a .NET 2.0
mscoree.dll: it needs the .NET 4 one described under Requirements.
Run this from the project root on the Win98 box:
UNINSTALL.BAT
It removes the v4 Framework directory, v4 GAC tree, C:\DOTNET48, this project's wrapper DLLs,
and the v4 CLR CRT files copied into C:\WINDOWS\SYSTEM; puts back the mscoree.dll and
mscorees.dll that were there before (or removes them if there were none); removes DN98FX
from KernelEx; and removes the .NET 4 detection keys and KernelEx compatibility values added by
this project. It leaves gdiplus.dll and dbghelp.dll in place, as other programs may use them.
Restart afterwards.
This is a runtime-focused install. It copies the CLR native files, CRT files, GAC assemblies
under C:\WINDOWS\Microsoft.NET\assembly, this project's wrapper/shim DLLs, registry detection
keys, and the KernelEx setting needed for mscoree.dll.
It does not attempt to reproduce every OS integration side effect of Microsoft's MSI install. The runtime-focused path installs the v4 files needed for managed applications to bind and run, but it does not install Explorer namespace extensions, services, developer tools, ASP.NET integration, or MSI product/uninstall registration.
Other .NET Framework pieces are intentionally not installed or not tested here:
- NGEN service/native image cache (
ngen.exe,mscorsvw.exe, native-image registry setup). - Developer and administration tools (
MSBuild.exe,csc.exe,vbc.exe,CasPol.exe,InstallUtil.exe,RegAsm.exe,RegSvcs.exe,.tlbregistration). - ASP.NET/IIS integration, performance counters, event-log setup, services, and uninstall/MSI product registration.
- WPF browser-host/native integration (
PresentationHost,PresentationNative,wpfgfx,wpftxt) beyond copying the managed GAC assemblies already listed ininstall\files.win98.txt.
CLRPROBE.EXEfails before the managed smoke test: checkC:\DOTNET48\CLRPROBE.LOG. This usually means a native DLL is missing, the wrongmscoree.dllwas supplied, or the wrapper DLLs were not copied toC:\WINDOWS\SYSTEM.WIN98SETUP.BATstops before extracting: place Microsoft'sNDP48-x86-x64-AllOS-ENU.exebeside it and rerun. If you already extracted the redist elsewhere, placenetfx_Full.mzzandWindows10.0-KB4486153-x86.cabbeside it.- If the managed smoke test fails early and
mscoree.dllwas supplied manually: use a 32-bit .NET 4.x-era copy. On 64-bit Windows, that meansC:\Windows\SysWOW64\mscoree.dll, notC:\Windows\System32\mscoree.dll. HelloDotNet48.exedoes not printHELLO48 OK: verify thatDN98INST.EXE PATCH C:\WINDOWScompleted and thatclr.dll/clrjit.dllinC:\WINDOWS\Microsoft.NET\Framework\v4.0.30319have.PRE_WIN98_TLS_HOTPATCHbackups.- Direct-launching a managed app fails but
HelloDotNet48.exeworks: check forNETSHIM_FATAL.LOGnext toNETSHIM.DLLin the Framework directory. For detailed assembly-load diagnostics, setNETSHIM_LOG=1before launching the app. - An app reports a vague error ("One or more errors occurred", a
TypeInitializationException): setNETSHIM_LOG=1and run it again.NETSHIM_EXCEPTIONS.LOG(besideNETSHIM.DLL) then lists every exception as it is thrown, with its stack trace - usually the original cause. - A Framework assembly fails to load with
0x8007001F("A device attached to the system is not functioning"): look beside the app for old copies of this project's DLLs (DNADVAPI.DLL,DNKERNEL.DLL,CORADV32.DLL,BCRYPT.DLL,W2_32W.DLL,TLS98.DLL) and delete them. Windows loads a copy in the app's folder before the one inC:\WINDOWS\SYSTEM. - HTTPS fails with a trust error for every site: check that
C:\WINDOWS\SYSTEM\CACERT.PEMexists and the system clock is right. SetTLS98_LOG=1and look atC:\DOTNET48\TLS98.LOG. - After changing KernelEx settings or replacing runtime DLLs, reboot Win98 before retesting.
- Run
WIN98SETUP.BATfrom an MS-DOS Prompt inside Windows, not from command-prompt-only mode. Real-mode DOS has no long-filename support, and both the batch file's own name and the Microsoft payload names are long. Same reason the payloads are unpacked with7za.exeinstead ofEXTRACT.EXE: real-mode DOS tools cannot create the cabinets' member names. - If Explorer shows the extracted files with short names like
WIN98S~1.BATorFILES~1.TXT, the long file names were lost on the way, and the install will fail. Extract the release.zipon the Windows 98 machine itself (install step 3), or use a copy method that keeps long names. A plain ISO9660 Level 1 CD (no Joliet) truncates everything to 8.3.
Four problems, four fixes:
- The CLR calls hundreds of KERNEL32/ADVAPI32 functions Win98 doesn't have, and does
version checks that reject anything below Windows XP. Fix: the installer (
DN98INST.EXE;src/wrappers/patch_imports.pydoes the same on another computer) rewrites the name string in each native DLL's import table (KERNEL32.DLL→DNKERNEL.DLL, same length, no relocation needed) to point at our own wrapper DLLs (src/wrappers/dnkernel.c/dnadvapi.c, generated bygen.pyfrom the import lists inanalysis/). Most exports are naked trampolines straight through to the real DLL; ~90 are reimplemented (reimpl_k32.c/reimpl_adv.c) - version spoofing, TLS/condition-variable fixes, a manualSEC_IMAGEPE mapper (Win98'sCreateFileMappingcan't doSEC_IMAGE, which the CLR requires to map assemblies), a workingVirtualAllocguard-page workaround, and more. Each reimplementation has a comment explaining the specific Win98 behavior it works around. - Inline TLS fast paths in
clr.dllandclrjit.dllread the NT thread-environment-block layout directly (fs:[TEB]), which doesn't exist on Win98 and faults. Fix:DN98INST.EXEflips the relevant conditional branches on the Win98 machine so both the CLR and JIT take their generic, safe TLS-access paths instead. - Double-click launch goes through a CLR code path that fails on this OS for reasons
never fully identified. Fix: we replace
mscoree!_CorExeMainwith our own entry point (dnk_hook_corexemaininreimpl_k32.c) that hosts the CLR directly and loads the exe by path viaNETSHIM.DLL(src/shim/netshim.cs) instead.DNKERNELresolvesNETSHIM.DLLfrom the CLR runtime directory, so it follows the installed Framework location rather than a separate tools directory. - Win98 has no TLS stack .NET can use. Its
secur32.dllhas no SChannel package and its crypt32 cannot verify SHA-256 certificate signatures. Fix:TLS98.DLL(src/tls98) implements the SChannel client side of SSPI on top of BearSSL, andDNKERNELroutes .NET'ssecur32P/Invokes to it. See "TLS" below.
TLS98.DLL gives .NET's SslStream (and so HttpWebRequest, WebClient and HttpClient)
TLS 1.0, 1.1 and 1.2 as a client, using BearSSL 0.6 (third_party/bearssl-0.6). There is no
TLS 1.3, server mode, client-certificate support or session resumption.
Server certificates are checked during the handshake against CACERT.PEM in
C:\WINDOWS\SYSTEM: Mozilla's trusted root CAs as extracted by the curl project
(third_party/cacert). To update the trusted roots, replace that file with a newer
cacert.pem. As with SChannel, a certificate that fails
the check does not end the handshake: .NET receives the verdict through TLS98's
CertGetCertificateChain/CertVerifyCertificateChainPolicy and reports it to the application
(RemoteCertificateValidationCallback, or a WebException by default). Set TLS98_LOG=1 to
log to C:\DOTNET48\TLS98.LOG.
The binaries in bin/ are built from the source in this repo. Rebuilding them needs Visual C++
6.0 (VC98) and the .NET Framework 4.x C# compiler; one script builds everything:
.\build-all.ps1 # everything into bin\ (application shims into bin\compat\)
.\build-all.ps1 -Out build\x # or into another directorysrc/native-tools/dn98inst.c is the Win98-side installer helper (downloading, unpacking,
copying and patching). src/native-tools/clrprobe.c and src/smoke-test/HelloDotNet48.cs are
the two checks C:\DOTNET48\VERIFY.BAT runs.
The pieces can also be built on their own. The two main wrapper DLLs:
cd src\wrappers
.\build.ps1 -src dnkernel.c -def dnkernel.def -out ..\..\bin\DNKERNEL.DLL -extraLibs "kernel32.lib advapi32.lib user32.lib"
.\build.ps1 -src dnadvapi.c -def dnadvapi.def -out ..\..\bin\DNADVAPI.DLL -extraLibs "kernel32.lib advapi32.lib user32.lib"TLS98.DLL has its own script, which also builds BearSSL:
cd src\tls98
.\build.ps1src/tls98/tlstest.c is a small native client that drives TLS98.DLL without .NET
(tlstest host [path] [dll]).
To regenerate dnkernel.c/.def/dnadvapi.c/.def from a different import list (e.g. after
targeting a different .NET 4.8 build), edit analysis/k32_needed.txt/adv_needed.txt and run
python gen.py from src/wrappers/.
Debug logging (DNK_LOG) is off by default. To build a logging variant, add /DDNK_LOG to
the CL.EXE line in src\wrappers\build.ps1 (needs user32.lib): DNKERNEL then writes
C:\DOTNET48\REIMPL.LOG and DNADVAPI C:\DOTNET48\DNADVAPI.LOG.
For managed shim assembly-load diagnostics, set NETSHIM_LOG=1; those logs are written next
to the installed NETSHIM.DLL.
tests/DN48Test is a console program with 115 tests across the .NET 4.8 surface: core types,
threading, I/O, networking, crypto, text, data, serialization, WinForms and Win32 interop.
Build it with tests\DN48Test\build.ps1 (output in build\tests), copy DN48TEST.EXE and
DN48TEST.EXE.config to the Win98 machine and run it. Results go to the console and to
DN48TEST.LOG beside the exe. --list lists the tests, --only <names> and
--skip <names> select them, and --timeout <seconds> changes the per-test limit.
- dotnet9x by itsmattkc, which brought .NET 2.0-3.5 to Windows 95/98 and showed the approach (video).
- KernelEx, which provides most of the newer Windows API
this builds on (GPL; installer in
third_party/kernelex-4.5.2). - BearSSL by Thomas Pornin, the TLS implementation in
TLS98.DLL(MIT). - Mozilla's CA certificate list, as extracted by the curl project (MPL 2.0).
- 7-Zip (
7za.exe, LGPL), which unpacks Microsoft's payloads. - The Internet Archive, whose copy of Microsoft's GDI+ redistributable the installer uses.
.NET Framework is Microsoft's. This project does not redistribute any of it: the installer downloads Microsoft's redistributable, or uses one you supply, and patches it on your machine.