Some memory manager cleanups

Hopefully fixed vfat fsd reported by Philip Susi
FAT lookups go through cache

svn path=/trunk/; revision=1499
This commit is contained in:
David Welch 2001-01-08 02:14:06 +00:00
parent 21c3a954d0
commit 48b5533bd5
28 changed files with 690 additions and 422 deletions

View file

@ -18,15 +18,17 @@
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN NTSTATUS
VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject, VfatReadSectors (IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector, IN ULONG SectorCount, IN UCHAR * Buffer) IN ULONG DiskSector,
IN ULONG SectorCount,
IN OUT PUCHAR Buffer)
{ {
LARGE_INTEGER sectorNumber; LARGE_INTEGER sectorNumber;
PIRP irp; PIRP Irp;
IO_STATUS_BLOCK ioStatus; IO_STATUS_BLOCK IoStatus;
KEVENT event; KEVENT event;
NTSTATUS status; NTSTATUS Status;
ULONG sectorSize; ULONG sectorSize;
sectorNumber.u.LowPart = DiskSector << 9; sectorNumber.u.LowPart = DiskSector << 9;
@ -35,7 +37,6 @@ VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject,
KeInitializeEvent (&event, NotificationEvent, FALSE); KeInitializeEvent (&event, NotificationEvent, FALSE);
sectorSize = BLOCKSIZE * SectorCount; sectorSize = BLOCKSIZE * SectorCount;
DPRINT ("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", DPRINT ("VFATReadSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
pDeviceObject, DiskSector, Buffer); pDeviceObject, DiskSector, Buffer);
DPRINT ("sectorNumber %08lx:%08lx sectorSize %ld\n", DPRINT ("sectorNumber %08lx:%08lx sectorSize %ld\n",
@ -44,53 +45,55 @@ VFATReadSectors (IN PDEVICE_OBJECT pDeviceObject,
DPRINT ("Building synchronous FSD Request...\n"); DPRINT ("Building synchronous FSD Request...\n");
irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ, Irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ,
pDeviceObject, pDeviceObject,
Buffer, Buffer,
sectorSize, sectorSize,
&sectorNumber, &event, &ioStatus); &sectorNumber,
&event,
&IoStatus);
if (!irp) if (Irp == NULL)
{ {
DbgPrint ("READ failed!!!\n"); DPRINT("IoBuildSynchronousFsdRequest failed\n");
return FALSE; return(STATUS_UNSUCCESSFUL);;
} }
DPRINT ("Calling IO Driver... with irp %x\n", irp); DPRINT ("Calling IO Driver... with irp %x\n", Irp);
status = IoCallDriver (pDeviceObject, irp); Status = IoCallDriver (pDeviceObject, Irp);
DPRINT ("Waiting for IO Operation for %x\n", irp); DPRINT ("Waiting for IO Operation for %x\n", Irp);
if (status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
DPRINT ("Operation pending\n"); DPRINT ("Operation pending\n");
KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL); KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL);
DPRINT ("Getting IO Status... for %x\n", irp); DPRINT ("Getting IO Status... for %x\n", Irp);
status = ioStatus.Status; Status = IoStatus.Status;
} }
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (Status))
{ {
DbgPrint ("IO failed!!! VFATREadSectors : Error code: %x\n", status); DPRINT ("IO failed!!! VFATREadSectors : Error code: %x\n", Status);
DbgPrint DPRINT ("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n",
("(pDeviceObject %x, DiskSector %x, Buffer %x, offset 0x%x%x)\n", pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart,
pDeviceObject, DiskSector, Buffer, sectorNumber.u.HighPart, sectorNumber.u.LowPart);
sectorNumber.u.LowPart); return (Status);
return FALSE;
} }
DPRINT ("Block request succeeded for %x\n", irp); DPRINT ("Block request succeeded for %x\n", Irp);
return TRUE; return (STATUS_SUCCESS);
} }
BOOLEAN NTSTATUS
VFATWriteSectors (IN PDEVICE_OBJECT pDeviceObject, VfatWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector, IN ULONG DiskSector,
IN ULONG SectorCount, IN UCHAR * Buffer) IN ULONG SectorCount,
IN PUCHAR Buffer)
{ {
LARGE_INTEGER sectorNumber; LARGE_INTEGER sectorNumber;
PIRP irp; PIRP Irp;
IO_STATUS_BLOCK ioStatus; IO_STATUS_BLOCK IoStatus;
KEVENT event; KEVENT event;
NTSTATUS status; NTSTATUS Status;
ULONG sectorSize; ULONG sectorSize;
DPRINT ("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n", DPRINT ("VFATWriteSector(pDeviceObject %x, DiskSector %d, Buffer %x)\n",
@ -104,35 +107,37 @@ VFATWriteSectors (IN PDEVICE_OBJECT pDeviceObject,
sectorSize = BLOCKSIZE * SectorCount; sectorSize = BLOCKSIZE * SectorCount;
DPRINT ("Building synchronous FSD Request...\n"); DPRINT ("Building synchronous FSD Request...\n");
irp = IoBuildSynchronousFsdRequest (IRP_MJ_WRITE, Irp = IoBuildSynchronousFsdRequest (IRP_MJ_WRITE,
pDeviceObject, pDeviceObject,
Buffer, Buffer,
sectorSize, sectorSize,
&sectorNumber, &event, &ioStatus); &sectorNumber,
&event,
&IoStatus);
if (!irp) if (!Irp)
{ {
DbgPrint ("WRITE failed!!!\n"); DPRINT ("WRITE failed!!!\n");
return FALSE; return (STATUS_UNSUCCESSFUL);
} }
DPRINT ("Calling IO Driver...\n"); DPRINT ("Calling IO Driver...\n");
status = IoCallDriver (pDeviceObject, irp); Status = IoCallDriver (pDeviceObject, Irp);
DPRINT ("Waiting for IO Operation...\n"); DPRINT ("Waiting for IO Operation...\n");
if (status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL); KeWaitForSingleObject (&event, Suspended, KernelMode, FALSE, NULL);
DPRINT ("Getting IO Status...\n"); 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); DPRINT ("IO failed!!! VFATWriteSectors : Error code: %x\n", Status);
return FALSE; return (Status);
} }
DPRINT ("Block request succeeded\n"); DPRINT ("Block request succeeded\n");
return TRUE; return (STATUS_SUCCESS);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -95,7 +95,8 @@ GetEntryName (PVOID Block, PULONG _Offset, PWSTR Name, PULONG _jloop,
Offset = 0; Offset = 0;
StartingSector++; //FIXME : nor always the next sector StartingSector++; //FIXME : nor always the next sector
jloop++; jloop++;
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
StartingSector, 1, Block); StartingSector, 1, Block);
test2 = (slot *) 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); DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i);
for (j = 0; j < Size; j++) 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++) 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); DPRINT ("FindFile : start at sector %lx, entry %ld\n", StartingSector, i);
for (j = 0; j < Size; j++) 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++) 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 */ /* entry is in next sector */
StartingSector++; StartingSector++;
/* FIXME : treat case of next sector fragmented */ /* FIXME : treat case of next sector fragmented */
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
StartingSector, 1, block); StartingSector, 1, block);
i = 0; i = 0;
} }
@ -563,7 +567,8 @@ FsdOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
ParentFcb = Temp; ParentFcb = Temp;
} }
FileObject->Flags = FileObject->Flags |
FO_FCB_IS_VALID | FO_DIRECT_CACHE_PAGING_READ;
FileObject->FsContext = (PVOID)&ParentFcb->RFCB; FileObject->FsContext = (PVOID)&ParentFcb->RFCB;
newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB)); newCCB = ExAllocatePool (NonPagedPool, sizeof (VFATCCB));
memset (newCCB, 0, sizeof (VFATCCB)); memset (newCCB, 0, sizeof (VFATCCB));

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -35,7 +35,8 @@ Fat32GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
Block = ExAllocatePool (NonPagedPool, 1024); Block = ExAllocatePool (NonPagedPool, 1024);
FATsector = CurrentCluster / (512 / sizeof (ULONG)); FATsector = CurrentCluster / (512 / sizeof (ULONG));
FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG))); FATeis = CurrentCluster - (FATsector * (512 / sizeof (ULONG)));
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
(ULONG) (DeviceExt->FATStart + FATsector), 1, (ULONG) (DeviceExt->FATStart + FATsector), 1,
(UCHAR *) Block); (UCHAR *) Block);
CurrentCluster = Block[FATeis]; CurrentCluster = Block[FATeis];
@ -53,11 +54,36 @@ Fat16GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
*/ */
{ {
PUSHORT Block; PUSHORT Block;
Block = (PUSHORT) DeviceExt->FAT; PVOID BaseAddress;
CurrentCluster = Block[CurrentCluster]; 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) if (CurrentCluster >= 0xfff8 && CurrentCluster <= 0xffff)
CurrentCluster = 0xffffffff; CurrentCluster = 0xffffffff;
DPRINT ("Returning %x\n", CurrentCluster); CcReleaseCacheSegment(DeviceExt->StorageBcb, CacheSeg, TRUE);
return (CurrentCluster); return (CurrentCluster);
} }
@ -71,17 +97,82 @@ Fat12GetNextCluster (PDEVICE_EXTENSION DeviceExt, ULONG CurrentCluster)
unsigned char *CBlock; unsigned char *CBlock;
ULONG FATOffset; ULONG FATOffset;
ULONG Entry; ULONG Entry;
CBlock = DeviceExt->FAT; PVOID PBlock;
FATOffset = (CurrentCluster * 12) / 8; //first byte containing value NTSTATUS Status;
if ((CurrentCluster % 2) == 0) 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]; Status = VfatReadSectors(DeviceExt->StorageDevice,
Entry |= ((CBlock[FATOffset + 1] & 0xf) << 8); 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 else
{ {
Entry = (CBlock[FATOffset] >> 4); Value2 = ((PUCHAR)BaseAddress)[(FATOffset % PAGESIZE) + 1];
Entry |= (CBlock[FATOffset + 1] << 4); 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); DPRINT ("Entry %x\n", Entry);
if (Entry >= 0xff8 && Entry <= 0xfff) if (Entry >= 0xff8 && Entry <= 0xfff)
@ -182,7 +273,8 @@ FAT32FindAvailableCluster (PDEVICE_EXTENSION DeviceExt)
sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32; sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
sector++) sector++)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
(ULONG) (DeviceExt->FATStart + sector), 1, (ULONG) (DeviceExt->FATStart + sector), 1,
(UCHAR *) Block); (UCHAR *) Block);
@ -278,7 +370,8 @@ FAT32CountAvailableClusters (PDEVICE_EXTENSION DeviceExt)
sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32; sector < ((struct _BootSector32 *) (DeviceExt->Boot))->FATSectors32;
sector++) sector++)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
(ULONG) (DeviceExt->FATStart + sector), 1, (ULONG) (DeviceExt->FATStart + sector), 1,
(UCHAR *) Block); (UCHAR *) Block);
@ -324,14 +417,16 @@ FAT12WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
{ {
if ((FATOffset % BLOCKSIZE) == (BLOCKSIZE - 1)) //entry is on 2 sectors if ((FATOffset % BLOCKSIZE) == (BLOCKSIZE - 1)) //entry is on 2 sectors
{ {
VFATWriteSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatWriteSectors (DeviceExt->StorageDevice,
DeviceExt->FATStart + FATsector DeviceExt->FATStart + FATsector
+ i * DeviceExt->Boot->FATSectors, + i * DeviceExt->Boot->FATSectors,
2, CBlock + FATsector * 512); 2, CBlock + FATsector * 512);
} }
else else
{ {
VFATWriteSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatWriteSectors (DeviceExt->StorageDevice,
DeviceExt->FATStart + FATsector DeviceExt->FATStart + FATsector
+ i * DeviceExt->Boot->FATSectors, + i * DeviceExt->Boot->FATSectors,
1, CBlock + FATsector * 512); 1, CBlock + FATsector * 512);
@ -363,7 +458,8 @@ FAT16WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
Start = DeviceExt->FATStart + FATsector; Start = DeviceExt->FATStart + FATsector;
for (i = 0; i < DeviceExt->Boot->FATCount; i++) for (i = 0; i < DeviceExt->Boot->FATCount; i++)
{ {
VFATWriteSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatWriteSectors (DeviceExt->StorageDevice,
Start, 1, ((UCHAR *) Block) + FATsector * 512); Start, 1, ((UCHAR *) Block) + FATsector * 512);
Start += DeviceExt->Boot->FATSectors; Start += DeviceExt->Boot->FATSectors;
} }
@ -387,7 +483,8 @@ FAT32WriteCluster (PDEVICE_EXTENSION DeviceExt, ULONG ClusterToWrite,
FATsector = ClusterToWrite / 128; FATsector = ClusterToWrite / 128;
FATeis = ClusterToWrite - (FATsector * 128); FATeis = ClusterToWrite - (FATsector * 128);
/* load sector, change value, then rewrite sector */ /* load sector, change value, then rewrite sector */
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
DeviceExt->FATStart + FATsector, 1, (UCHAR *) Block); DeviceExt->FATStart + FATsector, 1, (UCHAR *) Block);
Block[FATeis] = NewValue; Block[FATeis] = NewValue;
/* Write the changed FAT sector to disk (all FAT's) */ /* 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; pBoot = (struct _BootSector32 *) DeviceExt->Boot;
for (i = 0; i < pBoot->FATCount; i++) 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; Start += pBoot->FATSectors;
} }
ExFreePool (Block); ExFreePool (Block);
@ -503,7 +601,8 @@ VFATLoadCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
Sector = ClusterToSector (DeviceExt, Cluster); Sector = ClusterToSector (DeviceExt, Cluster);
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
Sector, DeviceExt->Boot->SectorsPerCluster, Buffer); Sector, DeviceExt->Boot->SectorsPerCluster, Buffer);
DPRINT ("Finished VFATReadSectors\n"); DPRINT ("Finished VFATReadSectors\n");
} }
@ -520,6 +619,7 @@ VFATWriteCluster (PDEVICE_EXTENSION DeviceExt, PVOID Buffer, ULONG Cluster)
Sector = ClusterToSector (DeviceExt, Cluster); Sector = ClusterToSector (DeviceExt, Cluster);
VFATWriteSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatWriteSectors (DeviceExt->StorageDevice,
Sector, DeviceExt->Boot->SectorsPerCluster, Buffer); Sector, DeviceExt->Boot->SectorsPerCluster, Buffer);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -51,7 +51,8 @@ VfatHasFileSystem (PDEVICE_OBJECT DeviceToMount)
Boot = ExAllocatePool (NonPagedPool, 512); 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); DPRINT ("Boot->SysType %.5s\n", Boot->SysType);
if (strncmp (Boot->SysType, "FAT12", 5) == 0 || if (strncmp (Boot->SysType, "FAT12", 5) == 0 ||
@ -75,10 +76,8 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
DPRINT ("DeviceExt %x\n", DeviceExt); DPRINT ("DeviceExt %x\n", DeviceExt);
DeviceExt->Boot = ExAllocatePool (NonPagedPool, 512); DeviceExt->Boot = ExAllocatePool (NonPagedPool, 512);
VFATReadSectors (DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot); /* FIXME: Check status */
VfatReadSectors (DeviceToMount, 0, 1, (UCHAR *) DeviceExt->Boot);
DPRINT ("DeviceExt->Boot->BytesPerSector %x\n",
DeviceExt->Boot->BytesPerSector);
DeviceExt->FATStart = DeviceExt->Boot->ReservedSectors; DeviceExt->FATStart = DeviceExt->Boot->ReservedSectors;
DeviceExt->rootDirectorySectors = DeviceExt->rootDirectorySectors =
@ -107,6 +106,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
if (strncmp (DeviceExt->Boot->SysType, "FAT12", 5) == 0) if (strncmp (DeviceExt->Boot->SysType, "FAT12", 5) == 0)
{ {
DbgPrint("FAT12\n");
DeviceExt->FatType = FAT12; DeviceExt->FatType = FAT12;
} }
else else
@ -114,6 +114,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
(((struct _BootSector32 *) (DeviceExt->Boot))->SysType, "FAT32", (((struct _BootSector32 *) (DeviceExt->Boot))->SysType, "FAT32",
5) == 0) 5) == 0)
{ {
DbgPrint("FAT32\n");
DeviceExt->FatType = FAT32; DeviceExt->FatType = FAT32;
DeviceExt->rootDirectorySectors = DeviceExt->Boot->SectorsPerCluster; DeviceExt->rootDirectorySectors = DeviceExt->Boot->SectorsPerCluster;
DeviceExt->rootStart = DeviceExt->rootStart =
@ -123,6 +124,7 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
} }
else else
{ {
DbgPrint("FAT16\n");
DeviceExt->FatType = FAT16; DeviceExt->FatType = FAT16;
} }
@ -133,7 +135,8 @@ VfatMountDevice (PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount)
DeviceExt->FAT = DeviceExt->FAT =
ExAllocatePool (NonPagedPool, ExAllocatePool (NonPagedPool,
BLOCKSIZE * DeviceExt->Boot->FATSectors); BLOCKSIZE * DeviceExt->Boot->FATSectors);
VFATReadSectors (DeviceToMount, DeviceExt->FATStart, /* FIXME: Check status */
VfatReadSectors (DeviceToMount, DeviceExt->FATStart,
DeviceExt->Boot->FATSectors, (UCHAR *) DeviceExt->FAT); DeviceExt->Boot->FATSectors, (UCHAR *) DeviceExt->FAT);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -147,6 +150,7 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
{ {
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
PDEVICE_EXTENSION DeviceExt; PDEVICE_EXTENSION DeviceExt;
NTSTATUS Status;
IoCreateDevice (VfatDriverObject, IoCreateDevice (VfatDriverObject,
sizeof (DEVICE_EXTENSION), sizeof (DEVICE_EXTENSION),
@ -159,6 +163,11 @@ VfatMount (PDEVICE_OBJECT DeviceToMount)
DeviceObject->Vpb->Flags |= VPB_MOUNTED; DeviceObject->Vpb->Flags |= VPB_MOUNTED;
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack (DeviceObject, DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack (DeviceObject,
DeviceToMount); DeviceToMount);
DeviceExt->StreamStorageDevice =
IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice);
Status = CcInitializeFileCache(DeviceExt->StreamStorageDevice,
&DeviceExt->StorageBcb,
PAGESIZE);
ExInitializeResourceLite (&DeviceExt->DirResource); ExInitializeResourceLite (&DeviceExt->DirResource);
ExInitializeResourceLite (&DeviceExt->FatResource); ExInitializeResourceLite (&DeviceExt->FatResource);

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -26,6 +26,24 @@
/* FUNCTIONS *****************************************************************/ /* 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 ULONG
OffsetToCluster(PDEVICE_EXTENSION DeviceExt, OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
ULONG FirstCluster, ULONG FirstCluster,
@ -33,6 +51,8 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
{ {
ULONG CurrentCluster; ULONG CurrentCluster;
ULONG i; ULONG i;
DPRINT("OffsetToCluster(FirstCluster 0x%x)\n", FirstCluster);
CurrentCluster = FirstCluster; CurrentCluster = FirstCluster;
if (FirstCluster == 1) if (FirstCluster == 1)
@ -48,6 +68,7 @@ OffsetToCluster(PDEVICE_EXTENSION DeviceExt,
CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster); CurrentCluster = GetNextCluster (DeviceExt, CurrentCluster);
} }
} }
DPRINT("OffsetToCluster() = 0x%x\n", CurrentCluster);
return(CurrentCluster); return(CurrentCluster);
} }
@ -139,7 +160,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
{ {
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
CurrentCluster, CurrentCluster,
DeviceExt->Boot->SectorsPerCluster, Temp); DeviceExt->Boot->SectorsPerCluster, Temp);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster; CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
@ -164,7 +186,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
{ {
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
CurrentCluster, CurrentCluster,
DeviceExt->Boot->SectorsPerCluster, Buffer); DeviceExt->Boot->SectorsPerCluster, Buffer);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster; CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
@ -190,7 +213,8 @@ VfatReadFileNoCache (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
(*LengthRead) = (*LengthRead) + Length; (*LengthRead) = (*LengthRead) + Length;
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
CurrentCluster, CurrentCluster,
DeviceExt->Boot->SectorsPerCluster, Temp); DeviceExt->Boot->SectorsPerCluster, Temp);
CurrentCluster += DeviceExt->Boot->SectorsPerCluster; CurrentCluster += DeviceExt->Boot->SectorsPerCluster;
@ -212,9 +236,11 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
PULONG CurrentCluster, PULONG CurrentCluster,
PVOID Destination) PVOID Destination)
{ {
DPRINT("VfatRawReadCluster() *CurrentCluster 0x%x\n", *CurrentCluster);
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
(*CurrentCluster), (*CurrentCluster),
DeviceExt->Boot->SectorsPerCluster, DeviceExt->Boot->SectorsPerCluster,
Destination); Destination);
@ -225,6 +251,8 @@ VfatRawReadCluster (PDEVICE_EXTENSION DeviceExt,
VFATLoadCluster (DeviceExt, Destination, (*CurrentCluster)); VFATLoadCluster (DeviceExt, Destination, (*CurrentCluster));
(*CurrentCluster) = GetNextCluster (DeviceExt, (*CurrentCluster)); (*CurrentCluster) = GetNextCluster (DeviceExt, (*CurrentCluster));
} }
DPRINT("VfatRawReadCluster() finished *CurrentCluster 0x%x\n",
*CurrentCluster);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
@ -297,9 +325,10 @@ VfatReadCluster(PDEVICE_EXTENSION DeviceExt,
ULONG i; ULONG i;
ULONG ReadOffset; ULONG ReadOffset;
ULONG InternalOffset; ULONG InternalOffset;
ReadOffset = ROUND_DOWN(StartOffset, PAGESIZE); /*
InternalOffset = StartOffset % PAGESIZE; * Otherwise we read a page of clusters together
*/
Status = CcRequestCacheSegment(Fcb->RFCB.Bcb, Status = CcRequestCacheSegment(Fcb->RFCB.Bcb,
ReadOffset, ReadOffset,
&BaseAddress, &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) if (!Valid)
{ {
ULONG StartCluster;
StartCluster = OffsetToCluster(DeviceExt, FirstCluster, ReadOffset);
for (i = 0; i < (PAGESIZE / BytesPerCluster); i++) for (i = 0; i < (PAGESIZE / BytesPerCluster); i++)
{ {
Status = VfatRawReadCluster(DeviceExt, Status = VfatRawReadCluster(DeviceExt,
FirstCluster, FirstCluster,
&StartCluster, CurrentCluster,
BaseAddress + (i * BytesPerCluster)); BaseAddress + (i * BytesPerCluster));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, FALSE); CcReleaseCacheSegment(Fcb->RFCB.Bcb, CacheSeg, FALSE);
return(Status); return(Status);
} }
if (CurrentCluster == 0xFFFFFFFF)
{
break;
}
} }
} }
/*
* Go on to the next cluster
*/
if (FirstCluster == 1)
{
(*CurrentCluster) += DeviceExt->Boot->SectorsPerCluster;
}
else 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 * Copy the data from the cache to the caller
@ -366,6 +401,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
PVFATFCB Fcb; PVFATFCB Fcb;
PVOID Temp; PVOID Temp;
ULONG TempLength; ULONG TempLength;
ULONG ChunkSize;
/* PRECONDITION */ /* PRECONDITION */
assert (DeviceExt != NULL); assert (DeviceExt != NULL);
@ -374,7 +410,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
assert (FileObject->FsContext != NULL); assert (FileObject->FsContext != NULL);
DPRINT ("FsdReadFile(DeviceExt %x, FileObject %x, Buffer %x, " 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); Length, ReadOffset);
Fcb = ((PVFATCCB)FileObject->FsContext2)->pFcb; Fcb = ((PVFATCCB)FileObject->FsContext2)->pFcb;
@ -404,13 +440,15 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
} }
} }
ChunkSize = max(DeviceExt->BytesPerCluster, PAGESIZE);
*LengthRead = 0; *LengthRead = 0;
/* /*
* Allocate a buffer to hold partial clusters * Allocate a buffer to hold partial clusters
*/ */
Temp = ExAllocatePool (NonPagedPool, DeviceExt->BytesPerCluster); Temp = ExAllocatePool (NonPagedPool, ChunkSize);
if (!Temp) if (!Temp)
return STATUS_UNSUCCESSFUL; 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 * If the read doesn't begin on a cluster boundary then read a full
* cluster and copy it. * cluster and copy it.
*/ */
if ((ReadOffset % DeviceExt->BytesPerCluster) != 0) if ((ReadOffset % ChunkSize) != 0)
{ {
VfatReadCluster(DeviceExt, Fcb, VfatReadCluster(DeviceExt, Fcb,
ROUND_DOWN(ReadOffset, DeviceExt->BytesPerCluster), ROUND_DOWN(ReadOffset, ChunkSize),
FirstCluster, &CurrentCluster, Temp, 1); FirstCluster, &CurrentCluster, Temp, 1);
TempLength = min (Length, DeviceExt->BytesPerCluster - TempLength = min (Length, ChunkSize - (ReadOffset % ChunkSize));
(ReadOffset % DeviceExt->BytesPerCluster));
memcpy (Buffer, Temp + ReadOffset % DeviceExt->BytesPerCluster, memcpy (Buffer, Temp + ReadOffset % ChunkSize, TempLength);
TempLength);
(*LengthRead) = (*LengthRead) + TempLength; (*LengthRead) = (*LengthRead) + TempLength;
Length = Length - TempLength; Length = Length - TempLength;
@ -442,7 +478,7 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
ReadOffset = ReadOffset + TempLength; ReadOffset = ReadOffset + TempLength;
} }
while (Length >= DeviceExt->BytesPerCluster) while (Length >= ChunkSize)
{ {
VfatReadCluster(DeviceExt, Fcb, ReadOffset, VfatReadCluster(DeviceExt, Fcb, ReadOffset,
FirstCluster, &CurrentCluster, Buffer, 1); FirstCluster, &CurrentCluster, Buffer, 1);
@ -452,10 +488,10 @@ VfatReadFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
} }
(*LengthRead) = (*LengthRead) + DeviceExt->BytesPerCluster; (*LengthRead) = (*LengthRead) + ChunkSize;
Buffer = Buffer + DeviceExt->BytesPerCluster; Buffer = Buffer + ChunkSize;
Length = Length - DeviceExt->BytesPerCluster; Length = Length - ChunkSize;
ReadOffset = ReadOffset + DeviceExt->BytesPerCluster; ReadOffset = ReadOffset + ChunkSize;
} }
if (Length > 0) if (Length > 0)
@ -558,7 +594,8 @@ VfatWriteFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
/* Read in the existing cluster data */ /* Read in the existing cluster data */
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
CurrentCluster, CurrentCluster,
DeviceExt->Boot->SectorsPerCluster, Temp); DeviceExt->Boot->SectorsPerCluster, Temp);
} }
@ -632,7 +669,8 @@ VfatWriteFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
/* Read in the existing cluster data */ /* Read in the existing cluster data */
if (FirstCluster == 1) if (FirstCluster == 1)
{ {
VFATReadSectors (DeviceExt->StorageDevice, /* FIXME: Check status */
VfatReadSectors (DeviceExt->StorageDevice,
CurrentCluster, CurrentCluster,
DeviceExt->Boot->SectorsPerCluster, Temp); DeviceExt->Boot->SectorsPerCluster, Temp);
} }

