mirror of
https://github.com/reactos/reactos.git
synced 2024-06-01 02:01:57 +00:00
2002-08-14 David Welch <welch@computer2.darkstar.org>
* subsys/smss/init.c (SmPagingFilesQueryRoutine): If possible take the size of the paging file from the registry. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/section.c (MmCreateDataFileSection): Extend the section if necessary. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/pagefile.c (NtCreatePagingFile): Set the file size using the FileAllocationInformation class. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/mm/anonmem.c (MmWritePageVirtualMemory): Implemented function to write anonymous memory pages to the swap file. * ntoskrnl/mm/anonmem.c (MmFreeVirtualMemoryPage): Free any swap page associated with the page. * ntoskrnl/mm/mpw.c (MmWriteDirtyPages): New function to find pages to write to disk. * ntoskrnl/mm/mpw.c (MmMpwThreadMain): Implemented MPW functionality. * ntoskrnl/mm/rmap.c (MmWritePagePhysicalAddress): New function to write a single page back to disk. * ntoskrnl/mm/rmap.c (MmSetCleanAllRmaps, MmSetDirtyAllRmaps, MmIsDirtyPageRmap): New rmap function to support the MPW thread. * ntoskrnl/mm/section.c (MmWritePageSectionView): Implemented function to write back section pages. * ntoskrnl/mm/section.c (MmFreeSectionPage): Free any swap entry associated with the page; mark pages shared with the cache as dirty if necessary. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/ldr/loader.c (LdrPEProcessModule): Set name of the module into the module text structure. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/io/rw.c (NtReadFile, NtWriteFile): Use the correct test for whether to wait for the completion of i/o. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/cm/ntfunc.c (NtFlushKey): Request synchronous i/o from NtOpenFile. * ntoskrnl/cm/regfile (CmiInitPermanentRegistryHive): Request synchronous i/o from NtCreateFile. * ntoskrnl/dbg/kdb_stabs.c (LdrpLoadModuleSymbols): Request synchronous i/o from NtOpenFile. * ntoskrnl/ldr/sysdll.c (LdrpMapSystemDll): Request synchronous i/o from NtOpenFile. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/cc/view.c (CcRosSuggestFreeCacheSegment): Maintain the correct reference count. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/cc/view.c (CcRosFlushCacheSegment): New function to write back a modified cache segment. * ntoskrnl/cc/view.c (CcRosFlushDirtyPages): New function to flush some dirty pages from the cache. * ntoskrnl/cc/view.c (CcRosMarkDirtyCacheSegment): New function to mark a cache segment modified while mapped into memory as dirty. 2002-08-14 David Welch <welch@computer2.darkstar.org> * ntoskrnl/cc/pin.c (CcMapData, CcUnpinData, CcSetDirtyPinnedData): Store the dirty status in the BCB; don't write back dirty data immediately. 2002-08-14 David Welch <welch@computer2.darkstar.org> * include/ntos/mm.h: Added SEC_XXXX defines from 'Windows NT/2000 Native API Reference' 2002-08-14 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/ea.c (VfatSetExtendedAttributes): Empty placeholder for extended attribute functions. 2002-08-14 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/finfo.c (VfatSetAllocationSizeInformation): Added function to set allocation size. 2002-08-14 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/fcb.c (vfatFCBInitializeCache): Renamed to vfatFCBInitializeCacheFromVolume. * drivers/fs/vfat/fcb.c (vfatMakeFCBFromDirEntry): Don't initialise the cache with a file object representing the volume unless the FCB is for a directory. 2002-08-14 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/create.c (VfatPagingFileCreate): Added a new function for handling paging file only code. * drivers/fs/vfat/create.c (VfatSupersedeFile): Added a new function for doing a file supersede. * drivers/fs/vfat/create.c (VfatCreateFile): Reformatted and adjusted control flow. Set allocation size and extended attributes on create. * drivers/fs/vfat/create.c (VfatCreate): Removed goto. 2002-08-14 David Welch <welch@computer2.darkstar.org> * drivers/fs/vfat/cleanup.c (VfatCleanupFile): Renamed updEntry to VfatUpdateEntry. * drivers/fs/vfat/close.c (VfatCloseFile): Renamed updEntry to VfatUpdateEntry. * drivers/fs/vfat/dirwr.c (updEntry): Renamed to VfatUpdateEntry. * drivers/fs/vfat/dirwr.c (addEntry): Renamed to VfatAddEntry. 2002-08-14 David Welch <welch@computer2.darkstar.org> * apps/tests/sectest/sectest.c (main): Fixed formatting. svn path=/trunk/; revision=3331
This commit is contained in:
parent
54865265f0
commit
8cec2e609d
|
@ -1,3 +1,127 @@
|
|||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* subsys/smss/init.c (SmPagingFilesQueryRoutine): If possible
|
||||
take the size of the paging file from the registry.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/mm/section.c (MmCreateDataFileSection): Extend the
|
||||
section if necessary.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/mm/pagefile.c (NtCreatePagingFile): Set the file
|
||||
size using the FileAllocationInformation class.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/mm/anonmem.c (MmWritePageVirtualMemory): Implemented
|
||||
function to write anonymous memory pages to the swap file.
|
||||
* ntoskrnl/mm/anonmem.c (MmFreeVirtualMemoryPage): Free any
|
||||
swap page associated with the page.
|
||||
* ntoskrnl/mm/mpw.c (MmWriteDirtyPages): New function to find
|
||||
pages to write to disk.
|
||||
* ntoskrnl/mm/mpw.c (MmMpwThreadMain): Implemented MPW functionality.
|
||||
* ntoskrnl/mm/rmap.c (MmWritePagePhysicalAddress): New function
|
||||
to write a single page back to disk.
|
||||
* ntoskrnl/mm/rmap.c (MmSetCleanAllRmaps, MmSetDirtyAllRmaps,
|
||||
MmIsDirtyPageRmap): New rmap function to support the MPW thread.
|
||||
* ntoskrnl/mm/section.c (MmWritePageSectionView): Implemented
|
||||
function to write back section pages.
|
||||
* ntoskrnl/mm/section.c (MmFreeSectionPage): Free any swap
|
||||
entry associated with the page; mark pages shared with
|
||||
the cache as dirty if necessary.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/ldr/loader.c (LdrPEProcessModule): Set name of
|
||||
the module into the module text structure.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/io/rw.c (NtReadFile, NtWriteFile): Use the correct
|
||||
test for whether to wait for the completion of i/o.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/cm/ntfunc.c (NtFlushKey): Request synchronous i/o
|
||||
from NtOpenFile.
|
||||
* ntoskrnl/cm/regfile (CmiInitPermanentRegistryHive): Request
|
||||
synchronous i/o from NtCreateFile.
|
||||
* ntoskrnl/dbg/kdb_stabs.c (LdrpLoadModuleSymbols): Request
|
||||
synchronous i/o from NtOpenFile.
|
||||
* ntoskrnl/ldr/sysdll.c (LdrpMapSystemDll): Request synchronous i/o
|
||||
from NtOpenFile.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/cc/view.c (CcRosSuggestFreeCacheSegment): Maintain the
|
||||
correct reference count.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/cc/view.c (CcRosFlushCacheSegment): New function to
|
||||
write back a modified cache segment.
|
||||
* ntoskrnl/cc/view.c (CcRosFlushDirtyPages): New function to
|
||||
flush some dirty pages from the cache.
|
||||
* ntoskrnl/cc/view.c (CcRosMarkDirtyCacheSegment): New function to
|
||||
mark a cache segment modified while mapped into memory as dirty.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/cc/pin.c (CcMapData, CcUnpinData, CcSetDirtyPinnedData):
|
||||
Store the dirty status in the BCB; don't write back dirty data
|
||||
immediately.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* include/ntos/mm.h: Added SEC_XXXX defines from 'Windows NT/2000
|
||||
Native API Reference'
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* drivers/fs/vfat/ea.c (VfatSetExtendedAttributes): Empty
|
||||
placeholder for extended attribute functions.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* drivers/fs/vfat/finfo.c (VfatSetAllocationSizeInformation):
|
||||
Added function to set allocation size.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* drivers/fs/vfat/fcb.c (vfatFCBInitializeCache): Renamed
|
||||
to vfatFCBInitializeCacheFromVolume.
|
||||
* drivers/fs/vfat/fcb.c (vfatMakeFCBFromDirEntry): Don't
|
||||
initialise the cache with a file object representing the
|
||||
volume unless the FCB is for a directory.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* drivers/fs/vfat/create.c (VfatPagingFileCreate): Added a
|
||||
new function for handling paging file only code.
|
||||
* drivers/fs/vfat/create.c (VfatSupersedeFile): Added a
|
||||
new function for doing a file supersede.
|
||||
* drivers/fs/vfat/create.c (VfatCreateFile): Reformatted and
|
||||
adjusted control flow. Set allocation size and extended attributes
|
||||
on create.
|
||||
* drivers/fs/vfat/create.c (VfatCreate): Removed goto.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* drivers/fs/vfat/cleanup.c (VfatCleanupFile): Renamed
|
||||
updEntry to VfatUpdateEntry.
|
||||
* drivers/fs/vfat/close.c (VfatCloseFile): Renamed
|
||||
updEntry to VfatUpdateEntry.
|
||||
* drivers/fs/vfat/dirwr.c (updEntry): Renamed to
|
||||
VfatUpdateEntry.
|
||||
* drivers/fs/vfat/dirwr.c (addEntry): Renamed to
|
||||
VfatAddEntry.
|
||||
|
||||
2002-08-14 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* apps/tests/sectest/sectest.c (main): Fixed formatting.
|
||||
|
||||
2002-08-10 David Welch <welch@computer2.darkstar.org>
|
||||
|
||||
* ntoskrnl/mm/i386/page.c (MmSetPageProtect): Fixed
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: sectest.c,v 1.1 2002/05/13 20:15:33 chorns Exp $ */
|
||||
/* $Id: sectest.c,v 1.2 2002/08/14 20:58:31 dwelch Exp $ */
|
||||
#define UNICODE
|
||||
#define _UNICODE
|
||||
#include <windows.h>
|
||||
|
@ -6,12 +6,12 @@
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE hFile;
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
|
||||
printf("Section Test\n");
|
||||
|
||||
hFile = CreateFile(_T("sectest.txt"),
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
|
||||
printf("Section Test\n");
|
||||
|
||||
hFile = CreateFile(_T("sectest.txt"),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
|
@ -20,53 +20,52 @@ int main(int argc, char* argv[])
|
|||
0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Failed to create file (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Section = CreateFileMapping(
|
||||
hFile,
|
||||
NULL,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
4096,
|
||||
NULL);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to create section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Mapping view of section\n");
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
4096);
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section (%d)\n", GetLastError());
|
||||
printf("Failed to create file (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Clearing section\n");
|
||||
|
||||
Section = CreateFileMapping(hFile,
|
||||
NULL,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
4096,
|
||||
NULL);
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to create section (err=%d)", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Mapping view of section\n");
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
4096);
|
||||
printf("BaseAddress %x\n", (UINT) BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section (%d)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Clearing section\n");
|
||||
FillMemory(BaseAddress, 4096, ' ');
|
||||
printf("Copying test data to section\n");
|
||||
strcpy(BaseAddress, "test data");
|
||||
|
||||
printf("Copying test data to section\n");
|
||||
strcpy(BaseAddress, "test data");
|
||||
|
||||
if (!UnmapViewOfFile(BaseAddress))
|
||||
{
|
||||
printf("Failed to unmap view of file (%d)\n", GetLastError());
|
||||
printf("Failed to unmap view of file (%d)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if (!CloseHandle(hFile))
|
||||
{
|
||||
printf("Failed to close file (%d)\n", GetLastError());
|
||||
printf("Failed to close file (%d)\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cleanup.c,v 1.6 2002/08/08 17:54:12 dwelch Exp $
|
||||
/* $Id: cleanup.c,v 1.7 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -43,7 +43,7 @@ VfatCleanupFile(PDEVICE_EXTENSION DeviceExt,
|
|||
{
|
||||
if (pFcb->Flags & FCB_UPDATE_DIRENTRY)
|
||||
{
|
||||
updEntry (DeviceExt, FileObject);
|
||||
VfatUpdateEntry (DeviceExt, FileObject);
|
||||
pFcb->Flags &= ~FCB_UPDATE_DIRENTRY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: close.c,v 1.12 2002/06/10 21:15:58 hbirr Exp $
|
||||
/* $Id: close.c,v 1.13 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -63,7 +63,7 @@ VfatCloseFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
|||
}
|
||||
if (pFcb->Flags & FCB_UPDATE_DIRENTRY)
|
||||
{
|
||||
updEntry (DeviceExt, FileObject);
|
||||
VfatUpdateEntry (DeviceExt, FileObject);
|
||||
pFcb->Flags &= ~FCB_UPDATE_DIRENTRY;
|
||||
}
|
||||
FileObject->FsContext2 = NULL;
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
/* $Id: create.c,v 1.42 2002/06/26 18:36:41 hbirr Exp $
|
||||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: create.c,v 1.43 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/vfat/create.c
|
||||
* PURPOSE: VFAT Filesystem
|
||||
|
@ -554,6 +571,80 @@ VfatOpenFile (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
|||
return Status;
|
||||
}
|
||||
|
||||
VOID STATIC
|
||||
VfatPagingFileCreate(PDEVICE_EXTENSION DeviceExt, PVFATFCB Fcb)
|
||||
{
|
||||
ULONG CurrentCluster, NextCluster, i;
|
||||
NTSTATUS Status;
|
||||
|
||||
Fcb->Flags |= FCB_IS_PAGE_FILE;
|
||||
Fcb->FatChainSize =
|
||||
((Fcb->entry.FileSize + DeviceExt->FatInfo.BytesPerCluster - 1) /
|
||||
DeviceExt->FatInfo.BytesPerCluster);
|
||||
if (Fcb->FatChainSize)
|
||||
{
|
||||
Fcb->FatChain =
|
||||
ExAllocatePool(NonPagedPool, Fcb->FatChainSize * sizeof(ULONG));
|
||||
}
|
||||
|
||||
if (DeviceExt->FatInfo.FatType == FAT32)
|
||||
{
|
||||
CurrentCluster = Fcb->entry.FirstCluster +
|
||||
Fcb->entry.FirstClusterHigh * 65536;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentCluster = Fcb->entry.FirstCluster;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
if (Fcb->FatChainSize)
|
||||
{
|
||||
while (CurrentCluster != 0xffffffff)
|
||||
{
|
||||
Fcb->FatChain[i] = CurrentCluster;
|
||||
Status = GetNextCluster (DeviceExt, CurrentCluster,
|
||||
&NextCluster, FALSE);
|
||||
i++;
|
||||
CurrentCluster = NextCluster;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID STATIC
|
||||
VfatSupersedeFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject,
|
||||
PVFATFCB Fcb)
|
||||
{
|
||||
ULONG Cluster, NextCluster;
|
||||
NTSTATUS Status;
|
||||
|
||||
Fcb->entry.FileSize = 0;
|
||||
if (DeviceExt->FatInfo.FatType == FAT32)
|
||||
{
|
||||
Cluster = Fcb->entry.FirstCluster + Fcb->entry.FirstClusterHigh * 65536;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cluster = Fcb->entry.FirstCluster;
|
||||
}
|
||||
Fcb->entry.FirstCluster = 0;
|
||||
Fcb->entry.FirstClusterHigh = 0;
|
||||
VfatUpdateEntry (DeviceExt, FileObject);
|
||||
if (Fcb->RFCB.FileSize.QuadPart > 0)
|
||||
{
|
||||
Fcb->RFCB.AllocationSize.QuadPart = 0;
|
||||
Fcb->RFCB.FileSize.QuadPart = 0;
|
||||
Fcb->RFCB.ValidDataLength.QuadPart = 0;
|
||||
CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->RFCB.AllocationSize);
|
||||
}
|
||||
while (Cluster != 0xffffffff && Cluster > 1)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE);
|
||||
WriteCluster (DeviceExt, Cluster, 0);
|
||||
Cluster = NextCluster;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
/*
|
||||
|
@ -568,57 +659,57 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
PVFATCCB pCcb;
|
||||
PVFATFCB pFcb;
|
||||
PWCHAR c;
|
||||
BOOLEAN PagingFileCreate = FALSE;
|
||||
|
||||
BOOLEAN PagingFileCreate = FALSE;
|
||||
|
||||
/* Unpack the various parameters. */
|
||||
Stack = IoGetCurrentIrpStackLocation (Irp);
|
||||
assert (Stack);
|
||||
RequestedDisposition = ((Stack->Parameters.Create.Options >> 24) & 0xff);
|
||||
RequestedOptions =
|
||||
Stack->Parameters.Create.Options & FILE_VALID_OPTION_FLAGS;
|
||||
PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
|
||||
if ((RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
&& RequestedDisposition == FILE_SUPERSEDE)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
PagingFileCreate = (Stack->Flags & SL_OPEN_PAGING_FILE) ? TRUE : FALSE;
|
||||
FileObject = Stack->FileObject;
|
||||
DeviceExt = DeviceObject->DeviceExtension;
|
||||
assert (DeviceExt);
|
||||
|
||||
if (FileObject->FileName.Length == 0 && FileObject->RelatedFileObject == NULL)
|
||||
{
|
||||
/* This a open operation for the volume itself */
|
||||
if (RequestedDisposition == FILE_CREATE ||
|
||||
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||
RequestedDisposition == FILE_SUPERSEDE)
|
||||
/* Check their validity. */
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE &&
|
||||
RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_ACCESS_DENIED;
|
||||
return STATUS_ACCESS_DENIED;
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_NOT_A_DIRECTORY;
|
||||
return STATUS_NOT_A_DIRECTORY;
|
||||
}
|
||||
pFcb = DeviceExt->VolumeFcb;
|
||||
pCcb = ExAllocatePoolWithTag (NonPagedPool, sizeof (VFATCCB), TAG_CCB);
|
||||
if (pCcb == NULL)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
memset(pCcb, 0, sizeof(VFATCCB));
|
||||
FileObject->Flags |= FO_FCB_IS_VALID;
|
||||
FileObject->SectionObjectPointers = &pFcb->SectionObjectPointers;
|
||||
FileObject->FsContext = (PVOID) &pFcb->RFCB;
|
||||
FileObject->FsContext2 = pCcb;
|
||||
pCcb->pFcb = pFcb;
|
||||
pCcb->PtrFileObject = FileObject;
|
||||
pFcb->pDevExt = DeviceExt;
|
||||
pFcb->RefCount++;
|
||||
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
/* This a open operation for the volume itself */
|
||||
if (FileObject->FileName.Length == 0 &&
|
||||
FileObject->RelatedFileObject == NULL)
|
||||
{
|
||||
if (RequestedDisposition == FILE_CREATE ||
|
||||
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||
RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
return(STATUS_ACCESS_DENIED);
|
||||
}
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
{
|
||||
return(STATUS_NOT_A_DIRECTORY);
|
||||
}
|
||||
pFcb = DeviceExt->VolumeFcb;
|
||||
pCcb = ExAllocatePoolWithTag (NonPagedPool, sizeof (VFATCCB), TAG_CCB);
|
||||
if (pCcb == NULL)
|
||||
{
|
||||
return (STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
memset(pCcb, 0, sizeof(VFATCCB));
|
||||
FileObject->Flags |= FO_FCB_IS_VALID;
|
||||
FileObject->SectionObjectPointers = &pFcb->SectionObjectPointers;
|
||||
FileObject->FsContext = (PVOID) &pFcb->RFCB;
|
||||
FileObject->FsContext2 = pCcb;
|
||||
pCcb->pFcb = pFcb;
|
||||
pCcb->PtrFileObject = FileObject;
|
||||
pFcb->pDevExt = DeviceExt;
|
||||
pFcb->RefCount++;
|
||||
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for illegal characters in the file name
|
||||
|
@ -628,182 +719,119 @@ VfatCreateFile (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
{
|
||||
if (*c == L'*' || *c == L'?' || (*c == L'\\' && c[1] == L'\\'))
|
||||
{
|
||||
Irp->IoStatus.Information = 0;
|
||||
Irp->IoStatus.Status = STATUS_OBJECT_NAME_INVALID;
|
||||
return(STATUS_OBJECT_NAME_INVALID);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
/* Try opening the file. */
|
||||
Status = VfatOpenFile (DeviceExt, FileObject, FileObject->FileName.Buffer);
|
||||
|
||||
/*
|
||||
* If the directory containing the file to open doesn't exist then
|
||||
* fail immediately
|
||||
*/
|
||||
Irp->IoStatus.Information = 0;
|
||||
if (Status == STATUS_OBJECT_PATH_NOT_FOUND)
|
||||
if (Status == STATUS_OBJECT_PATH_NOT_FOUND ||
|
||||
Status == STATUS_INVALID_PARAMETER ||
|
||||
Status == STATUS_DELETE_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
return Status;
|
||||
return(Status);
|
||||
}
|
||||
if (Status == STATUS_INVALID_PARAMETER)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
return Status;
|
||||
}
|
||||
if (Status == STATUS_DELETE_PENDING)
|
||||
{
|
||||
Irp->IoStatus.Status = Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the file open failed then create the required file
|
||||
*/
|
||||
if (!NT_SUCCESS (Status))
|
||||
{
|
||||
/*
|
||||
* If the file open failed then create the required file
|
||||
*/
|
||||
{
|
||||
if (RequestedDisposition == FILE_CREATE ||
|
||||
RequestedDisposition == FILE_OPEN_IF ||
|
||||
RequestedDisposition == FILE_OVERWRITE_IF ||
|
||||
RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
CHECKPOINT;
|
||||
Status =
|
||||
addEntry (DeviceExt, FileObject, RequestedOptions,
|
||||
(Stack->Parameters.
|
||||
Create.FileAttributes & FILE_ATTRIBUTE_VALID_FLAGS));
|
||||
ULONG Attributes;
|
||||
Attributes = Stack->Parameters.Create.FileAttributes;
|
||||
Status = VfatAddEntry (DeviceExt, FileObject, RequestedOptions,
|
||||
Attributes & FILE_ATTRIBUTE_VALID_FLAGS);
|
||||
if (NT_SUCCESS (Status))
|
||||
{
|
||||
if (PagingFileCreate)
|
||||
{
|
||||
DPRINT("Creating a new paging file.\n");
|
||||
pCcb = FileObject->FsContext2;
|
||||
pFcb = pCcb->pFcb;
|
||||
pFcb->Flags |= FCB_IS_PAGE_FILE;
|
||||
pFcb->FatChainSize = 0;
|
||||
pFcb->FatChain = NULL;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Information = FILE_CREATED;
|
||||
}
|
||||
/* FIXME set size if AllocationSize requested */
|
||||
/* FIXME set extended attributes? */
|
||||
/* FIXME set share access */
|
||||
/* IoSetShareAccess(DesiredAccess,ShareAccess,FileObject,
|
||||
* ((PVfatCCB)(FileObject->FsContext2))->pFcb->FCBShareAccess);
|
||||
*/
|
||||
{
|
||||
pCcb = FileObject->FsContext2;
|
||||
pFcb = pCcb->pFcb;
|
||||
Irp->IoStatus.Information = FILE_CREATED;
|
||||
VfatSetAllocationSizeInformation(FileObject,
|
||||
pFcb,
|
||||
DeviceObject,
|
||||
&Irp->Overlay.AllocationSize);
|
||||
VfatSetExtendedAttributes(FileObject,
|
||||
Irp->AssociatedIrp.SystemBuffer,
|
||||
Stack->Parameters.Create.EaLength);
|
||||
IoSetShareAccess(0 /*DesiredAccess*/,
|
||||
Stack->Parameters.Create.ShareAccess,
|
||||
FileObject,
|
||||
&pFcb->FCBShareAccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Otherwise fail if the caller wanted to create a new file
|
||||
*/
|
||||
if (RequestedDisposition == FILE_CREATE)
|
||||
{
|
||||
/* Otherwise fail if the caller wanted to create a new file */
|
||||
if (RequestedDisposition == FILE_CREATE)
|
||||
{
|
||||
Irp->IoStatus.Information = FILE_EXISTS;
|
||||
Status = STATUS_OBJECT_NAME_COLLISION;
|
||||
return(STATUS_OBJECT_NAME_COLLISION);
|
||||
}
|
||||
pCcb = FileObject->FsContext2;
|
||||
pFcb = pCcb->pFcb;
|
||||
/*
|
||||
* If requested then delete the file and create a new one with the
|
||||
* same name
|
||||
*/
|
||||
if (RequestedDisposition == FILE_SUPERSEDE)
|
||||
|
||||
pCcb = FileObject->FsContext2;
|
||||
pFcb = pCcb->pFcb;
|
||||
|
||||
/*
|
||||
* Check the file has the requested attributes
|
||||
*/
|
||||
if (RequestedOptions & FILE_NON_DIRECTORY_FILE &&
|
||||
pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
VfatCloseFile (DeviceExt, FileObject);
|
||||
return(STATUS_FILE_IS_A_DIRECTORY);
|
||||
}
|
||||
if (RequestedOptions & FILE_DIRECTORY_FILE &&
|
||||
!(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
VfatCloseFile (DeviceExt, FileObject);
|
||||
return(STATUS_NOT_A_DIRECTORY);
|
||||
}
|
||||
|
||||
/* Supersede the file */
|
||||
if (RequestedDisposition == FILE_SUPERSEDE)
|
||||
{
|
||||
VfatSupersedeFile(DeviceExt, FileObject, pFcb);
|
||||
Irp->IoStatus.Information = FILE_SUPERSEDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If this create was for a paging file then make sure all the
|
||||
* information needed to manipulate it is locked in memory.
|
||||
*/
|
||||
if (PagingFileCreate)
|
||||
{
|
||||
ULONG Cluster, NextCluster;
|
||||
/* FIXME set size to 0 and free clusters */
|
||||
pFcb->entry.FileSize = 0;
|
||||
if (DeviceExt->FatInfo.FatType == FAT32)
|
||||
Cluster = pFcb->entry.FirstCluster
|
||||
+ pFcb->entry.FirstClusterHigh * 65536;
|
||||
else
|
||||
Cluster = pFcb->entry.FirstCluster;
|
||||
pFcb->entry.FirstCluster = 0;
|
||||
pFcb->entry.FirstClusterHigh = 0;
|
||||
updEntry (DeviceExt, FileObject);
|
||||
if ((ULONG)pFcb->RFCB.FileSize.QuadPart > 0)
|
||||
{
|
||||
pFcb->RFCB.AllocationSize.QuadPart = 0;
|
||||
pFcb->RFCB.FileSize.QuadPart = 0;
|
||||
pFcb->RFCB.ValidDataLength.QuadPart = 0;
|
||||
CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&pFcb->RFCB.AllocationSize);
|
||||
}
|
||||
while (Cluster != 0xffffffff && Cluster > 1)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE);
|
||||
WriteCluster (DeviceExt, Cluster, 0);
|
||||
Cluster = NextCluster;
|
||||
}
|
||||
VfatPagingFileCreate(DeviceExt, pFcb);
|
||||
}
|
||||
|
||||
/*
|
||||
* If this create was for a paging file then make sure all the
|
||||
* information needed to manipulate it is locked in memory.
|
||||
*/
|
||||
if (PagingFileCreate)
|
||||
{
|
||||
ULONG CurrentCluster, NextCluster, i;
|
||||
DPRINT("Open an existing paging file\n");
|
||||
pFcb->Flags |= FCB_IS_PAGE_FILE;
|
||||
pFcb->FatChainSize =
|
||||
((pFcb->entry.FileSize + DeviceExt->FatInfo.BytesPerCluster - 1) / DeviceExt->FatInfo.BytesPerCluster);
|
||||
if (pFcb->FatChainSize)
|
||||
{
|
||||
pFcb->FatChain = ExAllocatePool(NonPagedPool,
|
||||
pFcb->FatChainSize * sizeof(ULONG));
|
||||
}
|
||||
/* FIXME : test share access */
|
||||
/* FIXME : test write access if requested */
|
||||
|
||||
if (DeviceExt->FatInfo.FatType == FAT32)
|
||||
{
|
||||
CurrentCluster = pFcb->entry.FirstCluster +
|
||||
pFcb->entry.FirstClusterHigh * 65536;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentCluster = pFcb->entry.FirstCluster;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
if (pFcb->FatChainSize)
|
||||
{
|
||||
while (CurrentCluster != 0xffffffff)
|
||||
{
|
||||
pFcb->FatChain[i] = CurrentCluster;
|
||||
Status = GetNextCluster (DeviceExt, CurrentCluster, &NextCluster,
|
||||
FALSE);
|
||||
i++;
|
||||
CurrentCluster = NextCluster;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the file has the requested attributes
|
||||
*/
|
||||
if ((RequestedOptions & FILE_NON_DIRECTORY_FILE)
|
||||
&& (pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
Status = STATUS_FILE_IS_A_DIRECTORY;
|
||||
}
|
||||
if ((RequestedOptions & FILE_DIRECTORY_FILE)
|
||||
&& !(pFcb->entry.Attrib & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
Status = STATUS_NOT_A_DIRECTORY;
|
||||
}
|
||||
/* FIXME : test share access */
|
||||
/* FIXME : test write access if requested */
|
||||
if (!NT_SUCCESS (Status))
|
||||
VfatCloseFile (DeviceExt, FileObject);
|
||||
else
|
||||
Irp->IoStatus.Information = FILE_OPENED;
|
||||
/* FIXME : make supersed or overwrite if requested */
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
|
||||
return Status;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -813,33 +841,35 @@ NTSTATUS VfatCreate (PVFAT_IRP_CONTEXT IrpContext)
|
|||
*/
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
|
||||
assert (IrpContext);
|
||||
|
||||
// if (IrpContext->DeviceObject->Size == sizeof (DEVICE_OBJECT))
|
||||
|
||||
if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
|
||||
{
|
||||
/* DeviceObject represents FileSystem instead of logical volume */
|
||||
DPRINT ("FsdCreate called with file system\n");
|
||||
IrpContext->Irp->IoStatus.Information = FILE_OPENED;
|
||||
Status = STATUS_SUCCESS;
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
{
|
||||
/* DeviceObject represents FileSystem instead of logical volume */
|
||||
DPRINT ("FsdCreate called with file system\n");
|
||||
IrpContext->Irp->IoStatus.Information = FILE_OPENED;
|
||||
IrpContext->Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
IoCompleteRequest (IrpContext->Irp, IO_DISK_INCREMENT);
|
||||
VfatFreeIrpContext(IrpContext);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
if (!(IrpContext->Flags & IRPCONTEXT_CANWAIT))
|
||||
{
|
||||
return VfatQueueRequest (IrpContext);
|
||||
}
|
||||
|
||||
{
|
||||
return(VfatQueueRequest (IrpContext));
|
||||
}
|
||||
|
||||
IrpContext->Irp->IoStatus.Information = 0;
|
||||
ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource, TRUE);
|
||||
Status = VfatCreateFile (IrpContext->DeviceObject, IrpContext->Irp);
|
||||
ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
|
||||
|
||||
ByeBye:
|
||||
IrpContext->Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest (IrpContext->Irp, NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
|
||||
IoCompleteRequest (IrpContext->Irp,
|
||||
NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT);
|
||||
VfatFreeIrpContext(IrpContext);
|
||||
return Status;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dirwr.c,v 1.26 2002/06/10 21:19:18 hbirr Exp $
|
||||
/* $Id: dirwr.c,v 1.27 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -31,7 +31,8 @@ vfatIsShortIllegal(char c)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
NTSTATUS updEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
|
||||
NTSTATUS
|
||||
VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT pFileObject)
|
||||
/*
|
||||
* update an existing FAT entry
|
||||
*/
|
||||
|
@ -173,10 +174,10 @@ findDirSpace(PDEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,
|
||||
UCHAR ReqAttr)
|
||||
/*
|
||||
create a new FAT entry
|
||||
*/
|
||||
|
|
47
reactos/drivers/fs/vfat/ea.c
Normal file
47
reactos/drivers/fs/vfat/ea.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: ea.c,v 1.1 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/vfat/ea.c
|
||||
* PURPOSE: VFAT Filesystem
|
||||
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
||||
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include "vfat.h"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
VfatSetExtendedAttributes(PFILE_OBJECT FileObject,
|
||||
PVOID Ea,
|
||||
ULONG EaLength)
|
||||
{
|
||||
return(STATUS_EAS_NOT_SUPPORTED);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: fcb.c,v 1.16 2002/08/08 17:54:12 dwelch Exp $
|
||||
/* $Id: fcb.c,v 1.17 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
*
|
||||
* FILE: fcb.c
|
||||
|
@ -151,7 +151,7 @@ vfatGrabFCBFromTable(PDEVICE_EXTENSION pVCB, PWSTR pFileName)
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
vfatFCBInitializeCache (PVCB vcb, PVFATFCB fcb)
|
||||
vfatFCBInitializeCacheFromVolume (PVCB vcb, PVFATFCB fcb)
|
||||
{
|
||||
NTSTATUS status;
|
||||
PFILE_OBJECT fileObject;
|
||||
|
@ -231,7 +231,7 @@ vfatMakeRootFCB(PDEVICE_EXTENSION pVCB)
|
|||
FCB->RFCB.ValidDataLength.QuadPart = Size;
|
||||
FCB->RFCB.AllocationSize.QuadPart = Size;
|
||||
|
||||
vfatFCBInitializeCache(pVCB, FCB);
|
||||
vfatFCBInitializeCacheFromVolume(pVCB, FCB);
|
||||
vfatAddFCBToTable(pVCB, FCB);
|
||||
vfatGrabFCB(pVCB, FCB);
|
||||
|
||||
|
@ -257,8 +257,8 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
|
|||
PVFATFCB directoryFCB,
|
||||
PWSTR longName,
|
||||
PFAT_DIR_ENTRY dirEntry,
|
||||
ULONG dirIndex,
|
||||
PVFATFCB * fileFCB)
|
||||
ULONG dirIndex,
|
||||
PVFATFCB* fileFCB)
|
||||
{
|
||||
PVFATFCB rcFCB;
|
||||
WCHAR pathName [MAX_PATH];
|
||||
|
@ -315,9 +315,11 @@ vfatMakeFCBFromDirEntry(PVCB vcb,
|
|||
rcFCB->RFCB.FileSize.QuadPart = Size;
|
||||
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
|
||||
rcFCB->RFCB.AllocationSize.QuadPart = ROUND_UP(Size, vcb->FatInfo.BytesPerCluster);
|
||||
// DPRINT1("%S %d %d\n", longName, Size, (ULONG)rcFCB->RFCB.AllocationSize.QuadPart);
|
||||
vfatFCBInitializeCache (vcb, rcFCB);
|
||||
rcFCB->RefCount++;
|
||||
if (vfatFCBIsDirectory(vcb, rcFCB))
|
||||
{
|
||||
vfatFCBInitializeCacheFromVolume(vcb, rcFCB);
|
||||
}
|
||||
vfatAddFCBToTable (vcb, rcFCB);
|
||||
*fileFCB = rcFCB;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: finfo.c,v 1.14 2002/07/20 11:44:37 ekohl Exp $
|
||||
/* $Id: finfo.c,v 1.15 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -344,6 +344,91 @@ VfatGetAllInformation(PFILE_OBJECT FileObject,
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject,
|
||||
PVFATFCB Fcb,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PLARGE_INTEGER AllocationSize)
|
||||
{
|
||||
ULONG OldSize;
|
||||
ULONG Cluster;
|
||||
ULONG Offset;
|
||||
NTSTATUS Status;
|
||||
PDEVICE_EXTENSION DeviceExt =
|
||||
(PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
ULONG ClusterSize = DeviceExt->FatInfo.BytesPerCluster;
|
||||
ULONG NewSize = AllocationSize->u.LowPart;
|
||||
ULONG NextCluster;
|
||||
|
||||
OldSize = Fcb->entry.FileSize;
|
||||
if (OldSize == AllocationSize->u.LowPart)
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
Fcb->entry.FileSize = AllocationSize->u.LowPart;
|
||||
Fcb->RFCB.AllocationSize = *AllocationSize;
|
||||
Fcb->RFCB.FileSize = *AllocationSize;
|
||||
Fcb->RFCB.ValidDataLength = *AllocationSize;
|
||||
CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->RFCB.AllocationSize);
|
||||
|
||||
if (DeviceExt->FatInfo.FatType == FAT32)
|
||||
{
|
||||
Cluster = Fcb->entry.FirstCluster + Fcb->entry.FirstClusterHigh * 65536;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cluster = Fcb->entry.FirstCluster;
|
||||
}
|
||||
|
||||
if (OldSize > NewSize &&
|
||||
ROUND_UP(OldSize, ClusterSize) > ROUND_DOWN(NewSize, ClusterSize))
|
||||
{
|
||||
/* Seek to the new end of the file. */
|
||||
Offset = 0;
|
||||
while (Cluster != 0xffffffff && Cluster > 1 && Offset <= NewSize)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE);
|
||||
Cluster = NextCluster;
|
||||
Offset += ClusterSize;
|
||||
}
|
||||
/* Free everything beyond this point. */
|
||||
while (Cluster != 0xffffffff && Cluster > 1)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, FALSE);
|
||||
WriteCluster (DeviceExt, Cluster, 0xFFFFFFFF);
|
||||
Cluster = NextCluster;
|
||||
}
|
||||
if (NewSize == 0)
|
||||
{
|
||||
Fcb->entry.FirstCluster = 0;
|
||||
Fcb->entry.FirstClusterHigh = 0;
|
||||
}
|
||||
}
|
||||
else if (NewSize > OldSize &&
|
||||
ROUND_UP(NewSize, ClusterSize) > ROUND_DOWN(OldSize, ClusterSize))
|
||||
{
|
||||
/* Seek to the new end of the file. */
|
||||
Offset = 0;
|
||||
if (OldSize == 0)
|
||||
{
|
||||
assert(Cluster == 0);
|
||||
Status = GetNextCluster (DeviceExt, 0, &NextCluster, TRUE);
|
||||
Fcb->entry.FirstCluster = (NextCluster & 0x0000FFFF) >> 0;
|
||||
Fcb->entry.FirstClusterHigh = (NextCluster & 0xFFFF0000) >> 16;
|
||||
Cluster = NextCluster;
|
||||
Offset += ClusterSize;
|
||||
}
|
||||
while (Cluster != 0xffffffff && Cluster > 1 && Offset <= NewSize)
|
||||
{
|
||||
Status = GetNextCluster (DeviceExt, Cluster, &NextCluster, TRUE);
|
||||
Cluster = NextCluster;
|
||||
Offset += ClusterSize;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the on-disk directory entry */
|
||||
VfatUpdateEntry(DeviceExt, FileObject);
|
||||
}
|
||||
|
||||
NTSTATUS VfatQueryInformation(PVFAT_IRP_CONTEXT IrpContext)
|
||||
/*
|
||||
|
@ -454,34 +539,36 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
|
|||
PVFATFCB FCB = NULL;
|
||||
NTSTATUS RC = STATUS_SUCCESS;
|
||||
PVOID SystemBuffer;
|
||||
|
||||
BOOL CanWait = IrpContext->Flags & IRPCONTEXT_CANWAIT;
|
||||
|
||||
/* PRECONDITION */
|
||||
assert(IrpContext);
|
||||
|
||||
|
||||
DPRINT("VfatSetInformation(IrpContext %x)\n", IrpContext);
|
||||
|
||||
|
||||
/* INITIALIZATION */
|
||||
FileInformationClass = IrpContext->Stack->Parameters.SetFile.FileInformationClass;
|
||||
FileInformationClass =
|
||||
IrpContext->Stack->Parameters.SetFile.FileInformationClass;
|
||||
FCB = ((PVFATCCB) IrpContext->FileObject->FsContext2)->pFcb;
|
||||
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
|
||||
DPRINT("FileInformationClass %d\n", FileInformationClass);
|
||||
DPRINT("SystemBuffer %x\n", SystemBuffer);
|
||||
|
||||
|
||||
if (FCB->Flags & FCB_IS_PAGE_FILE)
|
||||
{
|
||||
if (!ExAcquireResourceExclusiveLite(&FCB->PagingIoResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
|
||||
{
|
||||
return VfatQueueRequest (IrpContext);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (!ExAcquireResourceExclusiveLite(&FCB->PagingIoResource, CanWait))
|
||||
{
|
||||
return(VfatQueueRequest (IrpContext));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ExAcquireResourceExclusiveLite(&FCB->MainResource, IrpContext->Flags & IRPCONTEXT_CANWAIT))
|
||||
{
|
||||
return VfatQueueRequest (IrpContext);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (!ExAcquireResourceExclusiveLite(&FCB->MainResource, CanWait))
|
||||
{
|
||||
return(VfatQueueRequest (IrpContext));
|
||||
}
|
||||
}
|
||||
|
||||
switch (FileInformationClass)
|
||||
{
|
||||
|
@ -497,9 +584,14 @@ NTSTATUS VfatSetInformation(PVFAT_IRP_CONTEXT IrpContext)
|
|||
IrpContext->DeviceObject,
|
||||
SystemBuffer);
|
||||
break;
|
||||
case FileBasicInformation:
|
||||
case FileAllocationInformation:
|
||||
case FileAllocationInformation:
|
||||
case FileEndOfFileInformation:
|
||||
RC = VfatSetAllocationSizeInformation(IrpContext->FileObject,
|
||||
FCB,
|
||||
IrpContext->DeviceObject,
|
||||
(PLARGE_INTEGER)SystemBuffer);
|
||||
break;
|
||||
case FileBasicInformation:
|
||||
case FileRenameInformation:
|
||||
RC = STATUS_NOT_IMPLEMENTED;
|
||||
break;
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
/* $Id: iface.c,v 1.63 2002/05/15 18:05:00 ekohl Exp $
|
||||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: iface.c,v 1.64 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/vfat/iface.c
|
||||
* PURPOSE: VFAT Filesystem
|
||||
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
||||
* UPDATE HISTORY:
|
||||
* ?? Created
|
||||
* 24-10-1998 Fixed bugs in long filename support
|
||||
* Fixed a bug that prevented unsuccessful file open requests
|
||||
* being reported
|
||||
* Now works with long filenames that span over a sector
|
||||
* boundary
|
||||
* 28-10-1998 Reads entire FAT into memory
|
||||
* VFatReadSector modified to read in more than one sector at a
|
||||
* time
|
||||
* 7-11-1998 Fixed bug that assumed that directory data could be
|
||||
* fragmented
|
||||
* 8-12-1998 Added FAT32 support
|
||||
* Added initial writability functions
|
||||
* WARNING: DO NOT ATTEMPT TO TEST WRITABILITY FUNCTIONS!!!
|
||||
* 12-12-1998 Added basic support for FILE_STANDARD_INFORMATION request
|
||||
*
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
@ -35,7 +35,6 @@
|
|||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
|
||||
PVFAT_GLOBAL_DATA VfatGlobalData;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
@ -55,10 +54,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
UNICODE_STRING DeviceName;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("VFAT 0.0.6\n");
|
||||
|
||||
RtlInitUnicodeString(&DeviceName,
|
||||
L"\\Fat");
|
||||
RtlInitUnicodeString(&DeviceName, L"\\Fat");
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(VFAT_GLOBAL_DATA),
|
||||
&DeviceName,
|
||||
|
@ -84,15 +80,17 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
|
|||
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
|
||||
VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
|
||||
VfatBuildRequest;
|
||||
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown;
|
||||
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatBuildRequest;
|
||||
|
||||
DriverObject->DriverUnload = NULL;
|
||||
|
||||
IoRegisterFileSystem(DeviceObject);
|
||||
return STATUS_SUCCESS;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.39 2002/06/26 18:36:41 hbirr Exp $
|
||||
# $Id: makefile,v 1.40 2002/08/14 20:58:31 dwelch Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -25,7 +25,8 @@ TARGET_OBJECTS = \
|
|||
string.o \
|
||||
volume.o \
|
||||
misc.o \
|
||||
fsctl.o
|
||||
fsctl.o \
|
||||
ea.o
|
||||
|
||||
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: rw.c,v 1.43 2002/06/26 18:36:41 hbirr Exp $
|
||||
/* $Id: rw.c,v 1.44 2002/08/14 20:58:31 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -20,11 +20,6 @@
|
|||
|
||||
#include "vfat.h"
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
||||
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
|
@ -52,15 +47,15 @@ NextCluster(PDEVICE_EXTENSION DeviceExt,
|
|||
if (Extend)
|
||||
{
|
||||
Fcb->FatChain = ExAllocatePool(NonPagedPool, sizeof(ULONG));
|
||||
if (!Fcb->FatChain)
|
||||
if (Fcb->FatChain == NULL)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
return(STATUS_NO_MEMORY);
|
||||
}
|
||||
Status = GetNextCluster(DeviceExt, 0, CurrentCluster, TRUE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(Fcb->FatChain);
|
||||
return Status;
|
||||
return(Status);
|
||||
}
|
||||
Fcb->FatChain[0] = *CurrentCluster;
|
||||
Fcb->FatChainSize = 1;
|
||||
|
@ -1119,7 +1114,7 @@ NTSTATUS VfatWrite (PVFAT_IRP_CONTEXT IrpContext)
|
|||
// update dates/times and length
|
||||
if (OldAllocationSize != Fcb->RFCB.AllocationSize.u.LowPart)
|
||||
{
|
||||
updEntry (IrpContext->DeviceExt, IrpContext->FileObject);
|
||||
VfatUpdateEntry (IrpContext->DeviceExt, IrpContext->FileObject);
|
||||
Fcb->Flags &= ~FCB_UPDATE_DIRENTRY;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
/* $Id: vfat.h,v 1.43 2002/06/26 18:36:41 hbirr Exp $ */
|
||||
/* $Id: vfat.h,v 1.44 2002/08/14 20:58:32 dwelch Exp $ */
|
||||
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
||||
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
|
||||
|
||||
struct _BootSector
|
||||
{
|
||||
unsigned char magic0, res0, magic1;
|
||||
|
@ -114,8 +117,7 @@ typedef struct
|
|||
ULONG NumberOfClusters;
|
||||
ULONG FatType;
|
||||
ULONG Sectors;
|
||||
}
|
||||
FATINFO, *PFATINFO;
|
||||
} FATINFO, *PFATINFO;
|
||||
|
||||
struct _VFATFCB;
|
||||
|
||||
|
@ -133,18 +135,16 @@ typedef struct
|
|||
ULONG LastAvailableCluster;
|
||||
ULONG AvailableClusters;
|
||||
BOOLEAN AvailableClustersValid;
|
||||
ULONG Flags;
|
||||
ULONG Flags;
|
||||
struct _VFATFCB * VolumeFcb;
|
||||
}
|
||||
DEVICE_EXTENSION, *PDEVICE_EXTENSION, VCB, *PVCB;
|
||||
} DEVICE_EXTENSION, *PDEVICE_EXTENSION, VCB, *PVCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PDRIVER_OBJECT DriverObject;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
ULONG Flags;
|
||||
}
|
||||
VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
|
||||
} VFAT_GLOBAL_DATA, *PVFAT_GLOBAL_DATA;
|
||||
|
||||
extern PVFAT_GLOBAL_DATA VfatGlobalData;
|
||||
|
||||
|
@ -174,12 +174,12 @@ typedef struct _VFATFCB
|
|||
ERESOURCE PagingIoResource;
|
||||
ERESOURCE MainResource;
|
||||
ULONG TimerCount;
|
||||
SHARE_ACCESS FCBShareAccess;
|
||||
|
||||
/* Structure members used only for paging files. */
|
||||
ULONG FatChainSize;
|
||||
PULONG FatChain;
|
||||
}
|
||||
VFATFCB, *PVFATFCB;
|
||||
} VFATFCB, *PVFATFCB;
|
||||
|
||||
typedef struct _VFATCCB
|
||||
{
|
||||
|
@ -194,8 +194,7 @@ typedef struct _VFATCCB
|
|||
ULONG LastCluster;
|
||||
ULONG LastOffset;
|
||||
|
||||
}
|
||||
VFATCCB, *PVFATCCB;
|
||||
} VFATCCB, *PVFATCCB;
|
||||
|
||||
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
||||
|
||||
|
@ -232,8 +231,7 @@ typedef struct
|
|||
UCHAR MajorFunction;
|
||||
UCHAR MinorFunction;
|
||||
PFILE_OBJECT FileObject;
|
||||
}
|
||||
VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
|
||||
} VFAT_IRP_CONTEXT, *PVFAT_IRP_CONTEXT;
|
||||
|
||||
/* ------------------------------------------------------ shutdown.c */
|
||||
|
||||
|
@ -326,6 +324,12 @@ NTSTATUS VfatQueryInformation (PVFAT_IRP_CONTEXT IrpContext);
|
|||
|
||||
NTSTATUS VfatSetInformation (PVFAT_IRP_CONTEXT IrpContext);
|
||||
|
||||
NTSTATUS
|
||||
VfatSetAllocationSizeInformation(PFILE_OBJECT FileObject,
|
||||
PVFATFCB Fcb,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PLARGE_INTEGER AllocationSize);
|
||||
|
||||
/* --------------------------------------------------------- iface.c */
|
||||
|
||||
NTSTATUS STDCALL DriverEntry (PDRIVER_OBJECT DriverObject,
|
||||
|
@ -333,12 +337,12 @@ NTSTATUS STDCALL DriverEntry (PDRIVER_OBJECT DriverObject,
|
|||
|
||||
/* --------------------------------------------------------- dirwr.c */
|
||||
|
||||
NTSTATUS addEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,UCHAR ReqAttr);
|
||||
NTSTATUS VfatAddEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject,
|
||||
ULONG RequestedOptions,UCHAR ReqAttr);
|
||||
|
||||
NTSTATUS updEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject);
|
||||
NTSTATUS VfatUpdateEntry (PDEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT pFileObject);
|
||||
|
||||
NTSTATUS delEntry(PDEVICE_EXTENSION,
|
||||
PFILE_OBJECT);
|
||||
|
@ -516,5 +520,8 @@ PVOID VfatGetUserBuffer(IN PIRP);
|
|||
NTSTATUS VfatLockUserBuffer(IN PIRP, IN ULONG,
|
||||
IN LOCK_OPERATION);
|
||||
|
||||
|
||||
NTSTATUS
|
||||
VfatSetExtendedAttributes(PFILE_OBJECT FileObject,
|
||||
PVOID Ea,
|
||||
ULONG EaLength);
|
||||
/* EOF */
|
||||
|
|
|
@ -11,8 +11,6 @@ struct _CACHE_SEGMENT;
|
|||
|
||||
typedef struct _CACHE_SEGMENT* PCACHE_SEGMENT;
|
||||
|
||||
NTSTATUS STDCALL
|
||||
CcRosFlushCacheSegment (struct _CACHE_SEGMENT* CacheSeg);
|
||||
NTSTATUS STDCALL
|
||||
CcRosReleaseCacheSegment (struct _BCB* Bcb,
|
||||
struct _CACHE_SEGMENT* CacheSeg,
|
||||
|
|
|
@ -13,10 +13,20 @@
|
|||
#ifndef __INCLUDE_MM_H
|
||||
#define __INCLUDE_MM_H
|
||||
|
||||
#if 0
|
||||
#define SEC_COMMIT (134217728)
|
||||
#define SEC_IMAGE (16777216)
|
||||
#define SEC_NOCACHE (268435456)
|
||||
#define SEC_RESERVE (67108864)
|
||||
#else
|
||||
#define SEC_BASED (0x00200000)
|
||||
#define SEC_NO_CHANGE (0x00400000)
|
||||
#define SEC_IMAGE (0x01000000)
|
||||
#define SEC_VLM (0x02000000)
|
||||
#define SEC_RESERVE (0x04000000)
|
||||
#define SEC_COMMIT (0x08000000)
|
||||
#define SEC_NOCACHE (0x10000000)
|
||||
#endif
|
||||
#define PAGE_READONLY (2)
|
||||
#define PAGE_READWRITE (4)
|
||||
#define PAGE_WRITECOPY (8)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: pin.c,v 1.3 2002/07/17 21:04:55 dwelch Exp $
|
||||
/* $Id: pin.c,v 1.4 2002/08/14 20:58:32 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -32,6 +32,7 @@ typedef struct _INTERNAL_BCB
|
|||
{
|
||||
PUBLIC_BCB PFCB;
|
||||
PCACHE_SEGMENT CacheSegment;
|
||||
BOOLEAN Dirty;
|
||||
} INTERNAL_BCB, *PINTERNAL_BCB;
|
||||
|
||||
BOOLEAN STDCALL
|
||||
|
@ -95,6 +96,7 @@ CcMapData (IN PFILE_OBJECT FileObject,
|
|||
return FALSE;
|
||||
}
|
||||
iBcb->CacheSegment = CacheSeg;
|
||||
iBcb->Dirty = FALSE;
|
||||
iBcb->PFCB.MappedLength = Length;
|
||||
iBcb->PFCB.MappedFileOffset.QuadPart = FileOffset->QuadPart;
|
||||
*pBcb = (PVOID)iBcb;
|
||||
|
@ -106,7 +108,7 @@ CcUnpinData (IN PVOID Bcb)
|
|||
{
|
||||
PINTERNAL_BCB iBcb = Bcb;
|
||||
CcRosReleaseCacheSegment(iBcb->CacheSegment->Bcb, iBcb->CacheSegment, TRUE,
|
||||
FALSE, FALSE);
|
||||
iBcb->Dirty, FALSE);
|
||||
ExFreePool(iBcb);
|
||||
}
|
||||
|
||||
|
@ -115,7 +117,6 @@ CcSetDirtyPinnedData (IN PVOID Bcb,
|
|||
IN PLARGE_INTEGER Lsn)
|
||||
{
|
||||
PINTERNAL_BCB iBcb = Bcb;
|
||||
/* FIXME: write only the modifyed 4-pages back */
|
||||
WriteCacheSegment(iBcb->CacheSegment);
|
||||
iBcb->Dirty = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: view.c,v 1.45 2002/08/08 17:54:13 dwelch Exp $
|
||||
/* $Id: view.c,v 1.46 2002/08/14 20:58:32 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/cc/view.c
|
||||
* PURPOSE: Cache manager
|
||||
|
@ -81,6 +80,71 @@ CcRosInternalFreeCacheSegment(PBCB Bcb, PCACHE_SEGMENT CacheSeg);
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STATIC
|
||||
CcRosFlushCacheSegment(PCACHE_SEGMENT CacheSegment)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
Status = WriteCacheSegment(CacheSegment);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
CacheSegment->Dirty = FALSE;
|
||||
RemoveEntryList(&CacheSegment->DirtySegmentListEntry);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CcRosFlushDirtyPages(ULONG Target, PULONG Count)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PCACHE_SEGMENT current;
|
||||
ULONG PagesPerSegment;
|
||||
BOOLEAN Locked;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CcRosFlushDirtyPages(Target %d)\n", Target);
|
||||
|
||||
(*Count) = 0;
|
||||
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
current_entry = DirtySegmentListHead.Flink;
|
||||
while (current_entry != &DirtySegmentListHead && Target > 0)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry, CACHE_SEGMENT,
|
||||
DirtySegmentListEntry);
|
||||
current_entry = current_entry->Flink;
|
||||
Locked = ExTryToAcquireFastMutex(¤t->Lock);
|
||||
if (!Locked)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
assert(current->Dirty);
|
||||
if (current->ReferenceCount > 0)
|
||||
{
|
||||
ExReleaseFastMutex(¤t->Lock);
|
||||
continue;
|
||||
}
|
||||
current->ReferenceCount++;
|
||||
ExReleaseFastMutex(&ViewLock);
|
||||
PagesPerSegment = current->Bcb->CacheSegmentSize / PAGESIZE;
|
||||
Status = CcRosFlushCacheSegment(current);
|
||||
current->ReferenceCount--;
|
||||
ExReleaseFastMutex(¤t->Lock);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CC: Failed to flush cache segment.\n");
|
||||
}
|
||||
(*Count) += PagesPerSegment;
|
||||
Target -= PagesPerSegment;
|
||||
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
current_entry = DirtySegmentListHead.Flink;
|
||||
}
|
||||
ExReleaseFastMutex(&ViewLock);
|
||||
DPRINT("CcRosTrimCache() finished\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CcRosTrimCache(ULONG Target, ULONG Priority, PULONG NrFreed)
|
||||
/*
|
||||
|
@ -194,6 +258,28 @@ PCACHE_SEGMENT CcRosLookupCacheSegment(PBCB Bcb, ULONG FileOffset)
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset)
|
||||
{
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
|
||||
ExAcquireFastMutex(&ViewLock);
|
||||
CacheSeg = CcRosLookupCacheSegment(Bcb, FileOffset);
|
||||
if (CacheSeg == NULL)
|
||||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
ExAcquireFastMutex(&CacheSeg->Lock);
|
||||
if (!CacheSeg->Dirty)
|
||||
{
|
||||
InsertTailList(&DirtySegmentListHead, &CacheSeg->DirtySegmentListEntry);
|
||||
}
|
||||
CacheSeg->Dirty = TRUE;
|
||||
ExReleaseFastMutex(&CacheSeg->Lock);
|
||||
ExReleaseFastMutex(&ViewLock);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
CcRosSuggestFreeCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
|
||||
{
|
||||
|
@ -240,6 +326,7 @@ CcRosUnmapCacheSegment(PBCB Bcb, ULONG FileOffset, BOOLEAN NowDirty)
|
|||
ExAcquireFastMutex(&CacheSeg->Lock);
|
||||
CacheSeg->MappedCount--;
|
||||
CacheSeg->Dirty = CacheSeg->Dirty || NowDirty;
|
||||
CacheSeg->ReferenceCount--;
|
||||
ExReleaseFastMutex(&CacheSeg->Lock);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -516,7 +603,7 @@ CcRosDeleteFileCache(PFILE_OBJECT FileObject, PBCB Bcb)
|
|||
PCACHE_SEGMENT current;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("CcRosReleaseFileCache(FileObject %x, Bcb %x)\n", Bcb->FileObject,
|
||||
DPRINT("CcRosDeleteFileCache(FileObject %x, Bcb %x)\n", Bcb->FileObject,
|
||||
Bcb);
|
||||
|
||||
MmFreeSectionSegments(Bcb->FileObject);
|
||||
|
|
|
@ -703,11 +703,11 @@ END FIXME*/
|
|||
NULL);
|
||||
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
0);
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
NULL,
|
||||
0,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
|
@ -505,7 +505,7 @@ CmiInitPermanentRegistryHive(PREGISTRY_HIVE RegistryHive,
|
|||
FILE_ATTRIBUTE_NORMAL,
|
||||
0,
|
||||
CreateDisposition,
|
||||
FILE_NON_DIRECTORY_FILE,
|
||||
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ LdrpLoadModuleSymbols(PUNICODE_STRING FileName,
|
|||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
0,
|
||||
0);
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Could not open symbol file: %wZ\n", &SymFileName);
|
||||
|
|
30
reactos/ntoskrnl/include/internal/arch/ke.h
Normal file
30
reactos/ntoskrnl/include/internal/arch/ke.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H
|
||||
|
||||
#ifdef i386
|
||||
#include <internal/i386/ke.h>
|
||||
#else
|
||||
#error "Unknown processor"
|
||||
#endif
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_ARCH_KE_H */
|
||||
|
||||
/* EOF */
|
|
@ -1,3 +1,21 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_MM_H
|
||||
|
||||
|
|
33
reactos/ntoskrnl/include/internal/arch/ps.h
Normal file
33
reactos/ntoskrnl/include/internal/arch/ps.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H
|
||||
|
||||
#ifdef i386
|
||||
#include <internal/i386/ps.h>
|
||||
#define KiArchContextSwitch Ki386ContextSwitch
|
||||
#define KiArchInitThread Ke386InitThread
|
||||
#define KiArchInitThreadWithContext Ke386InitThreadWithContext
|
||||
#else
|
||||
#error "Unknown processor"
|
||||
#endif
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_ARCH_PS_H */
|
||||
|
||||
/* EOF */
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __INCLUDE_INTERNAL_CC_H
|
||||
#define __INCLUDE_INTERNAL_CC_H
|
||||
/* $Id: cc.h,v 1.12 2002/08/08 17:54:14 dwelch Exp $ */
|
||||
/* $Id: cc.h,v 1.13 2002/08/14 20:58:34 dwelch Exp $ */
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
typedef struct _BCB
|
||||
|
@ -77,4 +77,9 @@ CcRosGetCacheSegmentChain(PBCB Bcb,
|
|||
ULONG Length,
|
||||
PCACHE_SEGMENT* CacheSeg);
|
||||
VOID CcInitCacheZeroPage(VOID);
|
||||
NTSTATUS
|
||||
CcRosMarkDirtyCacheSegment(PBCB Bcb, ULONG FileOffset);
|
||||
NTSTATUS
|
||||
CcRosFlushDirtyPages(ULONG Target, PULONG Count);
|
||||
|
||||
#endif
|
||||
|
|
138
reactos/ntoskrnl/include/internal/i386/ke.h
Normal file
138
reactos/ntoskrnl/include/internal/i386/ke.h
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H
|
||||
|
||||
#define KTRAP_FRAME_DEBUGEBP (0x0)
|
||||
#define KTRAP_FRAME_DEBUGEIP (0x4)
|
||||
#define KTRAP_FRAME_DEBUGARGMARK (0x8)
|
||||
#define KTRAP_FRAME_DEBUGPOINTER (0xC)
|
||||
#define KTRAP_FRAME_TEMPCS (0x10)
|
||||
#define KTRAP_FRAME_TEMPEIP (0x14)
|
||||
#define KTRAP_FRAME_DR0 (0x18)
|
||||
#define KTRAP_FRAME_DR1 (0x1C)
|
||||
#define KTRAP_FRAME_DR2 (0x20)
|
||||
#define KTRAP_FRAME_DR3 (0x24)
|
||||
#define KTRAP_FRAME_DR6 (0x28)
|
||||
#define KTRAP_FRAME_DR7 (0x2C)
|
||||
#define KTRAP_FRAME_GS (0x30)
|
||||
#define KTRAP_FRAME_RESERVED1 (0x32)
|
||||
#define KTRAP_FRAME_ES (0x34)
|
||||
#define KTRAP_FRAME_RESERVED2 (0x36)
|
||||
#define KTRAP_FRAME_DS (0x38)
|
||||
#define KTRAP_FRAME_RESERVED3 (0x3A)
|
||||
#define KTRAP_FRAME_EDX (0x3C)
|
||||
#define KTRAP_FRAME_ECX (0x40)
|
||||
#define KTRAP_FRAME_EAX (0x44)
|
||||
#define KTRAP_FRAME_PREVIOUS_MODE (0x48)
|
||||
#define KTRAP_FRAME_EXCEPTION_LIST (0x4C)
|
||||
#define KTRAP_FRAME_FS (0x50)
|
||||
#define KTRAP_FRAME_RESERVED4 (0x52)
|
||||
#define KTRAP_FRAME_EDI (0x54)
|
||||
#define KTRAP_FRAME_ESI (0x58)
|
||||
#define KTRAP_FRAME_EBX (0x5C)
|
||||
#define KTRAP_FRAME_EBP (0x60)
|
||||
#define KTRAP_FRAME_ERROR_CODE (0x64)
|
||||
#define KTRAP_FRAME_EIP (0x68)
|
||||
#define KTRAP_FRAME_CS (0x6C)
|
||||
#define KTRAP_FRAME_EFLAGS (0x70)
|
||||
#define KTRAP_FRAME_ESP (0x74)
|
||||
#define KTRAP_FRAME_SS (0x78)
|
||||
#define KTRAP_FRAME_RESERVED5 (0x7A)
|
||||
#define KTRAP_FRAME_V86_ES (0x7C)
|
||||
#define KTRAP_FRAME_RESERVED6 (0x7E)
|
||||
#define KTRAP_FRAME_V86_DS (0x80)
|
||||
#define KTRAP_FRAME_RESERVED7 (0x82)
|
||||
#define KTRAP_FRAME_V86_FS (0x84)
|
||||
#define KTRAP_FRAME_RESERVED8 (0x86)
|
||||
#define KTRAP_FRAME_V86_GS (0x88)
|
||||
#define KTRAP_FRAME_RESERVED9 (0x8A)
|
||||
#define KTRAP_FRAME_SIZE (0x8C)
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
typedef struct _KTRAP_FRAME
|
||||
{
|
||||
PVOID DebugEbp;
|
||||
PVOID DebugEip;
|
||||
PVOID DebugArgMark;
|
||||
PVOID DebugPointer;
|
||||
PVOID TempCs;
|
||||
PVOID TempEip;
|
||||
PVOID Dr0;
|
||||
PVOID Dr1;
|
||||
PVOID Dr2;
|
||||
PVOID Dr3;
|
||||
PVOID Dr6;
|
||||
PVOID Dr7;
|
||||
USHORT Gs;
|
||||
USHORT Reserved1;
|
||||
USHORT Es;
|
||||
USHORT Reserved2;
|
||||
USHORT Ds;
|
||||
USHORT Reserved3;
|
||||
ULONG Edx;
|
||||
ULONG Ecx;
|
||||
ULONG Eax;
|
||||
ULONG PreviousMode;
|
||||
PVOID ExceptionList;
|
||||
USHORT Fs;
|
||||
USHORT Reserved4;
|
||||
ULONG Edi;
|
||||
ULONG Esi;
|
||||
ULONG Ebx;
|
||||
ULONG Ebp;
|
||||
ULONG ErrorCode;
|
||||
ULONG Eip;
|
||||
ULONG Cs;
|
||||
ULONG Eflags;
|
||||
ULONG Esp;
|
||||
USHORT Ss;
|
||||
USHORT Reserved5;
|
||||
USHORT V86_Es;
|
||||
USHORT Reserved6;
|
||||
USHORT V86_Ds;
|
||||
USHORT Reserved7;
|
||||
USHORT V86_Fs;
|
||||
USHORT Reserved8;
|
||||
USHORT V86_Gs;
|
||||
USHORT Reserved9;
|
||||
} KTRAP_FRAME, *PKTRAP_FRAME;
|
||||
|
||||
struct _KPCR;
|
||||
VOID
|
||||
KiInitializeGdt(struct _KPCR* Pcr);
|
||||
VOID
|
||||
Ki386ApplicationProcessorInitializeTSS(VOID);
|
||||
VOID
|
||||
Ki386BootInitializeTSS(VOID);
|
||||
VOID
|
||||
KiGdtPrepareForApplicationProcessorInit(ULONG Id);
|
||||
VOID
|
||||
Ki386InitializeLdt(VOID);
|
||||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||
VOID KeFreeGdtSelector(ULONG Entry);
|
||||
VOID
|
||||
NtEarlyInitVdm(VOID);
|
||||
|
||||
#endif /* __ASM__ */
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_KE_H */
|
||||
|
||||
/* EOF */
|
94
reactos/ntoskrnl/include/internal/i386/ps.h
Normal file
94
reactos/ntoskrnl/include/internal/i386/ps.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
|
||||
|
||||
/*
|
||||
* Defines for accessing KPCR and KTHREAD structure members
|
||||
*/
|
||||
#define KTHREAD_INITIAL_STACK 0x18
|
||||
#define KTHREAD_STACK_LIMIT 0x1C
|
||||
#define KTHREAD_TEB 0x20
|
||||
#define KTHREAD_KERNEL_STACK 0x28
|
||||
#define KTHREAD_PREVIOUS_MODE 0x137
|
||||
#define KTHREAD_TRAP_FRAME 0x128
|
||||
#define KTHREAD_CALLBACK_STACK 0x120
|
||||
|
||||
#define ETHREAD_THREADS_PROCESS 0x234
|
||||
|
||||
#define KPROCESS_DIRECTORY_TABLE_BASE 0x18
|
||||
|
||||
#define KPCR_BASE 0xFF000000
|
||||
|
||||
#define KPCR_EXCEPTION_LIST 0x0
|
||||
#define KPCR_SELF 0x18
|
||||
#define KPCR_TSS 0x28
|
||||
#define KPCR_CURRENT_THREAD 0x124
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
/*
|
||||
* Processor Control Region
|
||||
*/
|
||||
typedef struct _KPCR
|
||||
{
|
||||
PVOID ExceptionList; /* 00 */
|
||||
PVOID StackBase; /* 04 */
|
||||
PVOID StackLimit; /* 08 */
|
||||
PVOID SubSystemTib; /* 0C */
|
||||
PVOID Reserved1; /* 10 */
|
||||
PVOID ArbitraryUserPointer; /* 14 */
|
||||
struct _KPCR* Self; /* 18 */
|
||||
UCHAR ProcessorNumber; /* 1C */
|
||||
KIRQL Irql; /* 1D */
|
||||
UCHAR Reserved2[0x2]; /* 1E */
|
||||
PUSHORT IDT; /* 20 */
|
||||
PUSHORT GDT; /* 24 */
|
||||
KTSS* TSS; /* 28 */
|
||||
UCHAR Reserved3[0xF8]; /* 2C */
|
||||
struct _KTHREAD* CurrentThread; /* 124 */
|
||||
} __attribute__((packed)) KPCR, *PKPCR;
|
||||
|
||||
static inline PKPCR KeGetCurrentKPCR(VOID)
|
||||
{
|
||||
ULONG value;
|
||||
|
||||
__asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
|
||||
: "=r" (value)
|
||||
: /* no inputs */
|
||||
);
|
||||
return((PKPCR)value);
|
||||
}
|
||||
|
||||
VOID
|
||||
Ki386ContextSwitch(struct _KTHREAD* NewThread,
|
||||
struct _KTHREAD* OldThread);
|
||||
NTSTATUS
|
||||
Ke386InitThread(struct _KTHREAD* Thread, PKSTART_ROUTINE fn,
|
||||
PVOID StartContext);
|
||||
NTSTATUS
|
||||
Ke386InitThreadWithContext(struct _KTHREAD* Thread, PCONTEXT Context);
|
||||
NTSTATUS
|
||||
Ki386ValidateUserContext(PCONTEXT Context);
|
||||
|
||||
#endif /* __ASM__ */
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H */
|
||||
|
||||
/* EOF */
|
|
@ -38,13 +38,13 @@
|
|||
#define PCR_SELECTOR (0x30)
|
||||
/* Thread Environment Block */
|
||||
#define TEB_SELECTOR (0x38 + 0x3)
|
||||
#define RESERVED_SELECTOR (0x40)
|
||||
#define RESERVED_SELECTOR (0x40)
|
||||
/* Local Descriptor Table */
|
||||
#define LDT_SELECTOR (0x48)
|
||||
#define TRAP_TSS_SELECTOR (0x50)
|
||||
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_SEGMENT_H */
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
|
||||
#ifndef __NTOSKRNL_INCLUDE_INTERNAL_KE_H
|
||||
#define __NTOSKRNL_INCLUDE_INTERNAL_KE_H
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
|
@ -28,129 +28,26 @@
|
|||
#include <stdarg.h>
|
||||
#endif /* not __ASM__ */
|
||||
|
||||
#include <internal/arch/ke.h>
|
||||
|
||||
/* INTERNAL KERNEL FUNCTIONS ************************************************/
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
struct _KTHREAD;
|
||||
|
||||
#endif /* not __ASM__ */
|
||||
|
||||
#define KTRAP_FRAME_DEBUGEBP (0x0)
|
||||
#define KTRAP_FRAME_DEBUGEIP (0x4)
|
||||
#define KTRAP_FRAME_DEBUGARGMARK (0x8)
|
||||
#define KTRAP_FRAME_DEBUGPOINTER (0xC)
|
||||
#define KTRAP_FRAME_TEMPCS (0x10)
|
||||
#define KTRAP_FRAME_TEMPEIP (0x14)
|
||||
#define KTRAP_FRAME_DR0 (0x18)
|
||||
#define KTRAP_FRAME_DR1 (0x1C)
|
||||
#define KTRAP_FRAME_DR2 (0x20)
|
||||
#define KTRAP_FRAME_DR3 (0x24)
|
||||
#define KTRAP_FRAME_DR6 (0x28)
|
||||
#define KTRAP_FRAME_DR7 (0x2C)
|
||||
#define KTRAP_FRAME_GS (0x30)
|
||||
#define KTRAP_FRAME_RESERVED1 (0x32)
|
||||
#define KTRAP_FRAME_ES (0x34)
|
||||
#define KTRAP_FRAME_RESERVED2 (0x36)
|
||||
#define KTRAP_FRAME_DS (0x38)
|
||||
#define KTRAP_FRAME_RESERVED3 (0x3A)
|
||||
#define KTRAP_FRAME_EDX (0x3C)
|
||||
#define KTRAP_FRAME_ECX (0x40)
|
||||
#define KTRAP_FRAME_EAX (0x44)
|
||||
#define KTRAP_FRAME_PREVIOUS_MODE (0x48)
|
||||
#define KTRAP_FRAME_EXCEPTION_LIST (0x4C)
|
||||
#define KTRAP_FRAME_FS (0x50)
|
||||
#define KTRAP_FRAME_RESERVED4 (0x52)
|
||||
#define KTRAP_FRAME_EDI (0x54)
|
||||
#define KTRAP_FRAME_ESI (0x58)
|
||||
#define KTRAP_FRAME_EBX (0x5C)
|
||||
#define KTRAP_FRAME_EBP (0x60)
|
||||
#define KTRAP_FRAME_ERROR_CODE (0x64)
|
||||
#define KTRAP_FRAME_EIP (0x68)
|
||||
#define KTRAP_FRAME_CS (0x6C)
|
||||
#define KTRAP_FRAME_EFLAGS (0x70)
|
||||
#define KTRAP_FRAME_ESP (0x74)
|
||||
#define KTRAP_FRAME_SS (0x78)
|
||||
#define KTRAP_FRAME_RESERVED5 (0x7A)
|
||||
#define KTRAP_FRAME_V86_ES (0x7C)
|
||||
#define KTRAP_FRAME_RESERVED6 (0x7E)
|
||||
#define KTRAP_FRAME_V86_DS (0x80)
|
||||
#define KTRAP_FRAME_RESERVED7 (0x82)
|
||||
#define KTRAP_FRAME_V86_FS (0x84)
|
||||
#define KTRAP_FRAME_RESERVED8 (0x86)
|
||||
#define KTRAP_FRAME_V86_GS (0x88)
|
||||
#define KTRAP_FRAME_RESERVED9 (0x8A)
|
||||
#define KTRAP_FRAME_SIZE (0x8C)
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
typedef struct _KTRAP_FRAME
|
||||
{
|
||||
PVOID DebugEbp;
|
||||
PVOID DebugEip;
|
||||
PVOID DebugArgMark;
|
||||
PVOID DebugPointer;
|
||||
PVOID TempCs;
|
||||
PVOID TempEip;
|
||||
PVOID Dr0;
|
||||
PVOID Dr1;
|
||||
PVOID Dr2;
|
||||
PVOID Dr3;
|
||||
PVOID Dr6;
|
||||
PVOID Dr7;
|
||||
USHORT Gs;
|
||||
USHORT Reserved1;
|
||||
USHORT Es;
|
||||
USHORT Reserved2;
|
||||
USHORT Ds;
|
||||
USHORT Reserved3;
|
||||
ULONG Edx;
|
||||
ULONG Ecx;
|
||||
ULONG Eax;
|
||||
ULONG PreviousMode;
|
||||
PVOID ExceptionList;
|
||||
USHORT Fs;
|
||||
USHORT Reserved4;
|
||||
ULONG Edi;
|
||||
ULONG Esi;
|
||||
ULONG Ebx;
|
||||
ULONG Ebp;
|
||||
ULONG ErrorCode;
|
||||
ULONG Eip;
|
||||
ULONG Cs;
|
||||
ULONG Eflags;
|
||||
ULONG Esp;
|
||||
USHORT Ss;
|
||||
USHORT Reserved5;
|
||||
USHORT V86_Es;
|
||||
USHORT Reserved6;
|
||||
USHORT V86_Ds;
|
||||
USHORT Reserved7;
|
||||
USHORT V86_Fs;
|
||||
USHORT Reserved8;
|
||||
USHORT V86_Gs;
|
||||
USHORT Reserved9;
|
||||
} KTRAP_FRAME, *PKTRAP_FRAME;
|
||||
|
||||
VOID KiUpdateSystemTime (KIRQL oldIrql, ULONG Eip);
|
||||
|
||||
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
|
||||
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
|
||||
BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
||||
|
||||
#if 0
|
||||
VOID KiInterruptDispatch(ULONG irq);
|
||||
#endif
|
||||
VOID STDCALL KeExpireTimers(PKDPC Apc,
|
||||
PVOID Arg1,
|
||||
PVOID Arg2,
|
||||
PVOID Arg3);
|
||||
PVOID Arg2,
|
||||
PVOID Arg3);
|
||||
VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULONG Type,
|
||||
ULONG Size, ULONG SignalState);
|
||||
|
||||
VOID KeDumpStackFrames(PULONG Frame);
|
||||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||
VOID KeFreeGdtSelector(ULONG Entry);
|
||||
BOOLEAN KiTestAlert(VOID);
|
||||
VOID KeRemoveAllWaitsThread(struct _ETHREAD* Thread, NTSTATUS WaitStatus);
|
||||
PULONG KeGetStackTopThread(struct _ETHREAD* Thread);
|
||||
|
@ -179,9 +76,7 @@ VOID KeInit2(VOID);
|
|||
|
||||
BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame);
|
||||
VOID
|
||||
NtEarlyInitVdm(VOID);
|
||||
VOID
|
||||
KiAddProfileEvent(KPROFILE_SOURCE Source, ULONG Eip);
|
||||
KiAddProfileEvent(KPROFILE_SOURCE Source, ULONG Pc);
|
||||
VOID
|
||||
KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||
PCONTEXT Context,
|
||||
|
@ -190,21 +85,10 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
|||
BOOLEAN SearchFrames);
|
||||
VOID KeTrapFrameToContext(PKTRAP_FRAME TrapFrame,
|
||||
PCONTEXT Context);
|
||||
struct _KPCR;
|
||||
VOID
|
||||
KiInitializeGdt(struct _KPCR* Pcr);
|
||||
VOID
|
||||
KeApplicationProcessorInit();
|
||||
VOID
|
||||
Ki386ApplicationProcessorInitializeTSS(VOID);
|
||||
VOID
|
||||
Ki386BootInitializeTSS(VOID);
|
||||
VOID
|
||||
KiGdtPrepareForApplicationProcessorInit(ULONG Id);
|
||||
VOID
|
||||
KePrepareForApplicationProcessorInit(ULONG id);
|
||||
VOID
|
||||
Ki386InitializeLdt(VOID);
|
||||
ULONG
|
||||
KiUserTrapHandler(PKTRAP_FRAME Tf, ULONG ExceptionNr, PVOID Cr2);
|
||||
VOID STDCALL
|
||||
|
@ -225,4 +109,4 @@ KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG ExceptionNr, ULONG cr2);
|
|||
|
||||
#define MAXIMUM_PROCESSORS 32
|
||||
|
||||
#endif
|
||||
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */
|
||||
|
|
|
@ -64,12 +64,10 @@ typedef struct
|
|||
PSECTION_PAGE_TABLE PageTables[NR_SECTION_PAGE_TABLES];
|
||||
} SECTION_PAGE_DIRECTORY, *PSECTION_PAGE_DIRECTORY;
|
||||
|
||||
#define MM_PAGEFILE_SECTION (0x1)
|
||||
#define MM_IMAGE_SECTION (0x2)
|
||||
/*
|
||||
* Flags for section objects
|
||||
*/
|
||||
#define SO_PHYSICAL_MEMORY (0x4)
|
||||
#define SEC_PHYSICALMEMORY (0x80000000)
|
||||
|
||||
#define MM_PAGEFILE_SEGMENT (0x1)
|
||||
#define MM_DATAFILE_SEGMENT (0x2)
|
||||
|
||||
#define MM_SECTION_SEGMENT_BSS (0x1)
|
||||
|
||||
|
@ -95,12 +93,11 @@ typedef struct
|
|||
CSHORT Size;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
ULONG SectionPageProtection;
|
||||
ULONG AllocateAttributes;
|
||||
ULONG AllocationAttributes;
|
||||
PFILE_OBJECT FileObject;
|
||||
LIST_ENTRY ViewListHead;
|
||||
KSPIN_LOCK ViewListLock;
|
||||
KMUTEX Lock;
|
||||
ULONG Flags;
|
||||
ULONG NrSegments;
|
||||
PMM_SECTION_SEGMENT Segments;
|
||||
PVOID ImageBase;
|
||||
|
@ -276,7 +273,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
NTSTATUS MmWaitForPage(PVOID Page);
|
||||
VOID MmClearWaitPage(PVOID Page);
|
||||
VOID MmSetWaitPage(PVOID Page);
|
||||
BOOLEAN MmIsPageDirty(struct _EPROCESS* Process, PVOID Address);
|
||||
BOOLEAN MmIsDirtyPage(struct _EPROCESS* Process, PVOID Address);
|
||||
BOOLEAN MmIsPageTablePresent(PVOID PAddress);
|
||||
NTSTATUS
|
||||
MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
|
@ -329,14 +326,6 @@ typedef struct
|
|||
|
||||
extern MM_STATS MmStats;
|
||||
|
||||
NTSTATUS
|
||||
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address);
|
||||
NTSTATUS
|
||||
MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address);
|
||||
PVOID
|
||||
MmGetDirtyPagesFromWorkingSet(struct _EPROCESS* Process);
|
||||
NTSTATUS
|
||||
|
@ -594,4 +583,26 @@ MmProtectSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
ULONG Length,
|
||||
ULONG Protect,
|
||||
PULONG OldProtect);
|
||||
NTSTATUS
|
||||
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address,
|
||||
PMM_PAGEOP PageOp);
|
||||
NTSTATUS
|
||||
MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address,
|
||||
PMM_PAGEOP PageOp);
|
||||
VOID
|
||||
MmSetCleanAllRmaps(PHYSICAL_ADDRESS PhysicalAddress);
|
||||
VOID
|
||||
MmSetDirtyAllRmaps(PHYSICAL_ADDRESS PhysicalAddress);
|
||||
NTSTATUS
|
||||
MmWritePagePhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress);
|
||||
BOOL
|
||||
MmIsDirtyPageRmap(PHYSICAL_ADDRESS PhysicalAddress);
|
||||
NTSTATUS MmInitMpwThread(VOID);
|
||||
BOOLEAN
|
||||
MmIsAvailableSwapPage(VOID);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: ps.h,v 1.38 2002/08/09 17:23:56 dwelch Exp $
|
||||
/* $Id: ps.h,v 1.39 2002/08/14 20:58:34 dwelch Exp $
|
||||
*
|
||||
* FILE: ntoskrnl/ke/kthread.c
|
||||
* PURPOSE: Process manager definitions
|
||||
|
@ -28,73 +28,21 @@
|
|||
#ifndef __INCLUDE_INTERNAL_PS_H
|
||||
#define __INCLUDE_INTERNAL_PS_H
|
||||
|
||||
/*
|
||||
* Defines for accessing KPCR and KTHREAD structure members
|
||||
*/
|
||||
#define KTHREAD_INITIAL_STACK 0x18
|
||||
#define KTHREAD_STACK_LIMIT 0x1C
|
||||
#define KTHREAD_TEB 0x20
|
||||
#define KTHREAD_KERNEL_STACK 0x28
|
||||
#define KTHREAD_PREVIOUS_MODE 0x137
|
||||
#define KTHREAD_TRAP_FRAME 0x128
|
||||
#define KTHREAD_CALLBACK_STACK 0x120
|
||||
#ifndef __ASM__
|
||||
|
||||
#define ETHREAD_THREADS_PROCESS 0x234
|
||||
/* Forward declarations. */
|
||||
struct _KTHREAD;
|
||||
struct _KTRAPFRAME;
|
||||
|
||||
#define KPROCESS_DIRECTORY_TABLE_BASE 0x18
|
||||
#endif /* __ASM__ */
|
||||
|
||||
#define KPCR_BASE 0xFF000000
|
||||
|
||||
#define KPCR_EXCEPTION_LIST 0x0
|
||||
#define KPCR_SELF 0x18
|
||||
#define KPCR_TSS 0x28
|
||||
#define KPCR_CURRENT_THREAD 0x124
|
||||
#include <internal/arch/ps.h>
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
#include <internal/mm.h>
|
||||
#include <napi/teb.h>
|
||||
|
||||
struct _KTHREAD;
|
||||
struct _KTRAPFRAME;
|
||||
|
||||
/* FIXME: This does not work if we have more than 24 IRQs (ie. more than one I/O APIC) */
|
||||
#define VECTOR2IRQ(vector) (((vector) - 0x31) / 8)
|
||||
#define VECTOR2IRQL(vector) (4 + VECTOR2IRQ(vector))
|
||||
|
||||
/*
|
||||
* Processor Control Region
|
||||
*/
|
||||
typedef struct _KPCR
|
||||
{
|
||||
PVOID ExceptionList; /* 00 */
|
||||
PVOID StackBase; /* 04 */
|
||||
PVOID StackLimit; /* 08 */
|
||||
PVOID SubSystemTib; /* 0C */
|
||||
PVOID Reserved1; /* 10 */
|
||||
PVOID ArbitraryUserPointer; /* 14 */
|
||||
struct _KPCR* Self; /* 18 */
|
||||
UCHAR ProcessorNumber; /* 1C */
|
||||
KIRQL Irql; /* 1D */
|
||||
UCHAR Reserved2[0x2]; /* 1E */
|
||||
PUSHORT IDT; /* 20 */
|
||||
PUSHORT GDT; /* 24 */
|
||||
KTSS* TSS; /* 28 */
|
||||
UCHAR Reserved3[0xF8]; /* 2C */
|
||||
struct _KTHREAD* CurrentThread; /* 124 */
|
||||
} __attribute__((packed)) KPCR, *PKPCR;
|
||||
|
||||
static inline PKPCR KeGetCurrentKPCR(VOID)
|
||||
{
|
||||
ULONG value;
|
||||
|
||||
__asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
|
||||
: "=r" (value)
|
||||
: /* no inputs */
|
||||
);
|
||||
return((PKPCR)value);
|
||||
}
|
||||
|
||||
#define KeGetCurrentProcessorNumber() (KeGetCurrentKPCR()->ProcessorNumber)
|
||||
|
||||
extern HANDLE SystemProcessHandle;
|
||||
|
@ -102,7 +50,6 @@ extern HANDLE SystemProcessHandle;
|
|||
extern LCID PsDefaultThreadLocaleId;
|
||||
extern LCID PsDefaultSystemLocaleId;
|
||||
|
||||
|
||||
typedef struct _KAPC_STATE
|
||||
{
|
||||
LIST_ENTRY ApcListHead[2];
|
||||
|
@ -198,18 +145,7 @@ typedef struct _KTHREAD
|
|||
LIST_ENTRY ProcessThreadListEntry; /* 1B0 */
|
||||
} __attribute__((packed)) KTHREAD, *PKTHREAD;
|
||||
|
||||
// According to documentation the stack should have a commited [ 1 page ] and
|
||||
// a reserved part [ 1 M ] but can be specified otherwise in the image file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TopLevelIrp can be one of the following values:
|
||||
// FIXME I belong somewhere else
|
||||
|
||||
/* Top level irp definitions. */
|
||||
#define FSRTL_FSP_TOP_LEVEL_IRP (0x01)
|
||||
#define FSRTL_CACHE_TOP_LEVEL_IRP (0x02)
|
||||
#define FSRTL_MOD_WRITE_TOP_LEVEL_IRP (0x03)
|
||||
|
@ -231,7 +167,6 @@ typedef struct
|
|||
SECURITY_IMPERSONATION_LEVEL Level; // 0x8
|
||||
} PS_IMPERSONATION_INFO, *PPS_IMPERSONATION_INFO;
|
||||
|
||||
|
||||
typedef struct _ETHREAD
|
||||
{
|
||||
KTHREAD Tcb; /* 000 */
|
||||
|
@ -404,7 +339,7 @@ struct _EPROCESS
|
|||
struct _EPORT* ExceptionPort;
|
||||
PVOID ObjectTable;
|
||||
PVOID Token;
|
||||
// FAST_MUTEX WorkingSetLock;
|
||||
/* FAST_MUTEX WorkingSetLock; */
|
||||
KMUTEX WorkingSetLock;
|
||||
PVOID WorkingSetPage;
|
||||
UCHAR ProcessOutswapEnabled;
|
||||
|
@ -482,9 +417,6 @@ VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext);
|
|||
VOID PsBeginThreadWithContextInternal(VOID);
|
||||
VOID PiKillMostProcesses(VOID);
|
||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
|
||||
ULONG PsUnfreezeThread(PETHREAD Thread, PNTSTATUS WaitStatus);
|
||||
ULONG PsFreezeThread(PETHREAD Thread, PNTSTATUS WaitStatus,
|
||||
UCHAR Alertable, ULONG WaitMode);
|
||||
VOID PiInitApcManagement(VOID);
|
||||
VOID STDCALL PiDeleteThread(PVOID ObjectBody);
|
||||
VOID STDCALL PiCloseThread(PVOID ObjectBody, ULONG HandleCount);
|
||||
|
@ -522,9 +454,9 @@ NTSTATUS PsResumeThread(PETHREAD Thread, PULONG PreviousCount);
|
|||
|
||||
/*
|
||||
* Internal thread priorities, added by Phillip Susi
|
||||
* TODO: rebalence these to make use of all priorities... the ones above 16 can not all be used right now
|
||||
* TODO: rebalence these to make use of all priorities... the ones above 16
|
||||
* can not all be used right now
|
||||
*/
|
||||
|
||||
#define PROCESS_PRIO_IDLE 3
|
||||
#define PROCESS_PRIO_NORMAL 8
|
||||
#define PROCESS_PRIO_HIGH 13
|
||||
|
@ -534,10 +466,6 @@ NTSTATUS PsResumeThread(PETHREAD Thread, PULONG PreviousCount);
|
|||
VOID
|
||||
KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First);
|
||||
NTSTATUS KeReleaseThread(PETHREAD Thread);
|
||||
NTSTATUS
|
||||
Ke386InitThread(PKTHREAD Thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||
NTSTATUS
|
||||
Ke386InitThreadWithContext(PKTHREAD Thread, PCONTEXT Context);
|
||||
VOID STDCALL PiDeleteProcess(PVOID ObjectBody);
|
||||
VOID PsReapThreads(VOID);
|
||||
VOID PsUnfreezeOtherThread(PETHREAD Thread);
|
||||
|
@ -546,8 +474,6 @@ VOID PsFreezeProcessThreads(PEPROCESS Process);
|
|||
VOID PsUnfreezeProcessThreads(PEPROCESS Process);
|
||||
PEPROCESS PsGetNextProcess(PEPROCESS OldProcess);
|
||||
VOID
|
||||
Ki386ContextSwitch(PKTHREAD NewThread, PKTHREAD OldThread);
|
||||
VOID
|
||||
PsBlockThread(PNTSTATUS Status, UCHAR Alertable, ULONG WaitMode,
|
||||
BOOLEAN DispatcherLock, KIRQL WaitIrql);
|
||||
VOID
|
||||
|
@ -571,13 +497,6 @@ VOID STDCALL
|
|||
PiSuspendThreadNormalRoutine(PVOID NormalContext,
|
||||
PVOID SystemArgument1,
|
||||
PVOID SystemArgument2);
|
||||
|
||||
VOID STDCALL
|
||||
PiTimeoutThread(struct _KDPC *dpc,
|
||||
PVOID Context,
|
||||
PVOID arg1,
|
||||
PVOID arg2);
|
||||
|
||||
VOID STDCALL
|
||||
PsDispatchThread(ULONG NewThreadStatus);
|
||||
VOID
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: file.c,v 1.18 2002/07/20 01:00:34 ekohl Exp $
|
||||
/* $Id: file.c,v 1.19 2002/08/14 20:58:34 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -44,12 +44,9 @@ NtQueryInformationFile(HANDLE FileHandle,
|
|||
assert(IoStatusBlock != NULL);
|
||||
assert(FileInformation != NULL);
|
||||
|
||||
DPRINT("NtQueryInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
|
||||
FileHandle,
|
||||
IoStatusBlock,
|
||||
FileInformation,
|
||||
Length,
|
||||
FileInformationClass);
|
||||
DPRINT("NtQueryInformationFile(Handle %x StatBlk %x FileInfo %x Length %d "
|
||||
"Class %d)\n", FileHandle, IoStatusBlock, FileInformation,
|
||||
Length, FileInformationClass);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_ATTRIBUTES,
|
||||
|
@ -124,8 +121,7 @@ NtQueryInformationFile(HANDLE FileHandle,
|
|||
IoStatusBlock->Information);
|
||||
}
|
||||
|
||||
ExFreePool(SystemBuffer);
|
||||
|
||||
ExFreePool(SystemBuffer);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -223,12 +219,9 @@ NtSetInformationFile(HANDLE FileHandle,
|
|||
assert(IoStatusBlock != NULL)
|
||||
assert(FileInformation != NULL)
|
||||
|
||||
DPRINT("NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
|
||||
FileHandle,
|
||||
IoStatusBlock,
|
||||
FileInformation,
|
||||
Length,
|
||||
FileInformationClass);
|
||||
DPRINT("NtSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d "
|
||||
"Class %d)\n", FileHandle, IoStatusBlock, FileInformation,
|
||||
Length, FileInformationClass);
|
||||
|
||||
/* Get the file object from the file handle */
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iomgr.c,v 1.22 2002/06/10 08:47:21 ekohl Exp $
|
||||
/* $Id: iomgr.c,v 1.23 2002/08/14 20:58:34 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -120,75 +120,65 @@ VOID IoInit (VOID)
|
|||
HANDLE Handle;
|
||||
|
||||
IopInitDriverImplementation();
|
||||
|
||||
/*
|
||||
* Register iomgr types: DeviceObjectType
|
||||
*/
|
||||
IoDeviceObjectType = ExAllocatePool (NonPagedPool,
|
||||
sizeof (OBJECT_TYPE));
|
||||
|
||||
IoDeviceObjectType->Tag = TAG_DEVICE_TYPE;
|
||||
IoDeviceObjectType->TotalObjects = 0;
|
||||
IoDeviceObjectType->TotalHandles = 0;
|
||||
IoDeviceObjectType->MaxObjects = ULONG_MAX;
|
||||
IoDeviceObjectType->MaxHandles = ULONG_MAX;
|
||||
IoDeviceObjectType->PagedPoolCharge = 0;
|
||||
IoDeviceObjectType->NonpagedPoolCharge = sizeof (DEVICE_OBJECT);
|
||||
IoDeviceObjectType->Mapping = &IopFileMapping;
|
||||
IoDeviceObjectType->Dump = NULL;
|
||||
IoDeviceObjectType->Open = NULL;
|
||||
IoDeviceObjectType->Close = NULL;
|
||||
IoDeviceObjectType->Delete = NULL;
|
||||
IoDeviceObjectType->Parse = NULL;
|
||||
IoDeviceObjectType->Security = NULL;
|
||||
IoDeviceObjectType->QueryName = NULL;
|
||||
IoDeviceObjectType->OkayToClose = NULL;
|
||||
IoDeviceObjectType->Create = IopCreateDevice;
|
||||
IoDeviceObjectType->DuplicationNotify = NULL;
|
||||
|
||||
RtlInitUnicodeString (&IoDeviceObjectType->TypeName, L"Device");
|
||||
|
||||
/*
|
||||
* Register iomgr types: DeviceObjectType
|
||||
*/
|
||||
IoDeviceObjectType = ExAllocatePool (NonPagedPool,
|
||||
sizeof (OBJECT_TYPE));
|
||||
|
||||
IoDeviceObjectType->Tag = TAG_DEVICE_TYPE;
|
||||
IoDeviceObjectType->TotalObjects = 0;
|
||||
IoDeviceObjectType->TotalHandles = 0;
|
||||
IoDeviceObjectType->MaxObjects = ULONG_MAX;
|
||||
IoDeviceObjectType->MaxHandles = ULONG_MAX;
|
||||
IoDeviceObjectType->PagedPoolCharge = 0;
|
||||
IoDeviceObjectType->NonpagedPoolCharge = sizeof (DEVICE_OBJECT);
|
||||
IoDeviceObjectType->Mapping = &IopFileMapping;
|
||||
IoDeviceObjectType->Dump = NULL;
|
||||
IoDeviceObjectType->Open = NULL;
|
||||
IoDeviceObjectType->Close = NULL;
|
||||
IoDeviceObjectType->Delete = NULL;
|
||||
IoDeviceObjectType->Parse = NULL;
|
||||
IoDeviceObjectType->Security = NULL;
|
||||
IoDeviceObjectType->QueryName = NULL;
|
||||
IoDeviceObjectType->OkayToClose = NULL;
|
||||
IoDeviceObjectType->Create = IopCreateDevice;
|
||||
IoDeviceObjectType->DuplicationNotify = NULL;
|
||||
|
||||
RtlInitUnicodeString (
|
||||
& IoDeviceObjectType->TypeName,
|
||||
L"Device"
|
||||
);
|
||||
|
||||
/*
|
||||
* Register iomgr types: FileObjectType
|
||||
* (alias DriverObjectType)
|
||||
*/
|
||||
IoFileObjectType = ExAllocatePool (
|
||||
NonPagedPool,
|
||||
sizeof (OBJECT_TYPE)
|
||||
);
|
||||
|
||||
IoFileObjectType->Tag = TAG_FILE_TYPE;
|
||||
IoFileObjectType->TotalObjects = 0;
|
||||
IoFileObjectType->TotalHandles = 0;
|
||||
IoFileObjectType->MaxObjects = ULONG_MAX;
|
||||
IoFileObjectType->MaxHandles = ULONG_MAX;
|
||||
IoFileObjectType->PagedPoolCharge = 0;
|
||||
IoFileObjectType->NonpagedPoolCharge = sizeof(FILE_OBJECT);
|
||||
IoFileObjectType->Mapping = &IopFileMapping;
|
||||
IoFileObjectType->Dump = NULL;
|
||||
IoFileObjectType->Open = NULL;
|
||||
IoFileObjectType->Close = IopCloseFile;
|
||||
IoFileObjectType->Delete = IopDeleteFile;
|
||||
IoFileObjectType->Parse = NULL;
|
||||
IoFileObjectType->Security = NULL;
|
||||
IoFileObjectType->QueryName = NULL;
|
||||
IoFileObjectType->OkayToClose = NULL;
|
||||
IoFileObjectType->Create = IopCreateFile;
|
||||
IoFileObjectType->DuplicationNotify = NULL;
|
||||
|
||||
RtlInitUnicodeString (
|
||||
& IoFileObjectType->TypeName,
|
||||
L"File"
|
||||
);
|
||||
/*
|
||||
* Register iomgr types: FileObjectType
|
||||
* (alias DriverObjectType)
|
||||
*/
|
||||
IoFileObjectType = ExAllocatePool (NonPagedPool, sizeof (OBJECT_TYPE));
|
||||
|
||||
IoFileObjectType->Tag = TAG_FILE_TYPE;
|
||||
IoFileObjectType->TotalObjects = 0;
|
||||
IoFileObjectType->TotalHandles = 0;
|
||||
IoFileObjectType->MaxObjects = ULONG_MAX;
|
||||
IoFileObjectType->MaxHandles = ULONG_MAX;
|
||||
IoFileObjectType->PagedPoolCharge = 0;
|
||||
IoFileObjectType->NonpagedPoolCharge = sizeof(FILE_OBJECT);
|
||||
IoFileObjectType->Mapping = &IopFileMapping;
|
||||
IoFileObjectType->Dump = NULL;
|
||||
IoFileObjectType->Open = NULL;
|
||||
IoFileObjectType->Close = IopCloseFile;
|
||||
IoFileObjectType->Delete = IopDeleteFile;
|
||||
IoFileObjectType->Parse = NULL;
|
||||
IoFileObjectType->Security = NULL;
|
||||
IoFileObjectType->QueryName = NULL;
|
||||
IoFileObjectType->OkayToClose = NULL;
|
||||
IoFileObjectType->Create = IopCreateFile;
|
||||
IoFileObjectType->DuplicationNotify = NULL;
|
||||
|
||||
RtlInitUnicodeString (&IoFileObjectType->TypeName, L"File");
|
||||
|
||||
/*
|
||||
* Create the '\Driver' object directory
|
||||
*/
|
||||
RtlInitUnicodeString(&DirName,
|
||||
L"\\Driver");
|
||||
RtlInitUnicodeString(&DirName, L"\\Driver");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&DirName,
|
||||
0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rw.c,v 1.37 2002/04/27 19:22:09 hbirr Exp $
|
||||
/* $Id: rw.c,v 1.38 2002/08/14 20:58:35 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,10 +18,6 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* DATA ********************************************************************/
|
||||
|
||||
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
||||
|
@ -42,111 +38,123 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PIO_STATUS_BLOCK UserIoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT ptrEvent = NULL;
|
||||
IO_STATUS_BLOCK IoSB;
|
||||
|
||||
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
|
||||
"IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset,
|
||||
IoStatusBlock);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_DATA,
|
||||
IoFileObjectType,
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT Event = NULL;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
|
||||
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
|
||||
"IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset,
|
||||
IoStatusBlock);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
}
|
||||
|
||||
if (EventHandle != NULL)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(EventHandle,
|
||||
SYNCHRONIZE,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&Event,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Event = &FileObject->Event;
|
||||
KeResetEvent(Event);
|
||||
}
|
||||
|
||||
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
IoStatusBlock = &Iosb;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoStatusBlock = UserIoStatusBlock;
|
||||
}
|
||||
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
Event,
|
||||
IoStatusBlock);
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Read.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Read.Key = 0;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING && FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
BOOLEAN Alertable;
|
||||
|
||||
if (FileObject->Flags & FO_ALERTABLE_IO)
|
||||
{
|
||||
Alertable = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Alertable = FALSE;
|
||||
}
|
||||
|
||||
Status = KeWaitForSingleObject(Event,
|
||||
Executive,
|
||||
UserMode,
|
||||
(PVOID*)&FileObject,
|
||||
Alertable,
|
||||
NULL);
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
return Status;
|
||||
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
if (Status != STATUS_WAIT_0)
|
||||
{
|
||||
/* Wait failed. */
|
||||
return(Status);
|
||||
}
|
||||
Status = Iosb.Status;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (EventHandle != NULL)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(EventHandle,
|
||||
SYNCHRONIZE,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&ptrEvent,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrEvent = &FileObject->Event;
|
||||
KeResetEvent( ptrEvent );
|
||||
}
|
||||
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
ptrEvent,
|
||||
EventHandle ? IoStatusBlock : &IoSB);
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Read.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Read.Key = 0;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(FileObject->DeviceObject,
|
||||
Irp);
|
||||
if (EventHandle == NULL && Status == STATUS_PENDING &&
|
||||
!(FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
BOOLEAN Alertable;
|
||||
|
||||
if (FileObject->Flags & FO_ALERTABLE_IO)
|
||||
{
|
||||
Alertable = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Alertable = FALSE;
|
||||
}
|
||||
|
||||
Status = KeWaitForSingleObject(ptrEvent,
|
||||
Executive,
|
||||
KernelMode,
|
||||
Alertable,
|
||||
NULL);
|
||||
if( !NT_SUCCESS( Status ) )
|
||||
{
|
||||
DPRINT1( "WaitForSingleObject failed: %x\n", Status );
|
||||
}
|
||||
else Status = IoSB.Status;
|
||||
}
|
||||
if (IoStatusBlock && EventHandle == NULL)
|
||||
{
|
||||
*IoStatusBlock = IoSB;
|
||||
}
|
||||
return (Status);
|
||||
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
*UserIoStatusBlock = Iosb;
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,97 +175,123 @@ NTSTATUS STDCALL NtWriteFile(HANDLE FileHandle,
|
|||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PIO_STATUS_BLOCK UserIoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT ptrEvent;
|
||||
IO_STATUS_BLOCK IoSB;
|
||||
|
||||
DPRINT("NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
|
||||
FileHandle, Buffer, Length);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_WRITE_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT Event = NULL;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
|
||||
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
|
||||
"IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset,
|
||||
IoStatusBlock);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
}
|
||||
|
||||
if (EventHandle != NULL)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(EventHandle,
|
||||
SYNCHRONIZE,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&Event,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Event = &FileObject->Event;
|
||||
KeResetEvent(Event);
|
||||
}
|
||||
|
||||
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
IoStatusBlock = &Iosb;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoStatusBlock = UserIoStatusBlock;
|
||||
}
|
||||
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
Event,
|
||||
IoStatusBlock);
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = 0;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING && FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
BOOLEAN Alertable;
|
||||
|
||||
if (FileObject->Flags & FO_ALERTABLE_IO)
|
||||
{
|
||||
Alertable = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Alertable = FALSE;
|
||||
}
|
||||
|
||||
Status = KeWaitForSingleObject(Event,
|
||||
Executive,
|
||||
UserMode,
|
||||
Alertable,
|
||||
NULL);
|
||||
if (Status != STATUS_WAIT_0)
|
||||
{
|
||||
/* Wait failed. */
|
||||
return(Status);
|
||||
}
|
||||
Status = Iosb.Status;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
}
|
||||
|
||||
if (EventHandle != NULL)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(EventHandle,
|
||||
SYNCHRONIZE,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&ptrEvent,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptrEvent = &FileObject->Event;
|
||||
KeResetEvent( ptrEvent );
|
||||
}
|
||||
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
ptrEvent,
|
||||
EventHandle ? IoStatusBlock : &IoSB);
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = 0;
|
||||
}
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
if (EventHandle == NULL && Status == STATUS_PENDING &&
|
||||
!(FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(ptrEvent,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FileObject->Flags & FO_ALERTABLE_IO ? TRUE : FALSE,
|
||||
NULL);
|
||||
Status = IoSB.Status;
|
||||
}
|
||||
if (IoStatusBlock && EventHandle == NULL)
|
||||
{
|
||||
*IoStatusBlock = IoSB;
|
||||
}
|
||||
return(Status);
|
||||
if (FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
{
|
||||
*UserIoStatusBlock = Iosb;
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -392,8 +392,8 @@ KiDoubleFaultHandler(VOID)
|
|||
VOID
|
||||
KiDumpTrapFrame(PKTRAP_FRAME Tf, ULONG Parameter1, ULONG Parameter2)
|
||||
{
|
||||
unsigned int cr3;
|
||||
unsigned int i;
|
||||
ULONG cr3;
|
||||
ULONG i;
|
||||
ULONG StackLimit;
|
||||
PULONG Frame;
|
||||
ULONG Esp0;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: irq.c,v 1.21 2002/07/10 15:12:33 ekohl Exp $
|
||||
/* $Id: irq.c,v 1.22 2002/08/14 20:58:35 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/i386/irq.c
|
||||
|
@ -53,6 +53,13 @@
|
|||
|
||||
#ifdef MP
|
||||
|
||||
/*
|
||||
* FIXME: This does not work if we have more than 24 IRQs (ie. more than one
|
||||
* I/O APIC)
|
||||
*/
|
||||
#define VECTOR2IRQ(vector) (((vector) - 0x31) / 8)
|
||||
#define VECTOR2IRQL(vector) (4 + VECTOR2IRQ(vector))
|
||||
|
||||
#define IRQ_BASE FIRST_DEVICE_VECTOR
|
||||
#define NR_IRQS 0x100 - 0x30
|
||||
|
||||
|
|
|
@ -37,15 +37,17 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
#define FLAG_NT (1<<14)
|
||||
#define FLAG_VM (1<<17)
|
||||
#define FLAG_IF (1<<9)
|
||||
#define FLAG_IOPL ((1<<12)+(1<<13))
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
KeValidateUserContext(PCONTEXT Context)
|
||||
Ki386ValidateUserContext(PCONTEXT Context)
|
||||
/*
|
||||
* FUNCTION: Validates a processor context
|
||||
* ARGUMENTS:
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: kthread.c,v 1.31 2002/08/09 17:23:57 dwelch Exp $
|
||||
/* $Id: kthread.c,v 1.32 2002/08/14 20:58:35 dwelch Exp $
|
||||
*
|
||||
* FILE: ntoskrnl/ke/kthread.c
|
||||
* PURPOSE: Microkernel thread support
|
||||
|
@ -36,11 +36,6 @@
|
|||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* EXTERN ********************************************************************/
|
||||
|
||||
//extern VOID
|
||||
//PiTimeoutThread(struct _KDPC Dpc, PVOID Context, PVOID Arg1, PVOID Arg2);
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: main.c,v 1.133 2002/08/10 16:41:18 dwelch Exp $
|
||||
/* $Id: main.c,v 1.134 2002/08/14 20:58:35 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/main.c
|
||||
|
@ -633,7 +633,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock)
|
|||
KeLoaderBlock.ModsAddr = (ULONG)&KeLoaderModules;
|
||||
|
||||
/*
|
||||
* Convert a path specification in the grub to one understood by the
|
||||
* Convert a path specification in the grub format to one understood by the
|
||||
* rest of the kernel.
|
||||
*/
|
||||
if (((PUCHAR)_LoaderBlock->CommandLine)[0] == '(')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: timer.c,v 1.50 2002/05/14 21:19:18 dwelch Exp $
|
||||
/* $Id: timer.c,v 1.51 2002/08/14 20:58:35 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -173,12 +173,12 @@ KeQuerySystemTime(PLARGE_INTEGER CurrentTime)
|
|||
NTSTATUS STDCALL
|
||||
NtGetTickCount (PULONG UpTime)
|
||||
{
|
||||
LARGE_INTEGER TickCount;
|
||||
if ( UpTime == NULL )
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
KeQueryTickCount(&TickCount);
|
||||
*UpTime = TickCount.u.LowPart;
|
||||
return (STATUS_SUCCESS);
|
||||
LARGE_INTEGER TickCount;
|
||||
if (UpTime == NULL)
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
KeQueryTickCount(&TickCount);
|
||||
*UpTime = TickCount.u.LowPart;
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ KeSetTimerEx (PKTIMER Timer,
|
|||
InsertTailList(&TimerListHead,&Timer->TimerListEntry);
|
||||
KeReleaseSpinLock(&TimerListLock, oldlvl);
|
||||
|
||||
return FALSE;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
BOOLEAN STDCALL
|
||||
|
@ -291,7 +291,7 @@ KeInitializeTimer (PKTIMER Timer)
|
|||
* NOTE: This function initializes a notification timer
|
||||
*/
|
||||
{
|
||||
KeInitializeTimerEx(Timer,NotificationTimer);
|
||||
KeInitializeTimerEx(Timer, NotificationTimer);
|
||||
}
|
||||
|
||||
VOID STDCALL
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.119 2002/08/10 16:41:18 dwelch Exp $
|
||||
/* $Id: loader.c,v 1.120 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -344,7 +344,7 @@ LdrLoadModule(PUNICODE_STRING Filename,
|
|||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
0,
|
||||
0);
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
CHECKPOINT;
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -1133,19 +1133,20 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
|
|||
RtlZeroMemory(CreatedModuleObject, sizeof(MODULE_OBJECT));
|
||||
|
||||
/* Initialize ModuleObject data */
|
||||
CreatedModuleObject->Base = DriverBase;
|
||||
CreatedModuleObject->Flags = MODULE_FLAG_PE;
|
||||
|
||||
RtlCreateUnicodeString(&CreatedModuleObject->FullName,
|
||||
FileName->Buffer);
|
||||
LdrpBuildModuleBaseName(&CreatedModuleObject->BaseName,
|
||||
&CreatedModuleObject->FullName);
|
||||
|
||||
CreatedModuleObject->EntryPoint = (PVOID)((DWORD)DriverBase +
|
||||
PEOptionalHeader->AddressOfEntryPoint);
|
||||
CreatedModuleObject->Base = DriverBase;
|
||||
CreatedModuleObject->Flags = MODULE_FLAG_PE;
|
||||
|
||||
RtlCreateUnicodeString(&CreatedModuleObject->FullName,
|
||||
FileName->Buffer);
|
||||
LdrpBuildModuleBaseName(&CreatedModuleObject->BaseName,
|
||||
&CreatedModuleObject->FullName);
|
||||
|
||||
CreatedModuleObject->EntryPoint =
|
||||
(PVOID)((DWORD)DriverBase +
|
||||
PEOptionalHeader->AddressOfEntryPoint);
|
||||
CreatedModuleObject->Length = DriverSize;
|
||||
DPRINT("EntryPoint at %x\n", CreatedModuleObject->EntryPoint);
|
||||
|
||||
|
||||
CreatedModuleObject->Image.PE.FileHeader =
|
||||
(PIMAGE_FILE_HEADER) ((unsigned int) DriverBase + PEDosHeader->e_lfanew + sizeof(ULONG));
|
||||
|
||||
|
@ -1172,10 +1173,9 @@ LdrPEProcessModule(PVOID ModuleLoadBase,
|
|||
RtlZeroMemory(ModuleTextSection, sizeof(MODULE_TEXT_SECTION));
|
||||
ModuleTextSection->Base = (ULONG)DriverBase;
|
||||
ModuleTextSection->Length = DriverSize;
|
||||
ModuleTextSection->Name =
|
||||
ExAllocatePool(NonPagedPool,
|
||||
(wcslen(NameBuffer) + 1) * sizeof(WCHAR));
|
||||
wcscpy(ModuleTextSection->Name, NameBuffer);
|
||||
ModuleTextSection->Name = ExAllocatePool(NonPagedPool,
|
||||
(wcslen(CreatedModuleObject->BaseName.Buffer) + 1) * sizeof(WCHAR));
|
||||
wcscpy(ModuleTextSection->Name, CreatedModuleObject->BaseName.Buffer);
|
||||
ModuleTextSection->OptionalHeader =
|
||||
CreatedModuleObject->Image.PE.OptionalHeader;
|
||||
InsertTailList(&ModuleTextListHead, &ModuleTextSection->ListEntry);
|
||||
|
|
|
@ -79,6 +79,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
|||
PEPROCESS Process;
|
||||
ANSI_STRING ProcedureName;
|
||||
ULONG ViewSize;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
|
||||
/*
|
||||
* Locate and open NTDLL to determine ImageBase
|
||||
|
@ -97,7 +98,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
|||
&FileObjectAttributes,
|
||||
NULL,
|
||||
FILE_SHARE_READ,
|
||||
0);
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("NTDLL open failed (Status %x)\n", Status);
|
||||
|
@ -107,12 +108,12 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
|||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
&Iosb,
|
||||
BlockBuffer,
|
||||
sizeof(BlockBuffer),
|
||||
0,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
if (!NT_SUCCESS(Status) || Iosb.Information != sizeof(BlockBuffer))
|
||||
{
|
||||
DbgPrint("NTDLL header read failed (Status %x)\n", Status);
|
||||
ZwClose(FileHandle);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: anonmem.c,v 1.1 2002/08/10 16:41:19 dwelch Exp $
|
||||
/* $Id: anonmem.c,v 1.2 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/anonmem.c
|
||||
|
@ -40,12 +40,88 @@
|
|||
|
||||
NTSTATUS
|
||||
MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address)
|
||||
PMEMORY_AREA MemoryArea,
|
||||
PVOID Address,
|
||||
PMM_PAGEOP PageOp)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
SWAPENTRY SwapEntry;
|
||||
LARGE_INTEGER PhysicalAddress;
|
||||
PMDL Mdl;
|
||||
NTSTATUS Status;
|
||||
|
||||
/*
|
||||
* Check for paging out from a deleted virtual memory area.
|
||||
*/
|
||||
if (MemoryArea->DeleteInProgress)
|
||||
{
|
||||
PageOp->Status = STATUS_UNSUCCESSFUL;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
PhysicalAddress =
|
||||
MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
|
||||
|
||||
/*
|
||||
* Get that the page actually is dirty.
|
||||
*/
|
||||
if (!MmIsDirtyPage(MemoryArea->Process, Address))
|
||||
{
|
||||
PageOp->Status = STATUS_SUCCESS;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Speculatively set the mapping to clean.
|
||||
*/
|
||||
MmSetCleanPage(MemoryArea->Process, Address);
|
||||
|
||||
/*
|
||||
* If necessary, allocate an entry in the paging file for this page
|
||||
*/
|
||||
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
|
||||
if (SwapEntry == 0)
|
||||
{
|
||||
SwapEntry = MmAllocSwapPage();
|
||||
if (SwapEntry == 0)
|
||||
{
|
||||
MmSetDirtyPage(MemoryArea->Process, Address);
|
||||
PageOp->Status = STATUS_PAGEFILE_QUOTA_EXCEEDED;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_PAGEFILE_QUOTA_EXCEEDED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the page to the pagefile
|
||||
*/
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
MmBuildMdlFromPages(Mdl, (PULONG)&PhysicalAddress);
|
||||
Status = MmWriteToSwapPage(SwapEntry, Mdl);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
|
||||
Status);
|
||||
MmSetDirtyPage(MemoryArea->Process, Address);
|
||||
PageOp->Status = STATUS_UNSUCCESSFUL;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise we have succeeded.
|
||||
*/
|
||||
MmSetSavedSwapEntryPage(PhysicalAddress, SwapEntry);
|
||||
PageOp->Status = STATUS_SUCCESS;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
|
@ -67,33 +143,14 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
*/
|
||||
if (MemoryArea->DeleteInProgress)
|
||||
{
|
||||
PageOp->Status = STATUS_UNSUCCESSFUL;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Paging out code or readonly data is easy.
|
||||
*/
|
||||
if ((MemoryArea->Attributes & PAGE_READONLY) ||
|
||||
(MemoryArea->Attributes & PAGE_EXECUTE_READ))
|
||||
{
|
||||
MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE,
|
||||
NULL, &PhysicalAddress);
|
||||
MmDeleteAllRmaps(PhysicalAddress, NULL, NULL);
|
||||
if (MmGetSavedSwapEntryPage(PhysicalAddress) != 0)
|
||||
{
|
||||
DPRINT1("Read-only page was swapped out.\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddress);
|
||||
|
||||
PageOp->Status = STATUS_SUCCESS;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise this is read-write data
|
||||
* Disable the virtual mapping.
|
||||
*/
|
||||
MmDisableVirtualMapping(MemoryArea->Process, Address,
|
||||
&WasDirty, (PULONG)&PhysicalAddress);
|
||||
|
@ -101,6 +158,10 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
|||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Paging out non-dirty data is easy.
|
||||
*/
|
||||
if (!WasDirty)
|
||||
{
|
||||
MmDeleteVirtualMapping(MemoryArea->Process, Address, FALSE, NULL, NULL);
|
||||
|
@ -399,6 +460,13 @@ MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
|
|||
FALSE, NULL, NULL);
|
||||
if (PhysicalAddr.QuadPart != 0)
|
||||
{
|
||||
SWAPENTRY SavedSwapEntry;
|
||||
SavedSwapEntry = MmGetSavedSwapEntryPage(PhysicalAddr);
|
||||
if (SavedSwapEntry != 0)
|
||||
{
|
||||
MmFreeSwapPage(SavedSwapEntry);
|
||||
MmSetSavedSwapEntryPage(PhysicalAddr, 0);
|
||||
}
|
||||
MmDeleteRmap(PhysicalAddr, AddressSpace->Process,
|
||||
BaseAddress + (i * PAGESIZE));
|
||||
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddr);
|
||||
|
@ -455,13 +523,6 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
* a combination of PAGE_READONLY, PAGE_READWRITE,
|
||||
* PAGE_EXECUTE_READ, PAGE_EXECUTE_READWRITE, PAGE_GUARD,
|
||||
* PAGE_NOACCESS
|
||||
* REMARKS:
|
||||
* This function maps to the win32 VirtualAllocEx. Virtual memory is
|
||||
* process based so the protocol starts with a ProcessHandle. I
|
||||
* splitted the functionality of obtaining the actual address and
|
||||
* specifying the start address in two parameters ( BaseAddress and
|
||||
* StartAddress ) The NumberOfBytesAllocated specify the range and the
|
||||
* AllocationType and ProctectionType map to the other two parameters.
|
||||
* RETURNS: Status
|
||||
*/
|
||||
{
|
||||
|
@ -495,7 +556,6 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
PBaseAddress = *UBaseAddress;
|
||||
PRegionSize = *URegionSize;
|
||||
|
||||
|
||||
BaseAddress = (PVOID)PAGE_ROUND_DOWN(PBaseAddress);
|
||||
RegionSize = PAGE_ROUND_UP(PBaseAddress + PRegionSize) -
|
||||
PAGE_ROUND_DOWN(PBaseAddress);
|
||||
|
@ -593,6 +653,13 @@ MmFreeVirtualMemoryPage(PVOID Context,
|
|||
|
||||
if (PhysicalAddr.QuadPart != 0)
|
||||
{
|
||||
SWAPENTRY SavedSwapEntry;
|
||||
SavedSwapEntry = MmGetSavedSwapEntryPage(PhysicalAddr);
|
||||
if (SavedSwapEntry != 0)
|
||||
{
|
||||
MmFreeSwapPage(SavedSwapEntry);
|
||||
MmSetSavedSwapEntryPage(PhysicalAddr, 0);
|
||||
}
|
||||
MmDeleteRmap(PhysicalAddr, Process, Address);
|
||||
MmReleasePageMemoryConsumer(MC_USER, PhysicalAddr);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: balance.c,v 1.10 2002/06/10 21:34:37 hbirr Exp $
|
||||
/* $Id: balance.c,v 1.11 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/balance.c
|
||||
* PURPOSE: kernel memory managment functions
|
||||
|
@ -70,8 +69,10 @@ static ULONG MiMinimumPagesPerRun = 1;
|
|||
VOID MmPrintMemoryStatistic(VOID)
|
||||
{
|
||||
DbgPrint("MC_CACHE %d, MC_USER %d, MC_PPOOL %d, MC_NPPOOL %d\n",
|
||||
MiMemoryConsumers[MC_CACHE].PagesUsed, MiMemoryConsumers[MC_USER].PagesUsed,
|
||||
MiMemoryConsumers[MC_PPOOL].PagesUsed, MiMemoryConsumers[MC_NPPOOL].PagesUsed);
|
||||
MiMemoryConsumers[MC_CACHE].PagesUsed,
|
||||
MiMemoryConsumers[MC_USER].PagesUsed,
|
||||
MiMemoryConsumers[MC_PPOOL].PagesUsed,
|
||||
MiMemoryConsumers[MC_NPPOOL].PagesUsed);
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -86,7 +87,8 @@ MmInitializeBalancer(ULONG NrAvailablePages)
|
|||
/* Set up targets. */
|
||||
MiMinimumAvailablePages = 64;
|
||||
MiMemoryConsumers[MC_CACHE].PagesTarget = NrAvailablePages / 2;
|
||||
MiMemoryConsumers[MC_USER].PagesTarget = NrAvailablePages - MiMinimumAvailablePages;
|
||||
MiMemoryConsumers[MC_USER].PagesTarget =
|
||||
NrAvailablePages - MiMinimumAvailablePages;
|
||||
MiMemoryConsumers[MC_PPOOL].PagesTarget = NrAvailablePages / 2;
|
||||
MiMemoryConsumers[MC_NPPOOL].PagesTarget = 0xFFFFFFFF;
|
||||
}
|
||||
|
@ -114,29 +116,29 @@ MmReleasePageMemoryConsumer(ULONG Consumer, PHYSICAL_ADDRESS Page)
|
|||
|
||||
KeAcquireSpinLock(&AllocationListLock, &oldIrql);
|
||||
if (MmGetReferenceCountPage(Page) == 1)
|
||||
{
|
||||
InterlockedDecrement(&MiMemoryConsumers[Consumer].PagesUsed);
|
||||
InterlockedIncrement(&MiNrAvailablePages);
|
||||
InterlockedDecrement(&MiPagesRequired);
|
||||
if (IsListEmpty(&AllocationListHead))
|
||||
{
|
||||
InterlockedDecrement(&MiMemoryConsumers[Consumer].PagesUsed);
|
||||
InterlockedIncrement(&MiNrAvailablePages);
|
||||
InterlockedDecrement(&MiPagesRequired);
|
||||
if (IsListEmpty(&AllocationListHead))
|
||||
{
|
||||
KeReleaseSpinLock(&AllocationListLock, oldIrql);
|
||||
MmDereferencePage(Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
Entry = RemoveHeadList(&AllocationListHead);
|
||||
Request = CONTAINING_RECORD(Entry, MM_ALLOCATION_REQUEST, ListEntry);
|
||||
KeReleaseSpinLock(&AllocationListLock, oldIrql);
|
||||
Request->Page = Page;
|
||||
KeSetEvent(&Request->Event, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KeReleaseSpinLock(&AllocationListLock, oldIrql);
|
||||
MmDereferencePage(Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
Entry = RemoveHeadList(&AllocationListHead);
|
||||
Request = CONTAINING_RECORD(Entry, MM_ALLOCATION_REQUEST, ListEntry);
|
||||
KeReleaseSpinLock(&AllocationListLock, oldIrql);
|
||||
Request->Page = Page;
|
||||
KeSetEvent(&Request->Event, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
KeReleaseSpinLock(&AllocationListLock, oldIrql);
|
||||
MmDereferencePage(Page);
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: page.c,v 1.39 2002/08/10 16:41:20 dwelch Exp $
|
||||
/* $Id: page.c,v 1.40 2002/08/14 20:58:37 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/i386/page.c
|
||||
|
@ -703,7 +703,7 @@ PULONG MmGetPageEntry(PVOID PAddress)
|
|||
return(page_tlb);
|
||||
}
|
||||
|
||||
BOOLEAN MmIsPageDirty(PEPROCESS Process, PVOID Address)
|
||||
BOOLEAN MmIsDirtyPage(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
return((MmGetPageEntryForProcess(Process, Address)) & PA_DIRTY);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mminit.c,v 1.36 2002/07/17 21:04:56 dwelch Exp $
|
||||
/* $Id: mminit.c,v 1.37 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -355,6 +355,11 @@ VOID MmInit3(VOID)
|
|||
MmCreatePhysicalMemorySection();
|
||||
MmInitializeRmapList();
|
||||
|
||||
/*
|
||||
* Initialise the modified page writer.
|
||||
*/
|
||||
MmInitMpwThread();
|
||||
|
||||
/* FIXME: Read parameters from memory */
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
/* $Id: mpw.c,v 1.7 2001/12/31 01:53:45 dwelch Exp $
|
||||
/*
|
||||
* ReactOS kernel
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: mpw.c,v 1.8 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/mpw.c
|
||||
* PURPOSE: Writes data that has been modified in memory but not on
|
||||
|
@ -15,6 +32,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/cc.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -28,29 +46,62 @@ static volatile BOOLEAN MpwThreadShouldTerminate;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS STDCALL
|
||||
MmWriteDirtyPages(ULONG Target, PULONG Actual)
|
||||
{
|
||||
PHYSICAL_ADDRESS Page;
|
||||
PHYSICAL_ADDRESS NextPage;
|
||||
NTSTATUS Status;
|
||||
|
||||
Page = MmGetLRUFirstUserPage();
|
||||
while (Page.QuadPart != 0LL && Target > 0)
|
||||
{
|
||||
NextPage = MmGetLRUNextUserPage(Page);
|
||||
if (MmIsDirtyPageRmap(Page))
|
||||
{
|
||||
Status = MmWritePagePhysicalAddress(Page);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Target--;
|
||||
}
|
||||
}
|
||||
Page = NextPage;
|
||||
}
|
||||
*Actual = Target;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL
|
||||
MmMpwThreadMain(PVOID Ignored)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
ULONG PagesWritten;
|
||||
LARGE_INTEGER Timeout;
|
||||
|
||||
Timeout.QuadPart = -50000000;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
Status = KeWaitForSingleObject(&MpwThreadEvent,
|
||||
0,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("MpwThread: Wait failed\n");
|
||||
KeBugCheck(0);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (MpwThreadShouldTerminate)
|
||||
{
|
||||
DbgPrint("MpwThread: Terminating\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
Status = KeWaitForSingleObject(&MpwThreadEvent,
|
||||
0,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
&Timeout);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("MpwThread: Wait failed\n");
|
||||
KeBugCheck(0);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (MpwThreadShouldTerminate)
|
||||
{
|
||||
DbgPrint("MpwThread: Terminating\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
PagesWritten = 0;
|
||||
MmWriteDirtyPages(128, &PagesWritten);
|
||||
CcRosFlushDirtyPages(128, &PagesWritten);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,10 +110,8 @@ NTSTATUS MmInitMpwThread(VOID)
|
|||
NTSTATUS Status;
|
||||
|
||||
MpwThreadShouldTerminate = FALSE;
|
||||
KeInitializeEvent(&MpwThreadEvent,
|
||||
SynchronizationEvent,
|
||||
FALSE);
|
||||
|
||||
KeInitializeEvent(&MpwThreadEvent, SynchronizationEvent, FALSE);
|
||||
|
||||
Status = PsCreateSystemThread(&MpwThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
NULL,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: pagefile.c,v 1.21 2002/07/17 21:04:56 dwelch Exp $
|
||||
/* $Id: pagefile.c,v 1.22 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/pagefile.c
|
||||
|
@ -96,7 +96,7 @@ static PULONG MmCoreDumpBlockMap;
|
|||
static ULONG MmCoreDumpSize;
|
||||
static PULONG MmCoreDumpBlockMap = NULL;
|
||||
static MM_DUMP_POINTERS MmCoreDumpDeviceFuncs;
|
||||
DWORD MmCoreDumpType;
|
||||
ULONG MmCoreDumpType;
|
||||
|
||||
/*
|
||||
* Translate between a swap entry and a file and offset pair.
|
||||
|
@ -223,14 +223,13 @@ MmReserveSwapPages(ULONG Nr)
|
|||
KeAcquireSpinLock(&PagingFileListLock, &oldIrql);
|
||||
MiAvailSwapPages =
|
||||
(MiFreeSwapPages * MM_PAGEFILE_COMMIT_RATIO) + MM_PAGEFILE_COMMIT_GRACE;
|
||||
MiReservedSwapPages = MiReservedSwapPages + Nr;
|
||||
if (MM_PAGEFILE_COMMIT_RATIO != 0 && MiAvailSwapPages < MiReservedSwapPages)
|
||||
{
|
||||
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
|
||||
return(FALSE);
|
||||
}
|
||||
MiReservedSwapPages = MiReservedSwapPages + Nr;
|
||||
}
|
||||
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -305,6 +304,12 @@ MmFreeSwapPage(SWAPENTRY Entry)
|
|||
KeReleaseSpinLock(&PagingFileListLock, oldIrql);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
MmIsAvailableSwapPage(VOID)
|
||||
{
|
||||
return(MiFreeSwapPages > 0);
|
||||
}
|
||||
|
||||
SWAPENTRY
|
||||
MmAllocSwapPage(VOID)
|
||||
{
|
||||
|
@ -504,7 +509,6 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
|||
KIRQL oldIrql;
|
||||
ULONG AllocMapSize;
|
||||
ULONG i;
|
||||
PVOID Buffer;
|
||||
|
||||
DPRINT("NtCreatePagingFile(FileName %wZ, InitialSize %I64d)\n",
|
||||
FileName, InitialSize->QuadPart);
|
||||
|
@ -539,23 +543,16 @@ NtCreatePagingFile(IN PUNICODE_STRING FileName,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
Buffer = ExAllocatePool(NonPagedPool, 4096);
|
||||
memset(Buffer, 0, 4096);
|
||||
Status = NtWriteFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
4096,
|
||||
InitialSize,
|
||||
NULL);
|
||||
Status = NtSetInformationFile(FileHandle,
|
||||
&IoStatus,
|
||||
InitialSize,
|
||||
sizeof(LARGE_INTEGER),
|
||||
FileAllocationInformation);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NtClose(FileHandle);
|
||||
ZwClose(FileHandle);
|
||||
return(Status);
|
||||
}
|
||||
ExFreePool(Buffer);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: rmap.c,v 1.7 2002/08/10 16:41:19 dwelch Exp $
|
||||
/* $Id: rmap.c,v 1.8 2002/08/14 20:58:36 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -57,6 +57,100 @@ MmInitializeRmapList(VOID)
|
|||
ExInitializeFastMutex(&RmapListLock);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
MmWritePagePhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
PMM_RMAP_ENTRY entry;
|
||||
PMEMORY_AREA MemoryArea;
|
||||
ULONG Type;
|
||||
PVOID Address;
|
||||
PEPROCESS Process;
|
||||
PMM_PAGEOP PageOp;
|
||||
LARGE_INTEGER Offset;
|
||||
NTSTATUS Status;
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
entry = MmGetRmapListHeadPage(PhysicalAddress);
|
||||
if (entry == NULL)
|
||||
{
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
Process = entry->Process;
|
||||
Address = entry->Address;
|
||||
if ((((ULONG)Address) & 0xFFF) != 0)
|
||||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
MmLockAddressSpace(&Process->AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(&Process->AddressSpace, Address);
|
||||
Type = MemoryArea->Type;
|
||||
if (Type == MEMORY_AREA_SECTION_VIEW)
|
||||
{
|
||||
Offset.QuadPart = (ULONG)((Address - (ULONG)MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset);
|
||||
|
||||
/*
|
||||
* Get or create a pageop
|
||||
*/
|
||||
PageOp = MmGetPageOp(MemoryArea, 0, 0,
|
||||
MemoryArea->Data.SectionData.Segment,
|
||||
Offset.u.LowPart, MM_PAGEOP_PAGEOUT);
|
||||
if (PageOp == NULL)
|
||||
{
|
||||
DPRINT1("MmGetPageOp failed\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
if (PageOp->Thread != PsGetCurrentThread())
|
||||
{
|
||||
MmReleasePageOp(PageOp);
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release locks now we have a page op.
|
||||
*/
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
|
||||
/*
|
||||
* Do the actual page out work.
|
||||
*/
|
||||
Status = MmWritePageSectionView(&Process->AddressSpace, MemoryArea,
|
||||
Address, PageOp);
|
||||
}
|
||||
else if (Type == MEMORY_AREA_VIRTUAL_MEMORY)
|
||||
{
|
||||
PageOp = MmGetPageOp(MemoryArea, Process->UniqueProcessId,
|
||||
Address, NULL, 0, MM_PAGEOP_PAGEOUT);
|
||||
if (PageOp->Thread != PsGetCurrentThread())
|
||||
{
|
||||
MmReleasePageOp(PageOp);
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release locks now we have a page op.
|
||||
*/
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
|
||||
/*
|
||||
* Do the actual page out work.
|
||||
*/
|
||||
Status = MmWritePageVirtualMemory(&Process->AddressSpace, MemoryArea,
|
||||
Address, PageOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
|
@ -83,6 +177,7 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
MmLockAddressSpace(&Process->AddressSpace);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(&Process->AddressSpace, Address);
|
||||
Type = MemoryArea->Type;
|
||||
|
@ -107,7 +202,6 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
{
|
||||
MmReleasePageOp(PageOp);
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
@ -115,7 +209,6 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
* Release locks now we have a page op.
|
||||
*/
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
|
||||
/*
|
||||
* Do the actual page out work.
|
||||
|
@ -131,7 +224,6 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
{
|
||||
MmReleasePageOp(PageOp);
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
@ -139,7 +231,6 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
* Release locks now we have a page op.
|
||||
*/
|
||||
MmUnlockAddressSpace(&Process->AddressSpace);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
|
||||
/*
|
||||
* Do the actual page out work.
|
||||
|
@ -154,6 +245,71 @@ MmPageOutPhysicalAddress(PHYSICAL_ADDRESS PhysicalAddress)
|
|||
return(Status);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmSetCleanAllRmaps(PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
PMM_RMAP_ENTRY current_entry;
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
current_entry = MmGetRmapListHeadPage(PhysicalAddress);
|
||||
if (current_entry == NULL)
|
||||
{
|
||||
DPRINT1("MmIsDirtyRmap: No rmaps.\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
while (current_entry != NULL)
|
||||
{
|
||||
MmSetCleanPage(current_entry->Process, current_entry->Address);
|
||||
current_entry = current_entry->Next;
|
||||
}
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmSetDirtyAllRmaps(PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
PMM_RMAP_ENTRY current_entry;
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
current_entry = MmGetRmapListHeadPage(PhysicalAddress);
|
||||
if (current_entry == NULL)
|
||||
{
|
||||
DPRINT1("MmIsDirtyRmap: No rmaps.\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
while (current_entry != NULL)
|
||||
{
|
||||
MmSetDirtyPage(current_entry->Process, current_entry->Address);
|
||||
current_entry = current_entry->Next;
|
||||
}
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
}
|
||||
|
||||
BOOL
|
||||
MmIsDirtyPageRmap(PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
PMM_RMAP_ENTRY current_entry;
|
||||
|
||||
ExAcquireFastMutex(&RmapListLock);
|
||||
current_entry = MmGetRmapListHeadPage(PhysicalAddress);
|
||||
if (current_entry == NULL)
|
||||
{
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(FALSE);
|
||||
}
|
||||
while (current_entry != NULL)
|
||||
{
|
||||
if (MmIsDirtyPage(current_entry->Process, current_entry->Address))
|
||||
{
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(TRUE);
|
||||
}
|
||||
current_entry = current_entry->Next;
|
||||
}
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmInsertRmap(PHYSICAL_ADDRESS PhysicalAddress, PEPROCESS Process,
|
||||
PVOID Address)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: section.c,v 1.88 2002/08/10 16:41:19 dwelch Exp $
|
||||
/* $Id: section.c,v 1.89 2002/08/14 20:58:37 dwelch Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/section.c
|
||||
|
@ -133,14 +133,6 @@ MmFreeSectionSegments(PFILE_OBJECT FileObject)
|
|||
}
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MArea,
|
||||
PVOID Address)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
VOID
|
||||
MmLockSection(PSECTION_OBJECT Section)
|
||||
{
|
||||
|
@ -278,6 +270,8 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
|
|||
{
|
||||
PFILE_OBJECT FileObject;
|
||||
PREACTOS_COMMON_FCB_HEADER Fcb;
|
||||
SWAPENTRY SavedSwapEntry;
|
||||
PHYSICAL_ADDRESS Page;
|
||||
|
||||
MmSetPageEntrySectionSegment(Segment, Offset, 0);
|
||||
FileObject = Section->FileObject;
|
||||
|
@ -296,6 +290,14 @@ MmUnsharePageEntrySectionSegment(PSECTION_OBJECT Section,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Page = (PHYSICAL_ADDRESS)(LONGLONG)PAGE_FROM_SSE(Entry);
|
||||
SavedSwapEntry = MmGetSavedSwapEntryPage(Page);
|
||||
if (SavedSwapEntry != 0)
|
||||
{
|
||||
MmFreeSwapPage(SavedSwapEntry);
|
||||
MmSetSavedSwapEntryPage(Page, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -644,7 +646,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
/*
|
||||
* Satisfying a page fault on a map of /Device/PhysicalMemory is easy
|
||||
*/
|
||||
if (Section->Flags & SO_PHYSICAL_MEMORY)
|
||||
if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
|
||||
{
|
||||
/*
|
||||
* Just map the desired physical page
|
||||
|
@ -749,7 +751,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
MmUnlockSection(Section);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
|
||||
if (Segment->Flags & MM_PAGEFILE_SECTION)
|
||||
if (Segment->Flags & MM_PAGEFILE_SEGMENT)
|
||||
{
|
||||
Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page);
|
||||
}
|
||||
|
@ -1212,7 +1214,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
* This should never happen since mappings of physical memory are never
|
||||
* placed in the rmap lists.
|
||||
*/
|
||||
if (Section->Flags & SO_PHYSICAL_MEMORY)
|
||||
if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
|
||||
{
|
||||
DPRINT1("Trying to page out from physical memory section address 0x%X "
|
||||
"process %d\n", Address, AddressSpace->Process->UniqueProcessId);
|
||||
|
@ -1503,6 +1505,157 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
PMEMORY_AREA MemoryArea,
|
||||
PVOID Address,
|
||||
PMM_PAGEOP PageOp)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
PSECTION_OBJECT Section;
|
||||
PMM_SECTION_SEGMENT Segment;
|
||||
PHYSICAL_ADDRESS PhysicalAddress;
|
||||
SWAPENTRY SwapEntry;
|
||||
PMDL Mdl;
|
||||
ULONG Entry;
|
||||
BOOLEAN Private;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PREACTOS_COMMON_FCB_HEADER Fcb;
|
||||
BOOLEAN DirectMapped;
|
||||
|
||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||
|
||||
Offset.QuadPart = (ULONG)(Address - (ULONG)MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset;
|
||||
|
||||
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
|
||||
DirectMapped = FALSE;
|
||||
if (FileObject != NULL)
|
||||
{
|
||||
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
|
||||
|
||||
/*
|
||||
* If the file system is letting us go directly to the cache and the
|
||||
* memory area was mapped at an offset in the file which is page aligned
|
||||
* then note this is a direct mapped page.
|
||||
*/
|
||||
if (FileObject->Flags & FO_DIRECT_CACHE_PAGING_READ &&
|
||||
(Offset.QuadPart % PAGESIZE) == 0)
|
||||
{
|
||||
DirectMapped = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the segment and section.
|
||||
*/
|
||||
Segment = MemoryArea->Data.SectionData.Segment;
|
||||
Section = MemoryArea->Data.SectionData.Section;
|
||||
|
||||
/*
|
||||
* This should never happen since mappings of physical memory are never
|
||||
* placed in the rmap lists.
|
||||
*/
|
||||
if (Section->AllocationAttributes & SEC_PHYSICALMEMORY)
|
||||
{
|
||||
DPRINT1("Trying to write back page from physical memory mapped at %X "
|
||||
"process %d\n", Address, AddressSpace->Process->UniqueProcessId);
|
||||
KeBugCheck(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the section segment entry and the physical address.
|
||||
*/
|
||||
Entry = MmGetPageEntrySectionSegment(Segment, Offset.QuadPart);
|
||||
if (!MmIsPagePresent(AddressSpace->Process, Address))
|
||||
{
|
||||
DPRINT1("Trying to page out not-present page at (%d,0x%.8X).\n",
|
||||
AddressSpace->Process->UniqueProcessId, Address);
|
||||
KeBugCheck(0);
|
||||
}
|
||||
PhysicalAddress =
|
||||
MmGetPhysicalAddressForProcess(AddressSpace->Process, Address);
|
||||
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
|
||||
|
||||
/*
|
||||
* Check for a private (COWed) page.
|
||||
*/
|
||||
if (Segment->Characteristics & IMAGE_SECTION_CHAR_BSS ||
|
||||
IS_SWAP_FROM_SSE(Entry) ||
|
||||
(LONGLONG)PAGE_FROM_SSE(Entry) != PhysicalAddress.QuadPart)
|
||||
{
|
||||
Private = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Private = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Speculatively set all mappings of the page to clean.
|
||||
*/
|
||||
MmSetCleanAllRmaps(PhysicalAddress);
|
||||
|
||||
/*
|
||||
* If this page was direct mapped from the cache then the cache manager
|
||||
* will take care of writing it back to disk.
|
||||
*/
|
||||
if (DirectMapped && !Private)
|
||||
{
|
||||
assert(SwapEntry == 0);
|
||||
CcRosMarkDirtyCacheSegment(Fcb->Bcb, Offset.u.LowPart);
|
||||
PageOp->Status = STATUS_SUCCESS;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
* If necessary, allocate an entry in the paging file for this page
|
||||
*/
|
||||
SwapEntry = MmGetSavedSwapEntryPage(PhysicalAddress);
|
||||
if (SwapEntry == 0)
|
||||
{
|
||||
SwapEntry = MmAllocSwapPage();
|
||||
if (SwapEntry == 0)
|
||||
{
|
||||
MmSetDirtyAllRmaps(PhysicalAddress);
|
||||
PageOp->Status = STATUS_UNSUCCESSFUL;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the page to the pagefile
|
||||
*/
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
MmBuildMdlFromPages(Mdl, (PULONG)&PhysicalAddress);
|
||||
Status = MmWriteToSwapPage(SwapEntry, Mdl);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("MM: Failed to write to swap page (Status was 0x%.8X)\n",
|
||||
Status);
|
||||
MmSetDirtyAllRmaps(PhysicalAddress);
|
||||
PageOp->Status = STATUS_UNSUCCESSFUL;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise we have succeeded.
|
||||
*/
|
||||
DPRINT("MM: Wrote section page 0x%.8X to swap!\n", PhysicalAddress);
|
||||
MmSetSavedSwapEntryPage(PhysicalAddress, SwapEntry);
|
||||
PageOp->Status = STATUS_SUCCESS;
|
||||
KeSetEvent(&PageOp->CompletionEvent, IO_NO_INCREMENT, FALSE);
|
||||
MmReleasePageOp(PageOp);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
VOID STATIC
|
||||
MmAlterViewAttributes(PMADDRESS_SPACE AddressSpace,
|
||||
PVOID BaseAddress,
|
||||
|
@ -1610,7 +1763,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
|||
Info->RegionSize = MemoryArea->Length;
|
||||
Info->State = MEM_COMMIT;
|
||||
Info->Protect = Region->Protect;
|
||||
if (MemoryArea->Data.SectionData.Section->Flags & MM_IMAGE_SECTION)
|
||||
if (MemoryArea->Data.SectionData.Section->AllocationAttributes & SEC_IMAGE)
|
||||
{
|
||||
Info->Type = MEM_IMAGE;
|
||||
}
|
||||
|
@ -1628,19 +1781,19 @@ MmpDeleteSection(PVOID ObjectBody)
|
|||
PSECTION_OBJECT Section = (PSECTION_OBJECT)ObjectBody;
|
||||
|
||||
DPRINT("MmpDeleteSection(ObjectBody %x)\n", ObjectBody);
|
||||
if (Section->Flags & MM_IMAGE_SECTION)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i = 0; i < Section->NrSegments; i++)
|
||||
{
|
||||
InterlockedDecrement(&Section->Segments[i].ReferenceCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InterlockedDecrement(&Section->Segments->ReferenceCount);
|
||||
}
|
||||
if (Section->AllocationAttributes & SEC_IMAGE)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
for (i = 0; i < Section->NrSegments; i++)
|
||||
{
|
||||
InterlockedDecrement(&Section->Segments[i].ReferenceCount);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InterlockedDecrement(&Section->Segments->ReferenceCount);
|
||||
}
|
||||
if (Section->FileObject != NULL)
|
||||
{
|
||||
ObDereferenceObject(Section->FileObject);
|
||||
|
@ -1722,7 +1875,7 @@ MmCreatePhysicalMemorySection(VOID)
|
|||
DbgPrint("Failed to reference PhysicalMemory section\n");
|
||||
KeBugCheck(0);
|
||||
}
|
||||
PhysSection->Flags = PhysSection->Flags | SO_PHYSICAL_MEMORY;
|
||||
PhysSection->AllocationAttributes |= SEC_PHYSICALMEMORY;
|
||||
ObDereferenceObject((PVOID)PhysSection);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -1805,11 +1958,10 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
|
|||
* Initialize it
|
||||
*/
|
||||
Section->SectionPageProtection = SectionPageProtection;
|
||||
Section->AllocateAttributes = AllocationAttributes;
|
||||
Section->AllocationAttributes = AllocationAttributes;
|
||||
InitializeListHead(&Section->ViewListHead);
|
||||
KeInitializeSpinLock(&Section->ViewListLock);
|
||||
KeInitializeMutex(&Section->Lock, 0);
|
||||
Section->Flags = 0;
|
||||
Section->FileObject = NULL;
|
||||
Section->MaximumSize = MaximumSize;
|
||||
Segment = ExAllocatePoolWithTag(NonPagedPool, sizeof(MM_SECTION_SEGMENT),
|
||||
|
@ -1827,7 +1979,7 @@ MmCreatePageFileSection(PHANDLE SectionHandle,
|
|||
Segment->Protection = SectionPageProtection;
|
||||
Segment->Attributes = AllocationAttributes;
|
||||
Segment->Length = MaximumSize.u.LowPart;
|
||||
Segment->Flags = MM_PAGEFILE_SECTION;
|
||||
Segment->Flags = MM_PAGEFILE_SEGMENT;
|
||||
Segment->WriteCopy = FALSE;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -1878,11 +2030,10 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
* Initialize it
|
||||
*/
|
||||
Section->SectionPageProtection = SectionPageProtection;
|
||||
Section->AllocateAttributes = AllocationAttributes;
|
||||
Section->AllocationAttributes = AllocationAttributes;
|
||||
InitializeListHead(&Section->ViewListHead);
|
||||
KeInitializeSpinLock(&Section->ViewListLock);
|
||||
KeInitializeMutex(&Section->Lock, 0);
|
||||
Section->Flags = 0;
|
||||
Section->NrSegments = 1;
|
||||
Section->ImageBase = NULL;
|
||||
Section->EntryPoint = NULL;
|
||||
|
@ -1950,6 +2101,24 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
((PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize;
|
||||
}
|
||||
|
||||
if (MaximumSize.QuadPart >
|
||||
((PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext)->FileSize.QuadPart)
|
||||
{
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
Status = NtSetInformationFile(FileHandle,
|
||||
&Iosb,
|
||||
&MaximumSize,
|
||||
sizeof(LARGE_INTEGER),
|
||||
FileAllocationInformation);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ZwClose(*SectionHandle);
|
||||
ObDereferenceObject(Section);
|
||||
ObDereferenceObject(FileObject);
|
||||
return(STATUS_SECTION_NOT_EXTENDED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock the file
|
||||
*/
|
||||
|
@ -2008,7 +2177,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
Segment->FileOffset = 0;
|
||||
Segment->Protection = 0;
|
||||
Segment->Attributes = 0;
|
||||
Segment->Flags = 0;
|
||||
Segment->Flags = MM_DATAFILE_SEGMENT;
|
||||
Segment->Characteristics = 0;
|
||||
Segment->WriteCopy = FALSE;
|
||||
if (AllocationAttributes & SEC_RESERVE)
|
||||
|
@ -2032,7 +2201,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
DataSectionObject;
|
||||
Section->Segments = Segment;
|
||||
InterlockedIncrement((PLONG)&Segment->ReferenceCount);
|
||||
Status = KeWaitForSingleObject((PVOID)&Section->Lock,
|
||||
Status = KeWaitForSingleObject((PVOID)&Segment->Lock,
|
||||
0,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
|
@ -2054,6 +2223,7 @@ MmCreateDataFileSection(PHANDLE SectionHandle,
|
|||
}
|
||||
KeSetEvent((PVOID)&FileObject->Lock, IO_NO_INCREMENT, FALSE);
|
||||
Section->FileObject = FileObject;
|
||||
Section->MaximumSize = MaximumSize;
|
||||
KeReleaseMutex(&Segment->Lock, FALSE);
|
||||
|
||||
ObDereferenceObject(Section);
|
||||
|
@ -2227,11 +2397,10 @@ MmCreateImageSection(PHANDLE SectionHandle,
|
|||
* Initialize it
|
||||
*/
|
||||
Section->SectionPageProtection = SectionPageProtection;
|
||||
Section->AllocateAttributes = AllocationAttributes;
|
||||
Section->AllocationAttributes = AllocationAttributes;
|
||||
InitializeListHead(&Section->ViewListHead);
|
||||
KeInitializeSpinLock(&Section->ViewListLock);
|
||||
KeInitializeMutex(&Section->Lock, 0);
|
||||
Section->Flags = MM_IMAGE_SECTION;
|
||||
Section->NrSegments = PEHeader.FileHeader.NumberOfSections + 1;
|
||||
Section->ImageBase = (PVOID)PEHeader.OptionalHeader.ImageBase;
|
||||
Section->EntryPoint = (PVOID)PEHeader.OptionalHeader.AddressOfEntryPoint;
|
||||
|
@ -2687,32 +2856,56 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
|||
{
|
||||
PMEMORY_AREA MArea;
|
||||
ULONG Entry;
|
||||
PFILE_OBJECT FileObject;
|
||||
PREACTOS_COMMON_FCB_HEADER Fcb;
|
||||
ULONG Offset;
|
||||
SWAPENTRY SavedSwapEntry;
|
||||
PMM_PAGEOP PageOp;
|
||||
|
||||
MArea = (PMEMORY_AREA)Context;
|
||||
|
||||
Offset = ((ULONG)PAGE_ROUND_DOWN(Address) - (ULONG)MArea->BaseAddress) +
|
||||
MArea->Data.SectionData.ViewOffset;
|
||||
Entry = MmGetPageEntrySectionSegment(MArea->Data.SectionData.Segment,
|
||||
Offset);
|
||||
|
||||
PageOp = MmCheckForPageOp(MArea, 0, NULL, MArea->Data.SectionData.Segment,
|
||||
Offset);
|
||||
assert(PageOp == NULL);
|
||||
|
||||
/*
|
||||
* For a dirty, datafile, non-private page mark it as dirty in the
|
||||
* cache manager.
|
||||
*/
|
||||
if (MArea->Data.SectionData.Segment->Flags & MM_DATAFILE_SEGMENT)
|
||||
{
|
||||
if (PhysAddr.QuadPart == PAGE_FROM_SSE(Entry) && Dirty)
|
||||
{
|
||||
FileObject = MemoryArea->Data.SectionData.Section->FileObject;
|
||||
Fcb = (PREACTOS_COMMON_FCB_HEADER)FileObject->FsContext;
|
||||
CcRosMarkDirtyCacheSegment(Fcb->Bcb, Offset);
|
||||
assert(SwapEntry == 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (SwapEntry != 0)
|
||||
{
|
||||
MmFreeSwapPage(SwapEntry);
|
||||
}
|
||||
else if (PhysAddr.QuadPart != 0)
|
||||
{
|
||||
ULONG Offset;
|
||||
|
||||
Offset =
|
||||
((ULONG)PAGE_ROUND_DOWN(Address) - (ULONG)MArea->BaseAddress) +
|
||||
MArea->Data.SectionData.ViewOffset;
|
||||
|
||||
Entry = MmGetPageEntrySectionSegment(MArea->Data.SectionData.Segment,
|
||||
Offset);
|
||||
if (IS_SWAP_FROM_SSE(Entry))
|
||||
{
|
||||
KeBugCheck(0);
|
||||
}
|
||||
else if (PhysAddr.QuadPart != (PAGE_FROM_SSE(Entry)))
|
||||
{
|
||||
if (IS_SWAP_FROM_SSE(Entry) ||
|
||||
PhysAddr.QuadPart != (PAGE_FROM_SSE(Entry)))
|
||||
{
|
||||
/*
|
||||
* Just dereference private pages
|
||||
*/
|
||||
SavedSwapEntry = MmGetSavedSwapEntryPage(PhysAddr);
|
||||
if (SavedSwapEntry != 0)
|
||||
{
|
||||
MmFreeSwapPage(SavedSwapEntry);
|
||||
MmSetSavedSwapEntryPage(PhysAddr, 0);
|
||||
}
|
||||
MmDeleteRmap(PhysAddr, MArea->Process, Address);
|
||||
MmReleasePageMemoryConsumer(MC_USER, PhysAddr);
|
||||
}
|
||||
|
@ -2744,7 +2937,7 @@ MmUnmapViewOfSection(PEPROCESS Process,
|
|||
AddressSpace = &Process->AddressSpace;
|
||||
|
||||
DPRINT("Opening memory area Process %x BaseAddress %x\n",
|
||||
Process, BaseAddress);
|
||||
Process, BaseAddress);
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace,
|
||||
BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
|
@ -2752,6 +2945,8 @@ MmUnmapViewOfSection(PEPROCESS Process,
|
|||
MmUnlockAddressSpace(AddressSpace);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
MemoryArea->DeleteInProgress = TRUE;
|
||||
|
||||
MmLockSection(MemoryArea->Data.SectionData.Section);
|
||||
MmLockSectionSegment(MemoryArea->Data.SectionData.Segment);
|
||||
|
@ -2770,7 +2965,8 @@ MmUnmapViewOfSection(PEPROCESS Process,
|
|||
ExFreePool(CurrentRegion);
|
||||
}
|
||||
|
||||
if (MemoryArea->Data.SectionData.Section->Flags & SO_PHYSICAL_MEMORY)
|
||||
if (MemoryArea->Data.SectionData.Section->AllocationAttributes &
|
||||
SEC_PHYSICALMEMORY)
|
||||
{
|
||||
Status = MmFreeMemoryArea(&Process->AddressSpace,
|
||||
BaseAddress,
|
||||
|
@ -3087,7 +3283,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
|||
MmLockAddressSpace(AddressSpace);
|
||||
MmLockSection(SectionObject);
|
||||
|
||||
if (Section->Flags & MM_IMAGE_SECTION)
|
||||
if (Section->AllocationAttributes & SEC_IMAGE)
|
||||
{
|
||||
ULONG i;
|
||||
|
||||
|
@ -3139,7 +3335,11 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
|||
return(STATUS_MAPPED_ALIGNMENT);
|
||||
}
|
||||
|
||||
if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart)
|
||||
if ((*ViewSize) == 0)
|
||||
{
|
||||
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
|
||||
}
|
||||
else if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart)
|
||||
{
|
||||
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ntobj.c,v 1.8 2001/03/06 23:34:39 cnettel Exp $
|
||||
/* $Id: ntobj.c,v 1.9 2002/08/14 20:58:38 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -80,103 +80,96 @@ NtQueryObject (
|
|||
If we don't do it this way, we should anyway add switches and separate functions to handle
|
||||
the different object types*/
|
||||
{
|
||||
POBJECT_NAME_INFORMATION nameinfo;
|
||||
POBJECT_TYPE_INFORMATION typeinfo;
|
||||
PFILE_NAME_INFORMATION filenameinfo;
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
PFILE_OBJECT fileob;
|
||||
|
||||
Status = ObReferenceObjectByHandle(
|
||||
ObjectHandle,
|
||||
0,
|
||||
NULL,
|
||||
KernelMode,
|
||||
& Object,
|
||||
NULL
|
||||
);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
POBJECT_NAME_INFORMATION nameinfo;
|
||||
POBJECT_TYPE_INFORMATION typeinfo;
|
||||
PFILE_NAME_INFORMATION filenameinfo;
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
PFILE_OBJECT fileob;
|
||||
|
||||
Status = ObReferenceObjectByHandle(ObjectHandle,
|
||||
0,
|
||||
NULL,
|
||||
KernelMode,
|
||||
&Object,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
ObjectHeader = BODY_TO_HEADER(Object);
|
||||
|
||||
switch (ObjectInformationClass)
|
||||
{
|
||||
case ObjectNameInformation:
|
||||
if (Length!=sizeof(OBJECT_NAME_INFORMATION)) return STATUS_INVALID_BUFFER_SIZE;
|
||||
nameinfo = (POBJECT_NAME_INFORMATION)ObjectInformation;
|
||||
(*ResultLength)=Length;
|
||||
|
||||
if (ObjectHeader->Type==InternalFileType) // FIXME: Temporary QueryName implementation, or at least separate functions
|
||||
{
|
||||
return Status;
|
||||
fileob = (PFILE_OBJECT) Object;
|
||||
Status = internalNameBuilder(BODY_TO_HEADER(fileob->DeviceObject->Vpb->RealDevice), &nameinfo->Name);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
filenameinfo = ExAllocatePool(NonPagedPool,MAX_PATH*sizeof(WCHAR)+sizeof(ULONG));
|
||||
IoQueryFileInformation(fileob,FileNameInformation,MAX_PATH*sizeof(WCHAR)+sizeof(ULONG), filenameinfo,NULL);
|
||||
|
||||
Status = RtlAppendUnicodeToString(&(nameinfo->Name), filenameinfo->FileName);
|
||||
|
||||
ExFreePool( filenameinfo);
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
|
||||
ObjectHeader = BODY_TO_HEADER(Object);
|
||||
|
||||
|
||||
switch (ObjectInformationClass)
|
||||
else
|
||||
if (ObjectHeader->Name.Buffer) // If it's got a name there, we can probably just make the full path through Name and Parent
|
||||
{
|
||||
Status = internalNameBuilder(ObjectHeader, &nameinfo->Name);
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
ObDereferenceObject(Object);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
case ObjectTypeInformation:
|
||||
typeinfo = (POBJECT_TYPE_INFORMATION)ObjectInformation;
|
||||
if (Length!=sizeof(OBJECT_TYPE_INFORMATION)) return STATUS_INVALID_BUFFER_SIZE;
|
||||
|
||||
// FIXME: Is this supposed to only be the header's Name field?
|
||||
// Can somebody check/verify this?
|
||||
RtlCopyUnicodeString(&typeinfo->Name,&ObjectHeader->Name);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
case ObjectNameInformation:
|
||||
if (Length!=sizeof(OBJECT_NAME_INFORMATION)) return STATUS_INVALID_BUFFER_SIZE;
|
||||
nameinfo = (POBJECT_NAME_INFORMATION)ObjectInformation;
|
||||
(*ResultLength)=Length;
|
||||
|
||||
if (ObjectHeader->Type==InternalFileType) // FIXME: Temporary QueryName implementation, or at least separate functions
|
||||
{
|
||||
fileob = (PFILE_OBJECT) Object;
|
||||
Status = internalNameBuilder(BODY_TO_HEADER(fileob->DeviceObject->Vpb->RealDevice), &nameinfo->Name);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
filenameinfo = ExAllocatePool(NonPagedPool,MAX_PATH*sizeof(WCHAR)+sizeof(ULONG));
|
||||
IoQueryFileInformation(fileob,FileNameInformation,MAX_PATH*sizeof(WCHAR)+sizeof(ULONG), filenameinfo,NULL);
|
||||
|
||||
Status = RtlAppendUnicodeToString(&(nameinfo->Name), filenameinfo->FileName);
|
||||
|
||||
ExFreePool( filenameinfo);
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
else
|
||||
if (ObjectHeader->Name.Buffer) // If it's got a name there, we can probably just make the full path through Name and Parent
|
||||
{
|
||||
Status = internalNameBuilder(ObjectHeader, &nameinfo->Name);
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
ObDereferenceObject(Object);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
case ObjectTypeInformation:
|
||||
typeinfo = (POBJECT_TYPE_INFORMATION)ObjectInformation;
|
||||
if (Length!=sizeof(OBJECT_TYPE_INFORMATION)) return STATUS_INVALID_BUFFER_SIZE;
|
||||
|
||||
// FIXME: Is this supposed to only be the header's Name field?
|
||||
// Can somebody check/verify this?
|
||||
RtlCopyUnicodeString(&typeinfo->Name,&ObjectHeader->Name);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlCopyUnicodeString(&typeinfo->Type,&ObjectHeader->ObjectType->TypeName);
|
||||
//This should be info from the object header, not the object type, right?
|
||||
typeinfo->TotalHandles = ObjectHeader-> HandleCount;
|
||||
typeinfo->ReferenceCount = ObjectHeader -> RefCount;
|
||||
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
default:
|
||||
ObDereferenceObject(Object);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlCopyUnicodeString(&typeinfo->Type,&ObjectHeader->ObjectType->TypeName);
|
||||
//This should be info from the object header, not the object type, right?
|
||||
typeinfo->TotalHandles = ObjectHeader-> HandleCount;
|
||||
typeinfo->ReferenceCount = ObjectHeader -> RefCount;
|
||||
|
||||
ObDereferenceObject(Object);
|
||||
return Status;
|
||||
default:
|
||||
ObDereferenceObject(Object);
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ObMakeTemporaryObject (
|
||||
PVOID ObjectBody
|
||||
)
|
||||
VOID STDCALL
|
||||
ObMakeTemporaryObject (PVOID ObjectBody)
|
||||
{
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
|
||||
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
||||
ObjectHeader->Permanent = FALSE;
|
||||
POBJECT_HEADER ObjectHeader;
|
||||
|
||||
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
||||
ObjectHeader->Permanent = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: object.c,v 1.52 2002/07/17 21:04:56 dwelch Exp $
|
||||
/* $Id: object.c,v 1.53 2002/08/14 20:58:38 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -243,15 +243,10 @@ ObCreateObject(OUT PHANDLE Handle,
|
|||
|
||||
DPRINT("ObCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n",
|
||||
Handle, ObjectAttributes, Type);
|
||||
if (ObjectAttributes != NULL &&
|
||||
ObjectAttributes->ObjectName != NULL)
|
||||
{
|
||||
DPRINT("ObjectAttributes->ObjectName->Buffer %S\n",
|
||||
ObjectAttributes->ObjectName->Buffer);
|
||||
}
|
||||
|
||||
if (ObjectAttributes != NULL &&
|
||||
ObjectAttributes->ObjectName != NULL)
|
||||
ObjectAttributes->ObjectName != NULL &&
|
||||
ObjectAttributes->ObjectName->Buffer != NULL)
|
||||
{
|
||||
Status = ObFindObject(ObjectAttributes,
|
||||
&Parent,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.49 2002/08/09 17:23:57 dwelch Exp $
|
||||
/* $Id: create.c,v 1.50 2002/08/14 20:58:38 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -266,20 +266,6 @@ PsReferenceImpersonationToken(PETHREAD Thread,
|
|||
return(Thread->ImpersonationInfo->Token);
|
||||
}
|
||||
|
||||
VOID STDCALL
|
||||
PiTimeoutThread(struct _KDPC *dpc,
|
||||
PVOID Context,
|
||||
PVOID arg1,
|
||||
PVOID arg2)
|
||||
{
|
||||
/* Wake up the thread, and tell it it timed out */
|
||||
NTSTATUS Status = STATUS_TIMEOUT;
|
||||
|
||||
DPRINT("PiTimeoutThread()\n");
|
||||
|
||||
KeRemoveAllWaitsThread((PETHREAD)Context, Status);
|
||||
}
|
||||
|
||||
VOID
|
||||
PiBeforeBeginThread(CONTEXT c)
|
||||
{
|
||||
|
@ -575,8 +561,7 @@ NtCreateThread(PHANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
Status = Ke386InitThreadWithContext(&Thread->Tcb,
|
||||
ThreadContext);
|
||||
Status = KiArchInitThreadWithContext(&Thread->Tcb, ThreadContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
|
@ -683,9 +668,7 @@ PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
}
|
||||
|
||||
Thread->StartAddress = StartRoutine;
|
||||
Status = Ke386InitThread(&Thread->Tcb,
|
||||
StartRoutine,
|
||||
StartContext);
|
||||
Status = KiArchInitThread(&Thread->Tcb, StartRoutine, StartContext);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: thread.c,v 1.100 2002/08/08 17:54:16 dwelch Exp $
|
||||
/* $Id: thread.c,v 1.101 2002/08/14 20:58:38 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -142,23 +142,6 @@ VOID PsDumpThreads(BOOLEAN IncludeSystem)
|
|||
|
||||
static PETHREAD PsScanThreadList (KPRIORITY Priority, ULONG Affinity)
|
||||
{
|
||||
#if 0
|
||||
PLIST_ENTRY current_entry;
|
||||
PETHREAD current;
|
||||
|
||||
current_entry = RemoveHeadList(&PriorityListHead[Priority]);
|
||||
if (current_entry != &PriorityListHead[Priority])
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry, ETHREAD,
|
||||
Tcb.QueueListEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
current = NULL;
|
||||
}
|
||||
|
||||
return(current);
|
||||
#else
|
||||
PLIST_ENTRY current_entry;
|
||||
PETHREAD current;
|
||||
|
||||
|
@ -179,10 +162,8 @@ static PETHREAD PsScanThreadList (KPRIORITY Priority, ULONG Affinity)
|
|||
current_entry = current_entry->Flink;
|
||||
}
|
||||
return(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
||||
{
|
||||
KPRIORITY CurrentPriority;
|
||||
|
@ -225,7 +206,7 @@ VOID PsDispatchThreadNoLock (ULONG NewThreadStatus)
|
|||
CurrentThread = Candidate;
|
||||
|
||||
KeReleaseSpinLockFromDpcLevel(&PiThreadListLock);
|
||||
Ki386ContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
|
||||
KiArchContextSwitch(&CurrentThread->Tcb, &OldThread->Tcb);
|
||||
PsReapThreads();
|
||||
return;
|
||||
}
|
||||
|
@ -430,14 +411,13 @@ PsInitThreadManagment(VOID)
|
|||
DoneInitYet = TRUE;
|
||||
}
|
||||
|
||||
|
||||
LONG STDCALL
|
||||
KeSetBasePriorityThread (PKTHREAD Thread,
|
||||
LONG Increment)
|
||||
/*
|
||||
* Sets thread's base priority relative to the process' base priority
|
||||
* Should only be passed in THREAD_PRIORITY_ constants in pstypes.h
|
||||
*/
|
||||
LONG STDCALL
|
||||
KeSetBasePriorityThread (PKTHREAD Thread,
|
||||
LONG Increment)
|
||||
{
|
||||
Thread->BasePriority =
|
||||
((PETHREAD)Thread)->ThreadsProcess->Pcb.BasePriority + Increment;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: init.c,v 1.39 2002/06/14 07:46:47 ekohl Exp $
|
||||
/* $Id: init.c,v 1.40 2002/08/14 20:58:39 dwelch Exp $
|
||||
*
|
||||
* init.c - Session Manager initialization
|
||||
*
|
||||
|
@ -386,6 +386,7 @@ SmPagingFilesQueryRoutine(PWSTR ValueName,
|
|||
LARGE_INTEGER InitialSize;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
NTSTATUS Status;
|
||||
LPWSTR p;
|
||||
|
||||
#ifndef NDEBUG
|
||||
PrintString("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength);
|
||||
|
@ -398,23 +399,33 @@ SmPagingFilesQueryRoutine(PWSTR ValueName,
|
|||
}
|
||||
|
||||
/*
|
||||
* FIXME:
|
||||
* read initial and maximum size from the registry or use default values
|
||||
*
|
||||
* Format: "<path>[ <initial_size>[ <maximum_size>]]"
|
||||
*/
|
||||
if ((p = wcschr(ValueData, ' ')) != NULL)
|
||||
{
|
||||
*p = L'\0';
|
||||
InitialSize.QuadPart = wcstoul(p + 1, &p, 0);
|
||||
if (*p == ' ')
|
||||
{
|
||||
MaximumSize.QuadPart = wcstoul(p + 1, NULL, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InitialSize.QuadPart = 50 * 4096;
|
||||
MaximumSize.QuadPart = 80 * 4096;
|
||||
}
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)ValueData,
|
||||
&FileName,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
InitialSize.QuadPart = 50 * 4096;
|
||||
MaximumSize.QuadPart = 80 * 4096;
|
||||
&FileName,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DbgPrint("SMSS: Created paging file %wZ with size %dKB\n",
|
||||
&FileName, InitialSize.QuadPart / 1024);
|
||||
Status = NtCreatePagingFile(&FileName,
|
||||
&InitialSize,
|
||||
&MaximumSize,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: shell.c,v 1.9 2002/05/02 09:10:00 jfilby Exp $
|
||||
/* $Id: shell.c,v 1.10 2002/08/14 20:58:39 dwelch Exp $
|
||||
*
|
||||
* PROJECT : ReactOS Operating System
|
||||
* DESCRIPTION: ReactOS' Native Shell
|
||||
|
@ -124,6 +124,7 @@ void ExecuteType(char* cmdline)
|
|||
HANDLE FileHandle;
|
||||
char c;
|
||||
DWORD Result;
|
||||
BOOL Success;
|
||||
|
||||
FileHandle = CreateFile(cmdline,
|
||||
FILE_GENERIC_READ,
|
||||
|
@ -137,15 +138,19 @@ void ExecuteType(char* cmdline)
|
|||
debug_printf("Unknown file\n");
|
||||
return;
|
||||
}
|
||||
while (ReadFile(FileHandle,
|
||||
&c,
|
||||
1,
|
||||
&Result,
|
||||
NULL))
|
||||
do
|
||||
{
|
||||
debug_printf("%c",c);
|
||||
c = 0;
|
||||
}
|
||||
Success = ReadFile(FileHandle,
|
||||
&c,
|
||||
1,
|
||||
&Result,
|
||||
NULL);
|
||||
if (Success)
|
||||
{
|
||||
debug_printf("%c",c);
|
||||
c = 0;
|
||||
}
|
||||
} while (Success && Result > 0);
|
||||
CloseHandle(FileHandle);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue