diff --git a/reactos/Makefile b/reactos/Makefile index 6651af4b223..1613ba3cc76 100644 --- a/reactos/Makefile +++ b/reactos/Makefile @@ -54,7 +54,7 @@ NET_DEVICE_DRIVERS = ne2000 SYS_APPS = shell winlogon services APPS = args hello test cat bench apc shm lpc thread event file gditest \ - pteb consume dump_shared_data vmtest regtest + pteb consume dump_shared_data vmtest regtest ptest # objdir diff --git a/reactos/drivers/fs/vfat/fat.c b/reactos/drivers/fs/vfat/fat.c index 6a35b7a436e..4707effae8c 100644 --- a/reactos/drivers/fs/vfat/fat.c +++ b/reactos/drivers/fs/vfat/fat.c @@ -1,5 +1,5 @@ /* - * $Id: fat.c,v 1.7 2000/12/07 16:58:42 jean Exp $ + * $Id: fat.c,v 1.8 2000/12/28 03:38:08 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -22,7 +22,8 @@ /* FUNCTIONS ****************************************************************/ -ULONG Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) +ULONG +Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) /* * FUNCTION: Retrieve the next FAT32 cluster from the FAT table via a physical * disk read @@ -44,7 +45,8 @@ ULONG Fat32GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) return(CurrentCluster); } -ULONG Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) +ULONG +Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) /* * FUNCTION: Retrieve the next FAT16 cluster from the FAT table from the * in-memory FAT @@ -59,7 +61,8 @@ ULONG Fat16GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) return(CurrentCluster); } -ULONG Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) +ULONG +Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) /* * FUNCTION: Retrieve the next FAT12 cluster from the FAT table from the * in-memory FAT @@ -68,26 +71,27 @@ ULONG Fat12GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) unsigned char* CBlock; ULONG FATOffset; ULONG Entry; - CBlock = DeviceExt->FAT; - FATOffset = (CurrentCluster * 12)/ 8;//first byte containing value - if ((CurrentCluster % 2) == 0) + CBlock = DeviceExt->FAT; + FATOffset = (CurrentCluster * 12)/ 8;//first byte containing value + if ((CurrentCluster % 2) == 0) { - Entry = CBlock[FATOffset]; - Entry |= ((CBlock[FATOffset+1] & 0xf)<<8); + Entry = CBlock[FATOffset]; + Entry |= ((CBlock[FATOffset+1] & 0xf)<<8); } - else + else { - Entry = (CBlock[FATOffset] >> 4); - Entry |= (CBlock[FATOffset+1] << 4); + Entry = (CBlock[FATOffset] >> 4); + Entry |= (CBlock[FATOffset+1] << 4); } - DPRINT("Entry %x\n",Entry); - if (Entry >= 0xff8 && Entry <= 0xfff) + DPRINT("Entry %x\n",Entry); + if (Entry >= 0xff8 && Entry <= 0xfff) Entry = 0xffffffff; - DPRINT("Returning %x\n",Entry); - return(Entry); + DPRINT("Returning %x\n",Entry); + return(Entry); } -ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) +ULONG +GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) /* * FUNCTION: Retrieve the next cluster depending on the FAT type */ @@ -95,21 +99,21 @@ ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) ULONG NextCluster; DPRINT("GetNextCluster(DeviceExt %x, CurrentCluster %x)\n", - DeviceExt,CurrentCluster); + DeviceExt,CurrentCluster); ExAcquireResourceSharedLite(&DeviceExt->FatResource, TRUE); if (DeviceExt->FatType == FAT16) { - NextCluster = Fat16GetNextCluster(DeviceExt, CurrentCluster); + NextCluster = Fat16GetNextCluster(DeviceExt, CurrentCluster); } else if (DeviceExt->FatType == FAT32) { - NextCluster = Fat32GetNextCluster(DeviceExt, CurrentCluster); + NextCluster = Fat32GetNextCluster(DeviceExt, CurrentCluster); } else { - NextCluster = Fat12GetNextCluster(DeviceExt, CurrentCluster); + NextCluster = Fat12GetNextCluster(DeviceExt, CurrentCluster); } ExReleaseResourceLite(&DeviceExt->FatResource); @@ -117,7 +121,8 @@ ULONG GetNextCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) return(NextCluster); } -ULONG FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Finds the first available cluster in a FAT16 table */ @@ -132,7 +137,8 @@ ULONG FAT16FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) return 0; } -ULONG FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Finds the first available cluster in a FAT12 table */ @@ -162,7 +168,8 @@ ULONG FAT12FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) return 0; } -ULONG FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Finds the first available cluster in a FAT32 table */ @@ -192,7 +199,8 @@ ULONG FAT32FindAvailableCluster(PDEVICE_EXTENSION DeviceExt) return 0; } -ULONG FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Counts free cluster in a FAT12 table */ @@ -227,7 +235,8 @@ ULONG FAT12CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) return ulCount; } -ULONG FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Counts free clusters in a FAT16 table */ @@ -250,7 +259,8 @@ ULONG FAT16CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) return ulCount; } -ULONG FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) +ULONG +FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) /* * FUNCTION: Counts free clusters in a FAT32 table */ @@ -282,8 +292,9 @@ ULONG FAT32CountAvailableClusters(PDEVICE_EXTENSION DeviceExt) return ulCount; } -void FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, - ULONG NewValue) +VOID +FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, + ULONG NewValue) /* * FUNCTION: Writes a cluster to the FAT12 physical and in-memory tables */ @@ -330,8 +341,9 @@ void FAT12WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, } } -void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, - ULONG NewValue) +VOID +FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, + ULONG NewValue) /* * FUNCTION: Writes a cluster to the FAT16 physical and in-memory tables */ @@ -361,8 +373,9 @@ void FAT16WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, } } -void FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, - ULONG NewValue) +VOID +FAT32WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, + ULONG NewValue) /* * FUNCTION: Writes a cluster to the FAT32 physical tables */ @@ -397,8 +410,9 @@ DbgPrint("FAT32WriteCluster %u : %u\n",ClusterToWrite,NewValue); ExFreePool(Block); } -void WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, - ULONG NewValue) +VOID +WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, + ULONG NewValue) /* * FUNCTION: Write a changed FAT entry */ @@ -417,7 +431,8 @@ void WriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, } } -ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) +ULONG +GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) /* * FUNCTION: Determines the next cluster to be written */ @@ -474,8 +489,9 @@ ULONG GetNextWriteCluster(PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) } } -ULONG ClusterToSector(PDEVICE_EXTENSION DeviceExt, - unsigned long Cluster) +ULONG +ClusterToSector(PDEVICE_EXTENSION DeviceExt, + unsigned long Cluster) /* * FUNCTION: Converts the cluster number to a sector number for this physical * device @@ -484,7 +500,8 @@ ULONG ClusterToSector(PDEVICE_EXTENSION DeviceExt, return DeviceExt->dataStart+((Cluster-2)*DeviceExt->Boot->SectorsPerCluster); } -void VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) +VOID +VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) /* * FUNCTION: Load a cluster from the physical device */ @@ -503,7 +520,8 @@ void VFATLoadCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) DPRINT("Finished VFATReadSectors\n"); } -void VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) +VOID +VFATWriteCluster(PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) /* * FUNCTION: Write a cluster to the physical device */ diff --git a/reactos/install.sh b/reactos/install.sh index 14dd006b560..b6c81e5331e 100644 --- a/reactos/install.sh +++ b/reactos/install.sh @@ -24,7 +24,7 @@ cp apps/cat/cat.exe $1/reactos/bin cp subsys/smss/smss.exe $1/reactos/system32 cp subsys/csrss/csrss.exe $1/reactos/system32 cp subsys/win32k/win32k.sys $1/reactos/system32/drivers -#cp apps/system/winlogon/winlogon.exe $1/reactos/system32/ +cp apps/system/winlogon/winlogon.exe $1/reactos/system32/ cp apps/apc/apc.exe $1/reactos/bin cp apps/shm/shmsrv.exe $1/reactos/bin cp apps/shm/shmclt.exe $1/reactos/bin @@ -40,3 +40,4 @@ cp apps/dump_shared_data/dump_shared_data.exe $1/reactos/bin cp apps/vmtest/vmtest.exe $1/reactos/bin cp apps/uitest/uitest.exe $1/reactos/bin/ cp apps/gditest/gditest.exe $1/reactos/bin/ +cp apps/ptest/ptest.exe $1/reactos/bin diff --git a/reactos/ntoskrnl/include/internal/asm.inc b/reactos/ntoskrnl/include/internal/asm.inc deleted file mode 100644 index 477a241fc7a..00000000000 --- a/reactos/ntoskrnl/include/internal/asm.inc +++ /dev/null @@ -1,25 +0,0 @@ -%macro DECLARE_EXTERNAL_SYMBOL 1 -%ifdef coff -extern _%1 -%elifdef win32 -extern _%1 -%elifdef elf -extern %1 -_%1: - call %1 - ret -%endif -%endmacro - -%macro DECLARE_GLOBAL_SYMBOL 1 -%ifdef coff -global _%1 -_%1: -%elifdef win32 -global _%1 -_%1: -%elifdef elf -global %1 -%1: -%endif -%endmacro diff --git a/reactos/ntoskrnl/include/internal/cc.h b/reactos/ntoskrnl/include/internal/cc.h index 8750e29feef..40d981f42a5 100644 --- a/reactos/ntoskrnl/include/internal/cc.h +++ b/reactos/ntoskrnl/include/internal/cc.h @@ -1,10 +1,7 @@ #ifndef __INCLUDE_INTERNAL_CC_H #define __INCLUDE_INTERNAL_CCS_H -/* $Id: cc.h,v 1.1 2000/06/29 23:35:36 dwelch Exp $ */ -VOID -STDCALL -CcMdlReadCompleteDev ( - IN PMDL MdlChain, - IN PDEVICE_OBJECT DeviceObject - ); +/* $Id: cc.h,v 1.2 2000/12/28 03:38:07 dwelch Exp $ */ +VOID STDCALL +CcMdlReadCompleteDev (IN PMDL MdlChain, + IN PDEVICE_OBJECT DeviceObject); #endif diff --git a/reactos/ntoskrnl/include/internal/dbg.h b/reactos/ntoskrnl/include/internal/dbg.h index d6eaae46da0..3d0706b6df8 100644 --- a/reactos/ntoskrnl/include/internal/dbg.h +++ b/reactos/ntoskrnl/include/internal/dbg.h @@ -4,7 +4,8 @@ #include #include -NTSTATUS STDCALL LpcSendDebugMessagePort(PEPORT Port, - PLPC_DBG_MESSAGE Message); +NTSTATUS STDCALL +LpcSendDebugMessagePort(PEPORT Port, + PLPC_DBG_MESSAGE Message); #endif /* __INCLUDE_INTERNAL_DBG_H */ diff --git a/reactos/ntoskrnl/include/internal/ex.h b/reactos/ntoskrnl/include/internal/ex.h index 536738ed108..525439f924e 100644 --- a/reactos/ntoskrnl/include/internal/ex.h +++ b/reactos/ntoskrnl/include/internal/ex.h @@ -2,8 +2,8 @@ * internal executive prototypes */ -#ifndef _INCLUDE_INTERNAL_EXECUTIVE_H -#define _INCLUDE_INTERNAL_EXECUTIVE_H +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H +#define __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H #include #include @@ -14,10 +14,13 @@ TIME_ZONE_INFORMATION SystemTimeZoneInfo; /* INITIALIZATION FUNCTIONS *************************************************/ -VOID ExInit (VOID); -VOID ExInitTimeZoneInfo (VOID); -VOID ExInitializeWorkerThreads(VOID); +VOID +ExInit (VOID); +VOID +ExInitTimeZoneInfo (VOID); +VOID +ExInitializeWorkerThreads(VOID); -#endif /* _INCLUDE_INTERNAL_EXECUTIVE_H */ +#endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */ diff --git a/reactos/ntoskrnl/include/internal/i386/segment.h b/reactos/ntoskrnl/include/internal/i386/segment.h index 279b777dbae..aec35708d8b 100644 --- a/reactos/ntoskrnl/include/internal/i386/segment.h +++ b/reactos/ntoskrnl/include/internal/i386/segment.h @@ -20,27 +20,26 @@ * FILE: ntoskrnl/include/internal/i386/segment.h * PURPOSE: Segment selector definitions * PROGRAMMER: David Welch (welch@cwcom.net) - * UPDATE HISTORY: - * Created ??/??/?? */ /* INCLUDES *****************************************************************/ -#ifndef __INCLUDE_INTERNAL_I386_SEGMENT_H -#define __INCLUDE_INTERNAL_i386_SEGMENT_H +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H +#define __NTOSKRNL_INCLUDE_INTERNAL_i386_SEGMENT_H #define NULL_SELECTOR (0x0) #define KERNEL_CS (0x8) #define KERNEL_DS (0x10) #define USER_CS (0x18 + 0x3) #define USER_DS (0x20 + 0x3) -/* - * FIXME: We actually have one TSS per thread - */ +/* Task State Segment */ #define TSS_SELECTOR (0x28) +/* Processor Control Region */ #define PCR_SELECTOR (0x30) +/* Thread Environment Block */ #define TEB_SELECTOR (0x38 + 0x3) -#define RESERVED1_SELECTOR (0x40) +#define RESERVED_SELECTOR (0x40) +/* Local Descriptor Table */ #define LDT_SELECTOR (0x48) -#endif /* __INCLUDE_INTERNAL_I386_SEGMENT_H */ +#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H */ diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index fa0b8037e54..fb64d16291e 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -1,4 +1,22 @@ -/* $Id: io.h,v 1.6 2000/10/05 19:12:55 ekohl Exp $ +/* + * ReactOS kernel + * Copyright (C) 2000 David Welch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: io.h,v 1.7 2000/12/28 03:38:07 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -9,8 +27,8 @@ * 28/05/97: Created */ -#ifndef __INCLUDE_INTERNAL_IO_H -#define __INCLUDE_INTERNAL_IO_H +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_IO_H +#define __NTOSKRNL_INCLUDE_INTERNAL_IO_H #include #include @@ -23,14 +41,17 @@ extern POBJECT_TYPE IoSymbolicLinkType; * entry = pointer to the driver initialization routine * RETURNS: Success or failure */ -NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry); +NTSTATUS +IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry); - - -VOID IoInitCancelHandling(VOID); -VOID IoInitSymbolicLinkImplementation(VOID); -VOID IoInitFileSystemImplementation(VOID); -VOID IoInitVpbImplementation (VOID); +VOID +IoInitCancelHandling(VOID); +VOID +IoInitSymbolicLinkImplementation(VOID); +VOID +IoInitFileSystemImplementation(VOID); +VOID +IoInitVpbImplementation (VOID); NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject); POBJECT IoOpenSymlink(POBJECT SymbolicLink); diff --git a/reactos/ntoskrnl/include/internal/kd.h b/reactos/ntoskrnl/include/internal/kd.h index 6226f297bdc..f71831db979 100644 --- a/reactos/ntoskrnl/include/internal/kd.h +++ b/reactos/ntoskrnl/include/internal/kd.h @@ -1,4 +1,4 @@ -/* $Id: kd.h,v 1.1 2000/06/29 23:35:36 dwelch Exp $ +/* $Id: kd.h,v 1.2 2000/12/28 03:38:07 dwelch Exp $ * * kernel debugger prototypes */ @@ -6,8 +6,7 @@ #ifndef __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H #define __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H - -ULONG KdpPrintString (PANSI_STRING String); - +ULONG +KdpPrintString (PANSI_STRING String); #endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */ diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index f694d206ebb..f1e6406b4fc 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -1,9 +1,24 @@ /* - * Various useful prototypes + * ReactOS kernel + * Copyright (C) 2000 David Welch + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __INCLUDE_INTERNAL_KERNEL_H -#define __INCLUDE_INTERNAL_KERNEL_H +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H +#define __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H /* INCLUDES *****************************************************************/ diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 82e31521a78..0e81b6dfee1 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -42,6 +42,8 @@ enum #define SPE_DIRTY (0x8) #define SPE_IN_PAGEFILE (0x10) +#define SO_PHYSICAL_MEMORY (0x1) + typedef struct { ULONG Pages[NR_SECTION_PAGE_ENTRIES]; @@ -54,16 +56,17 @@ typedef struct typedef struct { - CSHORT Type; - CSHORT Size; - LARGE_INTEGER MaximumSize; - ULONG SectionPageProtection; - ULONG AllocateAttributes; - PFILE_OBJECT FileObject; - LIST_ENTRY ViewListHead; - KSPIN_LOCK ViewListLock; - KMUTEX Lock; - SECTION_PAGE_DIRECTORY PageDirectory; + CSHORT Type; + CSHORT Size; + LARGE_INTEGER MaximumSize; + ULONG SectionPageProtection; + ULONG AllocateAttributes; + PFILE_OBJECT FileObject; + LIST_ENTRY ViewListHead; + KSPIN_LOCK ViewListLock; + KMUTEX Lock; + SECTION_PAGE_DIRECTORY PageDirectory; + ULONG Flags; } SECTION_OBJECT, *PSECTION_OBJECT; typedef struct @@ -299,6 +302,8 @@ VOID MmUnlockPage(PVOID PhysicalPage); NTSTATUS MmSafeCopyFromUser(PVOID Dest, PVOID Src, ULONG Count); NTSTATUS MmSafeCopyToUser(PVOID Dest, PVOID Src, ULONG Count); +NTSTATUS +MmCreatePhysicalMemorySection(VOID); #define MM_PHYSICAL_PAGE_MPW_PENDING (0x8) diff --git a/reactos/ntoskrnl/ke/gdt.c b/reactos/ntoskrnl/ke/gdt.c index 1548aa614a4..ce56df63661 100644 --- a/reactos/ntoskrnl/ke/gdt.c +++ b/reactos/ntoskrnl/ke/gdt.c @@ -34,9 +34,7 @@ /* GLOBALS *******************************************************************/ -#define NR_TASKS 128 - -USHORT KiGdt[(8 + NR_TASKS) * 4] = +USHORT KiGdt[10 * 4] = { 0x0, 0x0, 0x0, 0x0, /* Null */ 0xffff, 0x0, 0x9a00, 0xcf, /* Kernel CS */ @@ -53,8 +51,9 @@ static KSPIN_LOCK GdtLock; /* FUNCTIONS *****************************************************************/ -VOID KeSetBaseGdtSelector(ULONG Entry, - PVOID Base) +VOID +KeSetBaseGdtSelector(ULONG Entry, + PVOID Base) { KIRQL oldIrql; @@ -84,7 +83,8 @@ VOID KeSetBaseGdtSelector(ULONG Entry, KeReleaseSpinLock(&GdtLock, oldIrql); } -VOID KeDumpGdtSelector(ULONG Entry) +VOID +KeDumpGdtSelector(ULONG Entry) { USHORT a, b, c, d; ULONG RawLimit; @@ -143,7 +143,8 @@ VOID KeFreeGdtSelector(ULONG Entry) #endif #if 0 -ULONG KeAllocateGdtSelector(ULONG Desc[2]) +ULONG +KeAllocateGdtSelector(ULONG Desc[2]) /* * FUNCTION: Allocate a gdt selector * ARGUMENTS: diff --git a/reactos/ntoskrnl/ke/multiboot.S b/reactos/ntoskrnl/ke/multiboot.S index 7303f99cff1..98b23e11193 100644 --- a/reactos/ntoskrnl/ke/multiboot.S +++ b/reactos/ntoskrnl/ke/multiboot.S @@ -3,8 +3,6 @@ #define KERNEL_BASE (0xc0000000) -#define NR_TASKS (128) - #define MULTIBOOT_HEADER_MAGIC (0x1BADB002) #define MULTIBOOT_HEADER_FLAGS (0x00010003) @@ -708,7 +706,7 @@ lowmem_pagetable: .long 0x3f8007,0x3f9007,0x3fa007,0x3fb007,0x3fc007,0x3fd007,0x3fe007,0x3ff007 _gdt_descr: - .word ((8+NR_TASKS)*8)-1 + .word (10*8)-1 .long _KiGdt _idt_descr: diff --git a/reactos/ntoskrnl/lpc/queue.c b/reactos/ntoskrnl/lpc/queue.c index bb408690c07..1abe36f0a41 100644 --- a/reactos/ntoskrnl/lpc/queue.c +++ b/reactos/ntoskrnl/lpc/queue.c @@ -1,4 +1,4 @@ -/* $Id: queue.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $ +/* $Id: queue.c,v 1.3 2000/12/28 03:38:07 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -20,67 +20,59 @@ #include -VOID -STDCALL -EiEnqueueMessagePort ( - IN OUT PEPORT Port, - IN PQUEUEDMESSAGE Message - ) +VOID STDCALL +EiEnqueueMessagePort (IN OUT PEPORT Port, + IN PQUEUEDMESSAGE Message) { - InsertTailList ( - & Port->QueueListHead, - & Message->QueueListEntry - ); - Port->QueueLength++; + InsertTailList (&Port->QueueListHead, + &Message->QueueListEntry); + Port->QueueLength++; } -PQUEUEDMESSAGE -STDCALL -EiDequeueMessagePort ( - IN OUT PEPORT Port - ) +PQUEUEDMESSAGE STDCALL +EiDequeueMessagePort (IN OUT PEPORT Port) { - PQUEUEDMESSAGE Message; - PLIST_ENTRY entry; + PQUEUEDMESSAGE Message; + PLIST_ENTRY entry; + + if (IsListEmpty(&Port->QueueListHead)) + { + return(NULL); + } + entry = RemoveHeadList (&Port->QueueListHead); + Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); + Port->QueueLength--; - entry = RemoveHeadList (& Port->QueueListHead); - Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); - Port->QueueLength--; - - return (Message); + return (Message); } -VOID -STDCALL -EiEnqueueConnectMessagePort ( - IN OUT PEPORT Port, - IN PQUEUEDMESSAGE Message - ) +VOID STDCALL +EiEnqueueConnectMessagePort (IN OUT PEPORT Port, + IN PQUEUEDMESSAGE Message) { - InsertTailList ( - & Port->ConnectQueueListHead, - & Message->QueueListEntry - ); - Port->ConnectQueueLength++; + InsertTailList (&Port->ConnectQueueListHead, + &Message->QueueListEntry); + Port->ConnectQueueLength++; } -PQUEUEDMESSAGE -STDCALL -EiDequeueConnectMessagePort ( - IN OUT PEPORT Port - ) +PQUEUEDMESSAGE STDCALL +EiDequeueConnectMessagePort (IN OUT PEPORT Port) { - PQUEUEDMESSAGE Message; - PLIST_ENTRY entry; - - entry = RemoveHeadList (& Port->ConnectQueueListHead); - Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); - Port->ConnectQueueLength--; - - return (Message); + PQUEUEDMESSAGE Message; + PLIST_ENTRY entry; + + if (IsListEmpty(&Port->ConnectQueueListHead)) + { + return(NULL); + } + entry = RemoveHeadList (&Port->ConnectQueueListHead); + Message = CONTAINING_RECORD (entry, QUEUEDMESSAGE, QueueListEntry); + Port->ConnectQueueLength--; + + return (Message); } diff --git a/reactos/ntoskrnl/lpc/reply.c b/reactos/ntoskrnl/lpc/reply.c index 8d002a770f0..967af7f0bcb 100644 --- a/reactos/ntoskrnl/lpc/reply.c +++ b/reactos/ntoskrnl/lpc/reply.c @@ -1,4 +1,4 @@ -/* $Id: reply.c,v 1.2 2000/10/22 16:36:51 ekohl Exp $ +/* $Id: reply.c,v 1.3 2000/12/28 03:38:07 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -9,7 +9,7 @@ * Created 22/05/98 */ -/* INCLUDES *****************************************************************/ +/* INCLUDES ******************************************************************/ #include #include @@ -19,7 +19,7 @@ #define NDEBUG #include - +/* FUNCTIONS *****************************************************************/ /********************************************************************** * NAME @@ -33,14 +33,11 @@ * REVISIONS * */ -NTSTATUS -STDCALL -EiReplyOrRequestPort ( - IN PEPORT Port, - IN PLPC_MESSAGE LpcReply, - IN ULONG MessageType, - IN PEPORT Sender - ) +NTSTATUS STDCALL +EiReplyOrRequestPort (IN PEPORT Port, + IN PLPC_MESSAGE LpcReply, + IN ULONG MessageType, + IN PEPORT Sender) { KIRQL oldIrql; PQUEUEDMESSAGE MessageReply; @@ -78,12 +75,9 @@ EiReplyOrRequestPort ( * REVISIONS * */ -NTSTATUS -STDCALL -NtReplyPort ( - IN HANDLE PortHandle, - IN PLPC_MESSAGE LpcReply - ) +NTSTATUS STDCALL +NtReplyPort (IN HANDLE PortHandle, + IN PLPC_MESSAGE LpcReply) { NTSTATUS Status; PEPORT Port; @@ -126,14 +120,11 @@ NtReplyPort ( * REVISIONS * */ -NTSTATUS -STDCALL -NtReplyWaitReceivePort ( - HANDLE PortHandle, - PULONG PortId, - PLPC_MESSAGE LpcReply, - PLPC_MESSAGE LpcMessage - ) +NTSTATUS STDCALL +NtReplyWaitReceivePort (HANDLE PortHandle, + PULONG PortId, + PLPC_MESSAGE LpcReply, + PLPC_MESSAGE LpcMessage) { NTSTATUS Status; PEPORT Port; @@ -176,33 +167,49 @@ NtReplyWaitReceivePort ( /* * Want for a message to be received */ - DPRINT("Entering wait for message\n"); - KeWaitForSingleObject(&Port->Event, - UserRequest, - UserMode, - FALSE, - NULL); - DPRINT("Woke from wait for message\n"); + do + { + Status = KeWaitForSingleObject(&Port->Event, + UserRequest, + UserMode, + FALSE, + NULL); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + + /* + * Dequeue the message + */ + KeAcquireSpinLock(&Port->Lock, &oldIrql); + Request = EiDequeueMessagePort(Port); + + /* + * There is a race between the event being set and the port being + * taken in which another thread may dequeue the same request so + * we may need to loop. + */ + if (Request == NULL) + { + KeReleaseSpinLock(&Port->Lock, oldIrql); + } + } while(Request == NULL); - /* - * Dequeue the message - */ - KeAcquireSpinLock(&Port->Lock, &oldIrql); - Request = EiDequeueMessagePort(Port); memcpy(LpcMessage, &Request->Message, Request->Message.MessageSize); if (Request->Message.MessageType == LPC_CONNECTION_REQUEST) { - EiEnqueueConnectMessagePort(Port, Request); - KeReleaseSpinLock(&Port->Lock, oldIrql); + EiEnqueueConnectMessagePort(Port, Request); + KeReleaseSpinLock(&Port->Lock, oldIrql); } else { - KeReleaseSpinLock(&Port->Lock, oldIrql); - ExFreePool(Request); + KeReleaseSpinLock(&Port->Lock, oldIrql); + ExFreePool(Request); } /* - * + * Dereference the port */ ObDereferenceObject(Port); return(STATUS_SUCCESS); @@ -221,14 +228,11 @@ NtReplyWaitReceivePort ( * REVISIONS * */ -NTSTATUS -STDCALL -NtReplyWaitReplyPort ( - HANDLE PortHandle, - PLPC_MESSAGE ReplyMessage - ) +NTSTATUS STDCALL +NtReplyWaitReplyPort (HANDLE PortHandle, + PLPC_MESSAGE ReplyMessage) { - UNIMPLEMENTED; + UNIMPLEMENTED; } diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 903bc45cca2..444c7562795 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -1,4 +1,4 @@ -/* $Id: mminit.c,v 1.11 2000/12/20 18:44:20 jean Exp $ +/* $Id: mminit.c,v 1.12 2000/12/28 03:38:07 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -273,6 +273,8 @@ VOID MmInit2(VOID) VOID MmInit3(VOID) { MmInitPagerThread(); + MmCreatePhysicalMemorySection(); + /* FIXME: Read parameters from memory */ } diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index e7200114403..0a24c21c57f 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,4 +1,4 @@ -/* $Id: section.c,v 1.39 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: section.c,v 1.40 2000/12/28 03:38:07 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -43,14 +43,16 @@ VOID MmLockSection(PSECTION_OBJECT Section) NULL); } -VOID MmUnlockSection(PSECTION_OBJECT Section) +VOID +MmUnlockSection(PSECTION_OBJECT Section) { KeReleaseMutex(&Section->Lock, FALSE); } -VOID MmSetPageEntrySection(PSECTION_OBJECT Section, - ULONG Offset, - ULONG Entry) +VOID +MmSetPageEntrySection(PSECTION_OBJECT Section, + ULONG Offset, + ULONG Entry) { PSECTION_PAGE_TABLE Table; ULONG DirectoryOffset; @@ -70,8 +72,9 @@ VOID MmSetPageEntrySection(PSECTION_OBJECT Section, Table->Pages[TableOffset] = Entry; } -ULONG MmGetPageEntrySection(PSECTION_OBJECT Section, - ULONG Offset) +ULONG +MmGetPageEntrySection(PSECTION_OBJECT Section, + ULONG Offset) { PSECTION_PAGE_TABLE Table; ULONG Entry; @@ -92,9 +95,10 @@ ULONG MmGetPageEntrySection(PSECTION_OBJECT Section, return(Entry); } -NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, - PVOID Address) +NTSTATUS +MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, + MEMORY_AREA* MemoryArea, + PVOID Address) { LARGE_INTEGER Offset; IO_STATUS_BLOCK IoStatus; @@ -128,6 +132,15 @@ NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, MmLockSection(Section); + /* + * Don't do an unaligned mapping of physical memory + */ + if (Section->Flags & SO_PHYSICAL_MEMORY) + { + MmUnlockSection(Section); + return(STATUS_UNSUCCESSFUL); + } + Page = MmAllocPageMaybeSwap(0); Mdl = MmCreateMdl(NULL, NULL, PAGESIZE); MmBuildMdlFromPages(Mdl, (PULONG)&Page); @@ -162,12 +175,13 @@ NTSTATUS MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, } -NTSTATUS MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace, - PMEMORY_AREA MemoryArea, - PVOID Address, - PSECTION_OBJECT Section, - LARGE_INTEGER Offset, - ULONG Entry) +NTSTATUS +MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID Address, + PSECTION_OBJECT Section, + LARGE_INTEGER Offset, + ULONG Entry) { PVOID Page; NTSTATUS Status; @@ -264,9 +278,10 @@ NTSTATUS MmWaitForPendingOperationSection(PMADDRESS_SPACE AddressSpace, return(STATUS_SUCCESS); } -NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, - PVOID Address) +NTSTATUS +MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, + MEMORY_AREA* MemoryArea, + PVOID Address) { LARGE_INTEGER Offset; IO_STATUS_BLOCK IoStatus; @@ -308,17 +323,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, Address)); } - DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress); - DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n", - MemoryArea->Data.SectionData.ViewOffset); - DPRINT("Got offset %x\n", Offset.QuadPart); - /* * Lock the section */ Section = MemoryArea->Data.SectionData.Section; MmLockSection(Section); + if (Section->Flags & SO_PHYSICAL_MEMORY) + { + /* + * Just map the desired physical page + */ + Status = MmCreateVirtualMapping(NULL, + Address, + MemoryArea->Attributes, + Offset.QuadPart); + MmUnlockSection(Section); + return(STATUS_SUCCESS); + } + /* * Get the entry corresponding to the offset within the section */ @@ -496,22 +519,25 @@ NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, } } -ULONG MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, - PVOID Address, - PBOOLEAN Ul) +ULONG +MmPageOutSectionView(PMADDRESS_SPACE AddressSpace, + MEMORY_AREA* MemoryArea, + PVOID Address, + PBOOLEAN Ul) { (*Ul) = FALSE; return(0); } -VOID MmpDeleteSection(PVOID ObjectBody) +VOID +MmpDeleteSection(PVOID ObjectBody) { DPRINT("MmpDeleteSection(ObjectBody %x)\n", ObjectBody); } -VOID MmpCloseSection(PVOID ObjectBody, - ULONG HandleCount) +VOID +MmpCloseSection(PVOID ObjectBody, + ULONG HandleCount) { DPRINT("MmpCloseSection(OB %x, HC %d) RC %d\n", ObjectBody, HandleCount, ObGetReferenceCount(ObjectBody)); @@ -552,40 +578,91 @@ NTSTATUS MmpCreateSection(PVOID ObjectBody, return(STATUS_SUCCESS); } -NTSTATUS MmInitSectionImplementation(VOID) +NTSTATUS +MmCreatePhysicalMemorySection(VOID) { - MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); + HANDLE PhysSectionH; + PSECTION_OBJECT PhysSection; + NTSTATUS Status; + OBJECT_ATTRIBUTES Obj; + UNICODE_STRING Name; + LARGE_INTEGER SectionSize; - RtlInitUnicodeString(&MmSectionObjectType->TypeName, L"Section"); + /* + * Create the section mapping physical memory + */ + SectionSize.QuadPart = 0xFFFFFFFF; + RtlInitUnicodeString(&Name, L"\\Device\\PhysicalMemory"); + InitializeObjectAttributes(&Obj, + &Name, + 0, + NULL, + NULL); + Status = NtCreateSection(&PhysSectionH, + SECTION_ALL_ACCESS, + &Obj, + &SectionSize, + PAGE_EXECUTE_READWRITE, + 0, + NULL); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to create PhysicalMemory section\n"); + KeBugCheck(0); + } + Status = ObReferenceObjectByHandle(PhysSectionH, + SECTION_ALL_ACCESS, + NULL, + KernelMode, + (PVOID*)&PhysSection, + NULL); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to reference PhysicalMemory section\n"); + KeBugCheck(0); + } + PhysSection->Flags = PhysSection->Flags | SO_PHYSICAL_MEMORY; + ObDereferenceObject((PVOID)PhysSection); + + return(STATUS_SUCCESS); +} - MmSectionObjectType->TotalObjects = 0; - MmSectionObjectType->TotalHandles = 0; - MmSectionObjectType->MaxObjects = ULONG_MAX; - MmSectionObjectType->MaxHandles = ULONG_MAX; - MmSectionObjectType->PagedPoolCharge = 0; - MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT); - MmSectionObjectType->Dump = NULL; - MmSectionObjectType->Open = NULL; - MmSectionObjectType->Close = MmpCloseSection; - MmSectionObjectType->Delete = MmpDeleteSection; - MmSectionObjectType->Parse = NULL; - MmSectionObjectType->Security = NULL; - MmSectionObjectType->QueryName = NULL; - MmSectionObjectType->OkayToClose = NULL; - MmSectionObjectType->Create = MmpCreateSection; +NTSTATUS +MmInitSectionImplementation(VOID) +{ + MmSectionObjectType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE)); + + RtlInitUnicodeString(&MmSectionObjectType->TypeName, L"Section"); + + MmSectionObjectType->TotalObjects = 0; + MmSectionObjectType->TotalHandles = 0; + MmSectionObjectType->MaxObjects = ULONG_MAX; + MmSectionObjectType->MaxHandles = ULONG_MAX; + MmSectionObjectType->PagedPoolCharge = 0; + MmSectionObjectType->NonpagedPoolCharge = sizeof(SECTION_OBJECT); + MmSectionObjectType->Dump = NULL; + MmSectionObjectType->Open = NULL; + MmSectionObjectType->Close = MmpCloseSection; + MmSectionObjectType->Delete = MmpDeleteSection; + MmSectionObjectType->Parse = NULL; + MmSectionObjectType->Security = NULL; + MmSectionObjectType->QueryName = NULL; + MmSectionObjectType->OkayToClose = NULL; + MmSectionObjectType->Create = MmpCreateSection; - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } /* FIXME: NtCS should call MmCS */ -NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize OPTIONAL, - IN ULONG SectionPageProtection OPTIONAL, - IN ULONG AllocationAttributes, - IN HANDLE FileHandle OPTIONAL) +NTSTATUS STDCALL +NtCreateSection (OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection OPTIONAL, + IN ULONG AllocationAttributes, + IN HANDLE FileHandle OPTIONAL) /* * FUNCTION: Creates a section object. * ARGUMENTS: @@ -640,8 +717,9 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, KeInitializeSpinLock(&Section->ViewListLock); KeInitializeMutex(&Section->Lock, 0); memset(&Section->PageDirectory, 0, sizeof(Section->PageDirectory)); - - if (FileHandle != (HANDLE)0xffffffff) + Section->Flags = 0; + + if (FileHandle != (HANDLE)0) { Status = ObReferenceObjectByHandle(FileHandle, FILE_READ_DATA, @@ -686,9 +764,10 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, * REVISIONS * */ -NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle, - ACCESS_MASK DesiredAccess, - POBJECT_ATTRIBUTES ObjectAttributes) +NTSTATUS STDCALL +NtOpenSection(PHANDLE SectionHandle, + ACCESS_MASK DesiredAccess, + POBJECT_ATTRIBUTES ObjectAttributes) { PVOID Object; NTSTATUS Status; @@ -765,16 +844,17 @@ NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle, * RETURN VALUE * Status. */ -NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, - HANDLE ProcessHandle, - PVOID* BaseAddress, - ULONG ZeroBits, - ULONG CommitSize, - PLARGE_INTEGER SectionOffset, - PULONG ViewSize, - SECTION_INHERIT InheritDisposition, - ULONG AllocationType, - ULONG Protect) +NTSTATUS STDCALL +NtMapViewOfSection(HANDLE SectionHandle, + HANDLE ProcessHandle, + PVOID* BaseAddress, + ULONG ZeroBits, + ULONG CommitSize, + PLARGE_INTEGER SectionOffset, + PULONG ViewSize, + SECTION_INHERIT InheritDisposition, + ULONG AllocationType, + ULONG Protect) { PSECTION_OBJECT Section; PEPROCESS Process; @@ -803,7 +883,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, if (!(NT_SUCCESS(Status))) { DPRINT("ObReference failed rc=%x\n",Status); - return Status; + return(Status); } DPRINT("Section %x\n",Section); @@ -821,7 +901,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, Status); MmUnlockSection(Section); ObDereferenceObject(Section); - return Status; + return(Status); } AddressSpace = &Process->AddressSpace; @@ -839,9 +919,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, } if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart) - { + { (*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset; - } + } DPRINT("Creating memory area\n"); MmLockAddressSpace(AddressSpace); @@ -861,7 +941,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, MmUnlockSection(Section); ObDereferenceObject(Section); - return Status; + return(Status); } KeAcquireSpinLock(&Section->ViewListLock, &oldIrql); @@ -884,8 +964,9 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle, return(STATUS_SUCCESS); } -NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process, - PMEMORY_AREA MemoryArea) +NTSTATUS STDCALL +MmUnmapViewOfSection(PEPROCESS Process, + PMEMORY_AREA MemoryArea) { PSECTION_OBJECT Section; KIRQL oldIrql; @@ -922,8 +1003,9 @@ NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process, * REVISIONS * */ -NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle, - PVOID BaseAddress) +NTSTATUS STDCALL +NtUnmapViewOfSection (HANDLE ProcessHandle, + PVOID BaseAddress) { PEPROCESS Process; NTSTATUS Status; @@ -964,10 +1046,20 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle, MemoryArea); DPRINT("MmFreeMemoryArea()\n"); - Status = MmFreeMemoryArea(&Process->AddressSpace, - BaseAddress, - 0, - TRUE); + if (MemoryArea->Data.SectionData.Section->Flags & SO_PHYSICAL_MEMORY) + { + Status = MmFreeMemoryArea(&Process->AddressSpace, + BaseAddress, + 0, + FALSE); + } + else + { + Status = MmFreeMemoryArea(&Process->AddressSpace, + BaseAddress, + 0, + TRUE); + } MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); @@ -975,11 +1067,12 @@ NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle, } -NTSTATUS STDCALL NtQuerySection (IN HANDLE SectionHandle, - IN CINT SectionInformationClass, - OUT PVOID SectionInformation, - IN ULONG Length, - OUT PULONG ResultLength) +NTSTATUS STDCALL +NtQuerySection (IN HANDLE SectionHandle, + IN CINT SectionInformationClass, + OUT PVOID SectionInformation, + IN ULONG Length, + OUT PULONG ResultLength) /* * FUNCTION: Queries the information of a section object. * ARGUMENTS: @@ -997,8 +1090,9 @@ NTSTATUS STDCALL NtQuerySection (IN HANDLE SectionHandle, } -NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle, - IN ULONG NewMaximumSize) +NTSTATUS STDCALL +NtExtendSection(IN HANDLE SectionHandle, + IN ULONG NewMaximumSize) { UNIMPLEMENTED; } @@ -1021,7 +1115,8 @@ NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle, * REVISIONS * */ -PVOID STDCALL MmAllocateSection (IN ULONG Length) +PVOID STDCALL +MmAllocateSection (IN ULONG Length) { PVOID Result; MEMORY_AREA* marea; @@ -1077,107 +1172,83 @@ PVOID STDCALL MmAllocateSection (IN ULONG Length) * Status. * */ -PVOID -STDCALL -MmMapViewOfSection ( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2, - DWORD Unknown3, - DWORD Unknown4, - DWORD Unknown5, - DWORD Unknown6, - DWORD Unknown7, - DWORD Unknown8, - DWORD Unknown9 - ) +PVOID STDCALL +MmMapViewOfSection (DWORD Unknown0, + DWORD Unknown1, + DWORD Unknown2, + DWORD Unknown3, + DWORD Unknown4, + DWORD Unknown5, + DWORD Unknown6, + DWORD Unknown7, + DWORD Unknown8, + DWORD Unknown9) { UNIMPLEMENTED; return (NULL); } -BOOLEAN -STDCALL -MmCanFileBeTruncated ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER NewFileSize - ) +BOOLEAN STDCALL +MmCanFileBeTruncated (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER NewFileSize) { - UNIMPLEMENTED; - return (FALSE); + UNIMPLEMENTED; + return (FALSE); } -BOOLEAN -STDCALL -MmDisableModifiedWriteOfSection ( - DWORD Unknown0 - ) +BOOLEAN STDCALL +MmDisableModifiedWriteOfSection (DWORD Unknown0) { - UNIMPLEMENTED; - return (FALSE); + UNIMPLEMENTED; + return (FALSE); } -BOOLEAN -STDCALL -MmFlushImageSection ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN MMFLUSH_TYPE FlushType - ) +BOOLEAN STDCALL +MmFlushImageSection (IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN MMFLUSH_TYPE FlushType) { - UNIMPLEMENTED; - return (FALSE); + UNIMPLEMENTED; + return (FALSE); } -BOOLEAN -STDCALL -MmForceSectionClosed ( - DWORD Unknown0, - DWORD Unknown1 - ) +BOOLEAN STDCALL +MmForceSectionClosed (DWORD Unknown0, + DWORD Unknown1) { - UNIMPLEMENTED; - return (FALSE); + UNIMPLEMENTED; + return (FALSE); } -NTSTATUS -STDCALL -MmMapViewInSystemSpace ( - IN PVOID Section, - OUT PVOID * MappedBase, - IN PULONG ViewSize - ) +NTSTATUS STDCALL +MmMapViewInSystemSpace (IN PVOID Section, + OUT PVOID * MappedBase, + IN PULONG ViewSize) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return (STATUS_NOT_IMPLEMENTED); } -NTSTATUS -STDCALL -MmUnmapViewInSystemSpace ( - DWORD Unknown0 - ) +NTSTATUS STDCALL +MmUnmapViewInSystemSpace (DWORD Unknown0) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return (STATUS_NOT_IMPLEMENTED); } -NTSTATUS -STDCALL -MmSetBankedSection ( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2, - DWORD Unknown3, - DWORD Unknown4, - DWORD Unknown5 - ) +NTSTATUS STDCALL +MmSetBankedSection (DWORD Unknown0, + DWORD Unknown1, + DWORD Unknown2, + DWORD Unknown3, + DWORD Unknown4, + DWORD Unknown5) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return (STATUS_NOT_IMPLEMENTED); } @@ -1234,20 +1305,23 @@ MmSetBankedSection ( * RETURN VALUE * Status. */ -NTSTATUS -STDCALL -MmCreateSection ( - OUT PSECTION_OBJECT * SectionObject, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize, - IN ULONG SectionPageProtection, - IN ULONG AllocationAttributes, - IN HANDLE FileHandle OPTIONAL, - IN PFILE_OBJECT File OPTIONAL - ) +NTSTATUS STDCALL +MmCreateSection (OUT PSECTION_OBJECT * SectionObject, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN HANDLE FileHandle OPTIONAL, + IN PFILE_OBJECT File OPTIONAL) { - return (STATUS_NOT_IMPLEMENTED); + return (STATUS_NOT_IMPLEMENTED); } /* EOF */ + + + + + +