├── cregfix.sys ├── LICENSE ├── README └── cregfix.asm /cregfix.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mintsuki/cregfix/HEAD/cregfix.sys -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2023-2025 mintsuki and contributors. 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted. 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 7 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 8 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 9 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 10 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 11 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 12 | PERFORMANCE OF THIS SOFTWARE. 13 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | CREGFIX 2 | ======= 3 | 4 | CREGFIX is a small DOS driver that works around an issue of many modern CSM 5 | BIOS implementations where certain control register bits are left "dirty", thus 6 | causing issues when trying to run legacy operating systems such as Microsoft 7 | Windows 9x (see "While initializing device VCACHE: Windows protection error" 8 | issue) or while trying to run EMM386.EXE. 9 | 10 | This program can be built using "nasm": 11 | 12 | nasm cregfix.asm -fbin -o cregfix.sys 13 | 14 | but included in this repository is the prebuilt "cregfix.sys" file. 15 | 16 | CREGFIX is a DOS-compatible .SYS driver which can be added to the beginning of 17 | the CONFIG.SYS file and it will sanitise the control register bits every time 18 | DOS boots up. For example: 19 | 20 | DEVICE=C:\CREGFIX.SYS 21 | -------------------------------------------------------------------------------- /cregfix.asm: -------------------------------------------------------------------------------- 1 | bits 16 2 | org 0 3 | 4 | ; Minimal device driver header 5 | dd -1 6 | dw 0x8000 7 | dw strategy 8 | dw interrupt 9 | db 'CREGFIX ' 10 | 11 | strategy: 12 | ; Strategy is called right before interrupt; save request 13 | ; header address for later 14 | mov [cs:req], bx 15 | mov [cs:req+2], es 16 | retf 17 | 18 | interrupt: 19 | push eax 20 | push ebx 21 | push ecx 22 | push edx 23 | push es 24 | pushf 25 | 26 | ; ES:BX = Request header 27 | les bx, [cs:req] 28 | 29 | ; If the command DOS requests is not INIT (0), do nothing 30 | cmp byte [es:bx+2], 0 31 | jne .done 32 | 33 | cli 34 | 35 | ; Clear control registers 36 | mov eax, 0x10 37 | mov cr0, eax 38 | 39 | xor eax, eax 40 | mov cr2, eax 41 | mov cr3, eax 42 | mov cr4, eax 43 | 44 | xor edx, edx 45 | mov ecx, 0xc0000080 46 | wrmsr 47 | 48 | ; Set driver size to 0 (don't stay resident) 49 | mov word [es:bx+14], 0 50 | mov word [es:bx+16], cs 51 | 52 | .done: 53 | ; Status = done 54 | mov word [es:bx+3], 0x0100 55 | 56 | popf 57 | pop es 58 | pop edx 59 | pop ecx 60 | pop ebx 61 | pop eax 62 | retf 63 | 64 | req dd 0 65 | --------------------------------------------------------------------------------