From f973efab32a4f399bc1cf20f6edb29e962efe998 Mon Sep 17 00:00:00 2001 From: Jaroslav Hensl Date: Mon, 10 Apr 2023 17:07:49 +0200 Subject: [PATCH] Large update --- .gitattributes | 2 + .gitmodules | 3 + CHANGELOG | 11 + Makefile | 261 +++++++++-------- README.md | 48 ++- batch.c | 614 +++++++++++++++++++++++++++++++++++++++ batch.h | 74 +++++ boot/README.md | 39 +++ boot/autoexec.bat | 9 + boot/cdrom.bat | 4 + boot/fdconfig.sys | 30 ++ boot/info.bat | 2 + boot/info.txt | 16 + boot/readme.txt.template | 13 + cputest.c | 6 +- exact.c | 27 +- files.c | 4 +- help.h | 35 +-- mspack/chmd.c | 4 +- mspack/mspack.h | 4 + mspack/system.c | 2 + mspack/system.h | 4 +- nocrt | 1 + patcher9x.c | 111 ++++--- patcher9x.h | 32 +- patcher9x.ico | Bin 0 -> 766 bytes patcher9x.rc | 58 ++++ patcher9x.xml | 12 + pe/ds_compress.c | 7 + pe/ds_decompress.c | 1 + pe/pew.c | 7 +- pwin32.c | 95 ++++++ system/bitstream.h | 4 + system/bpatcher.c | 1 + system/bpatcher.h | 4 + system/filesystem.c | 4 +- system/filesystem.h | 4 + unpacker.c | 356 ++++++++++++++++++++--- version.h | 9 +- vmm/makediff.manifest | 12 + vmm/makediff.rc | 2 + vmm/makediff.xml | 12 + vmm/makepatch.rc | 2 + vmm/makepatch.xml | 12 + vmm/patchedme.bin | Bin 16320 -> 16320 bytes vmm_patch_me1.h | 4 +- vmm_patch_me2.h | 4 +- 47 files changed, 1705 insertions(+), 261 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitmodules create mode 100644 batch.c create mode 100644 batch.h create mode 100644 boot/README.md create mode 100644 boot/autoexec.bat create mode 100644 boot/cdrom.bat create mode 100644 boot/fdconfig.sys create mode 100644 boot/info.bat create mode 100644 boot/info.txt create mode 100644 boot/readme.txt.template create mode 160000 nocrt create mode 100644 patcher9x.ico create mode 100644 patcher9x.rc create mode 100644 patcher9x.xml create mode 100644 pwin32.c create mode 100644 vmm/makediff.manifest create mode 100644 vmm/makediff.rc create mode 100644 vmm/makediff.xml create mode 100644 vmm/makepatch.rc create mode 100644 vmm/makepatch.xml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..300d425 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Treat all needed for boot freedos as binary (don't do CRNL<-->NL conversion) +boot/* binary diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..823e565 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "nocrt"] + path = nocrt + url = https://github.com/JHRobotics/nocrt diff --git a/CHANGELOG b/CHANGELOG index 974d8c3..57cc858 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +0.8.50 +- Support for Windows 95 4.0.950 +- "exact mode" removed, replace is batch mode, with simpler actions but offers + more powerful combinations +- Boot floppy now contain CD driver and utilities for create system disk and + copy files (fdisk, format, xcopy) +- improved TLB patches for 98 and Me (are more complicated, but should be but + more stable) +- more portable Win32/64 build (removed dependency on MSCRT.DLL) and default + path is now current work directory if program is running on NT + 0.7.45 - CPU Speed Limit bug is now supported and fixed - Using -millennium argument is no longer needed, Me patch is included in TLB set diff --git a/Makefile b/Makefile index 7127e9d..2af676b 100644 --- a/Makefile +++ b/Makefile @@ -25,23 +25,29 @@ STRIP ?= strip FASM ?= fasm ifdef RELEASE - CFLAGS ?= -g0 -static -Os -Wall -Wextra -Wno-unused-parameter -Wno-unused-function + CFLAGS ?= -std=gnu99 -g0 -static -Os -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -fdata-sections -ffunction-sections else - CFLAGS ?= -g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function + CFLAGS ?= -std=gnu99 -g -Wall -Wextra -Wno-unused-parameter -Wno-unused-function endif -CFLAGS := $(CFLAGS) -I./mspack -I./system -I./pe +CFLAGS := $(CFLAGS) -I./mspack -I./system -I./pe -I./nocrt -HOST_CC ?= $(CC) -HOST_CFLAGS ?= $(CFLAGS) -HOST_LDFLAGS ?= +HOST_CC ?= $(CC) +HOST_CFLAGS ?= $(CFLAGS) +HOST_LDFLAGS ?= $(LDFLAGS) -GUEST_CC ?= $(CC) -GUEST_CFLAGS ?= $(CFLAGS) -GUEST_LDFLAGS ?= +GUEST_CC ?= $(CC) +GUEST_CFLAGS ?= $(CFLAGS) +GUEST_LDFLAGS ?= $(LDFLAGS) + +WINDRES ?= windres +HOST_WINDRES ?= $(WINDRES) +GUEST_WINDRES ?= $(WINDRES) OUTNAME=patcher9x$(SUFIX) +OBJS_GUEST := + ifdef PROFILE ifeq ($(PROFILE),djgpp) GUEST_CC := i586-pc-msdosdjgpp-gcc @@ -49,24 +55,46 @@ ifdef PROFILE STRIP := i586-pc-msdosdjgpp-strip OUTNAME := patch9x$(SUFIX) endif + ifeq ($(PROFILE),nocrt) + GUEST_LDFLAGS += -nostdlib -nodefaultlibs -lgcc -lkernel32 -luser32 + GUEST_CFLAGS += -DNOCRT -DNOCRT_FLOAT -DNOCRT_MEM -DNOCRT_FILE -ffreestanding -march=pentium2 + OBJS_GUEST += nocrt/nocrt.g.o nocrt/nocrt_exe.g.o nocrt/nocrt_file_win.g.o nocrt/nocrt_math.g.o nocrt/nocrt_mem_win.g.o + endif + ifeq ($(PROFILE),nocrt64) + GUEST_LDFLAGS += -nostdlib -nodefaultlibs -lgcc -lkernel32 -luser32 + GUEST_CFLAGS += -DNOCRT -DNOCRT_FLOAT -DNOCRT_MEM -DNOCRT_FILE -ffreestanding + OBJS_GUEST += nocrt/nocrt.g.o nocrt/nocrt_exe.g.o nocrt/nocrt_file_win.g.o nocrt/nocrt_math.g.o nocrt/nocrt_mem_win.g.o + RES_FLAGS += --target=pe-x86-64 + endif endif ifdef VERSION_PATCH - HOST_CFLAGS := $(HOST_CFLAGS) -DPATCHER9X_PATCH=$(VERSION_PATCH) - GUEST_CFLAGS := $(GUEST_CFLAGS) -DPATCHER9X_PATCH=$(VERSION_PATCH) + HOST_CFLAGS += -DPATCHER9X_PATCH=$(VERSION_PATCH) + GUEST_CFLAGS += -DPATCHER9X_PATCH=$(VERSION_PATCH) + RES_FLAGS += -DPATCHER9X_PATCH=$(VERSION_PATCH) endif DEPS_HOST=Makefile system/bitstream.h version.h DEPS_GUEST=Makefile system/bitstream.h version.h -OBJS_GUEST=mspack/cabc.g.o mspack/cabd.g.o mspack/crc32.g.o mspack/hlpc.g.o mspack/hlpd.g.o mspack/chmc.g.o mspack/chmd.g.o mspack/kwajc.g.o mspack/kwajd.g.o mspack/litc.g.o \ +OBJS_GUEST +=mspack/cabc.g.o mspack/cabd.g.o mspack/crc32.g.o mspack/hlpc.g.o mspack/hlpd.g.o mspack/chmc.g.o mspack/chmd.g.o mspack/kwajc.g.o mspack/kwajd.g.o mspack/litc.g.o \ mspack/litd.g.o mspack/lzssd.g.o mspack/lzxc.g.o mspack/lzxd.g.o mspack/mszipc.g.o mspack/mszipd.g.o mspack/oabc.g.o mspack/oabd.g.o mspack/qtmd.g.o mspack/system.g.o \ - mspack/szddc.g.o mspack/szddd.g.o system/filesystem.g.o system/bpatcher.g.o pe/pew.g.o pe/ds_compress.g.o pe/ds_decompress.g.o + mspack/szddc.g.o mspack/szddd.g.o system/filesystem.g.o system/bpatcher.g.o pe/pew.g.o pe/ds_compress.g.o pe/ds_decompress.g.o pwin32.g.o -OBJS_OUT=$(OBJS_GUEST) unpacker.g.o patch.g.o trace.g.o patcher9x.g.o cputest.g.o files.g.o exact.g.o +OBJS_OUT=$(OBJS_GUEST) unpacker.g.o patch.g.o trace.g.o patcher9x.g.o cputest.g.o files.g.o batch.g.o OBJS_HOST=system/bpatcher.h.o +OBJS_MAKEPATCH = vmm/makepatch.h.o +OBJS_MAKEDIFF = vmm/makediff.h.o + +ifeq ($(filter $(OS),Windows_NT),Windows_NT) + OBJS_MAKEPATCH += vmm/makepatch.h.res + OBJS_MAKEDIFF += vmm/makediff.h.res + OBJS_OUT += patcher9x.g.res +endif + + TESTS=test_bitstream$(SUFIX) test_pe$(SUFIX) test_pe2$(SUFIX) test_ds$(SUFIX) test_ds_compress$(SUFIX) test_w3$(SUFIX) test_patch$(SUFIX) test_ds2$(SUFIX) all: $(OUTNAME) @@ -81,13 +109,19 @@ tests: $(TESTS) %.h.o: %.c $(DEPS_HOST) $(HOST_CC) $(HOST_CFLAGS) -c -o $@ $< +%.h.res: %.rc + $(HOST_WINDRES) $(RES_FLAGS) --input $< --output $@ --output-format=coff + +%.g.res: %.rc + $(GUEST_WINDRES) $(RES_FLAGS) --input $< --output $@ --output-format=coff + %.h: %.h.tmp $(CP) $< $@ %.bin: %.asm.gen $(FASM) $< $@ -$(OUTNAME): $(OBJS_OUT) +$(OUTNAME): $(OBJS_OUT) $(EXTRA_DEPS) $(GUEST_CC) $(GUEST_CFLAGS) -o $(OUTNAME) $(OBJS_OUT) $(GUEST_LDFLAGS) strip: $(OUTNAME) @@ -119,305 +153,305 @@ test_patch$(SUFIX): $(OBJS_GUEST) test/test_patch.g.o ########## patcher .h generators -makepatch$(HOST_SUFIX): $(OBJS_HOST) vmm/makepatch.h.o - $(HOST_CC) $(HOST_CFLAGS) -o makepatch$(HOST_SUFIX) $(OBJS_HOST) vmm/makepatch.h.o $(HOST_LDFLAGS) +makepatch$(HOST_SUFIX): $(OBJS_HOST) $(OBJS_MAKEPATCH) + $(HOST_CC) $(HOST_CFLAGS) -o $@ $^ $(HOST_LDFLAGS) -makediff$(HOST_SUFIX): $(OBJS_HOST) vmm/makediff.h.o - $(HOST_CC) $(HOST_CFLAGS) -o makediff$(HOST_SUFIX) $(OBJS_HOST) vmm/makediff.h.o $(HOST_LDFLAGS) +makediff$(HOST_SUFIX): $(OBJS_HOST) $(OBJS_MAKEDIFF) + $(HOST_CC) $(HOST_CFLAGS) -o $@ $^ $(HOST_LDFLAGS) ########## VMM patch (SE only) vmm/patched.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Dvmmbugfix1 vmm/FlushMappedCacheBlock.asm -o vmm/patched.asm.gen + $(CPP) -nostdinc -E -P -Dvmmbugfix1 $< -o $@ vmm/original.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode vmm/FlushMappedCacheBlock.asm -o vmm/original.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode $< -o $@ vmm/reloc.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dnofuncrelocate vmm/FlushMappedCacheBlock.asm -o vmm/reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dnofuncrelocate $< -o $@ # Version 2 vmm/patched_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Dvmmbugfix1 -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/patched_v2.asm.gen + $(CPP) -nostdinc -E -P -Dvmmbugfix1 -Dversion_2 $< -o $@ vmm/original_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/original_v2.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 $< -o $@ vmm/reloc_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dnofuncrelocate -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/reloc_v2.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dnofuncrelocate -Dversion_2 $< -o $@ ########## VMM patch (ME all) vmm/patchedme.asm.gen: vmm/FlushMappedCacheBlockMe.asm - $(CPP) -nostdinc -E -P -Dvmmbugfix2 vmm/FlushMappedCacheBlockMe.asm -o vmm/patchedme.asm.gen + $(CPP) -nostdinc -E -P -Dvmmbugfix2 $< -o $@ vmm/originalme.asm.gen: vmm/FlushMappedCacheBlockMe.asm - $(CPP) -nostdinc -E -P -Doriginalcode vmm/FlushMappedCacheBlockMe.asm -o vmm/originalme.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode $< -o $@ vmm/relocme.asm.gen: vmm/FlushMappedCacheBlockMe.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate vmm/FlushMappedCacheBlockMe.asm -o vmm/relocme.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate $< -o $@ ########## update old versions of patch (SE only) vmm/original_old.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P vmm/FlushMappedCacheBlock.asm -o vmm/original_old.asm.gen + $(CPP) -nostdinc -E -P $< -o $@ vmm/reloc_old.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Drelocate -Dnofuncrelocate vmm/FlushMappedCacheBlock.asm -o vmm/reloc_old.asm.gen + $(CPP) -nostdinc -E -P -Drelocate -Dnofuncrelocate $< -o $@ vmm/original_old_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/original_old_v2.asm.gen + $(CPP) -nostdinc -E -P -Dversion_2 $< -o $@ vmm/reloc_old_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Drelocate -Dversion_2 -Dnofuncrelocate vmm/FlushMappedCacheBlock.asm -o vmm/reloc_old_v2.asm.gen + $(CPP) -nostdinc -E -P -Drelocate -Dversion_2 -Dnofuncrelocate $< -o $@ -########## VMM patch (simler version: 98 ALL) +########## VMM patch (simpler version: 98 ALL) vmm/patched_simple.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P vmm/FlushMappedCacheBlock.asm -o vmm/patched_simple.asm.gen + $(CPP) -nostdinc -E -P $< -o $@ vmm/original_simple.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode vmm/FlushMappedCacheBlock.asm -o vmm/original_simple.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode $< -o $@ vmm/reloc_simple.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate vmm/FlushMappedCacheBlock.asm -o vmm/reloc_simple.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate $< -o $@ # Version 2 vmm/patched_simple_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/patched_simple_v2.asm.gen + $(CPP) -nostdinc -E -P -Dversion_2 $< -o $@ vmm/original_simple_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/original_simple_v2.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 $< -o $@ vmm/reloc_simple_v2.asm.gen: vmm/FlushMappedCacheBlock.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 vmm/FlushMappedCacheBlock.asm -o vmm/reloc_simple_v2.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 $< -o $@ ########## headers VMM # V1 (SE) vmm_patch.h.tmp: vmm/patched.bin vmm/original.bin vmm/reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98 vmm_patch 1040 448 592 > vmm_patch.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98 vmm_patch 1040 448 592 > $@ # V2 (SE) vmm_patch_v2.h.tmp: vmm/patched_v2.bin vmm/original_v2.bin vmm/reloc_v2.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98v2 vmm_patch_v2 1052 448 604 > vmm_patch_v2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98v2 vmm_patch_v2 1052 448 604 > $@ # ME (2 parts) vmm_patch_me1.h.tmp: vmm/patchedme.bin vmm/originalme.bin vmm/relocme.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) me vmm_patch_me1 16320 12 461 > vmm_patch_me1.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) me vmm_patch_me1 16320 12 461 > $@ vmm_patch_me2.h.tmp: vmm/patchedme.bin vmm/originalme.bin vmm/relocme.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) me vmm_patch_me2 16320 16160 160 > vmm_patch_me2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) me vmm_patch_me2 16320 16160 160 > $@ vmm/fasmdiff.h.tmp: vmm/original.bin vmm/dump.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff vmm/dump.bin vmm/original.bin > vmm/fasmdiff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff vmm/dump.bin vmm/original.bin > $@ vmm/fasmdiff_v2.h.tmp: vmm/original_v2.bin vmm/dump_v2.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_v2 vmm/dump_v2.bin vmm/original_v2.bin > vmm/fasmdiff_v2.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_v2 vmm/dump_v2.bin vmm/original_v2.bin > $@ vmm/fasmdiff_me.h.tmp: vmm/originalme.bin vmm/dumpme.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_me vmm/dumpme.bin vmm/originalme.bin 0x1D8 0x3F20 > vmm/fasmdiff_me.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_me vmm/dumpme.bin vmm/originalme.bin 0x1D8 0x3F20 > $@ vmm/fasmdiff_old.h.tmp: vmm/original_old.bin vmm/dump_old.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_old vmm/dump_old.bin vmm/original_old.bin > vmm/fasmdiff_old.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_old vmm/dump_old.bin vmm/original_old.bin > $@ vmm/fasmdiff_old_v2.h.tmp: vmm/original_old_v2.bin vmm/dump_old_v2.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_old_v2 vmm/dump_old_v2.bin vmm/original_old_v2.bin > vmm/fasmdiff_old_v2.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) fasmdiff_old_v2 vmm/dump_old_v2.bin vmm/original_old_v2.bin > $@ vmm_patch_old.h.tmp: vmm/patched.bin vmm/original_old.bin vmm/reloc_old.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98_old vmm_patch_old 1040 448 592 > vmm_patch_old.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98_old vmm_patch_old 1040 448 592 > $@ vmm_patch_old_v2.h.tmp: vmm/patched_v2.bin vmm/original_old_v2.bin vmm/reloc_old_v2.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98_old_v2 vmm_patch_old_v2 1052 448 604 > vmm_patch_old_v2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98_old_v2 vmm_patch_old_v2 1052 448 604 > $@ vmm_patch_simple.h.tmp: vmm/patched_simple.bin vmm/original_simple.bin vmm/reloc_simple.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98_simple vmm_patch_simple 1040 448 592 > vmm_patch_simple.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98_simple vmm_patch_simple 1040 448 592 > $@ vmm_patch_simple_v2.h.tmp: vmm/patched_simple_v2.bin vmm/original_simple_v2.bin vmm/reloc_simple_v2.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) 98_simple_v2 vmm_patch_simple_v2 1052 448 604 > vmm_patch_simple_v2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) 98_simple_v2 vmm_patch_simple_v2 1052 448 604 > $@ # cpu speed V1 cpuspeed/speed_v1.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Dversion_1 cpuspeed/speed_v1.asm -o cpuspeed/speed_v1.asm.gen + $(CPP) -nostdinc -E -P -Dversion_1 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v1_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_1 cpuspeed/speed_v1.asm -o cpuspeed/speed_v1_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_1 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v1_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_1 cpuspeed/speed_v1.asm -o cpuspeed/speed_v1_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_1 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v1_diff.h.tmp: cpuspeed/speed_v1_dump.bin cpuspeed/speed_v1_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v1_diff cpuspeed/speed_v1_dump.bin cpuspeed/speed_v1_orig.bin > cpuspeed/speed_v1_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v1_diff cpuspeed/speed_v1_dump.bin cpuspeed/speed_v1_orig.bin > $@ cpuspeed_patch_v1.h.tmp: cpuspeed/speed_v1.bin cpuspeed/speed_v1_orig.bin cpuspeed/speed_v1_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v1 cpuspeed_patch_v1 53 0 53 > cpuspeed_patch_v1.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v1 cpuspeed_patch_v1 53 0 53 > $@ # cpu speed V2 cpuspeed/speed_v2.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Dversion_2 cpuspeed/speed_v1.asm -o cpuspeed/speed_v2.asm.gen + $(CPP) -nostdinc -E -P -Dversion_2 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v2_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 cpuspeed/speed_v1.asm -o cpuspeed/speed_v2_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v2_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 cpuspeed/speed_v1.asm -o cpuspeed/speed_v2_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v2_diff.h.tmp: cpuspeed/speed_v2_dump.bin cpuspeed/speed_v2_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v2_diff cpuspeed/speed_v2_dump.bin cpuspeed/speed_v2_orig.bin > cpuspeed/speed_v2_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v2_diff cpuspeed/speed_v2_dump.bin cpuspeed/speed_v2_orig.bin > $@ cpuspeed_patch_v2.h.tmp: cpuspeed/speed_v2.bin cpuspeed/speed_v2_orig.bin cpuspeed/speed_v2_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v2 cpuspeed_patch_v2 53 0 53 > cpuspeed_patch_v2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v2 cpuspeed_patch_v2 53 0 53 > $@ # cpu speed V4 cpuspeed/speed_v4.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Dversion_4 cpuspeed/speed_v1.asm -o cpuspeed/speed_v4.asm.gen + $(CPP) -nostdinc -E -P -Dversion_4 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v4_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_4 cpuspeed/speed_v1.asm -o cpuspeed/speed_v4_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_4 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v4_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_4 cpuspeed/speed_v1.asm -o cpuspeed/speed_v4_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_4 cpuspeed/speed_v1.asm -o $@ cpuspeed/speed_v4_diff.h.tmp: cpuspeed/speed_v4_dump.bin cpuspeed/speed_v4_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v4_diff cpuspeed/speed_v4_dump.bin cpuspeed/speed_v4_orig.bin > cpuspeed/speed_v4_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v4_diff cpuspeed/speed_v4_dump.bin cpuspeed/speed_v4_orig.bin > $@ cpuspeed_patch_v4.h.tmp: cpuspeed/speed_v4.bin cpuspeed/speed_v4_orig.bin cpuspeed/speed_v4_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v4 cpuspeed_patch_v4 53 0 53 > cpuspeed_patch_v4.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v4 cpuspeed_patch_v4 53 0 53 > $@ # cpu speed V3 cpuspeed/speed_v3.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v3.asm - $(CPP) -nostdinc -E -P -Dversion_3 cpuspeed/speed_v3.asm -o cpuspeed/speed_v3.asm.gen + $(CPP) -nostdinc -E -P -Dversion_3 cpuspeed/speed_v3.asm -o $@ cpuspeed/speed_v3_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v3.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_3 cpuspeed/speed_v3.asm -o cpuspeed/speed_v3_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_3 cpuspeed/speed_v3.asm -o $@ cpuspeed/speed_v3_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v3.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_3 cpuspeed/speed_v3.asm -o cpuspeed/speed_v3_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_3 cpuspeed/speed_v3.asm -o $@ cpuspeed/speed_v3_diff.h.tmp: cpuspeed/speed_v3_dump.bin cpuspeed/speed_v3_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v3_diff cpuspeed/speed_v3_dump.bin cpuspeed/speed_v3_orig.bin > cpuspeed/speed_v3_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v3_diff cpuspeed/speed_v3_dump.bin cpuspeed/speed_v3_orig.bin > $@ cpuspeed_patch_v3.h.tmp: cpuspeed/speed_v3.bin cpuspeed/speed_v3_orig.bin cpuspeed/speed_v3_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v3 cpuspeed_patch_v3 44 0 44 > cpuspeed_patch_v3.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v3 cpuspeed_patch_v3 44 0 44 > $@ # cpu speed V5 cpuspeed/speed_v5.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Dversion_5 cpuspeed/speed_v5.asm -o cpuspeed/speed_v5.asm.gen + $(CPP) -nostdinc -E -P -Dversion_5 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v5_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_5 cpuspeed/speed_v5.asm -o cpuspeed/speed_v5_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_5 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v5_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_5 cpuspeed/speed_v5.asm -o cpuspeed/speed_v5_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_5 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v5_diff.h.tmp: cpuspeed/speed_v5_dump.bin cpuspeed/speed_v5_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v5_diff cpuspeed/speed_v5_dump.bin cpuspeed/speed_v5_orig.bin > cpuspeed/speed_v5_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v5_diff cpuspeed/speed_v5_dump.bin cpuspeed/speed_v5_orig.bin > $@ cpuspeed_patch_v5.h.tmp: cpuspeed/speed_v5.bin cpuspeed/speed_v5_orig.bin cpuspeed/speed_v5_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v5 cpuspeed_patch_v5 69 0 69 > cpuspeed_patch_v5.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v5 cpuspeed_patch_v5 69 0 69 > $@ # cpu speed V6 cpuspeed/speed_v6.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Dversion_6 cpuspeed/speed_v5.asm -o cpuspeed/speed_v6.asm.gen + $(CPP) -nostdinc -E -P -Dversion_6 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v6_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_6 cpuspeed/speed_v5.asm -o cpuspeed/speed_v6_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_6 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v6_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_6 cpuspeed/speed_v5.asm -o cpuspeed/speed_v6_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_6 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v6_diff.h.tmp: cpuspeed/speed_v6_dump.bin cpuspeed/speed_v6_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v6_diff cpuspeed/speed_v6_dump.bin cpuspeed/speed_v6_orig.bin > cpuspeed/speed_v6_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v6_diff cpuspeed/speed_v6_dump.bin cpuspeed/speed_v6_orig.bin > $@ cpuspeed_patch_v6.h.tmp: cpuspeed/speed_v6.bin cpuspeed/speed_v6_orig.bin cpuspeed/speed_v6_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v6 cpuspeed_patch_v6 69 0 69 > cpuspeed_patch_v6.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v6 cpuspeed_patch_v6 69 0 69 > $@ # cpu speed V7 cpuspeed/speed_v7.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Dversion_7 cpuspeed/speed_v5.asm -o cpuspeed/speed_v7.asm.gen + $(CPP) -nostdinc -E -P -Dversion_7 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v7_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_7 cpuspeed/speed_v5.asm -o cpuspeed/speed_v7_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_7 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v7_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v5.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_7 cpuspeed/speed_v5.asm -o cpuspeed/speed_v7_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_7 cpuspeed/speed_v5.asm -o $@ cpuspeed/speed_v7_diff.h.tmp: cpuspeed/speed_v7_dump.bin cpuspeed/speed_v7_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v7_diff cpuspeed/speed_v7_dump.bin cpuspeed/speed_v7_orig.bin > cpuspeed/speed_v7_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v7_diff cpuspeed/speed_v7_dump.bin cpuspeed/speed_v7_orig.bin > $@ cpuspeed_patch_v7.h.tmp: cpuspeed/speed_v7.bin cpuspeed/speed_v7_orig.bin cpuspeed/speed_v7_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v7 cpuspeed_patch_v7 69 0 69 > cpuspeed_patch_v7.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v7 cpuspeed_patch_v7 69 0 69 > $@ # cpu speed V8 cpuspeed/speed_v8.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v8.asm - $(CPP) -nostdinc -E -P -Dversion_8 cpuspeed/speed_v8.asm -o cpuspeed/speed_v8.asm.gen + $(CPP) -nostdinc -E -P -Dversion_8 cpuspeed/speed_v8.asm -o $@ cpuspeed/speed_v8_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v8.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_8 cpuspeed/speed_v8.asm -o cpuspeed/speed_v8_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_8 cpuspeed/speed_v8.asm -o $@ cpuspeed/speed_v8_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speed_v8.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_8 cpuspeed/speed_v8.asm -o cpuspeed/speed_v8_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_8 cpuspeed/speed_v8.asm -o $@ cpuspeed/speed_v8_diff.h.tmp: cpuspeed/speed_v8_dump.bin cpuspeed/speed_v8_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speed_v8_diff cpuspeed/speed_v8_dump.bin cpuspeed/speed_v8_orig.bin > cpuspeed/speed_v8_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speed_v8_diff cpuspeed/speed_v8_dump.bin cpuspeed/speed_v8_orig.bin > $@ cpuspeed_patch_v8.h.tmp: cpuspeed/speed_v8.bin cpuspeed/speed_v8_orig.bin cpuspeed/speed_v8_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speed_v8 cpuspeed_patch_v8 60 0 60 > cpuspeed_patch_v8.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speed_v8 cpuspeed_patch_v8 60 0 60 > $@ # cpu speed NDIS.VXD V1 cpuspeed/speedndis_v1.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Dversion_1 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v1.asm.gen + $(CPP) -nostdinc -E -P -Dversion_1 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v1_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_1 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v1_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_1 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v1_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_1 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v1_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_1 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v1_diff.h.tmp: cpuspeed/speedndis_v1_dump.bin cpuspeed/speedndis_v1_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v1_diff cpuspeed/speedndis_v1_dump.bin cpuspeed/speedndis_v1_orig.bin > cpuspeed/speedndis_v1_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v1_diff cpuspeed/speedndis_v1_dump.bin cpuspeed/speedndis_v1_orig.bin > $@ cpuspeed_ndis_patch_v1.h.tmp: cpuspeed/speedndis_v1.bin cpuspeed/speedndis_v1_orig.bin cpuspeed/speedndis_v1_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v1 cpuspeed_ndis_patch_v1 112 0 112 > cpuspeed_ndis_patch_v1.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v1 cpuspeed_ndis_patch_v1 112 0 112 > $@ # cpu speed NDIS.VXD V3 cpuspeed/speedndis_v3.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Dversion_3 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v3.asm.gen + $(CPP) -nostdinc -E -P -Dversion_3 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v3_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_3 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v3_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_3 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v3_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v1.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_3 cpuspeed/speedndis_v1.asm -o cpuspeed/speedndis_v3_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_3 cpuspeed/speedndis_v1.asm -o $@ cpuspeed/speedndis_v3_diff.h.tmp: cpuspeed/speedndis_v3_dump.bin cpuspeed/speedndis_v3_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v3_diff cpuspeed/speedndis_v3_dump.bin cpuspeed/speedndis_v3_orig.bin > cpuspeed/speedndis_v3_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v3_diff cpuspeed/speedndis_v3_dump.bin cpuspeed/speedndis_v3_orig.bin > $@ cpuspeed_ndis_patch_v3.h.tmp: cpuspeed/speedndis_v3.bin cpuspeed/speedndis_v3_orig.bin cpuspeed/speedndis_v3_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v3 cpuspeed_ndis_patch_v3 112 0 112 > cpuspeed_ndis_patch_v3.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v3 cpuspeed_ndis_patch_v3 112 0 112 > $@ # cpu speed NDIS.VXD V2 cpuspeed/speedndis_v2.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v2.asm - $(CPP) -nostdinc -E -P -Dversion_2 cpuspeed/speedndis_v2.asm -o cpuspeed/speedndis_v2.asm.gen + $(CPP) -nostdinc -E -P -Dversion_2 cpuspeed/speedndis_v2.asm -o $@ cpuspeed/speedndis_v2_orig.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v2.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 cpuspeed/speedndis_v2.asm -o cpuspeed/speedndis_v2_orig.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Dversion_2 cpuspeed/speedndis_v2.asm -o $@ cpuspeed/speedndis_v2_reloc.asm.gen: cpuspeed/speed.inc cpuspeed/speedndis_v2.asm - $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 cpuspeed/speedndis_v2.asm -o cpuspeed/speedndis_v2_reloc.asm.gen + $(CPP) -nostdinc -E -P -Doriginalcode -Drelocate -Dversion_2 cpuspeed/speedndis_v2.asm -o $@ cpuspeed/speedndis_v2_diff.h.tmp: cpuspeed/speedndis_v2_dump.bin cpuspeed/speedndis_v2_orig.bin makediff$(HOST_SUFIX) - $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v2_diff cpuspeed/speedndis_v2_dump.bin cpuspeed/speedndis_v2_orig.bin > cpuspeed/speedndis_v2_diff.h.tmp + $(RUNPATH)makediff$(HOST_SUFIX) speedndis_v2_diff cpuspeed/speedndis_v2_dump.bin cpuspeed/speedndis_v2_orig.bin > $@ cpuspeed_ndis_patch_v2.h.tmp: cpuspeed/speedndis_v2.bin cpuspeed/speedndis_v2_orig.bin cpuspeed/speedndis_v2_reloc.bin makepatch$(HOST_SUFIX) - $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v2 cpuspeed_ndis_patch_v2 128 0 128 > cpuspeed_ndis_patch_v2.h.tmp + $(RUNPATH)makepatch$(HOST_SUFIX) speedndis_v2 cpuspeed_ndis_patch_v2 128 0 128 > $@ patch.g.o: vmm_patch.h vmm_patch_v2.h vmm_patch_me1.h vmm_patch_me2.h cpuspeed_ndis_patch_v1.h cpuspeed_ndis_patch_v2.h cpuspeed_ndis_patch_v3.h \ cpuspeed_patch_v1.h cpuspeed_patch_v2.h cpuspeed_patch_v3.h cpuspeed_patch_v4.h cpuspeed_patch_v5.h cpuspeed_patch_v6.h cpuspeed_patch_v7.h cpuspeed_patch_v8.h \ @@ -430,16 +464,15 @@ fasmdiff: vmm/fasmdiff.h vmm/fasmdiff_v2.h vmm/fasmdiff_me.h \ vmm/fasmdiff_old.h vmm/fasmdiff_old_v2.h clean: - -$(RM) *.o + -$(RM) $(OBJS_OUT) + -$(RM) $(OBJS_HOST) + -$(RM) $(OBJS_MAKEPATCH) + -$(RM) $(OBJS_MAKEDIFF) -$(RM) *.tmp - -cd mspack && $(RM) *.o - -cd pe && $(RM) *.o - -cd system && $(RM) *.o - -cd test && $(RM) *.o - -cd vmm && $(RM) *.o + -$(RM) *.res -cd vmm && $(RM) *.gen -cd vmm && $(RM) *.tmp - -cd cpuspeed && $(RM) *.o + -cd vmm && $(RM) *.res -cd cpuspeed && $(RM) *.gen -cd cpuspeed && $(RM) *.tmp -$(RM) $(OUTNAME) diff --git a/README.md b/README.md index 136009c..fdd4036 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,41 @@ Patch will be run in interactive mode and the default strategy (*patch files, VM ![Successfuly working Windows 98 - AMD](/doc/amd-5-3500u.png) -### Patching installation media +## Operation modes + +### Interactive mode +This is default mode, the program asking questions and user answear. You can just double click on EXE (or type `patch9x` to DOS command prompt) and program guide to you in patching process. For Linux build, the help is prinded if no arguments are given (default behaviour for UNIX programs) so you need specify *path*. + +### Automatic mode +Same as interactive but don't ask anything. Can be enabled with `-auto` switch and *path* to CAB files or 9x WINDOWS/SYSTEM directory needs to be specified. + +### Batch mode +In this mode program operate with single steps. Examples: + +Extract `VMM32.VXD` from instalation media +``` +patcher9x --cabs-extract D:\WIN98 VMM32.VXD +``` + +Extract VMM.VXD from VMM32.VXD +``` +patcher9x --vxd-extract VMM32.VXD VMM.VXD +``` + +Patch individual File +``` +patcher9x --patch-tlb VMM.VXD +``` + +Patch VXD archive +``` +patcher9x --patch-all VMM32.VXD +``` + +## Boot floppy +Boot floppy now contain CD driver and few utilities to prepare system disk. If you wish run Windows Installer from boot floppy, add `/NM` switch to `setup.exe` (because of different memory manager, the setup cannot determine real RAM size). Utilities are listed in [boot/info.txt](boot/info.txt). + +## Patching installation media Copy the content of *win9x* folder (or *win95* - for Windows 95 or *win98* - for Windows 98) from a CD / extract it from an ISO image. Then run: ``` @@ -78,10 +112,16 @@ If the patch is successful, you can copy the modified files back to the image. T The Windows installer primarily takes files from the installation folder and if it can't find them, it'll scan the CAB archives instead. -For Windows 95, it is better to patch the installation media, or you will need to install the patch twice - after the first reboot and again after the installation of the net. +For Windows 95, it is better to patch the installation media, or you will need to install the patch twice - after the first reboot and again after the installation of the network. **Please note, that file `VMM32.VXD` from installation IS NOT THE SAME as the file in `Windows/system` folder. Don't interchange them! See the _Patching process_ section to know more about the VMM files.** +## More informations + +Check **patcher9x** thread at Vogons: https://www.vogons.org/viewtopic.php?f=24&t=88284 + +Check GPU driver for Windows 9x: https://github.com/JHRobotics/softgpu + ## Build from source To build from source you need: @@ -112,6 +152,8 @@ make RELEASE=1 PROFILE=djgpp make strip ``` +MinGW compiled programs are linked with `msvcrt.dll` by default. To eliminate this depency (`msvcrt.dll` is missing all Windows 9x versions where isn't IE 4 or better), this project can use my [NOCRT](https://github.com/JHRobotics/nocrt) library. Use `make PROFILE=nocrt` or `make PROFILE=nocrt64` to compile program for Windows with depency only to `kernel32.dll`. + **Executable file name for most real operation systems is called `patcher9x`. For DOS, it is called `patch9x.exe` because file names are limited to 8+3 characters.** ## Patching process @@ -149,4 +191,4 @@ If you want to know more about the code, see file [speed.inc](cpuspeed/speed.inc ## Development -In future I would like include ~~patch "CPU speed limit" (95, 98 FE)~~ and patch 48-bit LBA (95, 98, ME). +In future I would like include ~~patch "CPU speed limit" (95, 98 FE)~~ and patch 48-bit LBA (95, 98, ME). Memory limit patch I want include too. diff --git a/batch.c b/batch.c new file mode 100644 index 0000000..b59ef5c --- /dev/null +++ b/batch.c @@ -0,0 +1,614 @@ +/****************************************************************************** + * Copyright (c) 2022-2023 Jaroslav Hensl * + * * + * Permission is hereby granted, free of charge, to any person * + * obtaining a copy of this software and associated documentation * + * files (the "Software"), to deal in the Software without * + * restriction, including without limitation the rights to use, * + * copy, modify, merge, publish, distribute, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the * + * Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be * + * included in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * + * OTHER DEALINGS IN THE SOFTWARE. * + * * + ******************************************************************************/ +#include "patcher9x.h" + +/** + * Split pair source|destination to individual string, if name has no '|', source and destination are same + * + * return: 0 on failure + * + * NOTE: free both string with free() + * + **/ +static int name_split(const char *arg, char **source, char **dest) +{ + char *ptr = strchr(arg, '|'); + + if(ptr != NULL) + { + int p1 = ptr - arg; + int p2 = strlen(ptr+1); + + if(p1 > 0 && p2 > 0) + { + *source = malloc(p1 + 1); + if(*source == NULL) + { + return 0; + } + *dest = malloc(p2 + 1); + if(*dest == NULL) + { + free(*source); + *source = NULL; + return 0; + } + + memcpy(*source, arg, p1); + (*source)[p1] = '\0'; + strcpy(*dest, ptr+1); + + return 1; + } + } + + int p = strlen(arg); + + *source = malloc(p + 1); + if(*source == NULL) + { + return 0; + } + + *dest = malloc(p + 1); + if(*dest == NULL) + { + free(*source); + *source = NULL; + return 0; + } + + strcpy(*source, arg); + strcpy(*dest, arg); + + return 1; +} + +/** + * The list of files in single CAB file + * + * required argv[0]: source archive + * + **/ +int batch_cab_list(options_t *options, int argc, char **argv) +{ + if(argc == 0) + { + fprintf(stderr, "missing archive name\n"); + return -1; + } + + cab_filelist_t *list = cab_filelist_open(argv[0]); + + if(!list) + { + fprintf(stderr, "Failed to open CAB %s\n", argv[0]); + return -1; + } + + char *basename = fs_basename(argv[0]); + + printf("--------------------------------\n"); + printf("CAB: %s\n", basename); + printf("--------------------------------\n"); + + const char *fn; + while((fn = cab_filelist_get(list)) != NULL) + { + printf("%s\n", fn); + } + + printf("--------------------------------\n"); + + if(basename) + { + fs_path_free(basename); + } + + cab_filelist_close(list); + + return 0; +} + +/** + * Extract one or more files from archive + * + * required argv[0]: source archive + * required argv[1]: filename|destination + * optional argv[2]: another filename|destination + * argv[ ]: ... + * + **/ +int batch_cab_extract(options_t *options, int argc, char **argv) +{ + if(argc == 0){fprintf(stderr, "missing archive name\n"); return -1;} + if(argc == 1){fprintf(stderr, "missing name of file in archive\n"); return -1;} + + int r = PATCH_OK; + int i; + + for(i = 1; i < argc; i++) + { + char *inname = NULL; + char *outname = NULL; + if(!name_split(argv[i], &inname, &outname)) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + if(cab_unpack(argv[0], inname, outname, NULL) <= 0) + { + fprintf(stderr, "File %s in %s not found!\n", inname, argv[0]); + r = PATCH_E_NOTFOUNDINCABS; + } + + free(inname); + free(outname); + } + + return r; +} + +/** + * Extract one or more files from archive + * + * required argv[0]: directory with *.CAB + * required argv[1]: filename|destination + * optional argv[2]: another filename|destination + * argv[ ]: ... + * + **/ +int batch_cabs_extract(options_t *options, int argc, char **argv) +{ + if(argc == 0){fprintf(stderr, "missing archive name\n"); return -1;} + if(argc == 1){fprintf(stderr, "missing name of file in archive\n"); return -1;} + + int r = PATCH_OK; + int i; + + for(i = 1; i < argc; i++) + { + char *inname = NULL; + char *outname = NULL; + if(!name_split(argv[i], &inname, &outname)) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + if(cab_search_unpack(argv[0], inname, outname) <= 0) + { + fprintf(stderr, "File %s in *.cab on %s not found!\n", inname, argv[0]); + r = PATCH_E_NOTFOUNDINCABS; + } + + free(inname); + free(outname); + } + + return r; +} + +/** + * The list of files in VXD archive (W3 or W4) + * + * required argv[0]: source archive + * + **/ +int batch_vxd_list(options_t *options, int argc, char **argv) +{ + if(argc == 0){fprintf(stderr, "Missing archive name\n"); return -1;} + + char *tmpname = fs_path_get3(argv[0], "_vxd.tmp", NULL); + if(!tmpname) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + vxd_filelist_t *list = vxd_filelist_open(argv[0], tmpname); + if(!list) + { + fprintf(stderr, "Failed to open VXD archive (invalid file or read-only filesystem)\n"); + fs_path_free(tmpname); + return -1; + } + + printf("--------------------------------\n"); + printf("Int.name | File name\n"); + printf("--------------------------------\n"); + + const char *fn; + char fnfull[PE_W3_FILE_NAME_SIZE + 1 + 4]; + while((fn = vxd_filelist_get(list)) != NULL) + { + strcpy(fnfull, fn); + char *s = strchr(fnfull, ' '); + if(s) + { + *s = '\0'; + } + strcat(fnfull, ".VXD"); + + printf("%s => %s\n", fn, fnfull); + } + + printf("--------------------------------\n"); + + vxd_filelist_close(list); + fs_path_free(tmpname); + + return 0; +} + +/** + * Extract one or more files from VXD archive + * + * required argv[0]: source archive + * required argv[1]: driver|destination + * optional argv[2]: another driver|destination + * argv[ ]: ... + * + **/ +int batch_vxd_extract(options_t *options, int argc, char **argv) +{ + if(argc == 0){fprintf(stderr, "missing archive name\n"); return -1;} + if(argc == 1){fprintf(stderr, "missing name of driver in archive\n"); return -1;} + + int r = PATCH_OK; + int i; + + for(i = 1; i < argc; i++) + { + char *inname = NULL; + char *outname = NULL; + char *tmpname = NULL; + if(!name_split(argv[i], &inname, &outname)) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + tmpname = fs_path_get3(outname, "_vxd.tmp", NULL); + if(tmpname == NULL) + { + free(inname); + free(outname); + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + int t = wx_unpack(argv[0], inname, outname, tmpname); + if(t != PATCH_OK) + { + fprintf(stderr, "File %s in %s not found!\n", inname, argv[0]); + report_error(t); + r = t; + } + + fs_path_free(tmpname); + free(inname); + free(outname); + } + + return r; +} + +/** + * Convert W3->W4 and vice-versa + * + * + **/ +int batch_vxd_convert(options_t *options, int argc, char **argv) +{ + int r = PATCH_OK; + + if(argc == 0){fprintf(stderr, "missing archive name\n"); return -1;} + + char *inname = NULL; + char *outname = NULL; + char *tmpname = NULL; + + if(!name_split(argv[0], &inname, &outname)) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + tmpname = fs_path_get3(outname, "_vxd.tmp", NULL); + if(tmpname == NULL) + { + free(inname); + free(outname); + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + if(options->force_w3) + { + int t = wx_to_w3(inname, tmpname); + if(t == PATCH_OK) + { + fs_rename(tmpname, outname); + } + else + { + report_error(t); + r = t; + } + } + else if(options->force_w4) + { + int t = wx_to_w4(inname, tmpname); + if(t == PATCH_OK) + { + fs_rename(tmpname, outname); + } + else + { + report_error(t); + r = t; + } + } + else + { + printf("specify -force-w3 or -force-w4 to choose target format\n"); + } + + fs_path_free(tmpname); + free(inname); + free(outname); + return r; +} + +/** + * Extract one or more files from VXD archive + * + * required argv[0]: source VXD archive + * required argv[1]: destination dir + * + **/ +int batch_vxd_extract_all(options_t *options, int argc, char **argv) +{ + int r = PATCH_OK; + + if(argc == 0){fprintf(stderr, "missing archive name\n"); return -1;} + if(argc == 1){fprintf(stderr, "missing the destination dir\n"); return -1;} + + char *tmpname = fs_path_get(argv[1], "_vxd.tmp", NULL); + if(tmpname == NULL) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + vxd_filelist_t *list = vxd_filelist_open(argv[0], tmpname); + + if(!list) + { + fprintf(stderr, "Failed to open VXD archive (invalid file or read-only filesystem)\n"); + fs_path_free(tmpname); + return -1; + } + + const char *fn; + char fnfull[PE_W3_FILE_NAME_SIZE + 1 + 4]; + while((fn = vxd_filelist_get(list)) != NULL) + { + strcpy(fnfull, fn); + char *s = strchr(fnfull, ' '); + if(s) + { + *s = '\0'; + } + strcat(fnfull, ".VXD"); + + int t = PATCH_E_MEM; + char *out = fs_path_get(argv[1], fnfull, NULL); + if(out) + { + if(fs_file_exists(out)) + { + printf("%s ignored, file (%s) exist\n", fnfull, out); + fs_path_free(out); + continue; + } + t = wx_unpack(argv[0], fnfull, out, tmpname); + fs_path_free(out); + } + if(t != PATCH_OK) + { + report_error(t); + r = t; + } + else + { + printf("Extracted %s to %s\n", fnfull, argv[1]); + } + } + + vxd_filelist_close(list); + fs_path_free(tmpname); + + return r; +} + +/** + * Apply patch to file + * + **/ +static int batch_patch_sel(options_t *options, int argc, char **argv, uint32_t patches) +{ + int r = PATCH_OK; + int type; + int i; + + if(argc == 0){fprintf(stderr, "missing at least one file tu patch\n"); return -1;} + + for(i = 0; i < argc; i++) + { + char *inname = NULL; + char *outname = NULL; + if(!name_split(argv[i], &inname, &outname)) + { + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + dos_header_t dos; + pe_header_t pe; + + char *temp1 = fs_path_get3(outname, "_wx.tmp", NULL); + if(temp1 == NULL) + { + free(inname); + free(outname); + + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + char *temp2 = fs_path_get3(outname, "_vxd.tmp", NULL); + if(temp2 == NULL) + { + free(inname); + free(outname); + fs_path_free(temp1); + + fprintf(stderr, "Memory allocation fail!\n"); + return -2; + } + + FILE *fr = fopen(inname, "rb"); + + if(!fr) + { + fprintf(stderr, "Can't open %s!\n", inname); + + free(inname); + free(outname); + fs_path_free(temp1); + fs_path_free(temp2); + continue; + } + + type = pe_read(&dos, &pe, fr); + if(type == PE_W3 || type == PE_W4) + { + fclose(fr); + + int t = patch_apply_wx(inname, temp1, temp2, patches); + if(t == PATCH_OK) + { + fs_rename(temp1, outname); + } + else + { + report_error(t); + //fprintf(stderr, "error: %d\n", t); + } + + fs_path_free(temp1); + fs_path_free(temp2); + free(inname); + free(outname); + + continue; + } // is archive + else + { + if(type != PE_LE) + { + fprintf(stderr, "Warning: file %s is not driver!\n", argv[i]); + } + + fseek(fr, 0, SEEK_SET); + int t = patch_selected(fr, temp1, patches, NULL, NULL); + fclose(fr); + if(t == PATCH_OK) + { + fs_rename(temp1, outname); + } + else + { + report_error(t); + //fprintf(stderr, "error: %d\n", t); + } + + fs_path_free(temp1); + fs_path_free(temp2); + free(inname); + free(outname); + } // is not archive + } // for + + return r; +} + +int batch_patch_all(options_t *options, int argc, char **argv) +{ + return batch_patch_sel(options, argc, argv, PATCH_CPU_SPEED_ALL | PATCH_CPU_SPEED_NDIS_ALL | PATCH_VMM_ALL); +} + +int batch_patch_tlb(options_t *options, int argc, char **argv) +{ + return batch_patch_sel(options, argc, argv, PATCH_VMM_ALL); +} + +int batch_patch_cpuspeed(options_t *options, int argc, char **argv) +{ + return batch_patch_sel(options, argc, argv, PATCH_CPU_SPEED_ALL); +} + +int batch_patch_cpuspeed_ndis(options_t *options, int argc, char **argv) +{ + return batch_patch_sel(options, argc, argv, PATCH_CPU_SPEED_NDIS_ALL); +} + +#include "batch.h" + +int batch_arg(const char *arg) +{ + batch_action_t *action = &(actions[0]); + int i; + + for(i = 0; action->func != NULL; action++,i++) + { + if(istrcmp(action->name, arg) == 0) + { + return i; + } + } + + return -1; +} + +int batch_run(options_t *options, int id, int argc, char **argv) +{ + return actions[id].func(options, argc, argv); +} + diff --git a/batch.h b/batch.h new file mode 100644 index 0000000..1a730fe --- /dev/null +++ b/batch.h @@ -0,0 +1,74 @@ +/****************************************************************************** + * Copyright (c) 2023 Jaroslav Hensl * + * * + * Permission is hereby granted, free of charge, to any person * + * obtaining a copy of this software and associated documentation * + * files (the "Software"), to deal in the Software without * + * restriction, including without limitation the rights to use, * + * copy, modify, merge, publish, distribute, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the * + * Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be * + * included in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * + * OTHER DEALINGS IN THE SOFTWARE. * + * * + ******************************************************************************/ + +/* + * Typedef and function names in separate file for README.txt ganeration + */ + + +#ifdef HELP_PROGNAME + #define FUNC_NAME(_n) NULL + struct _options_t; + typedef struct _option_t options_t; +#else + #define FUNC_NAME(_n) _n +#endif + +typedef int (*batch_f)(options_t *options, int argc, char **argv); + +typedef struct _batch_action_t +{ + batch_f func; + const char *name; + const char *desc; +} batch_action_t; + +batch_action_t actions[] = { + {FUNC_NAME(batch_cab_list), "--cab-list", "archive.cab"}, + {FUNC_NAME(batch_cab_extract), "--cab-extract", "archive.cab file1 [file2 [...]]"}, + {FUNC_NAME(batch_cabs_extract), "--cabs-extract", "dir-to-search file1 [file2 [...]]"}, + {FUNC_NAME(batch_vxd_list), "--vxd-list", "archive.vxd"}, + {FUNC_NAME(batch_vxd_extract), "--vxd-extract", "archive.vxd file1 [file2 [...]]"}, + {FUNC_NAME(batch_vxd_convert), "--vxd-convert", "archive.vxd"}, + {FUNC_NAME(batch_vxd_extract_all), "--vxd-extract-all", "archive.vxd [destination-dir]"}, + {FUNC_NAME(batch_patch_all), "--patch-all", "file.vxd [file2.vxd [...]]"}, + {FUNC_NAME(batch_patch_tlb), "--patch-tlb", "file.vxd [file2.vxd [...]]"}, + {FUNC_NAME(batch_patch_cpuspeed), "--patch-cpuspeed", "file.vxd [file2.vxd [...]]"}, + {FUNC_NAME(batch_patch_cpuspeed_ndis), "--patch-cpuspeed-ndis", "file.vxd [file2.vxd [...]]"}, + {NULL, NULL, NULL} +}; + +void batch_help() +{ + batch_action_t *action = &(actions[0]); + + printf("\nBatch mode functions:\n"); + for(; action->name != NULL; action++) + { + printf("\t%-25s %s\n", action->name, action->desc); + } +} + diff --git a/boot/README.md b/boot/README.md new file mode 100644 index 0000000..6f76655 --- /dev/null +++ b/boot/README.md @@ -0,0 +1,39 @@ +# Files for FreeDOS boot floppy/disk + +For creating your own disk, you need FreeDOS Floppy Edition from here: +[freedos.org/download/](http://www.freedos.org/download/) + +Pick boot disk `x86BOOT.img` from folder `144m` in the archive. You can remove all files except these: +``` +CONFIG SYS +COMMAND COM +KERNEL SYS +FDISKPT INI +FDCONFIG SYS +``` + +Now you probably wants add some drivers: +``` +HIMEMX EXE +JEMM386 EXE +SHSUCDX COM +UDVD2 SYS +DEVLOAD COM +``` +You can find these files some were over floppies or download CD Edition if you want them on one place. + +Now you create/edit these files (all are text files): +``` +AUTOEXEC BAT +FDCONFIG SYS +``` +Or you can use my set of config files. Don’t load DOS to hight memory, Windows installer doesn’t like it (by documentation it doesn’t like non-Microsoft memory managers at all, but if DOS is loaded to low memory it’ll usualy works.) + +To run DOS version of **Patcher9x** you need `cwsdpmi.exe` from its author site: [sandmann.dotster.com/cwsdpmi/](http://sandmann.dotster.com/cwsdpmi/). This is memory manager for DJGPP executables so program can access more memory and not need residential memory manager - useful in safe mode or minimal configurations. +``` +CWSDPMI EXE +PATCH9X EXE +``` + +To my distribution, I included other tools, they listed in [info.txt](info.txt). All are form FreeDOS distribution. + diff --git a/boot/autoexec.bat b/boot/autoexec.bat new file mode 100644 index 0000000..ac7b692 --- /dev/null +++ b/boot/autoexec.bat @@ -0,0 +1,9 @@ +@ECHO OFF +ECHO. +ECHO -------------------------------- BOOT SUCCESS --------------------------------- +ECHO. +ECHO. + +REM CLS + +TYPE README.TXT diff --git a/boot/cdrom.bat b/boot/cdrom.bat new file mode 100644 index 0000000..cd4a738 --- /dev/null +++ b/boot/cdrom.bat @@ -0,0 +1,4 @@ +@ECHO OFF +ECHO FREEDOS CDROM loader +devload udvd2.sys /d:shsu-cdx +shsucdx /d:shsu-cdx diff --git a/boot/fdconfig.sys b/boot/fdconfig.sys new file mode 100644 index 0000000..d4c8788 --- /dev/null +++ b/boot/fdconfig.sys @@ -0,0 +1,30 @@ +!SET DOSDIR=A:\ + +!LASTDRIVE=Z +!BUFFERS=20 +!FILES=40 + +!MENUCOLOR=7,0 + +MENUDEFAULT=1,5 +MENU +MENU Patch for Windows 95/98/Me to fix CPU issues +MENU Boot and system utility disk +MENU +MENU 1 - FreeDOS EMS/XMS with CD-ROM (default) +MENU 2 - FreeDOS EMS/XMS without CD-ROM +MENU 3 - FreeDOS without extended memory (safe mode) + +REM Don't load freedos to highmemory because it will break Windows installer! +REM 12?DOS=HIGH +REM 12?DOS=UMB +REM 12?DOSDATA=UMB + +12?DEVICE=HIMEMX.EXE +12?DEVICE=JEMM386.EXE X=TEST I=TEST I=B000-B7FF NOVME NOINVLPG + +1?DEVICEHIGH=udvd2.sys /d:shsu-cdx +1?INSTALLHIGH=shsucdx.com /d:shsu-cdx + +REM 12?SHELLHIGH=COMMAND.COM /E:1024 /P=AUTOEXEC.BAT +123?SHELL=COMMAND.COM /E:1024 /P=AUTOEXEC.BAT diff --git a/boot/info.bat b/boot/info.bat new file mode 100644 index 0000000..7b52c17 --- /dev/null +++ b/boot/info.bat @@ -0,0 +1,2 @@ +@echo off +type info.txt diff --git a/boot/info.txt b/boot/info.txt new file mode 100644 index 0000000..13e82e5 --- /dev/null +++ b/boot/info.txt @@ -0,0 +1,16 @@ +Tools on this disk +============================================================ +PATCH9X Patch for Windows 9x for run on newest CPUs +CDROM Load FreeDOS CD/DVD driver and mount drives +FDISK Interactive disk partition tool +FORMAT Create/recreate file system on selected drive +XCOPY Copy files and folders +DELTREE Delete files and folders +EDIT Text editor + +Drivers +============================================================ +UDVD2.SYS FreeDOS IDE CD/DVD from driver +SHSUCDX.COM Provides access to CD-ROM drives +HIMEMX.EXE Extended memory host for using XMS +JEMM386.EXE Expanded memory manager diff --git a/boot/readme.txt.template b/boot/readme.txt.template new file mode 100644 index 0000000..e24d4f7 --- /dev/null +++ b/boot/readme.txt.template @@ -0,0 +1,13 @@ +Bootable floppy with patch for Windows 95/98/Me +for run on newest CPUs - AMD ZEN 2+, Intel Tiger Lake+ + +Version: %VERSION% + +For start patching (interactive mode) type: + patch9x + +For view help type: + patch9x -h + +For info about other tools on this disk type: + info diff --git a/cputest.c b/cputest.c index 9c2fde7..c2b4a36 100644 --- a/cputest.c +++ b/cputest.c @@ -120,7 +120,7 @@ INLINE tick_t looptest(uint32_t repeats) tick(c1); - asm volatile ( + __asm volatile ( "movl %0, %%ecx;" "loop_repeat:" "loop loop_repeat;" @@ -146,7 +146,7 @@ static void print_cpu() /* cpuid detection: * https://wiki.osdev.org/CPUID */ - asm volatile ( + __asm volatile ( "pushfl;" // Save EFLAGS "pushfl;" // Store EFLAGS "xorl $0x200000,(%%esp);" // Invert the ID bit in stored EFLAGS @@ -170,7 +170,7 @@ static void print_cpu() } /* cpuid - read brand identification */ - asm volatile ( + __asm volatile ( "movl $1,%%eax;" "cpuid;" "cmp $0x80000004,%%eax;" diff --git a/exact.c b/exact.c index 6cf2fcc..6285514 100644 --- a/exact.c +++ b/exact.c @@ -1,3 +1,28 @@ +/****************************************************************************** + * Copyright (c) 2022-2023 Jaroslav Hensl * + * * + * Permission is hereby granted, free of charge, to any person * + * obtaining a copy of this software and associated documentation * + * files (the "Software"), to deal in the Software without * + * restriction, including without limitation the rights to use, * + * copy, modify, merge, publish, distribute, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the * + * Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be * + * included in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * + * OTHER DEALINGS IN THE SOFTWARE. * + * * + ******************************************************************************/ #include "patcher9x.h" static int action_extract_cabs(options_t *options, const char *path, const char *out) @@ -24,7 +49,7 @@ static int action_extract_cab(options_t *options, const char *path, const char * in_cab_name = options->input; } - if(cab_unpack(path, in_cab_name, out) > 0) + if(cab_unpack(path, in_cab_name, out, NULL) > 0) { return PATCH_OK; } diff --git a/files.c b/files.c index 560a13c..79ceff2 100644 --- a/files.c +++ b/files.c @@ -41,6 +41,8 @@ static pfiles_t pfiles[] = { {"IOS.VXD", "VMM32", PATCH_VX_UNPACK | PATCH_CPU_SPEED_ALL }, {"ESDI_506.PDR", "IOSUB", PATCH_CPU_SPEED_ALL }, {"SCSIPORT.PDR", "IOSUB", PATCH_CPU_SPEED_ALL }, + {"ESDI_506.PDR", "IOSUBSYS", PATCH_CPU_SPEED_ALL }, /* WIN95 */ + {"SCSIPORT.PDR", "IOSUBSYS", PATCH_CPU_SPEED_ALL }, /* WIN95 */ {"NDIS.VXD", "", PATCH_CPU_SPEED_NDIS_ALL }, // {"CS3KIT.EXE", "", PATCH_CPU_SPEED_ALL }, {NULL, NULL, 0 } @@ -243,7 +245,7 @@ pmodfiles_t files_lookup(const char *upath, uint32_t global_flags, uint32_t glob else if((lookup_flags & PATCH_LOOKUP_ONE_CAB) != 0) { //printf("CAB unpack: %s -> %s\n", upath, fname); - if(cab_unpack(upath, pfile->file, fname) > 0) + if(cab_unpack(upath, pfile->file, fname, NULL) > 0) { FILE *fp = fopen(fname, "rb"); if(fp) diff --git a/help.h b/help.h index 6e83706..a1b3ef8 100644 --- a/help.h +++ b/help.h @@ -47,7 +47,9 @@ static const char HELP_NAME[] = "Patch for Windows 9x for run on newest CPUs - AMD ZEN 2+, Intel Tiger Lake+\n" "Version: " PATCHER9X_VERSION_STR "\n\n" - "Usage:\n" HELP_PROGSTR " [path] [batch options]\n" + "Usage:\n" HELP_PROGSTR " [options] [path]\n" + " or\n" + HELP_PROGSTR " [options] \n" "path: path to installed windows directory or directory with windows instalation\n" "options:\n" #ifndef HELP_SHORT /* shorten help a bit to fit 80x25 screen */ @@ -57,11 +59,6 @@ static const char HELP_NAME[] = "Patch for Windows 9x for run on newest CPUs - A "\t-hh: print longer help\n" #endif "\t-auto,-y: use default actions (if path given) and don't bother user\n" - "\t-cab-extract: extract file from MS cab archive\n" - "\t-wx-extract: extract file from VMM32.VXD\n" - "\t-patch-tlb: apply TLB patch to file\n" - "\t-patch-cpuspeed: apply CPU SPEED patch to file\n" - "\t-patch-cpuspeed-ndis: apply CPU SPEED for NDIS.VXD patch to file\n" "\t-no-backup: don't backup files before modify\n" #ifndef HELP_SHORT "\t-force-w3: when patching VMM32.VXD, leave it as W3 file\n" @@ -74,36 +71,14 @@ static const char HELP_NAME[] = "Patch for Windows 9x for run on newest CPUs - A "\t-no-cpupatch-ndis: do not apply CPU SPEED patches for NDIS.VXD\n" "\t-millennium: ignored, Me patch is included in TLB set\n" #endif - "\t-i : override input file name\n" - "\t-o : override output file name\n" "\n" - "Options can be chained:\n" - "example: " HELP_PROGSTR " D:\\WIN98 -cab-extract -wx-extract -patch-tlb -o C:\\windows\\system\\VMM32\\VMM.VXD\n" - "results patched VMM.VXD copied to system from instalation drive\n" -#ifndef HELP_SHORT - "\n" - "example: " HELP_PROGSTR " C:\\WINDOWS\\SYSTEM\\VMM32.VXD -wx-extract -i INT13 -o INT13.VXD\n" - "extract INT13.VXD from VMM32.VXD\n" - "\n" - "example: " HELP_PROGSTR " D:\\WIN98 -cab-extract -i IOS.VXD -o IOS.VXD\n" - "search CAB archives in D:\\WIN98 and extract from them IOS.VXD\n" - "\n" - "Defaults:\n" - "\t[path] = " DEFAULT_PATH "\n" - "\t = " DEFAULT_INPUT_VX " (if [path] leads to VMM32.VXD)\n" - "\t = " DEFAULT_INPUT_CAB " (if [path] leads to CAB archive)\n" - "\t = " DEFAULT_OUTPUT_LE " (if output is extracted from VMM32.VXD)\n" - "\t = " DEFAULT_OUTPUT_VX " (if output is patched VMM32.VXD)\n" - "\n" -#endif #ifdef HELP_EXTRA - "\n" - "When running without options program operate in interactive mode (ask user)\n" + "When running without arguments, program operate in interactive mode (ask user)\n" #endif ; #ifndef HELP_LONG_REP_ARG -# define HELP_LONG_REP_ARG(_arg) (_arg),(_arg),(_arg),(_arg) +# define HELP_LONG_REP_ARG(_arg) (_arg),(_arg) #endif #ifndef HELP_SHORT_REP_ARG diff --git a/mspack/chmd.c b/mspack/chmd.c index bc537b0..55aeffb 100644 --- a/mspack/chmd.c +++ b/mspack/chmd.c @@ -832,7 +832,9 @@ static int search_chunk(struct mschmd_header *chm, # include # define TOLOWER(x) towlower(x) #else -# include +# ifndef NOCRT +# include +# endif # define TOLOWER(x) tolower(x) #endif diff --git a/mspack/mspack.h b/mspack/mspack.h index 72bb49c..b570e17 100644 --- a/mspack/mspack.h +++ b/mspack/mspack.h @@ -165,6 +165,10 @@ extern "C" { #include #include +#ifdef NOCRT +#include "nocrt.h" +#endif + /** * System self-test function, to ensure both library and calling program * can use one another. diff --git a/mspack/system.c b/mspack/system.c index 47f5272..5383ed1 100644 --- a/mspack/system.c +++ b/mspack/system.c @@ -108,9 +108,11 @@ struct mspack_system *mspack_default_system = NULL; /* implementation of mspack_default_system for standard C library */ +#ifndef NOCRT #include #include #include +#endif #include struct mspack_file_p { diff --git a/mspack/system.h b/mspack/system.h index 7e4be46..a7d7659 100644 --- a/mspack/system.h +++ b/mspack/system.h @@ -43,7 +43,9 @@ extern "C" { #endif #if DEBUG -# include +# ifndef NOCRT +# include +# endif # define D(x) do { printf("%s:%d (%s) ",__FILE__, __LINE__, __func__); \ printf x ; fputc('\n', stdout); fflush(stdout);} while (0); #else diff --git a/nocrt b/nocrt new file mode 160000 index 0000000..9715359 --- /dev/null +++ b/nocrt @@ -0,0 +1 @@ +Subproject commit 9715359003a4c0afd90485dbfd7d6465df99bd04 diff --git a/patcher9x.c b/patcher9x.c index bf1ab36..f52aae5 100644 --- a/patcher9x.c +++ b/patcher9x.c @@ -41,7 +41,7 @@ #endif static char userpath[MAX_PATH]; -const char *patcher9x_default_path = DEFAULT_PATH; +char patcher9x_default_path[MAX_PATH] = DEFAULT_PATH; static const char *question_dir_select[] = { @@ -65,6 +65,7 @@ static void print_help(const char *progname, int longer) if(longer > 1) { printf(help_long, HELP_LONG_REP_ARG(progname)); + batch_help(); } else { @@ -72,6 +73,7 @@ static void print_help(const char *progname, int longer) } #else printf(help, HELP_LONG_REP_ARG(progname)); + batch_help(); #endif } @@ -79,11 +81,15 @@ static void print_help(const char *progname, int longer) * Parse argc/argv * **/ -static int read_arg(options_t *options, int argc, char **argv) +static int read_arg(options_t *options, int argc, char **argv, int *batch_id, int *batch_argc, char **batch_argv) { int i; memset(options, 0, sizeof(options_t)); options->mode = MODE_INTERACTIVE; + int unk_args = 0; + int unk_arg = 0; + + *batch_argc = 0; for(i = 1; i < argc; i++) { @@ -93,7 +99,7 @@ static int read_arg(options_t *options, int argc, char **argv) options->print_help = 1; } #ifdef DOS_MODE - if(istrcmp(arg, "-hh") == 0) + else if(istrcmp(arg, "-hh") == 0) { options->print_help = 2; } @@ -106,34 +112,6 @@ static int read_arg(options_t *options, int argc, char **argv) { options->cputest = 1; } - else if(istrcmp(arg, "-cab-extract") == 0) - { - options->cab_extract = 1; - options->mode = MODE_EXACT; - } - else if(istrcmp(arg, "-wx-extract") == 0) - { - options->wx_extract = 1; - options->mode = MODE_EXACT; - } - else if(istrcmp(arg, "-patch-tlb") == 0) - { - options->patch = 1; - options->patches |= PATCH_VMM_ALL; - options->mode = MODE_EXACT; - } - else if(istrcmp(arg, "-patch-cpuspeed") == 0) - { - options->patch = 1; - options->patches |= PATCH_CPU_SPEED_ALL; - options->mode = MODE_EXACT; - } - else if(istrcmp(arg, "-patch-cpuspeed-ndis") == 0) - { - options->patch = 1; - options->patches |= PATCH_CPU_SPEED_NDIS_ALL; - options->mode = MODE_EXACT; - } else if(istrcmp(arg, "-force-w3") == 0) { options->patches |= PATCH_FORCE_W3; @@ -188,30 +166,15 @@ static int read_arg(options_t *options, int argc, char **argv) options->mode = MODE_AUTO; } } - else if(istrcmp(arg, "-i") == 0) - { - if(i+1 < argc) - { - options->input = argv[++i]; - options->mode = MODE_EXACT; - } - else - { - fprintf(stderr, "Missing argument: expected file name\n"); - return -1; - } - } - else if(istrcmp(arg, "-o") == 0) + else if(batch_arg(arg) >= 0) { - if(i+1 < argc) + options->mode = MODE_BATCH; + if(*batch_id >= 0) { - options->output = argv[++i]; - } - else - { - fprintf(stderr, "Missing argument: expected file name\n"); - return -1; + fprintf(stderr, "Possible to use only ONE batch function in ONE run\n"); + return -2; } + *batch_id = batch_arg(arg); } else { @@ -221,12 +184,23 @@ static int read_arg(options_t *options, int argc, char **argv) } else { - fprintf(stderr, "Unknown argument: %s\n", arg); - return -1; + if(unk_args++ == 0) + { + unk_arg = i; + } } + + batch_argv[*batch_argc] = (char*)arg; + (*batch_argc)++; } } + if(options->mode != MODE_BATCH && unk_args > 0) + { + fprintf(stderr, "Unknown argument: %s\n", argv[unk_arg]); + return -1; + } + if(options->force_w3 && options->force_w4) { fprintf(stderr, "Incompatible arguments: -force-w3 and -force-w4\n"); @@ -275,7 +249,10 @@ static char *ask_user_path(options_t *options, const char *q, const char *defaul { if(i < MAX_PATH) { - input_buffer[i++] = c; + if(c != '\r') + { + input_buffer[i++] = c; + } } } } while(c != '\n' && c != EOF); @@ -337,7 +314,10 @@ static int ask_user(options_t *options, const char *q, const char **ans, int ans { if(i < USER_IN_MAX) { - input_buffer[i++] = c; + if(c != '\r') + { + input_buffer[i++] = c; + } } } } while(c != '\n' && c != EOF); @@ -398,6 +378,8 @@ static int ask_user_patch(options_t *options) do { c = fgetc(stdin); + if(c == '\r') continue; + switch(c) { case 'y': @@ -594,6 +576,7 @@ static int run_interactive(options_t *options) if(fs_is_writeable_dir(upath, NULL) == 0) { fprintf(stderr, "Error: %s is not writeable directory\n", upath); + goto run_interactive_fail; } else { @@ -657,6 +640,7 @@ static int run_interactive(options_t *options) } } +run_interactive_fail: if(patch_success > 0) { printf("Patch applied successfully!\n"); @@ -683,8 +667,13 @@ static int run_interactive(options_t *options) int main(int argc, char **argv) { int test; + int batch_id = -1; + int batch_argc = 0; + char **batch_argv = NULL; options_t options; + set_default_path(patcher9x_default_path); + /* self test by mspack */ MSPACK_SYS_SELFTEST(test); if(test != MSPACK_ERR_OK) @@ -693,7 +682,9 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - if(read_arg(&options, argc, argv) == 0) + batch_argv = calloc(sizeof(char*), argc); + + if(read_arg(&options, argc, argv, &batch_id, &batch_argc, batch_argv) == 0) { if(options.cputest) { @@ -710,9 +701,13 @@ int main(int argc, char **argv) print_help(argv[0], options.print_help); return EXIT_SUCCESS; } - else if(options.mode == MODE_EXACT) + /*else if(options.mode == MODE_EXACT) { return run_exact(&options); + }*/ + else if(options.mode == MODE_BATCH) + { + return batch_run(&options, batch_id, batch_argc, batch_argv); } else /* run interactive */ { diff --git a/patcher9x.h b/patcher9x.h index 98597bc..9265df7 100644 --- a/patcher9x.h +++ b/patcher9x.h @@ -33,6 +33,7 @@ #include #include #include +#include "nocrt.h" #include "version.h" @@ -131,6 +132,7 @@ #define MODE_AUTO 1 /* automaticly determine action from path */ #define MODE_INTERACTIVE 2 /* same as auto but ask user if sure */ #define MODE_EXACT 3 /* use steps by command line */ +#define MODE_BATCH 4 /* use one step on command line */ /* patch lookup flags */ #define PATCH_LOOKUP_CABS 1 /* scan cab files */ @@ -149,7 +151,7 @@ * Platform selection */ -#if defined(__MSDOS__) || (defined(_WIN32) && !defined(_WIN64)) +#if defined(__MSDOS__) || defined(_WIN32) #define RUN_WITHOUT_ARGS #endif @@ -182,19 +184,33 @@ typedef struct _options_t typedef struct _pmodfiles_t *pmodfiles_t; +struct scanned_files_list; +typedef struct scanned_files_list scanned_files_list_t; + /* * Functions */ /* unpack.c */ int cab_search_unpack(const char *dirname, const char *infilename, const char *out); -int cab_unpack(const char *srccab, const char *infilename, const char *out); -int cab_search_unpack(const char *dirname, const char *infilename, const char *out); +int cab_unpack(const char *srccab, const char *infilename, const char *out, scanned_files_list_t *list); int wx_unpack(const char *src, const char *infilename, const char *out, const char *tmpname); int wx_to_w3(const char *in, const char *out); int wx_to_w4(const char *in, const char *out); +struct cab_filelist; +typedef struct cab_filelist cab_filelist_t; +cab_filelist_t *cab_filelist_open(const char *file); +const char *cab_filelist_get(cab_filelist_t *list); +void cab_filelist_close(cab_filelist_t *list); + +struct vxd_filelist; +typedef struct vxd_filelist vxd_filelist_t; +vxd_filelist_t *vxd_filelist_open(const char *file, const char *tmp); +const char *vxd_filelist_get(vxd_filelist_t *list); +void vxd_filelist_close(vxd_filelist_t *list); + /* patch.c */ int patch_apply(const char *srcfile, const char *dstfile, int flags, int *applied); int patch_apply_wx(const char *srcfile, const char *dstfile, const char *tmpname, int flags); @@ -213,6 +229,11 @@ void files_print(pmodfiles_t list); /* exact.c */ int run_exact(options_t *options); +/* batch.c */ +int batch_arg(const char *arg); +int batch_run(options_t *options, int id, int argc, char **argv); +void batch_help(); + /* trace.c */ void print_trace(); FILE *fopen_log(const char *fn, const char *mode, const char *file, int line); @@ -224,10 +245,13 @@ void print_error(int code, const char *file, int line); /* cputest.c */ void cputest(); +/* pwin32.c */ +void set_default_path(char *default_path); + /* * Globals */ -extern const char *patcher9x_default_path; +extern char patcher9x_default_path[MAX_PATH]; #endif /* __PATCHER9X_INCLUDED__ */ diff --git a/patcher9x.ico b/patcher9x.ico new file mode 100644 index 0000000000000000000000000000000000000000..7f5fcfaeff9d03596ec32d77b5d8c99bd9c7f4b9 GIT binary patch literal 766 zcmb7Cu};G<6g(58IAXwEkTTJcu~HYL4&{@|1v^U+6BEBs(E-@Hks+$N zmy{-zy6~K{-@Q9OTUG$YF&-Pvm-xB>ZUEd7W8#63dK=WvhXeS*xo+Xi6jfDm6(O`A zLXeE$kdjPiLT4<-i$8@)24(Dl=j^UV$+|c2hGlQit?y`PX=;v!Smbn#A}QJq8tkvc z0M{PTZJ+_ZKSB(~LkvzDAT1N^x(;O4J{ovenuYh;dmmey|70pDkXz=NBbF$6NNyL* z#o%~@k?@?HJrrd_o*g*SB3Y9&TAcDPr8zpekMYykYK=i1LE z-n+hl*a=y~9UnD$EJGLU2SyY=~xlicL%{qQ> + + + Patcher9x + + + + + + + + diff --git a/pe/ds_compress.c b/pe/ds_compress.c index 9bb85ad..313e8a5 100644 --- a/pe/ds_compress.c +++ b/pe/ds_compress.c @@ -26,6 +26,7 @@ #include #include #include "doublespace.h" +#include "nocrt.h" #define FS_SEGMENT_SIZE 512 @@ -67,8 +68,10 @@ static void ds_out_pos(size_t count, size_t pos, bitstream_t *out) size_t pos2 = 0; size_t zeroes = 0; +#ifdef DEBUG assert(count >= 2); assert(pos < 4415); +#endif if(pos < 64) { @@ -95,7 +98,9 @@ static void ds_out_pos(size_t count, size_t pos, bitstream_t *out) //printf("count: %u num: %d zeroes: %u\n", count, num, zeroes); +#ifdef DEBUG assert(num >= 0); +#endif buf2 |= num << (zeroes + pos2 + 1); @@ -103,7 +108,9 @@ static void ds_out_pos(size_t count, size_t pos, bitstream_t *out) //printf(" buf: %08X\n", buf2); +#ifdef DEBUG assert(pos2 <= 32); +#endif bs_write_bit_le(out, buf2, pos2); } diff --git a/pe/ds_decompress.c b/pe/ds_decompress.c index be26d62..3c264c1 100644 --- a/pe/ds_decompress.c +++ b/pe/ds_decompress.c @@ -25,6 +25,7 @@ *******************************************************************************/ #include #include "doublespace.h" +#include "nocrt.h" /** * Read block "count" diff --git a/pe/pew.c b/pe/pew.c index a97ac85..3289885 100644 --- a/pe/pew.c +++ b/pe/pew.c @@ -29,6 +29,7 @@ #include #include "pew.h" #include "doublespace.h" +#include "nocrt.h" /* header of LE file */ static const uint8_t dos_program_le[] = @@ -172,11 +173,11 @@ pe_w3_t *pe_w3_read(dos_header_t *dos, pe_header_t *pe, FILE *fp) /* read files list */ fseek(fp, w3->pe_pos + sizeof(pe_header_t), SEEK_SET); fread(&(w3->files[0]), sizeof(pe_w3_file_t), pe->w3.vxd_count, fp); + + fseek(fp, 0, SEEK_END); + w3->file_size = ftell(fp); } - fseek(fp, 0, SEEK_END); - w3->file_size = ftell(fp); - return w3; } diff --git a/pwin32.c b/pwin32.c new file mode 100644 index 0000000..7328336 --- /dev/null +++ b/pwin32.c @@ -0,0 +1,95 @@ +/****************************************************************************** + * Copyright (c) 2023 Jaroslav Hensl * + * * + * Permission is hereby granted, free of charge, to any person * + * obtaining a copy of this software and associated documentation * + * files (the "Software"), to deal in the Software without * + * restriction, including without limitation the rights to use, * + * copy, modify, merge, publish, distribute, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the * + * Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be * + * included in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * + * OTHER DEALINGS IN THE SOFTWARE. * + * * + ******************************************************************************/ +#ifdef _WIN32 +#include +#endif + +#include "patcher9x.h" + +#ifdef _WIN32 +/* +* NT function tip from: https://stackoverflow.com/a/57130 + * but here is modification, 9x kernel has these function defined, but call them + * fail with ERROR_CALL_NOT_IMPLEMENTED. + */ +typedef BOOL (WINAPI * GetThreadPriorityBoostF)(HANDLE hThread, PBOOL pDisablePriorityBoost); +static BOOL version_is_nt() +{ + HANDLE h = GetModuleHandleA("kernel32.dll"); + if(h) + { + GetThreadPriorityBoostF GetThreadPriorityBoostH = (GetThreadPriorityBoostF)GetProcAddress(h, "GetThreadPriorityBoost"); + if(GetThreadPriorityBoostH != NULL) + { + BOOL junk; + if(GetThreadPriorityBoostH(GetCurrentThread(), &junk)) + { + return TRUE; + } + + if(GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + { + return TRUE; + } + } + } + + return FALSE; +} + +void set_default_path(char *default_path) +{ + if(version_is_nt()) + { + GetModuleFileNameA(NULL, default_path, MAX_PATH); + default_path[MAX_PATH-1] = '\0'; + + /* cutoff file name */ + char *p1 = strrchr(default_path, '\\'); + char *p2 = strrchr(default_path, '/'); + + if(p1 > p2) + { + *p1 = '\0'; + } + else if(p2 != NULL) + { + *p2 = '\0'; + } + } +} + +#else + +void set_default_path(char *default_path) +{ + (void)default_path; +} + +#endif + + + diff --git a/system/bitstream.h b/system/bitstream.h index b20d1b9..e649231 100644 --- a/system/bitstream.h +++ b/system/bitstream.h @@ -32,6 +32,10 @@ #include #include +#ifdef NOCRT_FILE +#include "nocrt.h" +#endif + /* stream types */ #define BITSTREAM_MEM 0 #define BITSTREAM_FILE 1 diff --git a/system/bpatcher.c b/system/bpatcher.c index a0da35f..e0f2bfc 100644 --- a/system/bpatcher.c +++ b/system/bpatcher.c @@ -25,6 +25,7 @@ *******************************************************************************/ #include #include "bpatcher.h" +#include "nocrt.h" /** * Search for 'needle' in 'haystack' using binary sieve on 'needle'. diff --git a/system/bpatcher.h b/system/bpatcher.h index ea11a40..3946e57 100644 --- a/system/bpatcher.h +++ b/system/bpatcher.h @@ -28,6 +28,10 @@ #include +#ifdef NOCRT_FILE +#include "nocrt.h" +#endif + #define BPATCHER_FILE_BUF 8192 ssize_t search_sieve(const uint8_t *haystack, size_t haystack_size, diff --git a/system/filesystem.c b/system/filesystem.c index 4773f5b..3e676ff 100644 --- a/system/filesystem.c +++ b/system/filesystem.c @@ -27,7 +27,6 @@ #include #include #include -#include "filesystem.h" #ifdef _WIN32 #include @@ -39,6 +38,9 @@ #include #endif +#include "filesystem.h" +#include "nocrt.h" + #define INT_MAGIC 0xF011EECC static char name_buffer[MAX_PATH]; diff --git a/system/filesystem.h b/system/filesystem.h index dd253fb..e1fb726 100644 --- a/system/filesystem.h +++ b/system/filesystem.h @@ -26,6 +26,10 @@ #ifndef __FILESYSTEM_H__INCLUDED__ #define __FILESYSTEM_H__INCLUDED__ +#ifdef NOCRT_FILE +#include "nocrt.h" +#endif + #define FS_FILTER_FILE 1 #define FS_FILTER_DIR 2 diff --git a/unpacker.c b/unpacker.c index afb23b9..bebd987 100644 --- a/unpacker.c +++ b/unpacker.c @@ -73,6 +73,19 @@ typedef struct _cab_list_t cab_list_item_t *last; } cab_list_t; +/* list of already scanned files */ +struct scanned_files_item +{ + char *filename; + struct scanned_files_item *next; +}; + +struct scanned_files_list +{ + struct scanned_files_item *first; + struct scanned_files_item *last; +}; + /* allocate and add item to the end of list */ static cab_list_item_t *cab_list_add(cab_list_t *list) { @@ -120,7 +133,70 @@ static void cab_list_clear(cab_list_t *list) static void cab_list_init(cab_list_t *list) { list->first = NULL; - list->last = NULL; + list->last = NULL; +} + +/* init file scan list */ +static void scanned_files_list_init(scanned_files_list_t *list) +{ + list->first = NULL; + list->last = NULL; +} + +static void scanned_files_list_add(scanned_files_list_t *list, const char *fn) +{ + size_t len = strlen(fn); + struct scanned_files_item *item = malloc(sizeof(struct scanned_files_item) + len + 1); + if(item != NULL) + { + item->filename = (char *)(item+1); + strcpy(item->filename, fn); + item->next = NULL; + + if(list->last == NULL) + { + list->first = item; + list->last = item; + } + else + { + list->last->next = item; + list->last = item; + } + } +} + +static int scanned_files_lookup(scanned_files_list_t *list, const char *fn) +{ + struct scanned_files_item *item = list->first; + + while(item != NULL) + { + if(istrcmp(item->filename, fn) == 0) + { + return 1; + } + + item = item->next; + } + + return 0; +} + +static void scanned_files_clean(scanned_files_list_t *list) +{ + struct scanned_files_item *item = list->first; + + while(item != NULL) + { + struct scanned_files_item *del_item = item; + item = item->next; + + free(del_item); + } + + list->first = NULL; + list->last = NULL; } /** @@ -292,7 +368,7 @@ static void cab_analyze(const char *srccab, char **prevcab, char **nextcab) * * @return: number of extracet files (should be 0 or 1) **/ -int cab_unpack(const char *srccab, const char *infilename, const char *out) +int cab_unpack(const char *srccab, const char *infilename, const char *out, scanned_files_list_t *sclist) { int cnt = 0; char *search; @@ -317,6 +393,9 @@ int cab_unpack(const char *srccab, const char *infilename, const char *out) cab_list_init(&prevlist); cab_list_init(&nextlist); + /* add file to list */ + if(sclist != NULL) scanned_files_list_add(sclist, fs_basename(srccab)); + /* search for archive previous parts */ search = (char*)srccab; do @@ -331,6 +410,8 @@ int cab_unpack(const char *srccab, const char *infilename, const char *out) { item->filename = prev; item->cab = cabd->open(cabd, item->filename); + + if(sclist != NULL) scanned_files_list_add(sclist, item->filename); // printf("PREV: %s\n", item->filename); } } @@ -351,6 +432,8 @@ int cab_unpack(const char *srccab, const char *infilename, const char *out) { item->filename = next; item->cab = cabd->open(cabd, item->filename); + + if(sclist != NULL) scanned_files_list_add(sclist, item->filename); // printf("NEXT: %s\n", item->filename); } } @@ -405,7 +488,7 @@ int cab_unpack(const char *srccab, const char *infilename, const char *out) { /* nice message for user */ char *cab_first = NULL; - char *cab_last = NULL; + char *cab_last = NULL; if(item_first_cab == NULL && item_last_cab == NULL) { @@ -468,8 +551,8 @@ int cab_unpack(const char *srccab, const char *infilename, const char *out) { printf("FAILURE (%d)\n", t); } - } - } + } // infilename + } // for files cabd->close(cabd, cab); } // cab @@ -498,20 +581,27 @@ int cab_search_unpack(const char *dirname, const char *infilename, const char *o fs_dir_t *dir = fs_dir_open(dirname); int cnt = 0; const char *fn; + + scanned_files_list_t sclist; + scanned_files_list_init(&sclist); + if(dir) { while((fn = fs_dir_read(dir, FS_FILTER_FILE)) != NULL) { if(fs_ext_match(fn, "cab") != 0) - { + { char *cabfile = fs_path_get(dirname, fn, NULL); - if(cab_unpack(cabfile, infilename, out) > 0) + if(!scanned_files_lookup(&sclist, fn)) { - //printf("extracted: %s\n", infilename); - cnt++; + if(cab_unpack(cabfile, infilename, out, &sclist) > 0) + { + //printf("extracted: %s\n", infilename); + cnt++; + } + fs_path_free(cabfile); } - fs_path_free(cabfile); } if(cnt > 0) @@ -522,6 +612,8 @@ int cab_search_unpack(const char *dirname, const char *infilename, const char *o fs_dir_close(&dir); } + scanned_files_clean(&sclist); + return cnt; } @@ -587,9 +679,13 @@ int wx_unpack(const char *src, const char *infilename, const char *out, const ch { status = PATCH_E_READ; } + + fclose(fp); } else if(t == PE_W4) { + fclose(fp); + if(exist_temp) { status = PATCH_E_CONVERT; @@ -600,33 +696,37 @@ int wx_unpack(const char *src, const char *infilename, const char *out, const ch { fp2 = FOPEN_LOG(tmpname, "rb"); if(fp2 != NULL) - { - w3 = pe_w3_read(&dos2, &pe2, fp2); - if(w3 != NULL) + { + if(pe_read(&dos2, &pe2, fp2) == PE_W3) { - char *path_without_ext = fs_path_get(NULL, infilename, ""); - int status_extract = 0; - - if(path_without_ext != NULL) + w3 = pe_w3_read(&dos2, &pe2, fp2); + if(w3 != NULL) { - status_extract = pe_w3_extract(w3, path_without_ext, out); - fs_path_free(path_without_ext); + char *path_without_ext = fs_path_get(NULL, infilename, ""); + int status_extract = 0; + + if(path_without_ext != NULL) + { + status_extract = pe_w3_extract(w3, path_without_ext, out); + fs_path_free(path_without_ext); + } + else + { + status_extract = pe_w3_extract(w3, infilename, out); + } + + if(status_extract == PE_OK) + { + status = PATCH_OK; + } + + pe_w3_free(w3); } else { - status_extract = pe_w3_extract(w3, infilename, out); + //printf("pe_w3_read FAIL\n"); + status = PATCH_E_READ; } - - if(status_extract == PE_OK) - { - status = PATCH_OK; - } - - pe_w3_free(w3); - } - else - { - status = PATCH_E_READ; } fclose(fp2); @@ -636,15 +736,15 @@ int wx_unpack(const char *src, const char *infilename, const char *out, const ch { status = PATCH_E_READ; } - } + } // wx_to_w3 } } else { + fclose(fp); status = PATCH_E_WRONG_TYPE; } - fclose(fp); - } + } // fopen else { status = PATCH_E_READ; @@ -758,3 +858,191 @@ int wx_to_w4(const char *in, const char *out) return status; } + +/* context listing - CABS */ +struct cab_filelist +{ + struct mscab_decompressor *cabd; + struct mscabd_cabinet *cab; + struct mscabd_file *file; +}; + +/** + * Open cab for file listing + * + **/ +cab_filelist_t *cab_filelist_open(const char *file) +{ + cab_filelist_t *list = malloc(sizeof(cab_filelist_t)); + list->cabd = NULL; + list->cab = NULL; + list->file = NULL; + + if((list->cabd = mspack_create_cab_decompressor(NULL)) == NULL) + { + free(list); + return NULL; + } + + list->cab = list->cabd->open(list->cabd, file); + if(list->cab == NULL) + { + mspack_destroy_cab_decompressor(list->cabd); + free(list); + return NULL; + } + + list->file = list->cab->files; + + return list; +} + +/** + * Return file name and move pointer to another file + * + **/ +const char *cab_filelist_get(cab_filelist_t *list) +{ + if(list->file != NULL) + { + const char *s = list->file->filename; + list->file = list->file->next; + + return s; + } + return NULL; +} + +/** + * Close CAB + * + **/ +void cab_filelist_close(cab_filelist_t *list) +{ + if(list->cab) + { + list->cabd->close(list->cabd, list->cab); + } + + if(list->cabd) + { + mspack_destroy_cab_decompressor(list->cabd); + } + + free(list); +} + +/* context listting - VXD */ +struct vxd_filelist +{ + pe_w3_t *w3; + size_t act; + const char *tmp; +}; + +/** + * Open VXD (W3/W4) for file listting, if W4 convert to W3 using tmp + * + **/ +vxd_filelist_t *vxd_filelist_open(const char *file, const char *tmp) +{ + dos_header_t dos; + pe_header_t pe; + int type; + FILE *fr; + + vxd_filelist_t *list = malloc(sizeof(vxd_filelist_t)); + if(list == NULL) + { + return NULL; + } + + list->w3 = NULL; + list->act = 0; + list->tmp = NULL; + + fr = fopen(file, "rb"); + if(!fr) + { + free(list); + return NULL; + } + + type = pe_read(&dos, &pe, fr); + if(type == PE_W3) + { + list->w3 = pe_w3_read(&dos, &pe, fr); + fclose(fr); + } + else if(type == PE_W4) + { + fclose(fr); + if(wx_to_w3(file, tmp) == PATCH_OK) + { + fr = fopen(tmp, "rb"); + if(fr) + { + type = pe_read(&dos, &pe, fr); + if(type == PE_W3) + { + list->w3 = pe_w3_read(&dos, &pe, fr); + list->tmp = tmp; + } + fclose(fr); + } + } + } + else + { + fclose(fr); + } + + if(list->w3 == NULL) + { + free(list); + return NULL; + } + + return list; +} + +/** + * Return file name and move pointer to another file + * + **/ +const char *vxd_filelist_get(vxd_filelist_t *list) +{ + static char cname[PE_W3_FILE_NAME_SIZE+1]; + + if(list->act < list->w3->files_cnt) + { + uint8_t *ptr = list->w3->files[list->act].name; + memcpy(cname, ptr, PE_W3_FILE_NAME_SIZE); + cname[PE_W3_FILE_NAME_SIZE] = '\0'; + + list->act++; + return cname; + } + + return NULL; +} + +/** + * Close the file and delete temp if was used + * + **/ +void vxd_filelist_close(vxd_filelist_t *list) +{ + if(list->w3 != NULL) + { + pe_w3_free(list->w3); + } + + if(list->tmp) + { + fs_unlink(list->tmp); + } + + free(list); +} + diff --git a/version.h b/version.h index 3eee1ff..46f52dd 100644 --- a/version.h +++ b/version.h @@ -4,13 +4,13 @@ #define PATCHER9X_STR(x) PATCHER9X_STR_(x) #define PATCHER9X_MAJOR 0 -#define PATCHER9X_MINOR 7 +#define PATCHER9X_MINOR 8 #ifndef PATCHER9X_PATCH -#define PATCHER9X_PATCH 45 +#define PATCHER9X_PATCH 50 #endif -#define PATCHER9X_TAG "BETA3" +#define PATCHER9X_TAG "BETA4" #define PATCHER9X_VERSION_STR_BUILD(_ma, _mi, _pa, _tag) \ _ma "." _mi "." _pa "-" _tag @@ -21,4 +21,7 @@ PATCHER9X_STR(PATCHER9X_PATCH), \ PATCHER9X_TAG) +#define PATCHER9X_VERSION_NUM \ + PATCHER9X_MAJOR,PATCHER9X_MINOR,PATCHER9X_PATCH,0 \ + #endif /* __PATCHER9X_VERSION_H__INCLUDED__ */ diff --git a/vmm/makediff.manifest b/vmm/makediff.manifest new file mode 100644 index 0000000..37f1e99 --- /dev/null +++ b/vmm/makediff.manifest @@ -0,0 +1,12 @@ + + + + Patcher9x makediff compilation tool + + + + + + + + diff --git a/vmm/makediff.rc b/vmm/makediff.rc new file mode 100644 index 0000000..a97105e --- /dev/null +++ b/vmm/makediff.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST makediff.xml diff --git a/vmm/makediff.xml b/vmm/makediff.xml new file mode 100644 index 0000000..29a28d1 --- /dev/null +++ b/vmm/makediff.xml @@ -0,0 +1,12 @@ + + + + Patcher9x makediff compilation tool + + + + + + + + diff --git a/vmm/makepatch.rc b/vmm/makepatch.rc new file mode 100644 index 0000000..d4f68a8 --- /dev/null +++ b/vmm/makepatch.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST makepatch.xml diff --git a/vmm/makepatch.xml b/vmm/makepatch.xml new file mode 100644 index 0000000..f1c90f3 --- /dev/null +++ b/vmm/makepatch.xml @@ -0,0 +1,12 @@ + + + + Patcher9x makepatch compilation tool + + + + + + + + diff --git a/vmm/patchedme.bin b/vmm/patchedme.bin index b09ffcf97134ad2c6bf944fad28de527bd6bdf91..2c24b7bd795954c8e1d69e266766104cdf9bba46 100644 GIT binary patch delta 41 zcmV+^0M`G&f53mRpaBaHAlVNh+35v7006VA0R=t~xc~$J0E>7KQ1hkf>%ss3Md=Y1 delta 41 zcmV+^0M`G&f53mRpaBc%3qAk