Fixed Makefile problem

Added tool to fix Win2k/XP NTVDM bug so DJGPP works without crashing

svn path=/trunk/; revision=2407
This commit is contained in:
Brian Palmer 2001-11-29 01:56:04 +00:00
parent 45422998d5
commit c157992a67
30 changed files with 207 additions and 109 deletions

View file

@ -23,19 +23,19 @@ export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
export MAKE = make
#FLAGS = -Wall -nostdinc -fno-builtin
FLAGS = -Wall -fno-builtin -I./ -DDEBUG -O3
#FLAGS = -Wall -fno-builtin
#FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -DDEBUG -O3
FLAGS = -Wall -nostdlib -nostdinc -fno-builtin -I./ -DDEBUG -O3
# asmcode.o has to be first in the link line because it contains the startup code
#OBJS = asmcode.a asmcode.o mb.o boot.o freeldr.o rtl.o fs.a fs.o fat.o \
# reactos.o tui.o menu.o miscboot.o options.o linux.o multiboot.o arcname.o \
# mem.o memory.o debug.o parseini.o registry.o import.o
ASM_OBJS = asmcode.o mb.o boot.o mem.o
C_OBJS = freeldr.o rtl/rtl.a fs/fs.a ui/ui.a miscboot.o options.o linux.o multiboot.o \
reactos/reactos.a comm/comm.a disk/disk.a mm/mm.a
C_OBJS2 = debug.o parseini.o oslist.o
OBJS = freeldr.o miscboot.o options.o linux.o multiboot.o debug.o parseini.o oslist.o
LIBS = rtl fs ui reactos comm disk mm
LIB_FILES = rtl/rtl.a fs/fs.a ui/ui.a reactos/reactos.a comm/comm.a disk/disk.a mm/mm.a
.PHONY : clean
@ -51,63 +51,39 @@ freeldr.exe: asmcode.a c_code.a
asmcode.a: $(ASM_OBJS)
$(LD) -r -o asmcode.a $(ASM_OBJS)
c_code.a: c_code1.a c_code2.a
$(LD) -r -o c_code.a c_code1.a c_code2.a
c_code.a: c_code1.a $(LIBS)
$(LD) -r -o c_code.a c_code1.a $(LIB_FILES)
c_code1.a: $(C_OBJS)
$(LD) -r -o c_code1.a $(C_OBJS)
c_code1.a: $(OBJS)
$(LD) -r -o c_code1.a $(OBJS)
c_code2.a: $(C_OBJS2)
$(LD) -r -o c_code2.a $(C_OBJS2)
asmcode.o: asmcode.S asmcode.h Makefile
asmcode.o: asmcode.S asmcode.h
$(CC) $(FLAGS) -o asmcode.o -c asmcode.S
mb.o: mb.S asmcode.h multiboot.h Makefile
mb.o: mb.S asmcode.h multiboot.h
$(CC) $(FLAGS) -o mb.o -c mb.S
boot.o: boot.S asmcode.h Makefile
boot.o: boot.S asmcode.h
$(CC) $(FLAGS) -o boot.o -c boot.S
mem.o: mem.S asmcode.h Makefile
mem.o: mem.S asmcode.h
$(CC) $(FLAGS) -o mem.o -c mem.S
freeldr.o: freeldr.c freeldr.h rtl.h fs.h reactos.h ui.h asmcode.h miscboot.h Makefile
freeldr.o: freeldr.c freeldr.h rtl.h fs.h reactos.h ui.h asmcode.h miscboot.h
$(CC) $(FLAGS) -o freeldr.o -c freeldr.c
rtl/rtl.a: rtl/print.o rtl/stdlib.o rtl/string.o rtl/memory.o Makefile
$(MAKE) -C rtl
fs/fs.a: fs/fs.o fs/fat.o Makefile
$(MAKE) -C fs
ui/ui.a: ui/tui.o ui/menu.o Makefile
$(MAKE) -C ui
miscboot.o: miscboot.c freeldr.h asmcode.h rtl.h fs.h ui.h miscboot.h Makefile
miscboot.o: miscboot.c freeldr.h asmcode.h rtl.h fs.h ui.h miscboot.h
$(CC) $(FLAGS) -o miscboot.o -c miscboot.c
options.o: options.c freeldr.h rtl.h ui.h options.h Makefile
options.o: options.c freeldr.h rtl.h ui.h options.h
$(CC) $(FLAGS) -o options.o -c options.c
linux.o: linux.c freeldr.h rtl.h ui.h linux.h Makefile
linux.o: linux.c freeldr.h rtl.h ui.h linux.h
$(CC) $(FLAGS) -o linux.o -c linux.c
multiboot.o: multiboot.c freeldr.h rtl.h fs.h multiboot.h ui.h Makefile
multiboot.o: multiboot.c freeldr.h rtl.h fs.h multiboot.h ui.h
$(CC) $(FLAGS) -o multiboot.o -c multiboot.c
reactos/reactos.a: reactos/arcname.o reactos/reactos.o reactos/reghive.o reactos/registry.o reactos/hwdetect.o Makefile
$(MAKE) -C reactos
comm/comm.a: comm/rs232.o comm/portio.o Makefile
$(MAKE) -C comm
disk/disk.a: disk/disk.o Makefile
$(MAKE) -C disk
mm/mm.a: mm/mm.o Makefile
$(MAKE) -C mm
debug.o: debug.c debug.h Makefile
$(CC) $(FLAGS) -o debug.o -c debug.c
@ -117,10 +93,33 @@ parseini.o: parseini.c parseini.h Makefile
oslist.o: oslist.c oslist.h Makefile
$(CC) $(FLAGS) -o oslist.o -c oslist.c
rtl:
$(MAKE) -C rtl
fs:
$(MAKE) -C fs
ui:
$(MAKE) -C ui
reactos:
$(MAKE) -C reactos
comm:
$(MAKE) -C comm
disk:
$(MAKE) -C disk
mm:
$(MAKE) -C mm
.PHONY : $(LIBS)
clean:
$(RM) *.o
$(RM) *.a
$(RM) *.sys
- $(RM) *.o
- $(RM) *.a
- $(RM) *.sys
$(MAKE) -C reactos clean
$(MAKE) -C comm clean
$(MAKE) -C disk clean

