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

@ -18,24 +18,24 @@
#
export CC = gcc
export LD = ld
export AR = ar
export RM = cmd /C del
export CP = cmd /C copy
export CC = gcc
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

@ -43,4 +43,4 @@
#endif // defined DEBUG
#endif // defined __DEBUG_H
#endif // defined __DEBUG_H

View file

@ -56,4 +56,4 @@ VOID DiskSetVolumeProperties(ULONG HiddenSectors);
BOOL DiskReadMultipleLogicalSectors(ULONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOL DiskReadLogicalSector(ULONG SectorNumber, PVOID Buffer);
#endif // defined __DISK_H
#endif // defined __DISK_H

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

@ -78,4 +78,4 @@ extern ULONG CursorYPos; // Cursor's Y Position
void BootMain(void);
#endif // defined __FREELDR_H
#endif // defined __FREELDR_H

View file

@ -107,4 +107,4 @@ BOOL IsEndOfFile(PFILE FileHandle);
#define FAT16 2
#define FAT32 3
#endif // #defined __FS_H
#endif // #defined __FS_H

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

@ -176,4 +176,4 @@ ULONG FatGetFilePointer(FILE *FileHandle);*/
#define FAT16 2
#define FAT32 3
#endif // #defined __FAT_H
#endif // #defined __FAT_H

View file

@ -24,4 +24,4 @@ void JumpToLinuxBootCode(void); // Implemented in boot.S
void LoadAndBootLinux(int DriveNum, int Partition, char *vmlinuz, char *cmd_line);
#endif // defined __LINUX_H
#endif // defined __LINUX_H

View file

@ -26,4 +26,4 @@ void LoadAndBootBootSector(int nOSToBoot);
void LoadAndBootPartition(int nOSToBoot);
void LoadAndBootDrive(int nOSToBoot);
#endif // defined __BOOT_H
#endif // defined __BOOT_H

View file

@ -35,4 +35,4 @@ int GetConventionalMemorySize(void); // Returns conventional memory size in K
int GetBiosMemoryMap(memory_map_t *mem_map); // Fills mem_map structure with BIOS memory map and returns length of memory map
#endif // defined __MEMORY_H
#endif // defined __MEMORY_H

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

@ -156,4 +156,4 @@ BOOL MultiBootCloseModule(PVOID ModuleBase, DWORD dwModuleSize);
#endif /* ! ASM */
#endif // defined __MULTIBOOT_H
#endif // defined __MULTIBOOT_H

View file

@ -393,4 +393,4 @@ void DrawOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int
}
}*/
}
#endif
#endif

View file

@ -28,4 +28,4 @@ int RunOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int n
void InitOptionsMenu(int *nOptionsMenuBoxLeft, int *nOptionsMenuBoxTop, int *nOptionsMenuBoxRight, int *nOptionsMenuBoxBottom, int OptionsMenuItemCount);
void DrawOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int nOptionSelected, char *OptionsMenuTitle, int nOptionsMenuBoxLeft, int nOptionsMenuBoxTop, int nOptionsMenuBoxRight, int nOptionsMenuBoxBottom);
#endif // #defined __OPTIONS_H
#endif // #defined __OPTIONS_H

View file

@ -39,4 +39,4 @@ BOOL IsValidSetting(char *setting, char *value);
void SetSetting(char *setting, char *value);
#endif // defined __PARSEINI_H
#endif // defined __PARSEINI_H

View file

@ -40,4 +40,4 @@ BOOL DissectArcPath(char *ArcPath, char *BootPath, PULONG BootDrive, PULONG Boot
//ULONG ConvertArcNameToBiosDrive(PUCHAR ArcName);
#endif // defined __REACTOS_H
#endif // defined __REACTOS_H

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

@ -36,4 +36,4 @@ DetectHardware(VOID)
printf("DetectHardware() done\n");
#endif
//for(;;);
}
}

View file

@ -103,4 +103,4 @@ void sprintf(char *buffer, char *format, ...);
#endif
#endif // defined __STDLIB_H
#endif // defined __STDLIB_H

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

@ -152,4 +152,4 @@ void DrawProgressBar(int nPos);
BOOL DisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, PULONG SelectedMenuItem);
#endif // #defined __TUI_H
#endif // #defined __TUI_H

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

View file

@ -715,4 +715,4 @@ void DrawProgressBar(int nPos)
DrawText(left+2+i, top+2, "\xB2", ATTR(cTextColor, cMenuBgColor));
UpdateDateTime();
}
}

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.