From ddfa2017c76286bbdbbdf245771f37462b4a6619 Mon Sep 17 00:00:00 2001 From: David Welch Date: Fri, 18 Aug 2000 22:27:09 +0000 Subject: [PATCH] Added .o -> .sys rule to simplify driver makefiles Added PATH_TO_ROOT variable to most makefiles Added system independant install utility Implemented prototype system for changing individual regions without a memory area Added some interesting articles from usenet svn path=/trunk/; revision=1306 --- reactos/.gdbinit | 5 + reactos/Makefile | 13 +- reactos/apps/tests/apc/makefile | 2 + reactos/apps/tests/args/makefile | 2 + reactos/apps/tests/bench/makefile | 2 + reactos/apps/tests/consume/Makefile | 2 + reactos/apps/tests/dump_shared_data/makefile | 2 + reactos/apps/tests/event/makefile | 2 + reactos/apps/tests/file/Makefile | 2 + reactos/apps/tests/gditest/makefile | 2 + reactos/apps/tests/hello/makefile | 2 + reactos/apps/tests/lpc/makefile | 2 + reactos/apps/tests/pteb/Makefile | 2 + reactos/apps/tests/shm/makefile | 2 + reactos/apps/tests/test_old/makefile | 2 + reactos/apps/tests/thread/makefile | 2 + reactos/apps/utils/buildno/Makefile | 4 +- reactos/apps/utils/cat/makefile | 2 + reactos/apps/utils/objdir/makefile | 2 + reactos/apps/utils/shell/makefile | 2 + reactos/doc/news1 | 142 +++++ reactos/doc/news2 | 52 ++ reactos/drivers/dd/beep/makefile | 4 +- reactos/drivers/dd/blue/makefile | 43 +- reactos/drivers/dd/floppy/Makefile | 4 +- reactos/drivers/dd/ide/makefile | 70 +-- reactos/drivers/dd/keyboard/makefile | 34 +- reactos/drivers/dd/mouse/makefile | 2 + reactos/drivers/dd/null/makefile | 4 +- reactos/drivers/dd/parallel/makefile | 4 +- reactos/drivers/dd/sdisk/makefile | 2 + reactos/drivers/dd/serial/makefile | 4 +- reactos/drivers/dd/sound/makefile | 2 + reactos/drivers/dd/test/makefile | 2 + reactos/drivers/dd/vga/display/makefile | 3 +- reactos/drivers/dd/vga/miniport/makefile | 3 +- reactos/drivers/dd/vidport/makefile | 3 +- reactos/drivers/fs/vfat/makefile | 3 +- reactos/iface/addsys/makefile | 4 +- reactos/iface/dll/makefile | 4 +- reactos/iface/native/makefile | 4 +- reactos/lib/advapi32/makefile | 14 +- reactos/lib/crtdll/makefile | 15 +- reactos/lib/fmifs/makefile | 15 +- reactos/lib/gdi32/makefile | 15 +- reactos/lib/kernel32/makefile | 19 +- reactos/lib/msvcrt/Makefile | 14 +- reactos/lib/ntdll/makefile | 4 +- reactos/lib/psxdll/makefile | 15 +- reactos/lib/rpcrt4/Makefile | 14 +- reactos/lib/secur32/Makefile | 14 +- reactos/lib/user32/makefile_rex | 14 +- reactos/lib/version/makefile | 15 +- reactos/ntoskrnl/include/internal/mm.h | 7 +- reactos/ntoskrnl/makefile_rex | 12 +- reactos/ntoskrnl/mm/mm.c | 4 +- reactos/ntoskrnl/mm/mpw.c | 4 +- reactos/ntoskrnl/mm/virtual.c | 543 +++++++++++++++++-- reactos/ntoskrnl/mm/wset.c | 4 +- reactos/rcopy.c | 87 +++ reactos/rules.mak | 58 +- 61 files changed, 999 insertions(+), 337 deletions(-) create mode 100644 reactos/.gdbinit create mode 100644 reactos/doc/news1 create mode 100644 reactos/doc/news2 create mode 100644 reactos/rcopy.c diff --git a/reactos/.gdbinit b/reactos/.gdbinit new file mode 100644 index 00000000000..57774eaa1e0 --- /dev/null +++ b/reactos/.gdbinit @@ -0,0 +1,5 @@ +file ntoskrnl/ntoskrnl.nostrip.exe +add-symbol-file lib/ntdll/ntdll.dll 0x77f61000 +add-symbol-file subsys/smss/smss.exe 0x401000 +#add-symbol-file subsys/csrss/csrss.exe 0x401000 +break exp.c:156 diff --git a/reactos/Makefile b/reactos/Makefile index 2565699e12a..b2645d3f0ba 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -6,7 +6,7 @@ # Select your host # #HOST = mingw32-linux -HOST = mingw32-windows +#HOST = mingw32-windows include rules.mak @@ -57,7 +57,16 @@ clean: buildno_clean $(COMPONENTS:%=%_clean) $(DLLS:%=%_clean) $(LOADERS:%=%_cle .PHONY: clean -install: make_install_dirs autoexec_install $(COMPONENTS:%=%_install) \ +ifeq ($(HOST),mingw32-linux) +rcopy$(EXE_POSTFIX): rcopy.c + $(NATIVE_CC) -g -DUNIX_PATHS rcopy.c -o rcopy$(EXE_POSTFIX) +endif +ifeq ($(HOST),mingw32-windows) +rcopy$(EXE_POSTFIX): rcopy.c + $(NATIVE_CC) -g -DDOS_PATHS rcopy.c -o rcopy$(EXE_POSTFIX) +endif + +install: rcopy$(EXE_POSTFIX) make_install_dirs autoexec_install $(COMPONENTS:%=%_install) \ $(DLLS:%=%_install) $(LOADERS:%=%_install) \ $(KERNEL_SERVICES:%=%_install) $(SUBSYS:%=%_install) \ $(APPS:%=%_install) diff --git a/reactos/apps/tests/apc/makefile b/reactos/apps/tests/apc/makefile index 12f1282f555..a662ec002d1 100644 --- a/reactos/apps/tests/apc/makefile +++ b/reactos/apps/tests/apc/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS= ../common/crt0.o apc.o PROGS= apc.exe diff --git a/reactos/apps/tests/args/makefile b/reactos/apps/tests/args/makefile index f265ac5acf8..39f1c79f2fe 100644 --- a/reactos/apps/tests/args/makefile +++ b/reactos/apps/tests/args/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS= args.o PROGS= args.exe diff --git a/reactos/apps/tests/bench/makefile b/reactos/apps/tests/bench/makefile index c05c0712453..9ded786cd03 100644 --- a/reactos/apps/tests/bench/makefile +++ b/reactos/apps/tests/bench/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + PROGS = bench-thread all: $(PROGS:%=%.exe) diff --git a/reactos/apps/tests/consume/Makefile b/reactos/apps/tests/consume/Makefile index 5e64600bce0..12b42f663e0 100644 --- a/reactos/apps/tests/consume/Makefile +++ b/reactos/apps/tests/consume/Makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS = consume.o PROGS = consume.exe LIBS = diff --git a/reactos/apps/tests/dump_shared_data/makefile b/reactos/apps/tests/dump_shared_data/makefile index 647168f52fe..125aef1403b 100644 --- a/reactos/apps/tests/dump_shared_data/makefile +++ b/reactos/apps/tests/dump_shared_data/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS = dump_shared_data.o PROGS = dump_shared_data.exe LIBS = diff --git a/reactos/apps/tests/event/makefile b/reactos/apps/tests/event/makefile index c84d51494f6..665b2a13ed9 100644 --- a/reactos/apps/tests/event/makefile +++ b/reactos/apps/tests/event/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + PROGS = event all: $(PROGS:%=%.exe) diff --git a/reactos/apps/tests/file/Makefile b/reactos/apps/tests/file/Makefile index 50061f4bd5f..09a3b37cd7a 100644 --- a/reactos/apps/tests/file/Makefile +++ b/reactos/apps/tests/file/Makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS= file.o PROGS= file.exe diff --git a/reactos/apps/tests/gditest/makefile b/reactos/apps/tests/gditest/makefile index d516c3dbd21..342e9a62418 100644 --- a/reactos/apps/tests/gditest/makefile +++ b/reactos/apps/tests/gditest/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + PROGS = gditest OBJECTS= ../common/crt0.o diff --git a/reactos/apps/tests/hello/makefile b/reactos/apps/tests/hello/makefile index 3af644441eb..9f63ce8f287 100644 --- a/reactos/apps/tests/hello/makefile +++ b/reactos/apps/tests/hello/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS = hello.o PROGS = hello.exe LIBS = diff --git a/reactos/apps/tests/lpc/makefile b/reactos/apps/tests/lpc/makefile index 4813ae35c15..0f3219eabb4 100644 --- a/reactos/apps/tests/lpc/makefile +++ b/reactos/apps/tests/lpc/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + SRV_OBJECTS= ../common/crt0.o lpcsrv.o CLT_OBJECTS= ../common/crt0.o lpcclt.o diff --git a/reactos/apps/tests/pteb/Makefile b/reactos/apps/tests/pteb/Makefile index 031e1b0ba40..4eff8251e88 100644 --- a/reactos/apps/tests/pteb/Makefile +++ b/reactos/apps/tests/pteb/Makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS = pteb.o PROGS = pteb.exe LIBS = diff --git a/reactos/apps/tests/shm/makefile b/reactos/apps/tests/shm/makefile index 215de317456..129df868d9f 100644 --- a/reactos/apps/tests/shm/makefile +++ b/reactos/apps/tests/shm/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + SRV_OBJECTS= ../common/crt0.o shmsrv.o CLT_OBJECTS= ../common/crt0.o shmclt.o diff --git a/reactos/apps/tests/test_old/makefile b/reactos/apps/tests/test_old/makefile index 2c4ee70445e..076df5c19d3 100644 --- a/reactos/apps/tests/test_old/makefile +++ b/reactos/apps/tests/test_old/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + PROGS= test-stdio tst-printf tstdiomisc bug2 bug3 \ temptest test-fseek test_rdwr diff --git a/reactos/apps/tests/thread/makefile b/reactos/apps/tests/thread/makefile index c3b6509a2cf..c5f213d3e4d 100644 --- a/reactos/apps/tests/thread/makefile +++ b/reactos/apps/tests/thread/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + PROGS = thread all: $(PROGS:%=%.exe) diff --git a/reactos/apps/utils/buildno/Makefile b/reactos/apps/utils/buildno/Makefile index 7b85ce5e51b..030b7b13e11 100644 --- a/reactos/apps/utils/buildno/Makefile +++ b/reactos/apps/utils/buildno/Makefile @@ -1,6 +1,8 @@ -# $Id: Makefile,v 1.6 2000/06/29 23:35:09 dwelch Exp $ +# $Id: Makefile,v 1.7 2000/08/18 22:26:53 dwelch Exp $ # +PATH_TO_TOP = ../.. + BASE_CFLAGS = TARGETNAME=buildno CLEAN_FILES= $(TARGETNAME).o $(TARGETNAME)$(EXE_POSTFIX) $(TARGETNAME).sym diff --git a/reactos/apps/utils/cat/makefile b/reactos/apps/utils/cat/makefile index eda3fbb0e3e..09be34da3cd 100644 --- a/reactos/apps/utils/cat/makefile +++ b/reactos/apps/utils/cat/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS= cat.o PROGS= cat.exe diff --git a/reactos/apps/utils/objdir/makefile b/reactos/apps/utils/objdir/makefile index ed2af76ac5d..b6aaaa97998 100644 --- a/reactos/apps/utils/objdir/makefile +++ b/reactos/apps/utils/objdir/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + TARGET_NAME=objdir OBJECTS= $(TARGET_NAME).o diff --git a/reactos/apps/utils/shell/makefile b/reactos/apps/utils/shell/makefile index f5c3286b058..c64affd2266 100644 --- a/reactos/apps/utils/shell/makefile +++ b/reactos/apps/utils/shell/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../.. + OBJECTS= ../common/crt0.o shell.o PROGS= shell.exe LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a diff --git a/reactos/doc/news1 b/reactos/doc/news1 new file mode 100644 index 00000000000..04eab36579c --- /dev/null +++ b/reactos/doc/news1 @@ -0,0 +1,142 @@ + + Correction / addition to Prasad's "Undocumented NT" + + From: dan_ps@my-deja.com + Reply to: dan_ps@my-deja.com + Date: Sun, 23 Apr 2000 10:03:30 GMT + Organization: Deja.com - Before you buy. + Newsgroups: + comp.os.ms-windows.programmer.nt.kernel-mode + Followup to: newsgroup + + + Recently , I had a chanche to borrow "Undocumented NT" by Mr Prasad +Dabak from one of my friends and read it. While reading the chapters +regarding builidng your own interrupt handlers or callgates under NT , +I found that the book glosses over very important topics such as IDT +in SMP enviroments , and a complete wrong presentation of what structure +a interrupt handler is supposed to build on the stack to ensure shamless +OS functionality. Mr's Prasad choice is a straigtforward pushad , +folowed by setting the FS segment to the ring0 PCR selector. This way +to build a trap frame for a interrupt is still used in Windows 95 , +but in Windows NT , the layout of a correct Trap Frame is a little bit +more complex. + The correct layout for a Trap Frame is the folowing: (note that +it consitis from two parts , a stack frame wich is built by the CPU +according to mode in wich was the CPU when the exception or software +interrupt was generated , and a Context Capure frame who has to be built +by the exception handler itself ) + +struc KeTrapFrame + +.DebugEBP resd 1 ; 00 +.DebugEIP resd 1 ; 04 +.DebugArgMark resd 1 ; 08 +.DebugPointer resd 1 ; 0C +.TempCS resd 1 ; 10 +.TempEsp resd 1 ; 14 + +.DR0 resd 1 ; 18 +.DR1 resd 1 ; 1C +.DR2 resd 1 ; 20 +.DR3 resd 1 ; 24 +.DR6 resd 1 ; 28 +.DR7 resd 1 ; 2C +.GS resw 1 ; 30 + resw 1 ; 32 +.ES resw 1 ; 34 + resw 1 ; 36 +.DS resw 1 ; 38 + resw 1 ; 3A +.EDX resd 1 ; 3C +.ECX resd 1 ; 40 +.EAX resd 1 ; 44 +.PreviousMode resd 1 ; 48 +.ExceptionList resd 1 ; 4C +.FS resw 1 ; 50 + resw 1 ; 52 +.EDI resd 1 ; 54 +.ESI resd 1 ; 58 +.EBX resd 1 ; 5C +.EBP resd 1 ; 60 +.Error resd 1 ; 64 +.EIP resd 1 ; 68 +.CS resw 1 ; 6C + resw 1 ; 6E +.EFLAGS resd 1 ; 70 +.ESP resd 1 ; 74 +.SS resw 1 ; 78 + resw 1 ; 7A +.ES_V86 resw 1 ; 7C + resw 1 ; 7E +.DS_V86 resw 1 ; 80 + resw 1 ; 82 +.FS_V86 resw 1 ; 84 + resw 1 ; 86 +.GS_V86 resw 1 ; 88 +endstruc + + Note that this is the complete layout of a TrapFrame structure. +Depending in what mode the CPU was when the exception occured , it may +break earlier than .GS_V86. Also , it seems that fields above .DR0 are +required only to debug builds. The declaration is for NASM , a free X86 +assembler , but this shouldnt have any kind of importance. + + Now why one should build the correct layout for this stack +frame ? The answer is that for shamlees operation of OS , a interrupt +handler HAS to poke into interrupted thread's KTHREAD strucure a +pointer to current TrapFrame existing on stack. This pointer will be +later used by several ntoskrnl API's to gain access to interrupted +thread;s acccess registers , or to gain information about the +interrupted thread's ring3 stack location , or simply to capture all +this information and package it into the form of a CONTEXT structure. +Since ntoskrnl assumes the above layout for a stack frame , using any +other structure size or layout can lead to unforeseen consequences. + + Other things wich one may want to do when building a stack +frame are : (assumes that the handler already set the FS register to +kernel PCR selector ) + + 1. Save old Exception List head , and patch -1 to FS:0 ( thus +overriding any potentialy pre-existing SEH handlers. + + 2. Determine whatever the interrupted thread was runing in +ring0 or in ring3 and save this information in PreviousMode field of +The Trap frame. This is also important , since many internal API's will +check the Provious mode , acting differently in each case. (check CS +image on stack for this ) + + 3. Get a pointer to the top of KeTrapFrame , and patch it into +KTHREAD structure, at KTHREAD->TrapFrame. if ya want the layout of +TrapFrame , there are multiple places where one can get it , but Im +willing to post it here on request. + + 4. In the case that the hardware stack built by CPU does not +contain an error code , fake one ( generaly , aborts always push an +error code on stack , some exceptions do , and traps never push an +error code by deafult. Suplimentary information can be found in intel +arch. reference manual . + + 5. Optionaly enable the interrupts trough a STI . NT uses +usualy interrupt gates , so the CPU will clear IF upon entering an +exception handler. Note that in the case handling the interrupt or +exception trough a trap gate , IF will not be automaticly cleared. + + If you are interesting in the code wich can actualy build such +a structure on the stack , use a kernel debugger and Break on Int +0x2E , and single step the code . + + As last words , I want to ensure Mr Prasad of my respect , and +the thing that the only reason for this posting is my feeling that all +holes must be covered , for the sake of all NT driver writing comunity. + + Later , Dan + + + + + + + +Sent via Deja.com http://www.deja.com/ +Before you buy. diff --git a/reactos/doc/news2 b/reactos/doc/news2 new file mode 100644 index 00000000000..af0d3b8390c --- /dev/null +++ b/reactos/doc/news2 @@ -0,0 +1,52 @@ + + Re: alternative to SeCaptureSubjectContext for Win2000 sought + + From: "dave porter" + Reply to: "dave porter" + Date: Mon, 26 Jun 2000 10:57:18 -0400 + Newsgroups: + comp.os.ms-windows.programmer.nt.kernel-mode + Followup to: newsgroup + References: + <39520e7f$0$15896@wodc7nh1.news.uu.net> + + <39575985$0$24336@wodc7nh0.news.uu.net> + + +> Under advise, I have tried ZwOpenProcessToken(), but to little avail. +> ZwQueryInformationToken( ..TokenUser ...) doesn't seem to want to do its +job +> either under NT4. + +I could be jumping in the middle here, but in what way doesn't it work? +This code works for me: + + int bufLen = 256; // we suppose this is enough + void* sidBuf = new char[bufLen]; + int sidLen = 0; + + void* pToken = PsReferencePrimaryToken(PsGetCurrentProcess()); + if (!pToken) ... error ... + + NTSTATUS ntstatus = ObOpenObjectByPointer(pToken, 0, 0, TOKEN_QUERY, +0, KernelMode, &handle); + if (!NT_SUCCESS(ntstatus)) ... error ... + + TOKEN_USER* user = static_cast(sidBuf); + ULONG tokenInfoLen; + ntstatus = ZwQueryInformationToken(handle, TokenUser, user, bufLen, +&tokenInfoLen); + if (!NT_SUCCESS(ntstatus)) ... error ... + + assert(tokenInfoLen <= bufLen); // else we would have got an error, +right? + assert(user->User.Sid == user+1); // SID is in buffer just past +TOKEN_USER structure + + sidLen = tokenInfoLen - sizeof (TOKEN_USER); + memmove(sidBuf, user->User.Sid, sidLen); // shuffle down the buffer + +Naturally, this returns the id of the thread that's running it. +If you execute this in DriverEntry, you're running in some +thread in the system process, which is not related to +the thread which executed the Win32 StartService call. diff --git a/reactos/drivers/dd/beep/makefile b/reactos/drivers/dd/beep/makefile index c7f0b2af695..66c17b5fe04 100644 --- a/reactos/drivers/dd/beep/makefile +++ b/reactos/drivers/dd/beep/makefile @@ -1,6 +1,8 @@ -# $Id: makefile,v 1.7 2000/08/11 12:41:58 ekohl Exp $ +# $Id: makefile,v 1.8 2000/08/18 22:27:04 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET = beep OBJECTS = beep.o beep.coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/blue/makefile b/reactos/drivers/dd/blue/makefile index 46854204cac..73aeafe1df9 100644 --- a/reactos/drivers/dd/blue/makefile +++ b/reactos/drivers/dd/blue/makefile @@ -1,13 +1,15 @@ -# $Id: makefile,v 1.12 2000/08/11 12:42:07 ekohl Exp $ +# $Id: makefile,v 1.13 2000/08/18 22:27:04 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET = blue BASE_CFLAGS = -I../../../include OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a -all: $(TARGET).sys +all: $(TARGET).sys $(TARGET).sys.unstripped .phony: all @@ -24,48 +26,13 @@ clean: install: $(FLOPPY_DIR)/drivers/$(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys: $(TARGET).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGET).sys $(FLOPPY_DIR)\drivers\$(TARGET).sys -else $(CP) $(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys -endif dist: ../../../$(DIST_DIR)/drivers/$(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGET).sys ..\..\..\$(DIST_DIR)\drivers\$(TARGET).sys -else $(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys -endif - -$(TARGET).sys: $(OBJECTS) - $(CC) \ - -specs=../../svc_specs \ - -mdll \ - -o junk.tmp \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,--base-file,base.tmp \ - $(OBJECTS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGET).sys \ - --base-file base.tmp \ - --output-exp temp.exp \ - --kill-at - - $(RM) base.tmp - $(CC) \ - --verbose \ - -Wl,--image-base,0x10000 \ - -Wl,-e,_DriverEntry@8 \ - -Wl,temp.exp \ - -specs=../../svc_specs \ - -mdll \ - -o $(TARGET).sys \ - $(OBJECTS) - - $(RM) temp.exp +$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) include ../../../rules.mak diff --git a/reactos/drivers/dd/floppy/Makefile b/reactos/drivers/dd/floppy/Makefile index b489bdffcac..84d771865b5 100644 --- a/reactos/drivers/dd/floppy/Makefile +++ b/reactos/drivers/dd/floppy/Makefile @@ -1,6 +1,8 @@ -# $Id: Makefile,v 1.2 2000/08/11 12:42:19 ekohl Exp $ +# $Id: Makefile,v 1.3 2000/08/18 22:27:04 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET=floppy OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/ide/makefile b/reactos/drivers/dd/ide/makefile index 6b5e9302fbf..af70c33ead9 100644 --- a/reactos/drivers/dd/ide/makefile +++ b/reactos/drivers/dd/ide/makefile @@ -1,13 +1,15 @@ -# $Id: makefile,v 1.14 2000/08/11 12:42:31 ekohl Exp $ +# $Id: makefile,v 1.15 2000/08/18 22:27:04 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET=ide OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a BASE_CFLAGS = -I. -I../../../include -all: $(TARGET).nostrip.sys $(TARGET).sys +all: $(TARGET).sys.unstripped $(TARGET).sys .phony: all @@ -25,76 +27,14 @@ clean: install: $(FLOPPY_DIR)/drivers/$(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys: $(TARGET).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGET).sys $(FLOPPY_DIR)\drivers\$(TARGET).sys -else $(CP) $(TARGET).sys $(FLOPPY_DIR)/drivers/$(TARGET).sys -endif dist: ../../../$(DIST_DIR)/drivers/$(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys: $(TARGET).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGET).sys ..\..\..\$(DIST_DIR)\drivers\$(TARGET).sys -else $(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys -endif - -$(TARGET).sys: $(OBJECTS) - $(STRIP) --strip-debug $(OBJECTS) - $(CC) \ - -specs=../../svc_specs \ - -mdll \ - -o junk.tmp \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,--base-file,base.tmp $(OBJECTS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGET).sys \ - --base-file base.tmp \ - --output-exp temp.exp \ - --kill-at - - $(RM) base.tmp - $(CC) \ - --verbose \ - -Wl,--image-base,0x10000 \ - -Wl,-e,_DriverEntry@8 \ - -Wl,temp.exp \ - -specs=../../svc_specs \ - -mdll \ - -o $(TARGET).sys \ - $(OBJECTS) - - $(RM) temp.exp - -$(TARGET).nostrip.sys: $(OBJECTS) - $(CC) \ - -specs=../../svc_specs \ - -mdll \ - -o junk.tmp \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,--base-file,base.tmp $(OBJECTS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGET).sys \ - --base-file base.tmp \ - --output-exp temp.exp \ - --kill-at - - $(RM) base.tmp - $(CC) \ - --verbose \ - -Wl,--image-base,0x10000 \ - -Wl,-e,_DriverEntry@8 \ - -Wl,temp.exp \ - -specs=../../svc_specs \ - -mdll \ - -o $(TARGET).nostrip.sys \ - $(OBJECTS) - - $(RM) temp.exp +$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) WITH_DEBUGGING=yes include ../../../rules.mak diff --git a/reactos/drivers/dd/keyboard/makefile b/reactos/drivers/dd/keyboard/makefile index ea94ddab346..466a770c1b5 100644 --- a/reactos/drivers/dd/keyboard/makefile +++ b/reactos/drivers/dd/keyboard/makefile @@ -1,13 +1,15 @@ -# $Id: makefile,v 1.10 2000/08/11 12:42:41 ekohl Exp $ +# $Id: makefile,v 1.11 2000/08/18 22:27:05 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET=keyboard OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a BASE_CFLAGS = -I. -I../../../include -all: $(TARGET).sys +all: $(TARGET).sys $(TARGET).sys.unstripped .phony: all @@ -39,32 +41,6 @@ else $(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys endif -$(TARGET).sys: $(OBJECTS) - $(CC) \ - -specs=../../svc_specs \ - -mdll \ - -o junk.tmp \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,--base-file,base.tmp \ - $(OBJECTS) - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGET).sys \ - --base-file base.tmp \ - --output-exp temp.exp \ - --kill-at - - $(RM) base.tmp - $(CC) \ - --verbose \ - -Wl,--image-base,0x10000 \ - -Wl,-e,_DriverEntry@8 \ - -Wl,temp.exp \ - -specs=../../svc_specs \ - -mdll \ - -o $(TARGET).sys \ - $(OBJECTS) - - $(RM) temp.exp +$(TARGET).sys $(TARGET).sys.unstripped: $(OBJECTS) include ../../../rules.mak diff --git a/reactos/drivers/dd/mouse/makefile b/reactos/drivers/dd/mouse/makefile index 1ca873e520d..d0ec12c1672 100644 --- a/reactos/drivers/dd/mouse/makefile +++ b/reactos/drivers/dd/mouse/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../../.. + TARGET=mouse OBJECTS= mouse.o ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/null/makefile b/reactos/drivers/dd/null/makefile index 1129eec26fd..634c69115e6 100644 --- a/reactos/drivers/dd/null/makefile +++ b/reactos/drivers/dd/null/makefile @@ -1,6 +1,8 @@ -# $Id: makefile,v 1.8 2000/08/11 12:42:58 ekohl Exp $ +# $Id: makefile,v 1.9 2000/08/18 22:27:06 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGETNAME=null OBJECTS= $(TARGETNAME).o $(TARGETNAME).coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/parallel/makefile b/reactos/drivers/dd/parallel/makefile index d6f6faa933b..9c2cee8a135 100644 --- a/reactos/drivers/dd/parallel/makefile +++ b/reactos/drivers/dd/parallel/makefile @@ -1,6 +1,8 @@ -# $Id: makefile,v 1.9 2000/08/11 12:43:09 ekohl Exp $ +# $Id: makefile,v 1.10 2000/08/18 22:27:06 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET=parallel OBJECTS= $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/sdisk/makefile b/reactos/drivers/dd/sdisk/makefile index ccfa542904b..6c881dcd345 100644 --- a/reactos/drivers/dd/sdisk/makefile +++ b/reactos/drivers/dd/sdisk/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../../.. + OBJECTS= sdisk.o ../../../ntoskrnl/ntoskrnl.a all: sdisk.sys diff --git a/reactos/drivers/dd/serial/makefile b/reactos/drivers/dd/serial/makefile index d91c9daf9cc..0da5037fde6 100644 --- a/reactos/drivers/dd/serial/makefile +++ b/reactos/drivers/dd/serial/makefile @@ -1,6 +1,8 @@ -# $Id: makefile,v 1.9 2000/08/11 12:43:19 ekohl Exp $ +# $Id: makefile,v 1.10 2000/08/18 22:27:07 dwelch Exp $ # # +PATH_TO_TOP = ../../.. + TARGET= serial OBJECTS= $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/dd/sound/makefile b/reactos/drivers/dd/sound/makefile index f6b4161afa2..d176a2fbc8c 100644 --- a/reactos/drivers/dd/sound/makefile +++ b/reactos/drivers/dd/sound/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../../.. + OBJECTS= sound.o ../../../ntoskrnl/ntoskrnl.a all: sound.sys diff --git a/reactos/drivers/dd/test/makefile b/reactos/drivers/dd/test/makefile index 85b9ce19760..d7098609927 100644 --- a/reactos/drivers/dd/test/makefile +++ b/reactos/drivers/dd/test/makefile @@ -1,6 +1,8 @@ # # # +PATH_TO_TOP = ../../.. + OBJECTS= test.o ../../../ntoskrnl/ntoskrnl.a all: test.sys diff --git a/reactos/drivers/dd/vga/display/makefile b/reactos/drivers/dd/vga/display/makefile index 90e9a2d63cf..9c159cbfeef 100644 --- a/reactos/drivers/dd/vga/display/makefile +++ b/reactos/drivers/dd/vga/display/makefile @@ -1,7 +1,8 @@ -# $Id: makefile,v 1.9 2000/08/11 12:43:43 ekohl Exp $ +# $Id: makefile,v 1.10 2000/08/18 22:27:08 dwelch Exp $ # # Makefile for ReactOS vgaddi.dll # +PATH_TO_TOP = ../../../.. TARGET=vgaddi BASE_CFLAGS = -I../../../../include -I. diff --git a/reactos/drivers/dd/vga/miniport/makefile b/reactos/drivers/dd/vga/miniport/makefile index 44d186fb846..53359a79e58 100644 --- a/reactos/drivers/dd/vga/miniport/makefile +++ b/reactos/drivers/dd/vga/miniport/makefile @@ -1,6 +1,7 @@ -# $Id: makefile,v 1.2 2000/08/11 12:43:51 ekohl Exp $ +# $Id: makefile,v 1.3 2000/08/18 22:27:08 dwelch Exp $ # # +PATH_TO_TOP = ../../../.. BASE_CFLAGS = -I../../../../include MP_OBJECTS = vgamp.o initvga.o vgavideo.o vgamp.coff ../../../../ntoskrnl/ntoskrnl.a ../../vidport/vidport.a diff --git a/reactos/drivers/dd/vidport/makefile b/reactos/drivers/dd/vidport/makefile index 8e845478bfd..75fa29071eb 100644 --- a/reactos/drivers/dd/vidport/makefile +++ b/reactos/drivers/dd/vidport/makefile @@ -1,6 +1,7 @@ -# $Id: makefile,v 1.8 2000/08/11 12:44:03 ekohl Exp $ +# $Id: makefile,v 1.9 2000/08/18 22:27:08 dwelch Exp $ # # +PATH_TO_TOP = ../../.. TARGET=vidport OBJECTS = $(TARGET).o $(TARGET).coff ../../../ntoskrnl/ntoskrnl.a diff --git a/reactos/drivers/fs/vfat/makefile b/reactos/drivers/fs/vfat/makefile index 281e32e39c6..9568d4a5927 100644 --- a/reactos/drivers/fs/vfat/makefile +++ b/reactos/drivers/fs/vfat/makefile @@ -1,6 +1,7 @@ -# $Id: makefile,v 1.20 2000/08/11 12:44:40 ekohl Exp $ +# $Id: makefile,v 1.21 2000/08/18 22:27:09 dwelch Exp $ # # +PATH_TO_TOP = ../../.. TARGET=vfatfs OBJECTS = blockdev.o close.o create.o dir.o dirwr.o iface.o string.o fat.o \ diff --git a/reactos/iface/addsys/makefile b/reactos/iface/addsys/makefile index 5c3ea848680..a52593451db 100644 --- a/reactos/iface/addsys/makefile +++ b/reactos/iface/addsys/makefile @@ -1,9 +1,11 @@ -# $Id: makefile,v 1.6 2000/06/24 09:02:02 ea Exp $ +# $Id: makefile,v 1.7 2000/08/18 22:26:58 dwelch Exp $ # # ReactOS Operating System # # Generate files for a kernel module that needs to add a service table. # +PATH_TO_TOP = ../.. + #TARGETNAME = mktab TARGETNAME = genw32k diff --git a/reactos/iface/dll/makefile b/reactos/iface/dll/makefile index fe3aaf18733..d01f12626f8 100644 --- a/reactos/iface/dll/makefile +++ b/reactos/iface/dll/makefile @@ -1,10 +1,12 @@ -# $Id: makefile,v 1.2 1999/08/29 13:44:52 dwelch Exp $ +# $Id: makefile,v 1.3 2000/08/18 22:26:58 dwelch Exp $ # # ReactOS Operating System # # Generate: # - defedf # +PATH_TO_TOP = ../.. + TARGET = defedf BASE_CFLAGS = -I../../include diff --git a/reactos/iface/native/makefile b/reactos/iface/native/makefile index 500af64eec5..33040b5691d 100644 --- a/reactos/iface/native/makefile +++ b/reactos/iface/native/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.9 1999/08/29 13:44:52 dwelch Exp $ +# $Id: makefile,v 1.10 2000/08/18 22:26:58 dwelch Exp $ # # ReactOS Operating System # @@ -8,6 +8,8 @@ # - ntoskrnl.exe Zw functions stubs to call Nt functions from kernel mode; # - ntdll.dll stubs to call system functions from user mode applications. # +PATH_TO_TOP = ../.. + TARGET = genntdll SYSTEM_CALLS_DB = sysfuncs.lst NTDLL_STUBS = ../../lib/ntdll/napi.c diff --git a/reactos/lib/advapi32/makefile b/reactos/lib/advapi32/makefile index 6b8da9b70eb..2c99c583da8 100644 --- a/reactos/lib/advapi32/makefile +++ b/reactos/lib/advapi32/makefile @@ -1,21 +1,15 @@ -# $Id: makefile,v 1.13 2000/08/11 12:31:17 ekohl Exp $ +# $Id: makefile,v 1.14 2000/08/18 22:26:59 dwelch Exp $ # # Makefile for ReactOS advapi32.dll # +PATH_TO_TOP = ../.. BASE_CFLAGS = -I../../include TARGETNAME=advapi32 -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGETNAME).a - else - DLLTARGET=$(TARGETNAME).dll - endif -else - DLLTARGET=$(TARGETNAME).dll -endif +DLLTARGET=$(TARGETNAME).dll + MISC_OBJECTS = misc/dllmain.o misc/shutdown.o \ diff --git a/reactos/lib/crtdll/makefile b/reactos/lib/crtdll/makefile index 1c44ac9832e..8ec83cf31be 100644 --- a/reactos/lib/crtdll/makefile +++ b/reactos/lib/crtdll/makefile @@ -1,17 +1,12 @@ -# $Id: makefile,v 1.37 2000/08/11 12:31:28 ekohl Exp $ +# $Id: makefile,v 1.38 2000/08/18 22:26:59 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET=crtdll -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll + BASE_CFLAGS = -I../../include diff --git a/reactos/lib/fmifs/makefile b/reactos/lib/fmifs/makefile index 75d6051d462..0cb3819bf0a 100644 --- a/reactos/lib/fmifs/makefile +++ b/reactos/lib/fmifs/makefile @@ -1,17 +1,12 @@ -# $Id: makefile,v 1.8 2000/08/11 12:31:37 ekohl Exp $ +# $Id: makefile,v 1.9 2000/08/18 22:26:59 dwelch Exp $ # # Makefile for fmifs.dll # +PATH_TO_TOP = ../.. + TARGET=fmifs -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll + BASE_CFLAGS = -I../../include diff --git a/reactos/lib/gdi32/makefile b/reactos/lib/gdi32/makefile index d93a5b06787..928963ed5bf 100644 --- a/reactos/lib/gdi32/makefile +++ b/reactos/lib/gdi32/makefile @@ -1,20 +1,15 @@ -# $Id: makefile,v 1.14 2000/08/11 12:31:49 ekohl Exp $ +# $Id: makefile,v 1.15 2000/08/18 22:27:00 dwelch Exp $ # # Makefile for ReactOS gdi32.dll # +PATH_TO_TOP = ../.. + TARGET=gdi32 BASE_CFLAGS = -I../../include -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll + all: $(DLLTARGET) diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index 693f886302e..fd00d43f684 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -1,7 +1,9 @@ -# $Id: makefile,v 1.38 2000/08/14 14:33:24 ea Exp $ +# $Id: makefile,v 1.39 2000/08/18 22:27:00 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET=kernel32 KERNEL32_BASE = 0x77f00000 @@ -10,16 +12,7 @@ BASE_CFLAGS = -I../../include CFLAGS = $(CFLAGS) -DKERNEL32_BASE=$(KERNEL32_BASE) -include ../../rules.mak -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll all: $(DLLTARGET) @@ -161,5 +154,5 @@ else endif WITH_DEBUGGING=yes -WARNINGS_ARE_ERRORS = yes - +#WARNINGS_ARE_ERRORS = yes +include ../../rules.mak diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index fc06f49bc2b..62a5630784e 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,17 +1,11 @@ -# $Id: Makefile,v 1.2 2000/08/11 12:32:53 ekohl Exp $ +# $Id: Makefile,v 1.3 2000/08/18 22:27:00 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET_NAME=msvcrt -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - TARGET_DLL=$(TARGET_NAME).a - else - TARGET_DLL=$(TARGET_NAME).dll - endif -else - TARGET_DLL=$(TARGET_NAME).dll -endif +TARGET_DLL=$(TARGET_NAME).dll BASE_CFLAGS = -I../../include diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index aa9cf810d64..cc72a533cca 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -1,7 +1,9 @@ -# $Id: makefile,v 1.51 2000/08/11 12:33:18 ekohl Exp $ +# $Id: makefile,v 1.52 2000/08/18 22:27:01 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET = ntdll BASE_CFLAGS = -I../../include -D__NTDLL__ diff --git a/reactos/lib/psxdll/makefile b/reactos/lib/psxdll/makefile index 8238f7ed860..fa20615cedb 100644 --- a/reactos/lib/psxdll/makefile +++ b/reactos/lib/psxdll/makefile @@ -1,18 +1,13 @@ -# $Id: makefile,v 1.7 2000/08/11 12:37:11 ekohl Exp $ +# $Id: makefile,v 1.8 2000/08/18 22:27:01 dwelch Exp $ # # ReactOS psxdll.dll makefile # +PATH_TO_TOP = ../.. + TARGETNAME=psxdll -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGETNAME).a - else - DLLTARGET=$(TARGETNAME).dll - endif -else - DLLTARGET=$(TARGETNAME).dll -endif +DLLTARGET=$(TARGETNAME).dll + BASE_CFLAGS =-Iinclude -I../../include -D__PSXDLL__ diff --git a/reactos/lib/rpcrt4/Makefile b/reactos/lib/rpcrt4/Makefile index 2ce28028a3e..5405713a889 100644 --- a/reactos/lib/rpcrt4/Makefile +++ b/reactos/lib/rpcrt4/Makefile @@ -1,7 +1,9 @@ -# $Id: Makefile,v 1.2 2000/08/11 12:37:21 ekohl Exp $ +# $Id: Makefile,v 1.3 2000/08/18 22:27:01 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET = midl rpcrt4 rpcss BASE_CFLAGS = -I../../include @@ -10,16 +12,8 @@ CFLAGS = $(CFLAGS) midl: +DLLTARGET=$(TARGET).dll -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif all: $(DLLTARGET) diff --git a/reactos/lib/secur32/Makefile b/reactos/lib/secur32/Makefile index 47d0cc3bb24..d4e9312bc50 100644 --- a/reactos/lib/secur32/Makefile +++ b/reactos/lib/secur32/Makefile @@ -1,7 +1,9 @@ -# $Id: Makefile,v 1.1 2000/08/12 19:33:19 dwelch Exp $ +# $Id: Makefile,v 1.2 2000/08/18 22:27:02 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = ../.. + TARGET = secur32 SECUR32_BASE = 0x10000000 @@ -11,15 +13,7 @@ BASE_CFLAGS = -I../../include CFLAGS = $(CFLAGS) include ../../rules.mak -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll all: $(DLLTARGET) diff --git a/reactos/lib/user32/makefile_rex b/reactos/lib/user32/makefile_rex index d7ac2e71c1f..4751ef3fec4 100644 --- a/reactos/lib/user32/makefile_rex +++ b/reactos/lib/user32/makefile_rex @@ -1,24 +1,18 @@ -# $Id: makefile_rex,v 1.10 2000/08/11 12:37:32 ekohl Exp $ +# $Id: makefile_rex,v 1.11 2000/08/18 22:27:02 dwelch Exp $ # # ReactOS Operating System # # Makefile for user32.dll # +PATH_TO_TOP = ../.. + BASE_CFLAGS = -I../../include include ../../rules.mak TARGET=user32 -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll all: $(DLLTARGET) diff --git a/reactos/lib/version/makefile b/reactos/lib/version/makefile index 96d42f709d4..1ba013b0ee6 100644 --- a/reactos/lib/version/makefile +++ b/reactos/lib/version/makefile @@ -1,21 +1,14 @@ -# $Id: makefile,v 1.3 2000/08/11 12:37:42 ekohl Exp $ +# $Id: makefile,v 1.4 2000/08/18 22:27:02 dwelch Exp $ # # Makefile for ReactOS version.dll # +PATH_TO_TOP = ../.. + TARGET=version BASE_CFLAGS = -I../../include -ifneq ($(HOST),mingw32-windows) - ifneq ($(HOST),mingw32-linux) - DLLTARGET=$(TARGET).a - else - DLLTARGET=$(TARGET).dll - endif -else - DOSCLI=yes - DLLTARGET=$(TARGET).dll -endif +DLLTARGET=$(TARGET).dll all: $(DLLTARGET) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index eca5db213a5..cdb903548aa 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -22,8 +22,7 @@ enum MEMORY_AREA_IO_MAPPING, MEMORY_AREA_SYSTEM, MEMORY_AREA_MDL_MAPPING, - MEMORY_AREA_COMMIT, - MEMORY_AREA_RESERVE, + MEMORY_AREA_VIRTUAL_MEMORY, MEMORY_AREA_SECTION_VIEW_RESERVE, MEMORY_AREA_CACHE_SEGMENT, MEMORY_AREA_SHARED_DATA, @@ -84,6 +83,10 @@ typedef struct ULONG ViewOffset; LIST_ENTRY ViewListEntry; } SectionData; + struct + { + LIST_ENTRY SegmentListHead; + } VirtualMemoryData; } Data; } MEMORY_AREA, *PMEMORY_AREA; diff --git a/reactos/ntoskrnl/makefile_rex b/reactos/ntoskrnl/makefile_rex index b924f5a2e20..184089e2d7e 100644 --- a/reactos/ntoskrnl/makefile_rex +++ b/reactos/ntoskrnl/makefile_rex @@ -1,7 +1,9 @@ -# $Id: makefile_rex,v 1.83 2000/08/11 12:38:45 ekohl Exp $ +# $Id: makefile_rex,v 1.84 2000/08/18 22:27:02 dwelch Exp $ # # ReactOS Operating System # +PATH_TO_TOP = .. + TARGETNAME = ntoskrnl OBJECTS_PATH = objects @@ -537,22 +539,14 @@ $(CLEAN_FILES:%=%_clean): %_clean: install: $(FLOPPY_DIR)/$(TARGETNAME).exe $(FLOPPY_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe -ifeq ($(DOSCLI),yes) - $(CP) $(TARGETNAME).exe $(FLOPPY_DIR)\$(TARGETNAME).exe -else $(CP) $(TARGETNAME).exe $(FLOPPY_DIR)/$(TARGETNAME).exe -endif .PHONY: dist dist: ../$(DIST_DIR)/$(TARGETNAME).exe ../$(DIST_DIR)/$(TARGETNAME).exe: $(TARGETNAME).exe -ifeq ($(DOSCLI),yes) - $(CP) $(TARGETNAME).exe ..\$(DIST_DIR)\$(TARGETNAME).exe -else $(CP) $(TARGETNAME).exe ../$(DIST_DIR)/$(TARGETNAME).exe -endif .PHONY: dist diff --git a/reactos/ntoskrnl/mm/mm.c b/reactos/ntoskrnl/mm/mm.c index 2a1a9ca3e82..9b7b2b33b76 100644 --- a/reactos/ntoskrnl/mm/mm.c +++ b/reactos/ntoskrnl/mm/mm.c @@ -1,4 +1,4 @@ -/* $Id: mm.c,v 1.35 2000/08/12 19:33:22 dwelch Exp $ +/* $Id: mm.c,v 1.36 2000/08/18 22:27:03 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -191,7 +191,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode, (PVOID)Address); break; - case MEMORY_AREA_COMMIT: + case MEMORY_AREA_VIRTUAL_MEMORY: Status = MmNotPresentFaultVirtualMemory(AddressSpace, MemoryArea, (PVOID)Address); diff --git a/reactos/ntoskrnl/mm/mpw.c b/reactos/ntoskrnl/mm/mpw.c index 633ede820be..73f2dd892eb 100644 --- a/reactos/ntoskrnl/mm/mpw.c +++ b/reactos/ntoskrnl/mm/mpw.c @@ -1,4 +1,4 @@ -/* $Id: mpw.c,v 1.2 2000/07/07 10:30:56 dwelch Exp $ +/* $Id: mpw.c,v 1.3 2000/08/18 22:27:03 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -57,7 +57,7 @@ ULONG MmWritePage(PMADDRESS_SPACE AddressSpace, Address); return(Status); - case MEMORY_AREA_COMMIT: + case MEMORY_AREA_VIRTUAL_MEMORY: Status = MmWritePageVirtualMemory(AddressSpace, MArea, Address); diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index 45df45d6d21..b94a27a0231 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -1,4 +1,4 @@ -/* $Id: virtual.c,v 1.32 2000/07/07 10:30:56 dwelch Exp $ +/* $Id: virtual.c,v 1.33 2000/08/18 22:27:03 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -25,7 +25,63 @@ #define NDEBUG #include -/* FUNCTIONS ****************************************************************/ +/* TYPES *********************************************************************/ + +typedef struct _MM_SEGMENT +{ + ULONG Type; + ULONG Protect; + ULONG Length; + LIST_ENTRY SegmentListEntry; +} MM_SEGMENT, *PMM_SEGMENT; + +/* FUNCTIONS *****************************************************************/ + +PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea, + PVOID Address, + PVOID* PCurrentAddress) +/* + * FUNCTION: Get the segment corresponding to a particular memory area and + * address. + * ARGUMENTS: + * MArea (IN) = The memory area + * Address (IN) = The address to get the segment for + * PCurrentAddress (OUT) = The start of the segment + * RETURNS: + * The corresponding memory or NULL if an error occurred + */ +{ + PVOID CurrentAddress; + PMM_SEGMENT CurrentSegment; + PLIST_ENTRY Current; + + if (Address < MArea->BaseAddress || + Address >= (MArea->BaseAddress + MArea->Length)) + { + KeBugCheck(0); + *PCurrentAddress = NULL; + return(NULL); + } + + Current = MArea->Data.VirtualMemoryData.SegmentListHead.Flink; + CurrentAddress = MArea->BaseAddress; + while (Current != &MArea->Data.VirtualMemoryData.SegmentListHead) + { + CurrentSegment = CONTAINING_RECORD(Current, + MM_SEGMENT, + SegmentListEntry); + if (Address >= CurrentAddress && + Address < (CurrentAddress + CurrentSegment->Length)) + { + *PCurrentAddress = CurrentAddress; + return(CurrentSegment); + } + CurrentAddress = CurrentAddress + CurrentSegment->Length; + Current = Current->Flink; + } + KeBugCheck(0); + return(NULL); +} NTSTATUS MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, PMEMORY_AREA MArea, @@ -160,6 +216,18 @@ NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, { PVOID Page; NTSTATUS Status; + PMM_SEGMENT Segment; + PVOID CurrentAddress; + + Segment = MmGetSegmentForAddress(MemoryArea, Address, &CurrentAddress); + if (Segment == NULL) + { + return(STATUS_UNSUCCESSFUL); + } + if (Segment->Type == MEM_RESERVE) + { + return(STATUS_UNSUCCESSFUL); + } if (MmIsPagePresent(NULL, Address)) { @@ -200,10 +268,349 @@ NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, return(STATUS_SUCCESS); } +VOID MmModifyAttributes(PMADDRESS_SPACE AddressSpace, + PVOID BaseAddress, + ULONG RegionSize, + ULONG OldType, + ULONG OldProtect, + ULONG NewType, + ULONG NewProtect) +{ + if (NewType == MEM_RESERVE && + OldType == MEM_COMMIT) + { + ULONG i; + + for (i=0; i<=(RegionSize/PAGESIZE); i++) + { + LARGE_INTEGER PhysicalAddr; + + PhysicalAddr = MmGetPhysicalAddress(BaseAddress + (i*PAGESIZE)); + if (PhysicalAddr.u.LowPart != 0) + { + MmRemovePageFromWorkingSet(AddressSpace->Process, + BaseAddress + (i*PAGESIZE)); + MmDereferencePage((PVOID)(ULONG)(PhysicalAddr.u.LowPart)); + } + } + } + if (NewType == MEM_COMMIT && OldType == MEM_COMMIT && + OldProtect != NewProtect) + { + ULONG i; + + for (i=0; i<(RegionSize/PAGESIZE); i++) + { + if (MmIsPagePresent(AddressSpace->Process, + BaseAddress + (i*PAGESIZE))) + { + MmSetPageProtect(AddressSpace->Process, + BaseAddress + (i*PAGESIZE), + NewProtect); + } + } + } +} + +VOID InsertAfterEntry(PLIST_ENTRY Previous, + PLIST_ENTRY Entry) +{ + Previous->Flink->Blink = Entry; + + Entry->Flink = Previous->Flink; + Entry->Blink = Previous; + + Previous->Flink = Entry; +} + +NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID BaseAddress, + ULONG RegionSize, + ULONG Type, + ULONG Protect, + PMM_SEGMENT CurrentSegment, + PVOID CurrentAddress) +/* + * FUNCTION: Split a memory segment internally + */ +{ + PMM_SEGMENT NewSegment; + PMM_SEGMENT NewTopSegment; + PMM_SEGMENT PreviousSegment; + ULONG OldType; + ULONG OldProtect; + + OldType = CurrentSegment->Type; + OldProtect = CurrentSegment->Protect; + + NewSegment = ExAllocatePool(NonPagedPool, sizeof(MM_SEGMENT)); + if (NewSegment == NULL) + { + return(STATUS_NO_MEMORY); + } + NewTopSegment = ExAllocatePool(NonPagedPool, sizeof(MM_SEGMENT)); + if (NewTopSegment == NULL) + { + ExFreePool(NewSegment); + return(STATUS_NO_MEMORY); + } + + if (CurrentSegment->Type == Type && + CurrentSegment->Protect == Protect) + { + return(STATUS_SUCCESS); + } + + if (CurrentAddress < BaseAddress) + { + NewSegment->Type = Type; + NewSegment->Protect = Protect; + NewSegment->Length = RegionSize; + + CurrentSegment->Length = BaseAddress - CurrentAddress; + + InsertAfterEntry(&CurrentSegment->SegmentListEntry, + &NewSegment->SegmentListEntry); + + PreviousSegment = NewSegment; + } + else + { + CurrentSegment->Type = Type; + CurrentSegment->Protect = Protect; + + PreviousSegment = CurrentSegment; + + ExFreePool(NewSegment); + NewSegment = NULL; + } + + if ((CurrentAddress + CurrentSegment->Length) > (BaseAddress + RegionSize)) + { + NewTopSegment->Type = OldType; + NewTopSegment->Protect = OldProtect; + NewTopSegment->Length = + (CurrentAddress + CurrentSegment->Length) - + (BaseAddress + RegionSize); + + InsertAfterEntry(&PreviousSegment->SegmentListEntry, + &NewTopSegment->SegmentListEntry); + } + else + { + ExFreePool(NewTopSegment); + NewTopSegment = NULL; + } + + MmModifyAttributes(AddressSpace, BaseAddress, RegionSize, + OldType, OldProtect, Type, Protect); + return(STATUS_SUCCESS); +} + +NTSTATUS MmGatherSegment(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID BaseAddress, + ULONG RegionSize, + ULONG Type, + ULONG Protect, + PMM_SEGMENT CurrentSegment, + PVOID CurrentAddress) +/* + * FUNCTION: Do a virtual memory operation that will effect several + * memory segments. + * ARGUMENTS: + * AddressSpace (IN) = Address space to affect + * MemoryArea (IN) = Memory area to affect + * BaseAddress (IN) = Base address of the region to affect + * RegionSize (IN) = Size of the region to affect + * Type (IN) = New type of the region + * Protect (IN) = New protection of the region + * CurrentSegment (IN) = First segment intersecting with the region + * CurrentAddress (IN) = Start address of the first segment + * interesting with the region + * RETURNS: Status + */ +{ + PMM_SEGMENT NewSegment; + PMM_SEGMENT NewTopSegment; + PMM_SEGMENT PreviousSegment; + PVOID LAddress; + ULONG RSize; + PLIST_ENTRY CurrentEntry; + PLIST_ENTRY ListHead; + + /* + * We will need a maximum of two new segments. Allocate them now + * because if we fail latter we may not be able to reverse the + * what we've already done + */ + NewSegment = ExAllocatePool(NonPagedPool, sizeof(MM_SEGMENT)); + if (NewSegment == NULL) + { + return(STATUS_NO_MEMORY); + } + NewTopSegment = ExAllocatePool(NonPagedPool, sizeof(MM_SEGMENT)); + if (NewTopSegment == NULL) + { + ExFreePool(NewSegment); + return(STATUS_NO_MEMORY); + } + + if (CurrentAddress < BaseAddress) + { + /* + * If a portion of the first segment is not covered by the region then + * we need to split it into two segments + */ + + NewSegment->Type = Type; + NewSegment->Protect = Protect; + NewSegment->Length = RegionSize; + + CurrentSegment->Length = + BaseAddress - CurrentAddress; + + InsertAfterEntry(&CurrentSegment->SegmentListEntry, + &NewSegment->SegmentListEntry); + + PreviousSegment = NewSegment; + + MmModifyAttributes(AddressSpace, BaseAddress, NewSegment->Length, + CurrentSegment->Type, + CurrentSegment->Protect, Type, Protect); + } + else + { + /* + * Otherwise just change the attributes of the segment + */ + + ULONG OldType; + ULONG OldProtect; + + OldType = CurrentSegment->Type; + OldProtect = CurrentSegment->Protect; + + CurrentSegment->Type = Type; + CurrentSegment->Protect = Protect; + + PreviousSegment = CurrentSegment; + + ExFreePool(NewSegment); + NewSegment = NULL; + + MmModifyAttributes(AddressSpace, BaseAddress, CurrentSegment->Length, + OldType, OldProtect, Type, Protect); + } + + LAddress = BaseAddress + PreviousSegment->Length; + RSize = RegionSize - PreviousSegment->Length; + CurrentEntry = PreviousSegment->SegmentListEntry.Flink; + ListHead = &MemoryArea->Data.VirtualMemoryData.SegmentListHead; + + while (CurrentEntry != ListHead && RSize > 0) + { + ULONG OldType; + ULONG OldProtect; + + CurrentSegment = CONTAINING_RECORD(CurrentEntry, + MM_SEGMENT, + SegmentListEntry); + + if (CurrentSegment->Length > RSize) + { + break; + } + + OldType = CurrentSegment->Type; + OldProtect = CurrentSegment->Protect; + CurrentSegment->Type = Type; + CurrentSegment->Protect = Protect; + + MmModifyAttributes(AddressSpace, LAddress, CurrentSegment->Length, + OldType, OldProtect, Type, Protect); + + RSize = RSize - CurrentSegment->Length; + LAddress = LAddress + CurrentSegment->Length; + + CurrentEntry = CurrentEntry->Flink; + } + + if (CurrentEntry == ListHead && RSize > 0) + { + KeBugCheck(0); + } + + if (RSize > 0) + { + NewTopSegment->Type = CurrentSegment->Type; + NewTopSegment->Protect = CurrentSegment->Protect; + NewTopSegment->Length = CurrentSegment->Length - RSize; + + CurrentSegment->Length = RSize; + CurrentSegment->Type = Type; + CurrentSegment->Protect = Protect; + + InsertAfterEntry(&CurrentSegment->SegmentListEntry, + &NewTopSegment->SegmentListEntry); + + MmModifyAttributes(AddressSpace, LAddress, RSize, + NewTopSegment->Type, + NewTopSegment->Protect, Type, Protect); + } + + return(STATUS_SUCCESS); +} + +NTSTATUS MmComplexVirtualMemoryOperation(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID BaseAddress, + ULONG RegionSize, + ULONG Type, + ULONG Protect) +{ + PMM_SEGMENT CurrentSegment; + PVOID CurrentAddress; + + CurrentSegment = MmGetSegmentForAddress(MemoryArea, + BaseAddress, + &CurrentAddress); + if (CurrentSegment == NULL) + { + KeBugCheck(0); + } + + if (BaseAddress >= CurrentAddress && + (BaseAddress + RegionSize) <= (CurrentAddress + CurrentSegment->Length)) + { + return((MmSplitSegment(AddressSpace, + MemoryArea, + BaseAddress, + RegionSize, + Type, + Protect, + CurrentSegment, + CurrentAddress))); + } + else + { + return((MmGatherSegment(AddressSpace, + MemoryArea, + BaseAddress, + RegionSize, + Type, + Protect, + CurrentSegment, + CurrentAddress))); + } +} + + NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, - IN OUT PVOID * BaseAddress, + IN OUT PVOID* PBaseAddress, IN ULONG ZeroBits, - IN OUT PULONG RegionSize, + IN OUT PULONG PRegionSize, IN ULONG AllocationType, IN ULONG Protect) /* @@ -240,19 +647,26 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, ULONG Type; NTSTATUS Status; PMADDRESS_SPACE AddressSpace; + PMM_SEGMENT Segment; + PVOID BaseAddress; + ULONG RegionSize; DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, " "ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n", ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType, Protect); + BaseAddress = (PVOID)PAGE_ROUND_DOWN((*PBaseAddress)); + RegionSize = PAGE_ROUND_UP((*PBaseAddress) + (*PRegionSize)) - + PAGE_ROUND_DOWN((*PBaseAddress)); + Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, NULL, UserMode, (PVOID*)(&Process), NULL); - if (Status != STATUS_SUCCESS) + if (!NT_SUCCESS(Status)) { DPRINT("NtAllocateVirtualMemory() = %x\n",Status); return(Status); @@ -260,58 +674,61 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, if (AllocationType & MEM_RESERVE) { - Type = MEMORY_AREA_RESERVE; + Type = MEM_RESERVE; } else { - Type = MEMORY_AREA_COMMIT; + Type = MEM_COMMIT; } AddressSpace = &Process->AddressSpace; MmLockAddressSpace(AddressSpace); - if ((*BaseAddress) != 0) + if (BaseAddress != 0) { MemoryArea = MmOpenMemoryAreaByAddress(&Process->AddressSpace, - *BaseAddress); + BaseAddress); - if (MemoryArea != NULL) + if (MemoryArea != NULL && + MemoryArea->Type == MEMORY_AREA_VIRTUAL_MEMORY && + MemoryArea->Length >= RegionSize) { - if (MemoryArea->BaseAddress == (*BaseAddress) && - MemoryArea->Length == *RegionSize) - { - MemoryArea->Type = Type; - MemoryArea->Attributes = Protect; - DPRINT("*BaseAddress %x\n",*BaseAddress); - MmUnlockAddressSpace(AddressSpace); - ObDereferenceObject(Process); - return(STATUS_SUCCESS); - } - - MemoryArea = MmSplitMemoryArea(Process, - &Process->AddressSpace, - MemoryArea, - *BaseAddress, - *RegionSize, - Type, - Protect); - DPRINT("*BaseAddress %x\n",*BaseAddress); + Status = MmComplexVirtualMemoryOperation(AddressSpace, + MemoryArea, + BaseAddress, + RegionSize, + Type, + Protect); /* FIXME: Reserve/dereserve swap pages */ MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); - return(STATUS_SUCCESS); + return(Status); } + else if (MemoryArea != NULL) + { + MmUnlockAddressSpace(AddressSpace); + ObDereferenceObject(Process); + return(STATUS_UNSUCCESSFUL); + } + } + + Segment = ExAllocatePool(NonPagedPool, sizeof(MM_SEGMENT)); + if (Segment == NULL) + { + MmUnlockAddressSpace(AddressSpace); + ObDereferenceObject(Process); + return(STATUS_UNSUCCESSFUL); } Status = MmCreateMemoryArea(Process, &Process->AddressSpace, - Type, - BaseAddress, - *RegionSize, + MEMORY_AREA_VIRTUAL_MEMORY, + &BaseAddress, + RegionSize, Protect, &MemoryArea); - if (Status != STATUS_SUCCESS) + if (!NT_SUCCESS(Status)) { DPRINT("NtAllocateVirtualMemory() = %x\n",Status); MmUnlockAddressSpace(AddressSpace); @@ -319,13 +736,25 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, return(Status); } + InitializeListHead(&MemoryArea->Data.VirtualMemoryData.SegmentListHead); + + Segment->Type = Type; + Segment->Protect = Protect; + Segment->Length = RegionSize; + InsertTailList(&MemoryArea->Data.VirtualMemoryData.SegmentListHead, + &Segment->SegmentListEntry); + DPRINT("*BaseAddress %x\n",*BaseAddress); if ((AllocationType & MEM_COMMIT) && ((Protect & PAGE_READWRITE) || (Protect & PAGE_EXECUTE_READWRITE))) { - MmReserveSwapPages(PAGE_ROUND_UP((*RegionSize))); + MmReserveSwapPages(RegionSize); } + + *PBaseAddress = BaseAddress; + *PRegionSize = RegionSize; + MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); return(STATUS_SUCCESS); @@ -352,8 +781,8 @@ NTSTATUS STDCALL NtFlushVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID * BaseAddress, - IN PULONG RegionSize, + IN PVOID* PBaseAddress, + IN PULONG PRegionSize, IN ULONG FreeType) /* * FUNCTION: Frees a range of virtual memory @@ -373,11 +802,16 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, PEPROCESS Process; PMADDRESS_SPACE AddressSpace; ULONG i; + PVOID BaseAddress; + ULONG RegionSize; DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, " "*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress, *RegionSize,FreeType); + BaseAddress = (PVOID)PAGE_ROUND_DOWN((*PBaseAddress)); + RegionSize = PAGE_ROUND_UP((*PBaseAddress) + (*PRegionSize)) - + PAGE_ROUND_DOWN((*PBaseAddress)); Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, @@ -385,7 +819,7 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, UserMode, (PVOID*)(&Process), NULL); - if (Status != STATUS_SUCCESS) + if (!NT_SUCCESS(Status)) { return(Status); } @@ -394,7 +828,7 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, MmLockAddressSpace(AddressSpace); MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, - *BaseAddress); + BaseAddress); if (MemoryArea == NULL) { MmUnlockAddressSpace(AddressSpace); @@ -405,18 +839,20 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, switch (FreeType) { case MEM_RELEASE: - if (MemoryArea->BaseAddress != (*BaseAddress)) + if (MemoryArea->BaseAddress != BaseAddress) { MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); return(STATUS_UNSUCCESSFUL); } +#if 0 if ((MemoryArea->Type == MEMORY_AREA_COMMIT) && ((MemoryArea->Attributes & PAGE_READWRITE) || (MemoryArea->Attributes & PAGE_EXECUTE_READWRITE))) { MmDereserveSwapPages(PAGE_ROUND_UP(MemoryArea->Length)); } +#endif for (i=0; i<=(MemoryArea->Length/PAGESIZE); i++) { @@ -442,22 +878,15 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, return(STATUS_SUCCESS); case MEM_DECOMMIT: - if ((MemoryArea->Type == MEMORY_AREA_COMMIT) && - ((MemoryArea->Attributes & PAGE_READWRITE) || - (MemoryArea->Attributes & PAGE_EXECUTE_READWRITE))) - { - MmDereserveSwapPages(PAGE_ROUND_UP((*RegionSize))); - } - MmSplitMemoryArea(Process, - &Process->AddressSpace, - MemoryArea, - *BaseAddress, - *RegionSize, - MEMORY_AREA_RESERVE, - MemoryArea->Attributes); + Status = MmComplexVirtualMemoryOperation(AddressSpace, + MemoryArea, + BaseAddress, + RegionSize, + MEM_RESERVE, + PAGE_NOACCESS); MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); - return(STATUS_SUCCESS); + return(Status); } MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); @@ -619,7 +1048,8 @@ NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle, return (STATUS_SUCCESS); } - if (MemoryArea->Type == MEMORY_AREA_COMMIT) +#if 0 + if (MemoryArea->Type == MEMORY_AREA_VIRTUAL_MEMORY) { Info->State = MEM_COMMIT; } @@ -627,7 +1057,8 @@ NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle, { Info->State = MEM_RESERVE; } - +#endif + Info->BaseAddress = MemoryArea->BaseAddress; Info->RegionSize = MemoryArea->Length; diff --git a/reactos/ntoskrnl/mm/wset.c b/reactos/ntoskrnl/mm/wset.c index 68b3b065138..2b8b59ad82e 100644 --- a/reactos/ntoskrnl/mm/wset.c +++ b/reactos/ntoskrnl/mm/wset.c @@ -1,4 +1,4 @@ -/* $Id: wset.c,v 1.4 2000/07/08 16:53:33 dwelch Exp $ +/* $Id: wset.c,v 1.5 2000/08/18 22:27:03 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -70,7 +70,7 @@ ULONG MmPageOutPage(PMADDRESS_SPACE AddressSpace, Ul); return(Count); - case MEMORY_AREA_COMMIT: + case MEMORY_AREA_VIRTUAL_MEMORY: Count = MmPageOutVirtualMemory(AddressSpace, MArea, Address, diff --git a/reactos/rcopy.c b/reactos/rcopy.c new file mode 100644 index 00000000000..b9af1a877b8 --- /dev/null +++ b/reactos/rcopy.c @@ -0,0 +1,87 @@ +#include +#include +#include + +char* convert_path(char* origpath) +{ + char* newpath; + int i; + + newpath = strdup(origpath); + + i = 0; + while (newpath[i] != 0) + { +#ifdef UNIX_PATHS + if (newpath[i] == '\\') + { + newpath[i] = '/'; + } +#else +#ifdef DOS_PATHS + if (newpath[i] == '/'); + { + newpath[i] = '\\'; + } +#endif +#endif + i++; + } + return(newpath); +} + +#define TRANSFER_SIZE (65536) + +int main(int argc, char* argv[]) +{ + char* path1; + char* path2; + FILE* in; + FILE* out; + char* buf; + int n_in; + int n_out; + + if (argc != 3) + { + fprintf(stderr, "Too many arguments\n"); + exit(1); + } + + path1 = convert_path(argv[1]); + path2 = convert_path(argv[2]); + + in = fopen(path1, "rb"); + if (in == NULL) + { + perror("Cannot open input file"); + exit(1); + } + + + + out = fopen(path2, "wb"); + if (out == NULL) + { + perror("Cannot open output file"); + fclose(in); + exit(1); + } + + buf = malloc(TRANSFER_SIZE); + + while (!feof(in)) + { + n_in = fread(buf, 1, TRANSFER_SIZE, in); + n_out = fwrite(buf, 1, n_in, out); + if (n_in != n_out) + { + perror("Failed to write to output file\n"); + free(buf); + fclose(in); + fclose(out); + exit(1); + } + } + exit(0); +} diff --git a/reactos/rules.mak b/reactos/rules.mak index 549a989aa91..f7dc8e03830 100644 --- a/reactos/rules.mak +++ b/reactos/rules.mak @@ -15,7 +15,8 @@ NASM_FORMAT = win32 PREFIX = i586-mingw32- EXE_POSTFIX = EXE_PREFIX = ./ -CP = cp +#CP = cp +CP = $(PATH_TO_TOP)/rcopy DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as NASM_CMD = nasm KM_SPECS = $(TOPDIR)/specs @@ -28,7 +29,8 @@ ifeq ($(HOST),mingw32-windows) NASM_FORMAT = win32 PREFIX = EXE_POSTFIX = .exe -CP = copy /B +#CP = copy /B +CP = rcopy DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as NASM_CMD = nasm RM = del @@ -95,5 +97,57 @@ RCINC = --include-dir ../include --include-dir ../../include --include-dir ../.. %.coff: %.rc $(RC) $(RCINC) $< $@ +%.sys: %.o + $(CC) \ + -specs=$(PATH_TO_TOP)/services/svc_specs \ + -mdll \ + -o junk.tmp \ + -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $^ + - $(RM) junk.tmp + $(DLLTOOL) \ + --dllname $@ \ + --base-file base.tmp \ + --output-exp temp.exp \ + --kill-at + - $(RM) base.tmp + $(CC) \ + --verbose \ + -Wl,--image-base,0x10000 \ + -Wl,-e,_DriverEntry@8 \ + -Wl,temp.exp \ + -specs=$(PATH_TO_TOP)/services/svc_specs \ + -mdll \ + -o $@.unstripped \ + $^ + - $(RM) temp.exp + $(STRIP) --strip-debug $< + $(CC) \ + -specs=$(PATH_TO_TOP)/services/svc_specs \ + -mdll \ + -o junk.tmp \ + -Wl,--defsym,_end=end \ + -Wl,--defsym,_edata=__data_end__ \ + -Wl,--defsym,_etext=etext \ + -Wl,--base-file,base.tmp $^ + - $(RM) junk.tmp + $(DLLTOOL) \ + --dllname $@ \ + --base-file base.tmp \ + --output-exp temp.exp \ + --kill-at + - $(RM) base.tmp + $(CC) \ + --verbose \ + -Wl,--image-base,0x10000 \ + -Wl,-e,_DriverEntry@8 \ + -Wl,temp.exp \ + -specs=$(PATH_TO_TOP)/services/svc_specs \ + -mdll \ + -o $@ \ + $^ + - $(RM) temp.exp RULES_MAK_INCLUDED = 1