View file

@ -35,12 +35,12 @@ all: comm.a
comm.a: $(OBJS)
$(LD) -r -o comm.a $(OBJS)
rs232.o: rs232.c ../comm.h Makefile
rs232.o: rs232.c ../comm.h
$(CC) $(FLAGS) -o rs232.o -c rs232.c
portio.o: portio.c ../comm.h Makefile
portio.o: portio.c ../comm.h
$(CC) $(FLAGS) -o portio.o -c portio.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -35,9 +35,9 @@ all: disk.a
disk.a: $(OBJS)
$(LD) -r -o disk.a $(OBJS)
disk.o: disk.c ../disk.h Makefile
disk.o: disk.c ../disk.h
$(CC) $(FLAGS) -o disk.o -c disk.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -160,7 +160,7 @@ ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSys
{
UCHAR DefaultOSText[80];
ULONG SectionId;
ULONG DefaultOS;
ULONG DefaultOS = 0;
ULONG Idx;
if (!OpenSection("FreeLoader", &SectionId))
@ -179,10 +179,6 @@ ULONG GetDefaultOperatingSystem(PUCHAR OperatingSystemList[], ULONG OperatingSys
}
}
}
else
{
DefaultOS = 0;
}
return DefaultOS;
}

View file

@ -35,12 +35,12 @@ all: fs.a
fs.a: $(OBJS)
$(LD) -r -o fs.a $(OBJS)
fs.o: fs.c fat.h ../fs.h Makefile
fs.o: fs.c fat.h ../fs.h
$(CC) $(FLAGS) -o fs.o -c fs.c
fat.o: fat.c fat.h ../fs.h Makefile
fat.o: fat.c fat.h ../fs.h
$(CC) $(FLAGS) -o fat.o -c fat.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -35,9 +35,9 @@ all: mm.a
mm.a: $(OBJS)
$(LD) -r -o mm.a $(OBJS)
mm.o: mm.c ../mm.h Makefile
mm.o: mm.c ../mm.h
$(CC) $(FLAGS) -o mm.o -c mm.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -52,7 +52,7 @@ VOID DumpMemoryAllocMap(VOID);
VOID IncrementAllocationCount(VOID);
VOID DecrementAllocationCount(VOID);
VOID MemAllocTest(VOID);
#endif DEBUG
#endif // DEBUG
VOID InitMemoryManager(PVOID BaseAddress, ULONG Length)
{
@ -151,7 +151,7 @@ PVOID AllocateMemory(ULONG NumberOfBytes)
IncrementAllocationCount();
DbgPrint((DPRINT_MEMORY, "Allocated %d bytes (%d blocks) of memory starting at block %d. AllocCount: %d\n", NumberOfBytes, BlocksNeeded, Idx, AllocationCount));
VerifyHeap();
#endif DEBUG
#endif // DEBUG
// Now return the pointer
return MemPointer;
@ -170,7 +170,7 @@ VOID FreeMemory(PVOID MemBlock)
{
BugCheck((DPRINT_MEMORY, "Bogus memory pointer (0x%x) passed to FreeMemory()\n", MemBlock));
}
#endif DEBUG
#endif // DEBUG
// Find out the block number if the first
// block of memory they allocated
@ -197,7 +197,7 @@ VOID FreeMemory(PVOID MemBlock)
DecrementAllocationCount();
DbgPrint((DPRINT_MEMORY, "Freed %d blocks of memory starting at block %d. AllocationCount: %d\n", BlockCount, BlockNumber, AllocationCount));
VerifyHeap();
#endif DEBUG
#endif // DEBUG
}
#ifdef DEBUG
@ -330,4 +330,4 @@ VOID MemAllocTest(VOID)
printf("MemPtr5: 0x%x\n", (int)MemPtr5);
getch();
}
#endif DEBUG
#endif // DEBUG

