diff --git a/freeldr/freeldr/Makefile b/freeldr/freeldr/Makefile index ea246ad62dc..890a09f62e5 100644 --- a/freeldr/freeldr/Makefile +++ b/freeldr/freeldr/Makefile @@ -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 diff --git a/freeldr/freeldr/comm/Makefile b/freeldr/freeldr/comm/Makefile index 97ac6f73793..436862c1249 100644 --- a/freeldr/freeldr/comm/Makefile +++ b/freeldr/freeldr/comm/Makefile @@ -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 diff --git a/freeldr/freeldr/debug.h b/freeldr/freeldr/debug.h index 04c345cb3c7..1bbafbff0a6 100644 --- a/freeldr/freeldr/debug.h +++ b/freeldr/freeldr/debug.h @@ -43,4 +43,4 @@ #endif // defined DEBUG -#endif // defined __DEBUG_H \ No newline at end of file +#endif // defined __DEBUG_H diff --git a/freeldr/freeldr/disk.h b/freeldr/freeldr/disk.h index 7132229808f..9902cae0dc8 100644 --- a/freeldr/freeldr/disk.h +++ b/freeldr/freeldr/disk.h @@ -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 \ No newline at end of file +#endif // defined __DISK_H diff --git a/freeldr/freeldr/disk/Makefile b/freeldr/freeldr/disk/Makefile index 41225ab2077..d3707c10edc 100644 --- a/freeldr/freeldr/disk/Makefile +++ b/freeldr/freeldr/disk/Makefile @@ -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 diff --git a/freeldr/freeldr/freeldr.c b/freeldr/freeldr/freeldr.c index 55ea31a46ab..70c18d629d8 100644 --- a/freeldr/freeldr/freeldr.c +++ b/freeldr/freeldr/freeldr.c @@ -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; } diff --git a/freeldr/freeldr/freeldr.h b/freeldr/freeldr/freeldr.h index 77cde426ada..8834646a9c9 100644 --- a/freeldr/freeldr/freeldr.h +++ b/freeldr/freeldr/freeldr.h @@ -78,4 +78,4 @@ extern ULONG CursorYPos; // Cursor's Y Position void BootMain(void); -#endif // defined __FREELDR_H \ No newline at end of file +#endif // defined __FREELDR_H diff --git a/freeldr/freeldr/fs.h b/freeldr/freeldr/fs.h index 4cbfe5170fb..b0b0edc300b 100644 --- a/freeldr/freeldr/fs.h +++ b/freeldr/freeldr/fs.h @@ -107,4 +107,4 @@ BOOL IsEndOfFile(PFILE FileHandle); #define FAT16 2 #define FAT32 3 -#endif // #defined __FS_H \ No newline at end of file +#endif // #defined __FS_H diff --git a/freeldr/freeldr/fs/Makefile b/freeldr/freeldr/fs/Makefile index cd2f5992bcb..d0af045a22b 100644 --- a/freeldr/freeldr/fs/Makefile +++ b/freeldr/freeldr/fs/Makefile @@ -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 diff --git a/freeldr/freeldr/fs/fat.h b/freeldr/freeldr/fs/fat.h index 4444023075c..bb8976ca89c 100644 --- a/freeldr/freeldr/fs/fat.h +++ b/freeldr/freeldr/fs/fat.h @@ -176,4 +176,4 @@ ULONG FatGetFilePointer(FILE *FileHandle);*/ #define FAT16 2 #define FAT32 3 -#endif // #defined __FAT_H \ No newline at end of file +#endif // #defined __FAT_H diff --git a/freeldr/freeldr/linux.h b/freeldr/freeldr/linux.h index 3f6eb030d7b..0b319e4b4fb 100644 --- a/freeldr/freeldr/linux.h +++ b/freeldr/freeldr/linux.h @@ -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 \ No newline at end of file +#endif // defined __LINUX_H diff --git a/freeldr/freeldr/miscboot.h b/freeldr/freeldr/miscboot.h index d6b6ef2dda0..05226248310 100644 --- a/freeldr/freeldr/miscboot.h +++ b/freeldr/freeldr/miscboot.h @@ -26,4 +26,4 @@ void LoadAndBootBootSector(int nOSToBoot); void LoadAndBootPartition(int nOSToBoot); void LoadAndBootDrive(int nOSToBoot); -#endif // defined __BOOT_H \ No newline at end of file +#endif // defined __BOOT_H diff --git a/freeldr/freeldr/mm.h b/freeldr/freeldr/mm.h index 2bbdf21147e..778035f6cea 100644 --- a/freeldr/freeldr/mm.h +++ b/freeldr/freeldr/mm.h @@ -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 \ No newline at end of file +#endif // defined __MEMORY_H diff --git a/freeldr/freeldr/mm/Makefile b/freeldr/freeldr/mm/Makefile index 742d1a2efdb..20399ba3777 100644 --- a/freeldr/freeldr/mm/Makefile +++ b/freeldr/freeldr/mm/Makefile @@ -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 diff --git a/freeldr/freeldr/mm/mm.c b/freeldr/freeldr/mm/mm.c index 24babccc351..2abd69d1e38 100644 --- a/freeldr/freeldr/mm/mm.c +++ b/freeldr/freeldr/mm/mm.c @@ -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 diff --git a/freeldr/freeldr/multiboot.h b/freeldr/freeldr/multiboot.h index 37577983444..270b9fd841e 100644 --- a/freeldr/freeldr/multiboot.h +++ b/freeldr/freeldr/multiboot.h @@ -156,4 +156,4 @@ BOOL MultiBootCloseModule(PVOID ModuleBase, DWORD dwModuleSize); #endif /* ! ASM */ -#endif // defined __MULTIBOOT_H \ No newline at end of file +#endif // defined __MULTIBOOT_H diff --git a/freeldr/freeldr/options.c b/freeldr/freeldr/options.c index c889f823322..cdb488fed9c 100644 --- a/freeldr/freeldr/options.c +++ b/freeldr/freeldr/options.c @@ -393,4 +393,4 @@ void DrawOptionsMenu(char OptionsMenuItems[][80], int OptionsMenuItemCount, int } }*/ } -#endif \ No newline at end of file +#endif diff --git a/freeldr/freeldr/options.h b/freeldr/freeldr/options.h index 5e1e25584fb..f408dacb317 100644 --- a/freeldr/freeldr/options.h +++ b/freeldr/freeldr/options.h @@ -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 \ No newline at end of file +#endif // #defined __OPTIONS_H diff --git a/freeldr/freeldr/parseini.h b/freeldr/freeldr/parseini.h index 32a29b669d5..23c690fcf67 100644 --- a/freeldr/freeldr/parseini.h +++ b/freeldr/freeldr/parseini.h @@ -39,4 +39,4 @@ BOOL IsValidSetting(char *setting, char *value); void SetSetting(char *setting, char *value); -#endif // defined __PARSEINI_H \ No newline at end of file +#endif // defined __PARSEINI_H diff --git a/freeldr/freeldr/reactos.h b/freeldr/freeldr/reactos.h index 3a5e69ff2b7..90631053268 100644 --- a/freeldr/freeldr/reactos.h +++ b/freeldr/freeldr/reactos.h @@ -40,4 +40,4 @@ BOOL DissectArcPath(char *ArcPath, char *BootPath, PULONG BootDrive, PULONG Boot //ULONG ConvertArcNameToBiosDrive(PUCHAR ArcName); -#endif // defined __REACTOS_H \ No newline at end of file +#endif // defined __REACTOS_H diff --git a/freeldr/freeldr/reactos/Makefile b/freeldr/freeldr/reactos/Makefile index 824d5b026e6..b724fe38d82 100644 --- a/freeldr/freeldr/reactos/Makefile +++ b/freeldr/freeldr/reactos/Makefile @@ -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 diff --git a/freeldr/freeldr/reactos/hwdetect.c b/freeldr/freeldr/reactos/hwdetect.c index 8782a5edead..7d90b093a63 100644 --- a/freeldr/freeldr/reactos/hwdetect.c +++ b/freeldr/freeldr/reactos/hwdetect.c @@ -36,4 +36,4 @@ DetectHardware(VOID) printf("DetectHardware() done\n"); #endif //for(;;); -} \ No newline at end of file +} diff --git a/freeldr/freeldr/rtl.h b/freeldr/freeldr/rtl.h index 3996325136e..1fd6bab5484 100644 --- a/freeldr/freeldr/rtl.h +++ b/freeldr/freeldr/rtl.h @@ -103,4 +103,4 @@ void sprintf(char *buffer, char *format, ...); #endif -#endif // defined __STDLIB_H \ No newline at end of file +#endif // defined __STDLIB_H diff --git a/freeldr/freeldr/rtl/Makefile b/freeldr/freeldr/rtl/Makefile index d1450bcd703..3a5ab94b3cc 100644 --- a/freeldr/freeldr/rtl/Makefile +++ b/freeldr/freeldr/rtl/Makefile @@ -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 diff --git a/freeldr/freeldr/ui.h b/freeldr/freeldr/ui.h index 47178c1f744..0a92d35f439 100644 --- a/freeldr/freeldr/ui.h +++ b/freeldr/freeldr/ui.h @@ -152,4 +152,4 @@ void DrawProgressBar(int nPos); BOOL DisplayMenu(PUCHAR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, PULONG SelectedMenuItem); -#endif // #defined __TUI_H \ No newline at end of file +#endif // #defined __TUI_H diff --git a/freeldr/freeldr/ui/Makefile b/freeldr/freeldr/ui/Makefile index 6ad9eb13893..7a2258cc446 100644 --- a/freeldr/freeldr/ui/Makefile +++ b/freeldr/freeldr/ui/Makefile @@ -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 diff --git a/freeldr/freeldr/ui/tui.c b/freeldr/freeldr/ui/tui.c index 778cc2422ef..1d444719a78 100644 --- a/freeldr/freeldr/ui/tui.c +++ b/freeldr/freeldr/ui/tui.c @@ -715,4 +715,4 @@ void DrawProgressBar(int nPos) DrawText(left+2+i, top+2, "\xB2", ATTR(cTextColor, cMenuBgColor)); UpdateDateTime(); -} \ No newline at end of file +} diff --git a/freeldr/ntvdmpat.c b/freeldr/ntvdmpat.c new file mode 100644 index 00000000000..9e16dac355f --- /dev/null +++ b/freeldr/ntvdmpat.c @@ -0,0 +1,85 @@ +/* Copyright (C) 2000 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugar Land, TX 77479 */ +#include +#include +#include +#include +#ifdef GO32 +#include +#else +#include +#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