diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c index ad350630a13..a2d26dbb75d 100644 --- a/reactos/drivers/fs/vfat/blockdev.c +++ b/reactos/drivers/fs/vfat/blockdev.c @@ -18,15 +18,17 @@ /* FUNCTIONS ***************************************************************/ -BOOLEAN -VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject, - IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR * Buffer) +NTSTATUS +VfatReadSectors (IN PDEVICE_OBJECT pDeviceObject, + IN ULONG DiskSector, + IN ULONG SectorCount, + IN OUT PUCHAR Buffer) { LARGE_INTEGER sectorNumber; - PIRP irp; - IO_STATUS_BLOCK ioStatus; + PIRP Irp; + IO_STATUS_BLOCK IoStatus; KEVENT event; - NTSTATUS status; + NTSTATUS Status; ULONG sectorSize; sectorNumber.u.LowPart = DiskSector << 9; @@ -35,7 +37,6 @@ VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject, KeInitializeEvent (&event, NotificationEvent, FALSE); sectorSize = BLOCKSIZE * SectorCount; - DPRINT ("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", pDeviceObject, DiskSector, Buffer); DPRINT ("sectorNumber %08lx:%08lx sectorSize %ld\n", @@ -44,53 +45,55 @@ VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject, DPRINT ("Building synchronous FSD Request...\n"); - irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ, + Irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ, pDeviceObject, Buffer, sectorSize, - §orNumber, &event, &ioStatus); + §orNumber, + &event, + &IoStatus); - if (!irp) + if (Irp == NULL) { - DbgPrint ("READ failed!!!\n"); - return FALSE; + DPRINT("IoBuildSynchronousFsdRequest failed\n"); + return(STATUS_UNSUCCESSFUL);; } - DPRINT ("Calling IO Driver... with irp %x\n", irp); - status = IoCallDriver (pDeviceObject, irp); + DPRINT ("Calling IO Driver... with irp %x\n", Irp); + Status = IoCallDriver (pDeviceObject, Irp); - DPRINT ("Waiting for IO Operation for %x\n", irp); - if (status == STATUS_PENDING) + DPRINT ("Waiting for IO Operation for %x\n", Irp); + if (Status == STATUS_PENDING) { DPRINT ("Operation pending\n"); KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL); - DPRINT ("Getting IO Status... for %x\n", irp); - status = ioStatus.Status; + DPRINT ("Getting IO Status... for %x\n", Irp); + Status = IoStatus.Status; } - if (!NT_SUCCESS (status)) + if (!NT_SUCCESS (Status)) { - DbgPrint ("IO failed!!! VFATREadSectors : Error code: %x\n", status); - DbgPrint - ("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n", - pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart, - sectorNumber.u.LowPart); - return FALSE; + DPRINT ("IO failed!!! VFATREadSectors : Error code: %x\n", Status); + DPRINT ("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n", + pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart, + sectorNumber.u.LowPart); + return (Status); } - DPRINT ("Block request succeeded for %x\n", irp); - return TRUE; + DPRINT ("Block request succeeded for %x\n", Irp); + return (STATUS_SUCCESS); } -BOOLEAN -VFATWriteSectors (IN PDEVICE_OBJECT pDeviceObject, +NTSTATUS +VfatWriteSectors (IN PDEVICE_OBJECT pDeviceObject, IN ULONG DiskSector, - IN ULONG SectorCount, IN UCHAR * Buffer) + IN ULONG SectorCount, + IN PUCHAR Buffer) { LARGE_INTEGER sectorNumber; - PIRP irp; - IO_STATUS_BLOCK ioStatus; + PIRP Irp; + IO_STATUS_BLOCK IoStatus; KEVENT event; - NTSTATUS status; + NTSTATUS Status; ULONG sectorSize; DPRINT ("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", @@ -104,35 +107,37 @@ VFATWriteSectors (IN PDEVICE_OBJECT pDeviceObject, sectorSize = BLOCKSIZE * SectorCount; DPRINT ("Building synchronous FSD Request...\n"); - irp = IoBuildSynchronousFsdRequest (IRP_MJ_WRITE, + Irp = IoBuildSynchronousFsdRequest (IRP_MJ_WRITE, pDeviceObject, Buffer, sectorSize, - §orNumber, &event, &ioStatus); + §orNumber, + &event, + &IoStatus); - if (!irp) + if (!Irp) { - DbgPrint ("WRITE failed!!!\n"); - return FALSE; + DPRINT ("WRITE failed!!!\n"); + return (STATUS_UNSUCCESSFUL); } DPRINT ("Calling IO Driver...\n"); - status = IoCallDriver (pDeviceObject, irp); + Status = IoCallDriver (pDeviceObject, Irp); DPRINT ("Waiting for IO Operation...\n"); - if (status == STATUS_PENDING) + if (Status == STATUS_PENDING) { KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL); DPRINT ("Getting IO Status...\n"); - status = ioStatus.Status; + Status = IoStatus.Status; } - if (!NT_SUCCESS (status)) + if (!NT_SUCCESS (Status)) { - DbgPrint ("IO failed!!! VFATWriteSectors : Error code: %x\n", status); - return FALSE; + DPRINT ("IO failed!!! VFATWriteSectors : Error code: %x\n", Status); + return (Status); } DPRINT ("Block request succeeded\n"); - return TRUE; + return (STATUS_SUCCESS); } diff --git a/reactos/drivers/fs/vfat/create.c b/reactos/drivers/fs/vfat/create.c index 071f221e584..7d6bb56d45c 100644 --- a/reactos/drivers/fs/vfat/create.c +++ b/reactos/drivers/fs/vfat/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.11 2001/01/01 04:42:11 dwelch Exp $ +/* $Id: create.c,v 1.12 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -95,7 +95,8 @@ GetEntryName (PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop, Offset = 0; StartingSector++; //FIXME : nor always the next sector jloop++; - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, StartingSector, 1, Block); test2 = (slot *) Block; } @@ -156,7 +157,8 @@ ReadVolumeLabel (PDEVICE_EXTENSION DeviceExt, PVPB Vpb) DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i); for (j = 0; j < Size; j++) { - VFATReadSectors (DeviceExt->StorageDevice, StartingSector, 1, block); + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, StartingSector, 1, block); for (i = 0; i < ENTRIES_PER_SECTOR; i++) { @@ -291,7 +293,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb, DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i); for (j = 0; j < Size; j++) { - VFATReadSectors (DeviceExt->StorageDevice, StartingSector, 1, block); + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, StartingSector, 1, block); for (i = (Entry) ? (*Entry) : 0; i < ENTRIES_PER_SECTOR; i++) { @@ -320,7 +323,8 @@ FindFile (PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb, /* entry is in next sector */ StartingSector++; /* FIXME : treat case of next sector fragmented */ - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, StartingSector, 1, block); i = 0; } @@ -563,7 +567,8 @@ FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, ParentFcb = Temp; } - + FileObject->Flags = FileObject->Flags | + FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ; FileObject->FsContext = (PVOID)&ParentFcb->RFCB; newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB)); memset (newCCB, 0, sizeof (VFATCCB)); diff --git a/reactos/drivers/fs/vfat/fat.c b/reactos/drivers/fs/vfat/fat.c index 06a92ffbe9b..0a15ae5603b 100644 --- a/reactos/drivers/fs/vfat/fat.c +++ b/reactos/drivers/fs/vfat/fat.c @@ -1,5 +1,5 @@ /* - * $Id: fat.c,v 1.9 2000/12/29 23:17:12 dwelch Exp $ + * $Id: fat.c,v 1.10 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -35,7 +35,8 @@ Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) Block = ExAllocatePool (NonPagedPool, 1024); FATsector = CurrentCluster / (512 / sizeof (ULONG)); FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG))); - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, (ULONG) (DeviceExt->FATStart + FATsector), 1, (UCHAR *) Block); CurrentCluster = Block[FATeis]; @@ -53,11 +54,36 @@ Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster) */ { PUSHORT Block; - Block = (PUSHORT) DeviceExt->FAT; - CurrentCluster = Block[CurrentCluster]; + PVOID BaseAddress; + BOOLEAN Valid; + PCACHE_SEGMENT CacheSeg; + NTSTATUS Status; + ULONG FATOffset; + + FATOffset = (DeviceExt->FATStart * BLOCKSIZE) + (CurrentCluster * 2); + + Status = CcRequestCacheSegment(DeviceExt->StorageBcb, + PAGE_ROUND_DOWN(FATOffset), + &BaseAddress, + &Valid, + &CacheSeg); + if (!Valid) + { + Status = VfatReadSectors(DeviceExt->StorageDevice, + PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE, + PAGESIZE / BLOCKSIZE, + BaseAddress); + if (!NT_SUCCESS(Status)) + { + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); + return(0xFFFFFFFF); + } + } + + CurrentCluster = *((PUSHORT)(BaseAddress + (FATOffset % PAGESIZE))); if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff) - CurrentCluster = 0xffffffff; - DPRINT ("Returning %x\n", CurrentCluster); + CurrentCluster = 0xffffffff; + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE); return (CurrentCluster); } @@ -71,17 +97,82 @@ 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) + PVOID PBlock; + NTSTATUS Status; + PVOID BaseAddress; + BOOLEAN Valid; + PCACHE_SEGMENT CacheSeg; + UCHAR Value1, Value2; + + FATOffset = (DeviceExt->FATStart * BLOCKSIZE) + ((CurrentCluster * 12) / 8); + + /* + * Get the page containing this offset + */ + Status = CcRequestCacheSegment(DeviceExt->StorageBcb, + PAGE_ROUND_DOWN(FATOffset), + &BaseAddress, + &Valid, + &CacheSeg); + if (!Valid) { - Entry = CBlock[FATOffset]; - Entry |= ((CBlock[FATOffset + 1] & 0xf) << 8); + Status = VfatReadSectors(DeviceExt->StorageDevice, + PAGE_ROUND_DOWN(FATOffset) / BLOCKSIZE, + PAGESIZE / BLOCKSIZE, + BaseAddress); + if (!NT_SUCCESS(Status)) + { + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); + return(0xFFFFFFFF); + } + } + Value1 = ((PUCHAR)BaseAddress)[FATOffset % PAGESIZE]; + + /* + * A FAT12 entry may straggle two sectors + */ + if ((FATOffset + 1) == PAGESIZE) + { + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE); + Status = CcRequestCacheSegment(DeviceExt->StorageBcb, + PAGE_ROUND_DOWN(FATOffset) + PAGESIZE, + &BaseAddress, + &Valid, + &CacheSeg); + if (!Valid) + { + ULONG NextOffset; + + NextOffset = (PAGE_ROUND_DOWN(FATOffset) + PAGESIZE) / BLOCKSIZE; + Status = + VfatReadSectors(DeviceExt->StorageDevice, + NextOffset, + PAGESIZE / BLOCKSIZE, + BaseAddress); + if (!NT_SUCCESS(Status)) + { + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, FALSE); + return(0xFFFFFFFF); + } + } + Value2 = ((PUCHAR)BaseAddress)[0]; + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE); } else { - Entry = (CBlock[FATOffset] >> 4); - Entry |= (CBlock[FATOffset + 1] << 4); + Value2 = ((PUCHAR)BaseAddress)[(FATOffset % PAGESIZE) + 1]; + CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE); + } + + if ((CurrentCluster % 2) == 0) + { + Entry = Value1; + Entry |= ((Value2 & 0xf) << 8); + } + else + { + Entry = (Value1 >> 4); + Entry |= (Value2 << 4); } DPRINT ("Entry %x\n", Entry); if (Entry >= 0xff8 && Entry <= 0xfff) @@ -182,7 +273,8 @@ FAT32FindAvailableCluster (PDEVICE_EXTENSION DeviceExt) sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32; sector++) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, (ULONG) (DeviceExt->FATStart + sector), 1, (UCHAR *) Block); @@ -278,7 +370,8 @@ FAT32CountAvailableClusters (PDEVICE_EXTENSION DeviceExt) sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32; sector++) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, (ULONG) (DeviceExt->FATStart + sector), 1, (UCHAR *) Block); @@ -324,14 +417,16 @@ FAT12WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, { if ((FATOffset % BLOCKSIZE) == (BLOCKSIZE - 1)) //entry is on 2 sectors { - VFATWriteSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatWriteSectors (DeviceExt->StorageDevice, DeviceExt->FATStart + FATsector + i * DeviceExt->Boot->FATSectors, 2, CBlock + FATsector * 512); } else { - VFATWriteSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatWriteSectors (DeviceExt->StorageDevice, DeviceExt->FATStart + FATsector + i * DeviceExt->Boot->FATSectors, 1, CBlock + FATsector * 512); @@ -363,7 +458,8 @@ FAT16WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, Start = DeviceExt->FATStart + FATsector; for (i = 0; i < DeviceExt->Boot->FATCount; i++) { - VFATWriteSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatWriteSectors (DeviceExt->StorageDevice, Start, 1, ((UCHAR *) Block) + FATsector * 512); Start += DeviceExt->Boot->FATSectors; } @@ -387,7 +483,8 @@ FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, FATsector = ClusterToWrite / 128; FATeis = ClusterToWrite - (FATsector * 128); /* load sector, change value, then rewrite sector */ - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, DeviceExt->FATStart + FATsector, 1, (UCHAR *) Block); Block[FATeis] = NewValue; /* Write the changed FAT sector to disk (all FAT's) */ @@ -395,7 +492,8 @@ FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite, pBoot = (struct _BootSector32 *) DeviceExt->Boot; for (i = 0; i < pBoot->FATCount; i++) { - VFATWriteSectors (DeviceExt->StorageDevice, Start, 1, (UCHAR *) Block); + /* FIXME: Check status */ + VfatWriteSectors (DeviceExt->StorageDevice, Start, 1, (UCHAR *) Block); Start += pBoot->FATSectors; } ExFreePool (Block); @@ -503,7 +601,8 @@ VFATLoadCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) Sector = ClusterToSector (DeviceExt, Cluster); - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, Sector, DeviceExt->Boot->SectorsPerCluster, Buffer); DPRINT ("Finished VFATReadSectors\n"); } @@ -520,6 +619,7 @@ VFATWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster) Sector = ClusterToSector (DeviceExt, Cluster); - VFATWriteSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatWriteSectors (DeviceExt->StorageDevice, Sector, DeviceExt->Boot->SectorsPerCluster, Buffer); } diff --git a/reactos/drivers/fs/vfat/iface.c b/reactos/drivers/fs/vfat/iface.c index b6d2adc1d1e..377374551c9 100644 --- a/reactos/drivers/fs/vfat/iface.c +++ b/reactos/drivers/fs/vfat/iface.c @@ -1,4 +1,4 @@ -/* $Id: iface.c,v 1.46 2001/01/01 04:42:11 dwelch Exp $ +/* $Id: iface.c,v 1.47 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -51,7 +51,8 @@ VfatHasFileSystem (PDEVICE_OBJECT DeviceToMount) Boot = ExAllocatePool (NonPagedPool, 512); - VFATReadSectors (DeviceToMount, 0, 1, (UCHAR *) Boot); + /* FIXME: Check status */ + VfatReadSectors (DeviceToMount, 0, 1, (UCHAR *) Boot); DPRINT ("Boot->SysType %.5s\n", Boot->SysType); if (strncmp (Boot->SysType, "FAT12", 5) == 0 || @@ -75,10 +76,8 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) DPRINT ("DeviceExt %x\n", DeviceExt); DeviceExt->Boot = ExAllocatePool (NonPagedPool, 512); - VFATReadSectors (DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot); - - DPRINT ("DeviceExt->Boot->BytesPerSector %x\n", - DeviceExt->Boot->BytesPerSector); + /* FIXME: Check status */ + VfatReadSectors (DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot); DeviceExt->FATStart = DeviceExt->Boot->ReservedSectors; DeviceExt->rootDirectorySectors = @@ -107,6 +106,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) if (strncmp (DeviceExt->Boot->SysType, "FAT12", 5) == 0) { + DbgPrint("FAT12\n"); DeviceExt->FatType = FAT12; } else @@ -114,6 +114,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) (((struct _BootSector32 *) (DeviceExt->Boot))->SysType, "FAT32", 5) == 0) { + DbgPrint("FAT32\n"); DeviceExt->FatType = FAT32; DeviceExt->rootDirectorySectors = DeviceExt->Boot->SectorsPerCluster; DeviceExt->rootStart = @@ -123,6 +124,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) } else { + DbgPrint("FAT16\n"); DeviceExt->FatType = FAT16; } @@ -133,7 +135,8 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) DeviceExt->FAT = ExAllocatePool (NonPagedPool, BLOCKSIZE * DeviceExt->Boot->FATSectors); - VFATReadSectors (DeviceToMount, DeviceExt->FATStart, + /* FIXME: Check status */ + VfatReadSectors (DeviceToMount, DeviceExt->FATStart, DeviceExt->Boot->FATSectors, (UCHAR *) DeviceExt->FAT); } return STATUS_SUCCESS; @@ -147,6 +150,7 @@ VfatMount (PDEVICE_OBJECT DeviceToMount) { PDEVICE_OBJECT DeviceObject; PDEVICE_EXTENSION DeviceExt; + NTSTATUS Status; IoCreateDevice (VfatDriverObject, sizeof (DEVICE_EXTENSION), @@ -159,6 +163,11 @@ VfatMount (PDEVICE_OBJECT DeviceToMount) DeviceObject->Vpb->Flags |= VPB_MOUNTED; DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack (DeviceObject, DeviceToMount); + DeviceExt->StreamStorageDevice = + IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice); + Status = CcInitializeFileCache(DeviceExt->StreamStorageDevice, + &DeviceExt->StorageBcb, + PAGESIZE); ExInitializeResourceLite (&DeviceExt->DirResource); ExInitializeResourceLite (&DeviceExt->FatResource); diff --git a/reactos/drivers/fs/vfat/rw.c b/reactos/drivers/fs/vfat/rw.c index 34c52842e76..99375df4f14 100644 --- a/reactos/drivers/fs/vfat/rw.c +++ b/reactos/drivers/fs/vfat/rw.c @@ -1,4 +1,4 @@ -/* $Id: rw.c,v 1.13 2001/01/01 04:42:12 dwelch Exp $ +/* $Id: rw.c,v 1.14 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -26,6 +26,24 @@ /* FUNCTIONS *****************************************************************/ +VOID +NextCluster(PDEVICE_EXTENSION DeviceExt, + ULONG FirstCluster, + PULONG CurrentCluster) +{ + DPRINT("NextCluster() (*CurrentCluster) 0x%x\n", (*CurrentCluster)); + if (FirstCluster == 1) + { + (*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster; + } + else + { + (*CurrentCluster) = GetNextCluster(DeviceExt, (*CurrentCluster)); + } + DPRINT("NextCluster() finished (*CurrentCluster) 0x%x\n", + (*CurrentCluster)); +} + ULONG OffsetToCluster(PDEVICE_EXTENSION DeviceExt, ULONG FirstCluster, @@ -33,6 +51,8 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt, { ULONG CurrentCluster; ULONG i; + + DPRINT("OffsetToCluster(FirstCluster 0x%x)\n", FirstCluster); CurrentCluster = FirstCluster; if (FirstCluster == 1) @@ -48,6 +68,7 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt, CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); } } + DPRINT("OffsetToCluster() = 0x%x\n", CurrentCluster); return(CurrentCluster); } @@ -139,7 +160,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, { if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, CurrentCluster, DeviceExt->Boot->SectorsPerCluster, Temp); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; @@ -164,7 +186,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, { if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, CurrentCluster, DeviceExt->Boot->SectorsPerCluster, Buffer); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; @@ -190,7 +213,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, (*LengthRead) = (*LengthRead) + Length; if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, CurrentCluster, DeviceExt->Boot->SectorsPerCluster, Temp); CurrentCluster += DeviceExt->Boot->SectorsPerCluster; @@ -212,9 +236,11 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt, PULONG CurrentCluster, PVOID Destination) { + DPRINT("VfatRawReadCluster() *CurrentCluster 0x%x\n", *CurrentCluster); if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, (*CurrentCluster), DeviceExt->Boot->SectorsPerCluster, Destination); @@ -225,6 +251,8 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt, VFATLoadCluster (DeviceExt, Destination, (*CurrentCluster)); (*CurrentCluster) = GetNextCluster (DeviceExt, (*CurrentCluster)); } + DPRINT("VfatRawReadCluster() finished *CurrentCluster 0x%x\n", + *CurrentCluster); return(STATUS_SUCCESS); } @@ -297,9 +325,10 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt, ULONG i; ULONG ReadOffset; ULONG InternalOffset; - - ReadOffset = ROUND_DOWN(StartOffset, PAGESIZE); - InternalOffset = StartOffset % PAGESIZE; + + /* + * Otherwise we read a page of clusters together + */ Status = CcRequestCacheSegment(Fcb->RFCB.Bcb, ReadOffset, &BaseAddress, @@ -311,37 +340,43 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt, } /* - * If necessary read all the data for the page + * If necessary read all the data for the page, unfortunately the + * file length may not be page aligned in which case the page will + * only be partially filled. + * FIXME: So zero fill the rest? */ if (!Valid) { - ULONG StartCluster; - - StartCluster = OffsetToCluster(DeviceExt, FirstCluster, ReadOffset); - for (i = 0; i < (PAGESIZE / BytesPerCluster); i++) { Status = VfatRawReadCluster(DeviceExt, FirstCluster, - &StartCluster, + CurrentCluster, BaseAddress + (i * BytesPerCluster)); if (!NT_SUCCESS(Status)) { CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, FALSE); return(Status); } + if (CurrentCluster == 0xFFFFFFFF) + { + break; + } } } - /* - * Go on to the next cluster - */ - if (FirstCluster == 1) - { - (*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster; - } else { - (*CurrentCluster) = GetNextCluster(DeviceExt, (*CurrentCluster)); + /* + * Otherwise just move onto the next cluster + */ + for (i = 0; i < (PAGESIZE / DeviceExt->BytesPerCluster); i++) + { + NextCluster(DeviceExt, FirstCluster, CurrentCluster); + if (CurrentCluster == 0xFFFFFFFF) + { + break; + } + } } /* * Copy the data from the cache to the caller @@ -366,6 +401,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PVFATFCB Fcb; PVOID Temp; ULONG TempLength; + ULONG ChunkSize; /* PRECONDITION */ assert (DeviceExt != NULL); @@ -374,7 +410,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, assert (FileObject->FsContext != NULL); DPRINT ("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, " - "Length %d, ReadOffset %d)\n", DeviceExt, FileObject, Buffer, + "Length %d, ReadOffset 0x%x)\n", DeviceExt, FileObject, Buffer, Length, ReadOffset); Fcb = ((PVFATCCB)FileObject->FsContext2)->pFcb; @@ -404,13 +440,15 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, } } + + ChunkSize = max(DeviceExt->BytesPerCluster, PAGESIZE); *LengthRead = 0; /* * Allocate a buffer to hold partial clusters */ - Temp = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster); + Temp = ExAllocatePool (NonPagedPool, ChunkSize); if (!Temp) return STATUS_UNSUCCESSFUL; @@ -425,16 +463,14 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, * If the read doesn't begin on a cluster boundary then read a full * cluster and copy it. */ - if ((ReadOffset % DeviceExt->BytesPerCluster) != 0) + if ((ReadOffset % ChunkSize) != 0) { VfatReadCluster(DeviceExt, Fcb, - ROUND_DOWN(ReadOffset, DeviceExt->BytesPerCluster), + ROUND_DOWN(ReadOffset, ChunkSize), FirstCluster, &CurrentCluster, Temp, 1); - TempLength = min (Length, DeviceExt->BytesPerCluster - - (ReadOffset % DeviceExt->BytesPerCluster)); + TempLength = min (Length, ChunkSize - (ReadOffset % ChunkSize)); - memcpy (Buffer, Temp + ReadOffset % DeviceExt->BytesPerCluster, - TempLength); + memcpy (Buffer, Temp + ReadOffset % ChunkSize, TempLength); (*LengthRead) = (*LengthRead) + TempLength; Length = Length - TempLength; @@ -442,7 +478,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, ReadOffset = ReadOffset + TempLength; } - while (Length >= DeviceExt->BytesPerCluster) + while (Length >= ChunkSize) { VfatReadCluster(DeviceExt, Fcb, ReadOffset, FirstCluster, &CurrentCluster, Buffer, 1); @@ -452,10 +488,10 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, return (STATUS_SUCCESS); } - (*LengthRead) = (*LengthRead) + DeviceExt->BytesPerCluster; - Buffer = Buffer + DeviceExt->BytesPerCluster; - Length = Length - DeviceExt->BytesPerCluster; - ReadOffset = ReadOffset + DeviceExt->BytesPerCluster; + (*LengthRead) = (*LengthRead) + ChunkSize; + Buffer = Buffer + ChunkSize; + Length = Length - ChunkSize; + ReadOffset = ReadOffset + ChunkSize; } if (Length > 0) @@ -558,7 +594,8 @@ VfatWriteFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, /* Read in the existing cluster data */ if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, CurrentCluster, DeviceExt->Boot->SectorsPerCluster, Temp); } @@ -632,7 +669,8 @@ VfatWriteFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, /* Read in the existing cluster data */ if (FirstCluster == 1) { - VFATReadSectors (DeviceExt->StorageDevice, + /* FIXME: Check status */ + VfatReadSectors (DeviceExt->StorageDevice, CurrentCluster, DeviceExt->Boot->SectorsPerCluster, Temp); } diff --git a/reactos/drivers/fs/vfat/vfat.h b/reactos/drivers/fs/vfat/vfat.h index a091d930057..ca05bb017f3 100644 --- a/reactos/drivers/fs/vfat/vfat.h +++ b/reactos/drivers/fs/vfat/vfat.h @@ -1,4 +1,4 @@ -/* $Id: vfat.h,v 1.19 2000/12/29 23:17:12 dwelch Exp $ */ +/* $Id: vfat.h,v 1.20 2001/01/08 02:14:06 dwelch Exp $ */ #include @@ -74,19 +74,21 @@ typedef struct _slot slot; typedef struct { - ERESOURCE DirResource; - ERESOURCE FatResource; - - KSPIN_LOCK FcbListLock; - LIST_ENTRY FcbListHead; - - PDEVICE_OBJECT StorageDevice; - BootSector *Boot; - int rootDirectorySectors, FATStart, rootStart, dataStart; - int FATEntriesPerSector, FATUnit; - ULONG BytesPerCluster; - ULONG FatType; - unsigned char* FAT; + ERESOURCE DirResource; + ERESOURCE FatResource; + + KSPIN_LOCK FcbListLock; + LIST_ENTRY FcbListHead; + + PDEVICE_OBJECT StorageDevice; + PFILE_OBJECT StreamStorageDevice; + PBCB StorageBcb; + BootSector *Boot; + int rootDirectorySectors, FATStart, rootStart, dataStart; + int FATEntriesPerSector, FATUnit; + ULONG BytesPerCluster; + ULONG FatType; + unsigned char* FAT; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; typedef struct _VFATFCB @@ -119,7 +121,6 @@ typedef struct _VFATCCB #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry)) - typedef struct __DOSTIME { WORD Second:5; @@ -154,14 +155,14 @@ VfatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp); /* internal functions in blockdev.c */ -BOOLEAN -VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, +NTSTATUS +VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject, IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR* Buffer); -BOOLEAN -VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject, +NTSTATUS +VfatWriteSectors(IN PDEVICE_OBJECT pDeviceObject, IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR* Buffer); diff --git a/reactos/include/ddk/iotypes.h b/reactos/include/ddk/iotypes.h index fc8e5c99545..f2c710822c4 100644 --- a/reactos/include/ddk/iotypes.h +++ b/reactos/include/ddk/iotypes.h @@ -1,4 +1,4 @@ -/* $Id: iotypes.h,v 1.21 2000/12/29 23:17:11 dwelch Exp $ +/* $Id: iotypes.h,v 1.22 2001/01/08 02:14:05 dwelch Exp $ * */ @@ -267,10 +267,14 @@ typedef struct _IO_COMPLETION_CONTEXT #define FO_HANDLE_CREATED 0x00040000 #define FO_FILE_FAST_IO_READ 0x00080000 +/* + * ReactOS specific flags + */ #define FO_DIRECT_CACHE_READ 0x72000001 #define FO_DIRECT_CACHE_WRITE 0x72000002 #define FO_DIRECT_CACHE_PAGING_READ 0x72000004 #define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008 +#define FO_FCB_IS_VALID 0x72000010 typedef struct _FILE_OBJECT { diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 2c4b391c2ef..0375e4084db 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1,4 +1,4 @@ -/* $Id: ntddk.h,v 1.16 2000/08/27 22:35:22 ekohl Exp $ +/* $Id: ntddk.h,v 1.17 2001/01/08 02:14:05 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,6 +23,7 @@ extern "C" #ifndef FASTCALL #define FASTCALL STDCALL #endif +#define STATIC static #include #include diff --git a/reactos/include/pe.h b/reactos/include/pe.h index 995821d1311..306302e41fd 100644 --- a/reactos/include/pe.h +++ b/reactos/include/pe.h @@ -426,7 +426,7 @@ typedef struct _IMAGE_CONTROL_DATA{ #define BUTTON 0x80 #define EDIT 0x81 -#define STATIC 0x82 +//#define STATIC 0x82 #define LISTBOX 0x83 #define SCROLLBAR 0x84 #define COMBOBOX 0x85 diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index ebfcd619ca0..ba720fcba86 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -13,20 +13,18 @@ struct _EPROCESS; typedef ULONG SWAPENTRY; -enum -{ - MEMORY_AREA_INVALID, - MEMORY_AREA_SECTION_VIEW_COMMIT, - MEMORY_AREA_CONTINUOUS_MEMORY, - MEMORY_AREA_NO_CACHE, - MEMORY_AREA_IO_MAPPING, - MEMORY_AREA_SYSTEM, - MEMORY_AREA_MDL_MAPPING, - MEMORY_AREA_VIRTUAL_MEMORY, - MEMORY_AREA_SECTION_VIEW_RESERVE, - MEMORY_AREA_CACHE_SEGMENT, - MEMORY_AREA_SHARED_DATA, -}; +#define MEMORY_AREA_INVALID (0) +#define MEMORY_AREA_SECTION_VIEW_COMMIT (1) +#define MEMORY_AREA_CONTINUOUS_MEMORY (2) +#define MEMORY_AREA_NO_CACHE (3) +#define MEMORY_AREA_IO_MAPPING (4) +#define MEMORY_AREA_SYSTEM (5) +#define MEMORY_AREA_MDL_MAPPING (7) +#define MEMORY_AREA_VIRTUAL_MEMORY (8) +#define MEMORY_AREA_SECTION_VIEW_RESERVE (9) +#define MEMORY_AREA_CACHE_SEGMENT (10) +#define MEMORY_AREA_SHARED_DATA (11) + #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \ ((x) / (4*1024*1024)) @@ -42,8 +40,27 @@ enum #define SPE_DIRTY (0x8) #define SPE_IN_PAGEFILE (0x10) +/* + * Flags for section objects + */ #define SO_PHYSICAL_MEMORY (0x1) +/* + * Additional flags for protection attributes + */ +#define PAGE_WRITETHROUGH (1024) +#define PAGE_SYSTEM (2048) +#define PAGE_FLAGS_VALID_FROM_USER_MODE (PAGE_READONLY | \ + PAGE_READWRITE | \ + PAGE_WRITECOPY | \ + PAGE_EXECUTE | \ + PAGE_EXECUTE_READ | \ + PAGE_EXECUTE_READWRITE | \ + PAGE_EXECUTE_WRITECOPY | \ + PAGE_GUARD | \ + PAGE_NOACCESS | \ + PAGE_NOCACHE) + typedef struct { ULONG Pages[NR_SECTION_PAGE_ENTRIES]; @@ -259,7 +276,6 @@ VOID MmInit3(VOID); NTSTATUS MmInitPagerThread(VOID); VOID MmInitKernelMap(PVOID BaseAddress); -unsigned int alloc_pool_region(unsigned int nr_pages); VOID MmWaitForFreePages(VOID); PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry); diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index 25c70de7c3a..248ade44de7 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.34 2000/12/23 02:37:39 dwelch Exp $ +/* $Id: create.c,v 1.35 2001/01/08 02:14:05 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -168,41 +168,36 @@ PFILE_OBJECT STDCALL IoCreateStreamFileObject (PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject) { - HANDLE FileHandle; - PFILE_OBJECT CreatedFileObject; + HANDLE FileHandle; + PFILE_OBJECT CreatedFileObject; + + DbgPrint("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", + FileObject, DeviceObject); - DbgPrint("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", - FileObject, - DeviceObject - ); - - assert_irql (PASSIVE_LEVEL); - - CreatedFileObject = ObCreateObject ( - & FileHandle, - STANDARD_RIGHTS_REQUIRED, - NULL, - IoFileObjectType - ); - if (NULL == CreatedFileObject) - { - return (NULL); - } - - if (FileObject != NULL) - { - DeviceObject = FileObject->DeviceObject; - } - DeviceObject = IoGetAttachedDevice(DeviceObject); - CreatedFileObject->DeviceObject = DeviceObject; - CreatedFileObject->Vpb = DeviceObject->Vpb; - CreatedFileObject->Type = InternalFileType; - //CreatedFileObject->Flags = CreatedFileObject->Flags | FO_DIRECT_DEVICE_OPEN; - CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN; - - ZwClose (FileHandle); - - return (CreatedFileObject); + assert_irql (PASSIVE_LEVEL); + + CreatedFileObject = ObCreateObject (&FileHandle, + STANDARD_RIGHTS_REQUIRED, + NULL, + IoFileObjectType); + if (NULL == CreatedFileObject) + { + return (NULL); + } + + if (FileObject != NULL) + { + DeviceObject = FileObject->DeviceObject; + } + DeviceObject = IoGetAttachedDevice(DeviceObject); + CreatedFileObject->DeviceObject = DeviceObject; + CreatedFileObject->Vpb = DeviceObject->Vpb; + CreatedFileObject->Type = InternalFileType; + CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN; + + ZwClose (FileHandle); + + return (CreatedFileObject); } diff --git a/reactos/ntoskrnl/io/page.c b/reactos/ntoskrnl/io/page.c index 3c6251a641f..65b09f23f28 100644 --- a/reactos/ntoskrnl/io/page.c +++ b/reactos/ntoskrnl/io/page.c @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.9 2000/07/07 10:30:55 dwelch Exp $ +/* $Id: page.c,v 1.10 2001/01/08 02:14:05 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -49,7 +49,7 @@ NTSTATUS STDCALL IoPageWrite(PFILE_OBJECT FileObject, DPRINT("Before IoCallDriver\n"); Status = IoCallDriver(FileObject->DeviceObject,Irp); DPRINT("Status %d STATUS_PENDING %d\n",Status,STATUS_PENDING); - if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) + if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO)) { DPRINT("Waiting for io operation\n"); if (FileObject->Flags & FO_ALERTABLE_IO) diff --git a/reactos/ntoskrnl/ldr/sysdll.c b/reactos/ntoskrnl/ldr/sysdll.c index 72ba0c924ba..b633389592e 100644 --- a/reactos/ntoskrnl/ldr/sysdll.c +++ b/reactos/ntoskrnl/ldr/sysdll.c @@ -232,9 +232,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle, /* * retrieve ntdll's startup address - */ + */ RtlInitAnsiString (&ProcedureName, "LdrInitializeThunk"); + DPRINT1("Getting address of system DLL entrypoint\n"); Status = LdrGetProcedureAddress ((PVOID)ImageBase, &ProcedureName, 0, @@ -247,7 +248,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle, ZwClose(NTDllSectionHandle); return (Status); } - DPRINT("SystemDllEntryPoint 0x%08lx\n", + DPRINT1("SystemDllEntryPoint 0x%08lx\n", SystemDllEntryPoint); *LdrStartupAddr = SystemDllEntryPoint; diff --git a/reactos/ntoskrnl/mm/aspace.c b/reactos/ntoskrnl/mm/aspace.c index 9034009446b..1543fcbcab0 100644 --- a/reactos/ntoskrnl/mm/aspace.c +++ b/reactos/ntoskrnl/mm/aspace.c @@ -1,4 +1,4 @@ -/* $Id: aspace.c,v 1.4 2000/08/20 17:02:08 dwelch Exp $ +/* $Id: aspace.c,v 1.5 2001/01/08 02:14:05 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -19,11 +19,12 @@ /* GLOBALS ******************************************************************/ -static MADDRESS_SPACE KernelAddressSpace; +STATIC MADDRESS_SPACE KernelAddressSpace; /* FUNCTIONS *****************************************************************/ -VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace) +VOID +MmLockAddressSpace(PMADDRESS_SPACE AddressSpace) { (VOID)KeWaitForMutexObject(&AddressSpace->Lock, 0, @@ -32,12 +33,14 @@ VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace) NULL); } -VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace) +VOID +MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace) { KeReleaseMutex(&AddressSpace->Lock, FALSE); } -VOID MmInitializeKernelAddressSpace(VOID) +VOID +MmInitializeKernelAddressSpace(VOID) { MmInitializeAddressSpace(NULL, &KernelAddressSpace); } @@ -52,8 +55,9 @@ PMADDRESS_SPACE MmGetKernelAddressSpace(VOID) return(&KernelAddressSpace); } -NTSTATUS MmInitializeAddressSpace(PEPROCESS Process, - PMADDRESS_SPACE AddressSpace) +NTSTATUS +MmInitializeAddressSpace(PEPROCESS Process, + PMADDRESS_SPACE AddressSpace) { InitializeListHead(&AddressSpace->MAreaListHead); KeInitializeMutex(&AddressSpace->Lock, 1); @@ -84,7 +88,8 @@ NTSTATUS MmInitializeAddressSpace(PEPROCESS Process, return(STATUS_SUCCESS); } -NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace) +NTSTATUS +MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace) { return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/mm/cont.c b/reactos/ntoskrnl/mm/cont.c index 10751c46dee..1ad86b519c8 100644 --- a/reactos/ntoskrnl/mm/cont.c +++ b/reactos/ntoskrnl/mm/cont.c @@ -1,4 +1,4 @@ -/* $Id: cont.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $ +/* $Id: cont.c,v 1.6 2001/01/08 02:14:05 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -69,11 +69,19 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes, PBase = MmGetContinuousPages(NumberOfBytes, HighestAcceptableAddress); + if (PBase == NULL) + { + MmFreeMemoryArea(MmGetKernelAddressSpace(), + BaseAddress, + 0, + TRUE); + return(NULL); + } for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++) { MmCreateVirtualMapping(NULL, BaseAddress + (i * 4096), - PAGE_EXECUTE_READWRITE, + PAGE_EXECUTE_READWRITE | PAGE_SYSTEM, (ULONG)(PBase + (i * 4096))); } return(BaseAddress); diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index b0164be4d69..6c4602704d8 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -475,7 +475,8 @@ VOID MmUnlockPage(PVOID PhysicalAddress) } -PVOID MmAllocPage(SWAPENTRY SavedSwapEntry) +PVOID +MmAllocPage(SWAPENTRY SavedSwapEntry) { ULONG offset; PLIST_ENTRY ListEntry; @@ -518,7 +519,8 @@ PVOID MmAllocPage(SWAPENTRY SavedSwapEntry) return((PVOID)offset); } -PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry) +PVOID +MmMustAllocPage(SWAPENTRY SavedSwapEntry) { PVOID Page; @@ -532,7 +534,8 @@ PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry) return(Page); } -PVOID MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry) +PVOID +MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry) { PVOID Page; @@ -545,7 +548,8 @@ PVOID MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry) return(Page); } -NTSTATUS MmWaitForPage(PVOID PhysicalAddress) +NTSTATUS +MmWaitForPage(PVOID PhysicalAddress) { NTSTATUS Status; ULONG Start; @@ -559,7 +563,8 @@ NTSTATUS MmWaitForPage(PVOID PhysicalAddress) return(Status); } -VOID MmClearWaitPage(PVOID PhysicalAddress) +VOID +MmClearWaitPage(PVOID PhysicalAddress) { ULONG Start; @@ -568,7 +573,8 @@ VOID MmClearWaitPage(PVOID PhysicalAddress) KeClearEvent(&MmPageArray[Start].Event); } -VOID MmSetWaitPage(PVOID PhysicalAddress) +VOID +MmSetWaitPage(PVOID PhysicalAddress) { ULONG Start; diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index e8f0003147d..366412f0161 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -1,4 +1,4 @@ -/* $Id: page.c,v 1.16 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: page.c,v 1.17 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -25,17 +25,23 @@ #define PA_BIT_PRESENT (0) #define PA_BIT_READWRITE (1) #define PA_BIT_USER (2) +#define PA_BIT_WT (3) +#define PA_BIT_CD (4) +#define PA_BIT_ACCESSED (5) #define PA_BIT_DIRTY (6) -#define PA_PRESENT (1<AddressSpace, - BaseAddress, - NumberOfBytes, - TRUE); + MmFreeMemoryArea (MmGetKernelAddressSpace(), + BaseAddress, + NumberOfBytes, + TRUE); } diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index bc721490e01..2281e1927ef 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1,4 +1,4 @@ -/* $Id: npool.c,v 1.32 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: npool.c,v 1.33 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -76,6 +76,9 @@ static KSPIN_LOCK MmNpoolLock; unsigned int EiFreeNonPagedPool = 0; unsigned int EiUsedNonPagedPool = 0; +unsigned int +alloc_pool_region(unsigned int nr_pages); + /* FUNCTIONS ***************************************************************/ VOID ExInitNonPagedPool(ULONG BaseAddress) diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index 8e6a965a6e6..2f8b65f61b1 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -1,4 +1,4 @@ -/* $Id: pagefile.c,v 1.7 2000/09/03 14:53:03 ekohl Exp $ +/* $Id: pagefile.c,v 1.8 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -21,7 +21,7 @@ /* TYPES *********************************************************************/ -typedef struct _PPAGINGFILE +typedef struct _PAGINGFILE { LIST_ENTRY PagingFileListEntry; PFILE_OBJECT FileObject; @@ -347,3 +347,10 @@ NTSTATUS STDCALL NtCreatePagingFile(IN PUNICODE_STRING PageFileName, /* EOF */ + + + + + + + diff --git a/reactos/ntoskrnl/mm/pager.c b/reactos/ntoskrnl/mm/pager.c index e046be10c74..57756a5db4d 100644 --- a/reactos/ntoskrnl/mm/pager.c +++ b/reactos/ntoskrnl/mm/pager.c @@ -1,4 +1,4 @@ -/* $Id: pager.c,v 1.5 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: pager.c,v 1.6 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -78,7 +78,7 @@ static NTSTATUS MmPagerThreadMain(PVOID Ignored) { DbgPrint("PagerThread: Wait failed\n"); KeBugCheck(0); - } + } if (PagerThreadShouldTerminate) { DbgPrint("PagerThread: Terminating\n"); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 0a24c21c57f..e4a32601798 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,4 +1,4 @@ -/* $Id: section.c,v 1.40 2000/12/28 03:38:07 dwelch Exp $ +/* $Id: section.c,v 1.41 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -27,9 +27,10 @@ POBJECT_TYPE EXPORTED MmSectionObjectType = NULL; /* FUNCTIONS *****************************************************************/ -NTSTATUS MmWritePageSectionView(PMADDRESS_SPACE AddressSpace, - PMEMORY_AREA MArea, - PVOID Address) +NTSTATUS +MmWritePageSectionView(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MArea, + PVOID Address) { return(STATUS_UNSUCCESSFUL); } @@ -153,8 +154,9 @@ MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace, &IoStatus); if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) { - MmLockAddressSpace(AddressSpace); - return(Status); + DPRINT("IoPageRead failed (%x)\n", Status); + MmLockAddressSpace(AddressSpace); + return(Status); } MmLockAddressSpace(AddressSpace); @@ -434,9 +436,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, /* * FIXME: What do we know in this case? */ - - MmLockAddressSpace(AddressSpace); - return(Status); + DPRINT("IoPageRead failed (Status %x)\n", Status); + MmLockAddressSpace(AddressSpace); + return(Status); } /* @@ -481,7 +483,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace, KeBugCheck(0); } MmUnlockSection(Section); - + DPRINT("MmNotPresentFaultSectionView succeeded\n"); return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index cfbbd4a390f..b750e90f65a 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -1,4 +1,4 @@ -/* $Id: virtual.c,v 1.35 2000/10/22 16:36:52 ekohl Exp $ +/* $Id: virtual.c,v 1.36 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -35,9 +35,10 @@ typedef struct _MM_SEGMENT /* FUNCTIONS *****************************************************************/ -PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea, - PVOID Address, - PVOID* PCurrentAddress) +PMM_SEGMENT +MmGetSegmentForAddress(PMEMORY_AREA MArea, + PVOID Address, + PVOID* PCurrentAddress) /* * FUNCTION: Get the segment corresponding to a particular memory area and * address. @@ -46,7 +47,7 @@ PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea, * 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 + * The corresponding segment or NULL if an error occurred */ { PVOID CurrentAddress; @@ -81,9 +82,10 @@ PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea, return(NULL); } -NTSTATUS MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, - PMEMORY_AREA MArea, - PVOID Address) +NTSTATUS +MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MArea, + PVOID Address) { SWAPENTRY se; ULONG Flags; @@ -196,9 +198,10 @@ ULONG MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace, return(0); } -NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, - MEMORY_AREA* MemoryArea, - PVOID Address) +NTSTATUS +MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, + MEMORY_AREA* MemoryArea, + PVOID Address) /* * FUNCTION: Move data into memory to satisfy a page not present fault * ARGUMENTS: @@ -284,55 +287,68 @@ 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) +VOID STATIC +MmModifyAttributes(PMADDRESS_SPACE AddressSpace, + PVOID BaseAddress, + ULONG RegionSize, + ULONG OldType, + ULONG OldProtect, + ULONG NewType, + ULONG NewProtect) /* * FUNCTION: Modify the attributes of a memory region */ { - 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; + /* + * If we are switching a previously committed region to reserved then + * free any allocated pages within the region + */ + 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)); + } + MmDeleteVirtualMapping(AddressSpace->Process, + BaseAddress + (i*PAGESIZE), + FALSE); + } + } + + /* + * If we are changing the protection attributes of a committed region then + * alter the attributes for any allocated pages within the region + */ + 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); - } - } - } + 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) +VOID STATIC +InsertAfterEntry(PLIST_ENTRY Previous, + PLIST_ENTRY Entry) /* * FUNCTION: Insert a list entry after another entry in the list */ @@ -345,7 +361,9 @@ VOID InsertAfterEntry(PLIST_ENTRY Previous, Previous->Flink = Entry; } -VOID MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea) +#if 0 +VOID STATIC +MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea) { PVOID CurrentAddress; PLIST_ENTRY CurrentEntry; @@ -372,15 +390,17 @@ VOID MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea) CurrentEntry = CurrentEntry->Flink; } } +#endif -NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace, - PMEMORY_AREA MemoryArea, - PVOID RegionAddress, - ULONG RegionLength, - ULONG Type, - ULONG Protect, - PMM_SEGMENT FirstSegment, - PVOID FirstAddress) +NTSTATUS +MmSplitSegment(PMADDRESS_SPACE AddressSpace, + PMEMORY_AREA MemoryArea, + PVOID RegionAddress, + ULONG RegionLength, + ULONG Type, + ULONG Protect, + PMM_SEGMENT FirstSegment, + PVOID FirstAddress) /* * FUNCTION: Split a memory segment internally */ @@ -397,6 +417,15 @@ NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace, OldType = FirstSegment->Type; OldProtect = FirstSegment->Protect; OldLength = FirstSegment->Length; + + /* + * If the segment is already of the right type and protection then + * there is nothing to do. + */ + if (FirstSegment->Type == Type && FirstSegment->Protect == Protect) + { + return(STATUS_SUCCESS); + } /* * Allocate the segment we might need here because if the allocation @@ -408,15 +437,6 @@ NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace, return(STATUS_NO_MEMORY); } - /* - * If the segment is already of the right type and protection then - * there is nothing to do. - */ - if (FirstSegment->Type == Type && FirstSegment->Protect == Protect) - { - return(STATUS_SUCCESS); - } - if (FirstAddress < RegionAddress) { /* @@ -710,12 +730,13 @@ NTSTATUS MmComplexVirtualMemoryOperation(PMADDRESS_SPACE AddressSpace, } -NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, - IN OUT PVOID* PBaseAddress, - IN ULONG ZeroBits, - IN OUT PULONG PRegionSize, - IN ULONG AllocationType, - IN ULONG Protect) +NTSTATUS STDCALL +NtAllocateVirtualMemory(IN HANDLE ProcessHandle, + IN OUT PVOID* UBaseAddress, + IN ULONG ZeroBits, + IN OUT PULONG URegionSize, + IN ULONG AllocationType, + IN ULONG Protect) /* * FUNCTION: Allocates a block of virtual memory in the process address space * ARGUMENTS: @@ -753,15 +774,28 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, PMM_SEGMENT Segment; PVOID BaseAddress; ULONG RegionSize; - + PVOID PBaseAddress; + ULONG PRegionSize; + 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)); + /* + * Check the validity of the parameters + */ + if ((Protect & PAGE_FLAGS_VALID_FROM_USER_MODE) != Protect) + { + return(STATUS_INVALID_PAGE_PROTECTION); + } + PBaseAddress = *UBaseAddress; + PRegionSize = *URegionSize; + + + BaseAddress = (PVOID)PAGE_ROUND_DOWN(PBaseAddress); + RegionSize = PAGE_ROUND_UP(PBaseAddress + PRegionSize) - + PAGE_ROUND_DOWN(PBaseAddress); Status = ObReferenceObjectByHandle(ProcessHandle, PROCESS_VM_OPERATION, @@ -855,8 +889,8 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, MmReserveSwapPages(RegionSize); } - *PBaseAddress = BaseAddress; - *PRegionSize = RegionSize; + *UBaseAddress = BaseAddress; + *URegionSize = RegionSize; MmUnlockAddressSpace(AddressSpace); ObDereferenceObject(Process); @@ -864,10 +898,11 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, } -NTSTATUS STDCALL NtFlushVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN ULONG NumberOfBytesToFlush, - OUT PULONG NumberOfBytesFlushed OPTIONAL) +NTSTATUS STDCALL +NtFlushVirtualMemory(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN ULONG NumberOfBytesToFlush, + OUT PULONG NumberOfBytesFlushed OPTIONAL) /* * FUNCTION: Flushes virtual memory to file * ARGUMENTS: @@ -883,10 +918,11 @@ NTSTATUS STDCALL NtFlushVirtualMemory(IN HANDLE ProcessHandle, } -NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID* PBaseAddress, - IN PULONG PRegionSize, - IN ULONG FreeType) +NTSTATUS STDCALL +NtFreeVirtualMemory(IN HANDLE ProcessHandle, + IN PVOID* PBaseAddress, + IN PULONG PRegionSize, + IN ULONG FreeType) /* * FUNCTION: Frees a range of virtual memory * ARGUMENTS: @@ -997,19 +1033,21 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, } -NTSTATUS STDCALL NtLockVirtualMemory(HANDLE ProcessHandle, - PVOID BaseAddress, - ULONG NumberOfBytesToLock, - PULONG NumberOfBytesLocked) +NTSTATUS STDCALL +NtLockVirtualMemory(HANDLE ProcessHandle, + PVOID BaseAddress, + ULONG NumberOfBytesToLock, + PULONG NumberOfBytesLocked) { - UNIMPLEMENTED; + UNIMPLEMENTED; } -VOID MmChangeAreaProtection(PEPROCESS Process, - PVOID BaseAddress, - ULONG Length, - ULONG Protect) +VOID +MmChangeAreaProtection(PEPROCESS Process, + PVOID BaseAddress, + ULONG Length, + ULONG Protect) { ULONG i; @@ -1179,11 +1217,12 @@ NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle, } -NTSTATUS STDCALL NtReadVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - OUT PVOID Buffer, - IN ULONG NumberOfBytesToRead, - OUT PULONG NumberOfBytesRead) +NTSTATUS STDCALL +NtReadVirtualMemory(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + OUT PVOID Buffer, + IN ULONG NumberOfBytesToRead, + OUT PULONG NumberOfBytesRead) { NTSTATUS Status; PMDL Mdl; @@ -1226,20 +1265,22 @@ NTSTATUS STDCALL NtReadVirtualMemory(IN HANDLE ProcessHandle, } -NTSTATUS STDCALL NtUnlockVirtualMemory(HANDLE ProcessHandle, - PVOID BaseAddress, - ULONG NumberOfBytesToUnlock, - PULONG NumberOfBytesUnlocked OPTIONAL) +NTSTATUS STDCALL +NtUnlockVirtualMemory(HANDLE ProcessHandle, + PVOID BaseAddress, + ULONG NumberOfBytesToUnlock, + PULONG NumberOfBytesUnlocked OPTIONAL) { UNIMPLEMENTED; } -NTSTATUS STDCALL NtWriteVirtualMemory(IN HANDLE ProcessHandle, - IN PVOID BaseAddress, - IN PVOID Buffer, - IN ULONG NumberOfBytesToWrite, - OUT PULONG NumberOfBytesWritten) +NTSTATUS STDCALL +NtWriteVirtualMemory(IN HANDLE ProcessHandle, + IN PVOID BaseAddress, + IN PVOID Buffer, + IN ULONG NumberOfBytesToWrite, + OUT PULONG NumberOfBytesWritten) { NTSTATUS Status; PMDL Mdl; diff --git a/reactos/ntoskrnl/mm/wset.c b/reactos/ntoskrnl/mm/wset.c index 2b8b59ad82e..67d9cfdd778 100644 --- a/reactos/ntoskrnl/mm/wset.c +++ b/reactos/ntoskrnl/mm/wset.c @@ -1,4 +1,4 @@ -/* $Id: wset.c,v 1.5 2000/08/18 22:27:03 dwelch Exp $ +/* $Id: wset.c,v 1.6 2001/01/08 02:14:06 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -198,3 +198,4 @@ BOOLEAN MmAddPageToWorkingSet(PEPROCESS Process, } +