View file

@ -35,21 +35,21 @@ all: reactos.a
reactos.a: $(OBJS)
$(LD) -r -o reactos.a $(OBJS)
reactos.o: reactos.c ../reactos.h Makefile
reactos.o: reactos.c ../reactos.h
$(CC) $(FLAGS) -o reactos.o -c reactos.c
arcname.o: arcname.c ../reactos.h Makefile
arcname.o: arcname.c ../reactos.h
$(CC) $(FLAGS) -o arcname.o -c arcname.c
hwdetect.o: hwdetect.c ../reactos.h Makefile
hwdetect.o: hwdetect.c ../reactos.h
$(CC) $(FLAGS) -o hwdetect.o -c hwdetect.c
reghive.o: reghive.c ../reactos.h Makefile
reghive.o: reghive.c ../reactos.h
$(CC) $(FLAGS) -o reghive.o -c reghive.c
registry.o: registry.c ../reactos.h Makefile
registry.o: registry.c ../reactos.h
$(CC) $(FLAGS) -o registry.o -c registry.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -35,18 +35,18 @@ all: rtl.a
rtl.a: $(OBJS)
$(LD) -r -o rtl.a $(OBJS)
memory.o: memory.c ../rtl.h Makefile
memory.o: memory.c ../rtl.h
$(CC) $(FLAGS) -o memory.o -c memory.c
print.o: print.c ../rtl.h Makefile
print.o: print.c ../rtl.h
$(CC) $(FLAGS) -o print.o -c print.c
stdlib.o: stdlib.c ../rtl.h Makefile
stdlib.o: stdlib.c ../rtl.h
$(CC) $(FLAGS) -o stdlib.o -c stdlib.c
string.o: string.c ../rtl.h Makefile
string.o: string.c ../rtl.h
$(CC) $(FLAGS) -o string.o -c string.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