View file

@ -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 <ddk/ntifs.h> #include <ddk/ntifs.h>
@ -74,19 +74,21 @@ typedef struct _slot slot;
typedef struct typedef struct
{ {
ERESOURCE DirResource; ERESOURCE DirResource;
ERESOURCE FatResource; ERESOURCE FatResource;
KSPIN_LOCK FcbListLock; KSPIN_LOCK FcbListLock;
LIST_ENTRY FcbListHead; LIST_ENTRY FcbListHead;
PDEVICE_OBJECT StorageDevice; PDEVICE_OBJECT StorageDevice;
BootSector *Boot; PFILE_OBJECT StreamStorageDevice;
int rootDirectorySectors, FATStart, rootStart, dataStart; PBCB StorageBcb;
int FATEntriesPerSector, FATUnit; BootSector *Boot;
ULONG BytesPerCluster; int rootDirectorySectors, FATStart, rootStart, dataStart;
ULONG FatType; int FATEntriesPerSector, FATUnit;
unsigned char* FAT; ULONG BytesPerCluster;
ULONG FatType;
unsigned char* FAT;
} DEVICE_EXTENSION, *PDEVICE_EXTENSION; } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
typedef struct _VFATFCB typedef struct _VFATFCB
@ -119,7 +121,6 @@ typedef struct _VFATCCB
#define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry)) #define ENTRIES_PER_SECTOR (BLOCKSIZE / sizeof(FATDirEntry))
typedef struct __DOSTIME typedef struct __DOSTIME
{ {
WORD Second:5; WORD Second:5;
@ -154,14 +155,14 @@ VfatQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
/* internal functions in blockdev.c */ /* internal functions in blockdev.c */
BOOLEAN NTSTATUS
VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, VfatReadSectors(IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector, IN ULONG DiskSector,
IN ULONG SectorCount, IN ULONG SectorCount,
IN UCHAR* Buffer); IN UCHAR* Buffer);
BOOLEAN NTSTATUS
VFATWriteSectors(IN PDEVICE_OBJECT pDeviceObject, VfatWriteSectors(IN PDEVICE_OBJECT pDeviceObject,
IN ULONG DiskSector, IN ULONG DiskSector,
IN ULONG SectorCount, IN ULONG SectorCount,
IN UCHAR* Buffer); IN UCHAR* Buffer);

View file

@ -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_HANDLE_CREATED 0x00040000
#define FO_FILE_FAST_IO_READ 0x00080000 #define FO_FILE_FAST_IO_READ 0x00080000
/*
* ReactOS specific flags
*/
#define FO_DIRECT_CACHE_READ 0x72000001 #define FO_DIRECT_CACHE_READ 0x72000001
#define FO_DIRECT_CACHE_WRITE 0x72000002 #define FO_DIRECT_CACHE_WRITE 0x72000002
#define FO_DIRECT_CACHE_PAGING_READ 0x72000004 #define FO_DIRECT_CACHE_PAGING_READ 0x72000004
#define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008 #define FO_DIRECT_CACHE_PAGING_WRITE 0x72000008
#define FO_FCB_IS_VALID 0x72000010
typedef struct _FILE_OBJECT typedef struct _FILE_OBJECT
{ {

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -23,6 +23,7 @@ extern "C"
#ifndef FASTCALL #ifndef FASTCALL
#define FASTCALL STDCALL #define FASTCALL STDCALL
#endif #endif
#define STATIC static
#include <ntos/types.h> #include <ntos/types.h>
#include <ntos/disk.h> #include <ntos/disk.h>

View file

@ -426,7 +426,7 @@ typedef struct _IMAGE_CONTROL_DATA{
#define BUTTON 0x80 #define BUTTON 0x80
#define EDIT 0x81 #define EDIT 0x81
#define STATIC 0x82 //#define STATIC 0x82
#define LISTBOX 0x83 #define LISTBOX 0x83
#define SCROLLBAR 0x84 #define SCROLLBAR 0x84
#define COMBOBOX 0x85 #define COMBOBOX 0x85

View file

@ -13,20 +13,18 @@
struct _EPROCESS; struct _EPROCESS;
typedef ULONG SWAPENTRY; typedef ULONG SWAPENTRY;
enum #define MEMORY_AREA_INVALID (0)
{ #define MEMORY_AREA_SECTION_VIEW_COMMIT (1)
MEMORY_AREA_INVALID, #define MEMORY_AREA_CONTINUOUS_MEMORY (2)
MEMORY_AREA_SECTION_VIEW_COMMIT, #define MEMORY_AREA_NO_CACHE (3)
MEMORY_AREA_CONTINUOUS_MEMORY, #define MEMORY_AREA_IO_MAPPING (4)
MEMORY_AREA_NO_CACHE, #define MEMORY_AREA_SYSTEM (5)
MEMORY_AREA_IO_MAPPING, #define MEMORY_AREA_MDL_MAPPING (7)
MEMORY_AREA_SYSTEM, #define MEMORY_AREA_VIRTUAL_MEMORY (8)
MEMORY_AREA_MDL_MAPPING, #define MEMORY_AREA_SECTION_VIEW_RESERVE (9)
MEMORY_AREA_VIRTUAL_MEMORY, #define MEMORY_AREA_CACHE_SEGMENT (10)
MEMORY_AREA_SECTION_VIEW_RESERVE, #define MEMORY_AREA_SHARED_DATA (11)
MEMORY_AREA_CACHE_SEGMENT,
MEMORY_AREA_SHARED_DATA,
};
#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \ #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \
((x) / (4*1024*1024)) ((x) / (4*1024*1024))
@ -42,8 +40,27 @@ enum
#define SPE_DIRTY (0x8) #define SPE_DIRTY (0x8)
#define SPE_IN_PAGEFILE (0x10) #define SPE_IN_PAGEFILE (0x10)
/*
* Flags for section objects
*/
#define SO_PHYSICAL_MEMORY (0x1) #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 typedef struct
{ {
ULONG Pages[NR_SECTION_PAGE_ENTRIES]; ULONG Pages[NR_SECTION_PAGE_ENTRIES];
@ -259,7 +276,6 @@ VOID MmInit3(VOID);
NTSTATUS MmInitPagerThread(VOID); NTSTATUS MmInitPagerThread(VOID);
VOID MmInitKernelMap(PVOID BaseAddress); VOID MmInitKernelMap(PVOID BaseAddress);
unsigned int alloc_pool_region(unsigned int nr_pages);
VOID MmWaitForFreePages(VOID); VOID MmWaitForFreePages(VOID);
PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry); PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry);

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -168,41 +168,36 @@ PFILE_OBJECT STDCALL
IoCreateStreamFileObject (PFILE_OBJECT FileObject, IoCreateStreamFileObject (PFILE_OBJECT FileObject,
PDEVICE_OBJECT DeviceObject) PDEVICE_OBJECT DeviceObject)
{ {
HANDLE FileHandle; HANDLE FileHandle;
PFILE_OBJECT CreatedFileObject; PFILE_OBJECT CreatedFileObject;
DbgPrint("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n",
FileObject, DeviceObject);
DbgPrint("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", assert_irql (PASSIVE_LEVEL);
FileObject,
DeviceObject CreatedFileObject = ObCreateObject (&FileHandle,
); STANDARD_RIGHTS_REQUIRED,
NULL,
assert_irql (PASSIVE_LEVEL); IoFileObjectType);
if (NULL == CreatedFileObject)
CreatedFileObject = ObCreateObject ( {
& FileHandle, return (NULL);
STANDARD_RIGHTS_REQUIRED, }
NULL,
IoFileObjectType if (FileObject != NULL)
); {
if (NULL == CreatedFileObject) DeviceObject = FileObject->DeviceObject;
{ }
return (NULL); DeviceObject = IoGetAttachedDevice(DeviceObject);
} CreatedFileObject->DeviceObject = DeviceObject;
CreatedFileObject->Vpb = DeviceObject->Vpb;
if (FileObject != NULL) CreatedFileObject->Type = InternalFileType;
{ CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
DeviceObject = FileObject->DeviceObject;
} ZwClose (FileHandle);
DeviceObject = IoGetAttachedDevice(DeviceObject);
CreatedFileObject->DeviceObject = DeviceObject; return (CreatedFileObject);
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);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -49,7 +49,7 @@ NTSTATUS STDCALL IoPageWrite(PFILE_OBJECT FileObject,
DPRINT("Before IoCallDriver\n"); DPRINT("Before IoCallDriver\n");
Status = IoCallDriver(FileObject->DeviceObject,Irp); Status = IoCallDriver(FileObject->DeviceObject,Irp);
DPRINT("Status %d STATUS_PENDING %d\n",Status,STATUS_PENDING); 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"); DPRINT("Waiting for io operation\n");
if (FileObject->Flags & FO_ALERTABLE_IO) if (FileObject->Flags & FO_ALERTABLE_IO)

View file

@ -232,9 +232,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
/* /*
* retrieve ntdll's startup address * retrieve ntdll's startup address
*/ */
RtlInitAnsiString (&ProcedureName, RtlInitAnsiString (&ProcedureName,
"LdrInitializeThunk"); "LdrInitializeThunk");
DPRINT1("Getting address of system DLL entrypoint\n");
Status = LdrGetProcedureAddress ((PVOID)ImageBase, Status = LdrGetProcedureAddress ((PVOID)ImageBase,
&ProcedureName, &ProcedureName,
0, 0,
@ -247,7 +248,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
ZwClose(NTDllSectionHandle); ZwClose(NTDllSectionHandle);
return (Status); return (Status);
} }
DPRINT("SystemDllEntryPoint 0x%08lx\n", DPRINT1("SystemDllEntryPoint 0x%08lx\n",
SystemDllEntryPoint); SystemDllEntryPoint);
*LdrStartupAddr = SystemDllEntryPoint; *LdrStartupAddr = SystemDllEntryPoint;

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -19,11 +19,12 @@
/* GLOBALS ******************************************************************/ /* GLOBALS ******************************************************************/
static MADDRESS_SPACE KernelAddressSpace; STATIC MADDRESS_SPACE KernelAddressSpace;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace) VOID
MmLockAddressSpace(PMADDRESS_SPACE AddressSpace)
{ {
(VOID)KeWaitForMutexObject(&AddressSpace->Lock, (VOID)KeWaitForMutexObject(&AddressSpace->Lock,
0, 0,
@ -32,12 +33,14 @@ VOID MmLockAddressSpace(PMADDRESS_SPACE AddressSpace)
NULL); NULL);
} }
VOID MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace) VOID
MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace)
{ {
KeReleaseMutex(&AddressSpace->Lock, FALSE); KeReleaseMutex(&AddressSpace->Lock, FALSE);
} }
VOID MmInitializeKernelAddressSpace(VOID) VOID
MmInitializeKernelAddressSpace(VOID)
{ {
MmInitializeAddressSpace(NULL, &KernelAddressSpace); MmInitializeAddressSpace(NULL, &KernelAddressSpace);
} }
@ -52,8 +55,9 @@ PMADDRESS_SPACE MmGetKernelAddressSpace(VOID)
return(&KernelAddressSpace); return(&KernelAddressSpace);
} }
NTSTATUS MmInitializeAddressSpace(PEPROCESS Process, NTSTATUS
PMADDRESS_SPACE AddressSpace) MmInitializeAddressSpace(PEPROCESS Process,
PMADDRESS_SPACE AddressSpace)
{ {
InitializeListHead(&AddressSpace->MAreaListHead); InitializeListHead(&AddressSpace->MAreaListHead);
KeInitializeMutex(&AddressSpace->Lock, 1); KeInitializeMutex(&AddressSpace->Lock, 1);
@ -84,7 +88,8 @@ NTSTATUS MmInitializeAddressSpace(PEPROCESS Process,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace) NTSTATUS
MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace)
{ {
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -69,11 +69,19 @@ MmAllocateContiguousMemory (IN ULONG NumberOfBytes,
PBase = MmGetContinuousPages(NumberOfBytes, PBase = MmGetContinuousPages(NumberOfBytes,
HighestAcceptableAddress); HighestAcceptableAddress);
if (PBase == NULL)
{
MmFreeMemoryArea(MmGetKernelAddressSpace(),
BaseAddress,
0,
TRUE);
return(NULL);
}
for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++) for (i = 0; i < (PAGE_ROUND_UP(NumberOfBytes) / 4096); i++)
{ {
MmCreateVirtualMapping(NULL, MmCreateVirtualMapping(NULL,
BaseAddress + (i * 4096), BaseAddress + (i * 4096),
PAGE_EXECUTE_READWRITE, PAGE_EXECUTE_READWRITE | PAGE_SYSTEM,
(ULONG)(PBase + (i * 4096))); (ULONG)(PBase + (i * 4096)));
} }
return(BaseAddress); return(BaseAddress);

View file

@ -475,7 +475,8 @@ VOID MmUnlockPage(PVOID PhysicalAddress)
} }
PVOID MmAllocPage(SWAPENTRY SavedSwapEntry) PVOID
MmAllocPage(SWAPENTRY SavedSwapEntry)
{ {
ULONG offset; ULONG offset;
PLIST_ENTRY ListEntry; PLIST_ENTRY ListEntry;
@ -518,7 +519,8 @@ PVOID MmAllocPage(SWAPENTRY SavedSwapEntry)
return((PVOID)offset); return((PVOID)offset);
} }
PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry) PVOID
MmMustAllocPage(SWAPENTRY SavedSwapEntry)
{ {
PVOID Page; PVOID Page;
@ -532,7 +534,8 @@ PVOID MmMustAllocPage(SWAPENTRY SavedSwapEntry)
return(Page); return(Page);
} }
PVOID MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry) PVOID
MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry)
{ {
PVOID Page; PVOID Page;
@ -545,7 +548,8 @@ PVOID MmAllocPageMaybeSwap(SWAPENTRY SavedSwapEntry)
return(Page); return(Page);
} }
NTSTATUS MmWaitForPage(PVOID PhysicalAddress) NTSTATUS
MmWaitForPage(PVOID PhysicalAddress)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Start; ULONG Start;
@ -559,7 +563,8 @@ NTSTATUS MmWaitForPage(PVOID PhysicalAddress)
return(Status); return(Status);
} }
VOID MmClearWaitPage(PVOID PhysicalAddress) VOID
MmClearWaitPage(PVOID PhysicalAddress)
{ {
ULONG Start; ULONG Start;
@ -568,7 +573,8 @@ VOID MmClearWaitPage(PVOID PhysicalAddress)
KeClearEvent(&MmPageArray[Start].Event); KeClearEvent(&MmPageArray[Start].Event);
} }
VOID MmSetWaitPage(PVOID PhysicalAddress) VOID
MmSetWaitPage(PVOID PhysicalAddress)
{ {
ULONG Start; ULONG Start;

View file

@ -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 * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -25,17 +25,23 @@
#define PA_BIT_PRESENT (0) #define PA_BIT_PRESENT (0)
#define PA_BIT_READWRITE (1) #define PA_BIT_READWRITE (1)
#define PA_BIT_USER (2) #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_BIT_DIRTY (6)
#define PA_PRESENT (1<<PA_BIT_PRESENT) #define PA_PRESENT (1 << PA_BIT_PRESENT)
#define PA_DIRTY (1<<PA_BIT_DIRTY) #define PA_DIRTY (1 << PA_BIT_DIRTY)
#define PA_WT (1 << PA_BIT_WT)
#define PA_CD (1 << PA_BIT_CD)
#define PAGETABLE_MAP (0xf0000000) #define PAGETABLE_MAP (0xf0000000)
#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024))) #define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024)))
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
PULONG MmGetPageDirectory(void) PULONG
MmGetPageDirectory(VOID)
{ {
unsigned int page_dir=0; unsigned int page_dir=0;
__asm__("movl %%cr3,%0\n\t" __asm__("movl %%cr3,%0\n\t"
@ -43,23 +49,36 @@ PULONG MmGetPageDirectory(void)
return((PULONG)page_dir); return((PULONG)page_dir);
} }
static ULONG ProtectToPTE(ULONG flProtect) static ULONG
ProtectToPTE(ULONG flProtect)
{ {
ULONG Attributes = 0; ULONG Attributes = 0;
if (flProtect & PAGE_NOACCESS || flProtect & PAGE_GUARD) if (flProtect & PAGE_NOACCESS || flProtect & PAGE_GUARD)
{ {
Attributes = 0; Attributes = 0;
} }
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE) if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
{ {
Attributes = PA_WRITE | PA_USER; Attributes = PA_WRITE;
} }
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE || if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
flProtect & PAGE_EXECUTE_READ) flProtect & PAGE_EXECUTE_READ)
{ {
Attributes = PA_READ | PA_USER; Attributes = PA_READ;
} }
if (!(flProtect & PAGE_SYSTEM))
{
Attributes = Attributes | PA_USER;
}
if (!(flProtect & PAGE_NOCACHE))
{
Attributes = Attributes | PA_CD;
}
if (!(flProtect & PAGE_WRITETHROUGH))
{
Attributes = Attributes | PA_WT;
}
return(Attributes); return(Attributes);
} }
@ -448,9 +467,8 @@ NTSTATUS MmCreateVirtualMapping(PEPROCESS Process,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
VOID MmSetPageProtect(PEPROCESS Process, VOID
PVOID Address, MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
ULONG flProtect)
{ {
ULONG Attributes = 0; ULONG Attributes = 0;
PULONG PageEntry; PULONG PageEntry;
@ -471,7 +489,8 @@ VOID MmSetPageProtect(PEPROCESS Process,
} }
} }
PHYSICAL_ADDRESS STDCALL MmGetPhysicalAddress(PVOID vaddr) PHYSICAL_ADDRESS STDCALL
MmGetPhysicalAddress(PVOID vaddr)
/* /*
* FUNCTION: Returns the physical address corresponding to a virtual address * FUNCTION: Returns the physical address corresponding to a virtual address
*/ */

View file

@ -1,4 +1,4 @@
/* $Id: iospace.c,v 1.6 2000/08/20 17:02:08 dwelch Exp $ /* $Id: iospace.c,v 1.7 2001/01/08 02:14:05 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -47,9 +47,10 @@
* REVISIONS * REVISIONS
* *
*/ */
PVOID STDCALL MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress, PVOID STDCALL
IN ULONG NumberOfBytes, MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
IN BOOLEAN CacheEnable) IN ULONG NumberOfBytes,
IN BOOLEAN CacheEnable)
{ {
PVOID Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
@ -69,17 +70,18 @@ PVOID STDCALL MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
{ {
return (NULL); return (NULL);
} }
Attributes = PA_WRITE | PA_READ | PA_EXECUTE | PA_SYSTEM; Attributes = PAGE_EXECUTE_READWRITE | PAGE_SYSTEM;
if (!CacheEnable) if (!CacheEnable)
{ {
Attributes |= (PA_PWT | PA_PCD); Attributes |= (PAGE_NOCACHE | PAGE_WRITETHROUGH);
} }
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++) for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++)
{ {
Status = MmCreateVirtualMapping (NULL, Status =
(Result + (i * PAGESIZE)), MmCreateVirtualMapping (NULL,
PAGE_READWRITE, (Result + (i * PAGESIZE)),
(PhysicalAddress.u.LowPart + (i * PAGESIZE))); Attributes,
PhysicalAddress.u.LowPart + (i * PAGESIZE));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DbgPrint("Unable to create virtual mapping\n"); DbgPrint("Unable to create virtual mapping\n");
@ -127,33 +129,20 @@ VOID STDCALL MmUnmapIoSpace (IN PVOID BaseAddress,
* NAME EXPORTED * NAME EXPORTED
* MmMapVideoDisplay@16 * MmMapVideoDisplay@16
*/ */
PVOID PVOID STDCALL
STDCALL MmMapVideoDisplay (IN PHYSICAL_ADDRESS PhysicalAddress,
MmMapVideoDisplay ( IN ULONG NumberOfBytes,
IN PHYSICAL_ADDRESS PhysicalAddress, IN MEMORY_CACHING_TYPE CacheType)
IN ULONG NumberOfBytes,
IN MEMORY_CACHING_TYPE CacheType
)
{ {
return MmMapIoSpace ( return MmMapIoSpace (PhysicalAddress, NumberOfBytes, CacheType);
PhysicalAddress,
NumberOfBytes,
CacheType
);
} }
VOID VOID STDCALL
STDCALL MmUnmapVideoDisplay (IN PVOID BaseAddress,
MmUnmapVideoDisplay ( IN ULONG NumberOfBytes)
IN PVOID BaseAddress,
IN ULONG NumberOfBytes
)
{ {
MmUnmapIoSpace ( MmUnmapIoSpace (BaseAddress, NumberOfBytes);
BaseAddress,
NumberOfBytes
);
} }

View file

@ -1,4 +1,4 @@
/* $Id: kmap.c,v 1.4 2000/10/22 16:36:51 ekohl Exp $ /* $Id: kmap.c,v 1.5 2001/01/08 02:14:06 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -34,7 +34,8 @@ static PVOID kernel_pool_base;
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
VOID ExUnmapPage(PVOID Addr) VOID
ExUnmapPage(PVOID Addr)
{ {
KIRQL oldIrql; KIRQL oldIrql;
ULONG i = (Addr - kernel_pool_base) / PAGESIZE; ULONG i = (Addr - kernel_pool_base) / PAGESIZE;
@ -48,7 +49,8 @@ VOID ExUnmapPage(PVOID Addr)
KeReleaseSpinLock(&AllocMapLock, oldIrql); KeReleaseSpinLock(&AllocMapLock, oldIrql);
} }
PVOID ExAllocatePage(VOID) PVOID
ExAllocatePage(VOID)
{ {
KIRQL oldlvl; KIRQL oldlvl;
ULONG addr; ULONG addr;
@ -73,7 +75,7 @@ PVOID ExAllocatePage(VOID)
addr = (ULONG)(kernel_pool_base + (i*PAGESIZE)); addr = (ULONG)(kernel_pool_base + (i*PAGESIZE));
Status = MmCreateVirtualMapping(NULL, Status = MmCreateVirtualMapping(NULL,
(PVOID)addr, (PVOID)addr,
PAGE_READWRITE, PAGE_READWRITE | PAGE_SYSTEM,
PhysPage); PhysPage);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -88,13 +90,15 @@ PVOID ExAllocatePage(VOID)
return(NULL); return(NULL);
} }
VOID MmInitKernelMap(PVOID BaseAddress) VOID
MmInitKernelMap(PVOID BaseAddress)
{ {
kernel_pool_base = BaseAddress; kernel_pool_base = BaseAddress;
KeInitializeSpinLock(&AllocMapLock); KeInitializeSpinLock(&AllocMapLock);
} }
unsigned int alloc_pool_region(unsigned int nr_pages) unsigned int
alloc_pool_region(unsigned int nr_pages)
/* /*
* FUNCTION: Allocates a region of pages within the nonpaged pool area * FUNCTION: Allocates a region of pages within the nonpaged pool area
*/ */

View file

@ -1,4 +1,4 @@
/* $Id: mdl.c,v 1.26 2000/10/22 16:36:51 ekohl Exp $ /* $Id: mdl.c,v 1.27 2001/01/08 02:14:06 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -311,3 +311,12 @@ VOID STDCALL MmMapMemoryDumpMdl (PVOID Unknown0)
} }
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: mm.c,v 1.39 2000/10/22 16:36:52 ekohl Exp $ /* $Id: mm.c,v 1.40 2001/01/08 02:14:06 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -196,7 +196,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
Status = MmCreateVirtualMapping(PsGetCurrentProcess(), Status = MmCreateVirtualMapping(PsGetCurrentProcess(),
(PVOID)PAGE_ROUND_DOWN(Address), (PVOID)PAGE_ROUND_DOWN(Address),
PAGE_READONLY, PAGE_READONLY,
(ULONG)MmSharedDataPagePhysicalAddress); (ULONG)MmSharedDataPagePhysicalAddress);
break; break;
default: default:
@ -210,13 +210,10 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
/* Miscellanea functions: they may fit somewhere else */ /* Miscellanea functions: they may fit somewhere else */
DWORD DWORD STDCALL
STDCALL MmAdjustWorkingSetSize (DWORD Unknown0,
MmAdjustWorkingSetSize ( DWORD Unknown1,
DWORD Unknown0, DWORD Unknown2)
DWORD Unknown1,
DWORD Unknown2
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (0); return (0);

View file

@ -1,4 +1,4 @@
/* $Id: ncache.c,v 1.6 2000/08/20 17:02:08 dwelch Exp $ /* $Id: ncache.c,v 1.7 2001/01/08 02:14:06 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -44,13 +44,15 @@
* REVISIONS * REVISIONS
* *
*/ */
PVOID STDCALL MmAllocateNonCachedMemory(IN ULONG NumberOfBytes) PVOID STDCALL
MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
{ {
PVOID Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
NTSTATUS Status; NTSTATUS Status;
ULONG i; ULONG i;
ULONG Attributes;
Result = NULL; Result = NULL;
Status = MmCreateMemoryArea (NULL, Status = MmCreateMemoryArea (NULL,
MmGetKernelAddressSpace(), MmGetKernelAddressSpace(),
@ -63,17 +65,17 @@ PVOID STDCALL MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
{ {
return (NULL); return (NULL);
} }
for (i = 0; (i <= (NumberOfBytes / PAGESIZE)); i++) Attributes = PAGE_READWRITE | PAGE_SYSTEM | PAGE_NOCACHE |
PAGE_WRITETHROUGH;
for (i = 0; i <= (NumberOfBytes / PAGESIZE); i++)
{ {
Status = MmCreateVirtualMapping (NULL, PVOID NPage;
(Result + (i * PAGESIZE)),
PAGE_READWRITE, NPage = MmAllocPageMaybeSwap(0);
(ULONG)MmAllocPage(0)); MmCreateVirtualMapping (NULL,
if (!NT_SUCCESS(Status)) Result + (i * PAGESIZE),
{ Attributes,
DbgPrint("Unable to create virtual mapping\n"); (ULONG)NPage);
KeBugCheck(0);
}
} }
return ((PVOID)Result); return ((PVOID)Result);
} }
@ -108,10 +110,10 @@ PVOID STDCALL MmAllocateNonCachedMemory(IN ULONG NumberOfBytes)
VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress, VOID STDCALL MmFreeNonCachedMemory (IN PVOID BaseAddress,
IN ULONG NumberOfBytes) IN ULONG NumberOfBytes)
{ {
MmFreeMemoryArea (&PsGetCurrentProcess()->AddressSpace, MmFreeMemoryArea (MmGetKernelAddressSpace(),
BaseAddress, BaseAddress,
NumberOfBytes, NumberOfBytes,
TRUE); TRUE);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -76,6 +76,9 @@ static KSPIN_LOCK MmNpoolLock;
unsigned int EiFreeNonPagedPool = 0; unsigned int EiFreeNonPagedPool = 0;
unsigned int EiUsedNonPagedPool = 0; unsigned int EiUsedNonPagedPool = 0;
unsigned int
alloc_pool_region(unsigned int nr_pages);
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
VOID ExInitNonPagedPool(ULONG BaseAddress) VOID ExInitNonPagedPool(ULONG BaseAddress)

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -21,7 +21,7 @@
/* TYPES *********************************************************************/ /* TYPES *********************************************************************/
typedef struct _PPAGINGFILE typedef struct _PAGINGFILE
{ {
LIST_ENTRY PagingFileListEntry; LIST_ENTRY PagingFileListEntry;
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
@ -347,3 +347,10 @@ NTSTATUS STDCALL NtCreatePagingFile(IN PUNICODE_STRING PageFileName,
/* EOF */ /* EOF */

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -78,7 +78,7 @@ static NTSTATUS MmPagerThreadMain(PVOID Ignored)
{ {
DbgPrint("PagerThread: Wait failed\n"); DbgPrint("PagerThread: Wait failed\n");
KeBugCheck(0); KeBugCheck(0);
} }
if (PagerThreadShouldTerminate) if (PagerThreadShouldTerminate)
{ {
DbgPrint("PagerThread: Terminating\n"); DbgPrint("PagerThread: Terminating\n");

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -27,9 +27,10 @@ POBJECT_TYPE EXPORTED MmSectionObjectType = NULL;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS MmWritePageSectionView(PMADDRESS_SPACE AddressSpace, NTSTATUS
PMEMORY_AREA MArea, MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
PVOID Address) PMEMORY_AREA MArea,
PVOID Address)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
@ -153,8 +154,9 @@ MmUnalignedLoadPageForSection(PMADDRESS_SPACE AddressSpace,
&IoStatus); &IoStatus);
if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE) if (!NT_SUCCESS(Status) && Status != STATUS_END_OF_FILE)
{ {
MmLockAddressSpace(AddressSpace); DPRINT("IoPageRead failed (%x)\n", Status);
return(Status); MmLockAddressSpace(AddressSpace);
return(Status);
} }
MmLockAddressSpace(AddressSpace); MmLockAddressSpace(AddressSpace);
@ -434,9 +436,9 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
/* /*
* FIXME: What do we know in this case? * FIXME: What do we know in this case?
*/ */
DPRINT("IoPageRead failed (Status %x)\n", Status);
MmLockAddressSpace(AddressSpace); MmLockAddressSpace(AddressSpace);
return(Status); return(Status);
} }
/* /*
@ -481,7 +483,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
KeBugCheck(0); KeBugCheck(0);
} }
MmUnlockSection(Section); MmUnlockSection(Section);
DPRINT("MmNotPresentFaultSectionView succeeded\n");
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }

View file

@ -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 * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -35,9 +35,10 @@ typedef struct _MM_SEGMENT
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea, PMM_SEGMENT
PVOID Address, MmGetSegmentForAddress(PMEMORY_AREA MArea,
PVOID* PCurrentAddress) PVOID Address,
PVOID* PCurrentAddress)
/* /*
* FUNCTION: Get the segment corresponding to a particular memory area and * FUNCTION: Get the segment corresponding to a particular memory area and
* address. * address.
@ -46,7 +47,7 @@ PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea,
* Address (IN) = The address to get the segment for * Address (IN) = The address to get the segment for
* PCurrentAddress (OUT) = The start of the segment * PCurrentAddress (OUT) = The start of the segment
* RETURNS: * RETURNS:
* The corresponding memory or NULL if an error occurred * The corresponding segment or NULL if an error occurred
*/ */
{ {
PVOID CurrentAddress; PVOID CurrentAddress;
@ -81,9 +82,10 @@ PMM_SEGMENT MmGetSegmentForAddress(PMEMORY_AREA MArea,
return(NULL); return(NULL);
} }
NTSTATUS MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace, NTSTATUS
PMEMORY_AREA MArea, MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
PVOID Address) PMEMORY_AREA MArea,
PVOID Address)
{ {
SWAPENTRY se; SWAPENTRY se;
ULONG Flags; ULONG Flags;
@ -196,9 +198,10 @@ ULONG MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
return(0); return(0);
} }
NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace, NTSTATUS
MEMORY_AREA* MemoryArea, MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
PVOID Address) MEMORY_AREA* MemoryArea,
PVOID Address)
/* /*
* FUNCTION: Move data into memory to satisfy a page not present fault * FUNCTION: Move data into memory to satisfy a page not present fault
* ARGUMENTS: * ARGUMENTS:
@ -284,55 +287,68 @@ NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
VOID MmModifyAttributes(PMADDRESS_SPACE AddressSpace, VOID STATIC
PVOID BaseAddress, MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
ULONG RegionSize, PVOID BaseAddress,
ULONG OldType, ULONG RegionSize,
ULONG OldProtect, ULONG OldType,
ULONG NewType, ULONG OldProtect,
ULONG NewProtect) ULONG NewType,
ULONG NewProtect)
/* /*
* FUNCTION: Modify the attributes of a memory region * FUNCTION: Modify the attributes of a memory region
*/ */
{ {
if (NewType == MEM_RESERVE && /*
OldType == MEM_COMMIT) * If we are switching a previously committed region to reserved then
{ * free any allocated pages within the region
ULONG i; */
if (NewType == MEM_RESERVE && OldType == MEM_COMMIT)
for (i=0; i<=(RegionSize/PAGESIZE); i++) {
{ ULONG i;
LARGE_INTEGER PhysicalAddr;
for (i=0; i <= (RegionSize/PAGESIZE); i++)
PhysicalAddr = MmGetPhysicalAddress(BaseAddress + (i*PAGESIZE)); {
if (PhysicalAddr.u.LowPart != 0) LARGE_INTEGER PhysicalAddr;
{
MmRemovePageFromWorkingSet(AddressSpace->Process, PhysicalAddr = MmGetPhysicalAddress(BaseAddress + (i*PAGESIZE));
BaseAddress + (i*PAGESIZE)); if (PhysicalAddr.u.LowPart != 0)
MmDereferencePage((PVOID)(ULONG)(PhysicalAddr.u.LowPart)); {
} MmRemovePageFromWorkingSet(AddressSpace->Process,
} BaseAddress + (i*PAGESIZE));
} MmDereferencePage((PVOID)(ULONG)(PhysicalAddr.u.LowPart));
if (NewType == MEM_COMMIT && OldType == MEM_COMMIT && }
OldProtect != NewProtect) MmDeleteVirtualMapping(AddressSpace->Process,
{ BaseAddress + (i*PAGESIZE),
ULONG i; 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++) for (i=0; i <= (RegionSize/PAGESIZE); i++)
{ {
if (MmIsPagePresent(AddressSpace->Process, if (MmIsPagePresent(AddressSpace->Process,
BaseAddress + (i*PAGESIZE))) BaseAddress + (i*PAGESIZE)))
{ {
MmSetPageProtect(AddressSpace->Process, MmSetPageProtect(AddressSpace->Process,
BaseAddress + (i*PAGESIZE), BaseAddress + (i*PAGESIZE),
NewProtect); NewProtect);
} }
} }
} }
} }
VOID InsertAfterEntry(PLIST_ENTRY Previous, VOID STATIC
PLIST_ENTRY Entry) InsertAfterEntry(PLIST_ENTRY Previous,
PLIST_ENTRY Entry)
/* /*
* FUNCTION: Insert a list entry after another entry in the list * FUNCTION: Insert a list entry after another entry in the list
*/ */
@ -345,7 +361,9 @@ VOID InsertAfterEntry(PLIST_ENTRY Previous,
Previous->Flink = Entry; Previous->Flink = Entry;
} }
VOID MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea) #if 0
VOID STATIC
MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea)
{ {
PVOID CurrentAddress; PVOID CurrentAddress;
PLIST_ENTRY CurrentEntry; PLIST_ENTRY CurrentEntry;
@ -372,15 +390,17 @@ VOID MmDumpSegmentsMemoryArea(PMEMORY_AREA MemoryArea)
CurrentEntry = CurrentEntry->Flink; CurrentEntry = CurrentEntry->Flink;
} }
} }
#endif
NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace, NTSTATUS
PMEMORY_AREA MemoryArea, MmSplitSegment(PMADDRESS_SPACE AddressSpace,
PVOID RegionAddress, PMEMORY_AREA MemoryArea,
ULONG RegionLength, PVOID RegionAddress,
ULONG Type, ULONG RegionLength,
ULONG Protect, ULONG Type,
PMM_SEGMENT FirstSegment, ULONG Protect,
PVOID FirstAddress) PMM_SEGMENT FirstSegment,
PVOID FirstAddress)
/* /*
* FUNCTION: Split a memory segment internally * FUNCTION: Split a memory segment internally
*/ */
@ -397,6 +417,15 @@ NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace,
OldType = FirstSegment->Type; OldType = FirstSegment->Type;
OldProtect = FirstSegment->Protect; OldProtect = FirstSegment->Protect;
OldLength = FirstSegment->Length; 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 * Allocate the segment we might need here because if the allocation
@ -408,15 +437,6 @@ NTSTATUS MmSplitSegment(PMADDRESS_SPACE AddressSpace,
return(STATUS_NO_MEMORY); 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) if (FirstAddress < RegionAddress)
{ {
/* /*
@ -710,12 +730,13 @@ NTSTATUS MmComplexVirtualMemoryOperation(PMADDRESS_SPACE AddressSpace,
} }
NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN OUT PVOID* PBaseAddress, NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
IN ULONG ZeroBits, IN OUT PVOID* UBaseAddress,
IN OUT PULONG PRegionSize, IN ULONG ZeroBits,
IN ULONG AllocationType, IN OUT PULONG URegionSize,
IN ULONG Protect) IN ULONG AllocationType,
IN ULONG Protect)
/* /*
* FUNCTION: Allocates a block of virtual memory in the process address space * FUNCTION: Allocates a block of virtual memory in the process address space
* ARGUMENTS: * ARGUMENTS:
@ -753,15 +774,28 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
PMM_SEGMENT Segment; PMM_SEGMENT Segment;
PVOID BaseAddress; PVOID BaseAddress;
ULONG RegionSize; ULONG RegionSize;
PVOID PBaseAddress;
ULONG PRegionSize;
DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, " DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, "
"ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n", "ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n",
ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType, ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType,
Protect); Protect);
BaseAddress = (PVOID)PAGE_ROUND_DOWN((*PBaseAddress)); /*
RegionSize = PAGE_ROUND_UP((*PBaseAddress) + (*PRegionSize)) - * Check the validity of the parameters
PAGE_ROUND_DOWN((*PBaseAddress)); */
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, Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_VM_OPERATION, PROCESS_VM_OPERATION,
@ -855,8 +889,8 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
MmReserveSwapPages(RegionSize); MmReserveSwapPages(RegionSize);
} }
*PBaseAddress = BaseAddress; *UBaseAddress = BaseAddress;
*PRegionSize = RegionSize; *URegionSize = RegionSize;
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
ObDereferenceObject(Process); ObDereferenceObject(Process);
@ -864,10 +898,11 @@ NTSTATUS STDCALL NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtFlushVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN PVOID BaseAddress, NtFlushVirtualMemory(IN HANDLE ProcessHandle,
IN ULONG NumberOfBytesToFlush, IN PVOID BaseAddress,
OUT PULONG NumberOfBytesFlushed OPTIONAL) IN ULONG NumberOfBytesToFlush,
OUT PULONG NumberOfBytesFlushed OPTIONAL)
/* /*
* FUNCTION: Flushes virtual memory to file * FUNCTION: Flushes virtual memory to file
* ARGUMENTS: * ARGUMENTS:
@ -883,10 +918,11 @@ NTSTATUS STDCALL NtFlushVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN PVOID* PBaseAddress, NtFreeVirtualMemory(IN HANDLE ProcessHandle,
IN PULONG PRegionSize, IN PVOID* PBaseAddress,
IN ULONG FreeType) IN PULONG PRegionSize,
IN ULONG FreeType)
/* /*
* FUNCTION: Frees a range of virtual memory * FUNCTION: Frees a range of virtual memory
* ARGUMENTS: * ARGUMENTS:
@ -997,19 +1033,21 @@ NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtLockVirtualMemory(HANDLE ProcessHandle, NTSTATUS STDCALL
PVOID BaseAddress, NtLockVirtualMemory(HANDLE ProcessHandle,
ULONG NumberOfBytesToLock, PVOID BaseAddress,
PULONG NumberOfBytesLocked) ULONG NumberOfBytesToLock,
PULONG NumberOfBytesLocked)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
VOID MmChangeAreaProtection(PEPROCESS Process, VOID
PVOID BaseAddress, MmChangeAreaProtection(PEPROCESS Process,
ULONG Length, PVOID BaseAddress,
ULONG Protect) ULONG Length,
ULONG Protect)
{ {
ULONG i; ULONG i;
@ -1179,11 +1217,12 @@ NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtReadVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN PVOID BaseAddress, NtReadVirtualMemory(IN HANDLE ProcessHandle,
OUT PVOID Buffer, IN PVOID BaseAddress,
IN ULONG NumberOfBytesToRead, OUT PVOID Buffer,
OUT PULONG NumberOfBytesRead) IN ULONG NumberOfBytesToRead,
OUT PULONG NumberOfBytesRead)
{ {
NTSTATUS Status; NTSTATUS Status;
PMDL Mdl; PMDL Mdl;
@ -1226,20 +1265,22 @@ NTSTATUS STDCALL NtReadVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtUnlockVirtualMemory(HANDLE ProcessHandle, NTSTATUS STDCALL
PVOID BaseAddress, NtUnlockVirtualMemory(HANDLE ProcessHandle,
ULONG NumberOfBytesToUnlock, PVOID BaseAddress,
PULONG NumberOfBytesUnlocked OPTIONAL) ULONG NumberOfBytesToUnlock,
PULONG NumberOfBytesUnlocked OPTIONAL)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }
NTSTATUS STDCALL NtWriteVirtualMemory(IN HANDLE ProcessHandle, NTSTATUS STDCALL
IN PVOID BaseAddress, NtWriteVirtualMemory(IN HANDLE ProcessHandle,
IN PVOID Buffer, IN PVOID BaseAddress,
IN ULONG NumberOfBytesToWrite, IN PVOID Buffer,
OUT PULONG NumberOfBytesWritten) IN ULONG NumberOfBytesToWrite,
OUT PULONG NumberOfBytesWritten)
{ {
NTSTATUS Status; NTSTATUS Status;
PMDL Mdl; PMDL Mdl;

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -198,3 +198,4 @@ BOOLEAN MmAddPageToWorkingSet(PEPROCESS Process,
} }