View file

@ -35,12 +35,12 @@ all: ui.a
ui.a: $(OBJS)
$(LD) -r -o ui.a $(OBJS)
tui.o: tui.c ../ui.h Makefile
tui.o: tui.c ../ui.h
$(CC) $(FLAGS) -o tui.o -c tui.c
menu.o: menu.c ../ui.h Makefile
menu.o: menu.c ../ui.h
$(CC) $(FLAGS) -o menu.o -c menu.c
clean:
$(RM) *.o
$(RM) *.a
- $(RM) *.o
- $(RM) *.a

85
freeldr/ntvdmpat.c Normal file
View file

@ -0,0 +1,85 @@
/* Copyright (C) 2000 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugar Land, TX 77479 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#ifdef GO32
#include <unistd.h>
#else
#include <io.h>
#endif
char view_only = 0;
const char *client_patch_code;
char buffer[20480];
unsigned long search_base = 0x4c800L;
int f;
char oldpatch[] = {0x3b, 0x05, 0xac, 0xe6 };
char newpatch[] = {0x3b, 0x05, 0x58, 0x5e };
void patch_image(char *filename)
{
int i,size;
view_only = 0;
f = open(filename, O_RDWR | O_BINARY);
if (f < 0) {
f = open(filename, O_RDONLY | O_BINARY);
if (f < 0) {
perror(filename);
return;
}
view_only = 1;
}
lseek(f, search_base, SEEK_SET);
size = read(f, buffer, sizeof(buffer));
client_patch_code = NULL;
for(i=0; i<size && !client_patch_code; i++)
if(!memcmp(buffer+i,oldpatch,sizeof(oldpatch)))
client_patch_code = (buffer+i);
if(!client_patch_code) {
printf("Old patch string not found in %s!\n",filename);
} else {
lseek(f, search_base+i-1, SEEK_SET); /* Ready to update */
if(!view_only) {
write(f, newpatch, sizeof(newpatch));
printf("%s patched\n",filename);
} else
printf("%s patchable (not changed, readonly)\n",filename);
}
close(f);
return;
}
int main(int argc, char **argv)
{
int i;
char filename[256];
char buf1[256];
char file2[256];
if (argc != 1) { /* If they specify names, patch them, exit */
for(i=1; i<argc; i++)
patch_image(argv[i]);
return 0;
}
fprintf(stderr, "This image patches Windows 2000 NTVDM to fix nesting DPMI bug.\n");
strcpy(filename,getenv("SYSTEMROOT"));
strcpy(file2,filename);
strcat(filename,"\\system32\\ntvdm.exe");
strcat(file2,"\\system32\\dllcache\\ntvdm.exe");
sprintf(buf1,"copy %s %s\\system32\\ntvdm.ori",filename,getenv("SYSTEMROOT"));
printf("%s\n",buf1);
system(buf1);
patch_image(file2);
patch_image(filename);
return 0;
}

BIN
freeldr/ntvdmpat.exe Normal file

Binary file not shown.

18
freeldr/readme Normal file
View file

@ -0,0 +1,18 @@
Perform at your own risk.
Directions for patching NTVDM on Windows 2000
1) Start a Command Prompt Window
2) Start Task Manager. Sort by Name. If NTVDM.EXE is a task End Process.
3) Execute NTVDMPAT.EXE from this ZIP file.
Notes:
With no arguments the executable patches both the DLLCACHE (for system file
protection) and the version in SYSTEM32. The image is a Win32 executable
(launching a DJGPP image will require NTVDM, locking the DLL so it can't
be patched). It saves the old version into NTVDM.ORI if you want to go
back. If you specify arguments on the command line it will patch the
executables you specify instead of automating the process (if you want to
do the archives/patches/moves yourself). Good luck.
Source included if you want to hack your own version.