Author: tkreuzer
Date: Sat Jun 5 17:58:01 2010
New Revision: 47591
URL:
http://svn.reactos.org/svn/reactos?rev=47591&view=rev
Log:
[WIN32K]
- Simplify the logic of the mapping functions a bit, by using either FILEVIEW or
ENGSECTION, not both.
- Set FILEVIEW::LastWriteTime
Modified:
branches/reactos-yarotows/subsystems/win32/win32k/eng/mapping.c
Modified: branches/reactos-yarotows/subsystems/win32/win32k/eng/mapping.c
URL:
http://svn.reactos.org/svn/reactos/branches/reactos-yarotows/subsystems/win…
==============================================================================
--- branches/reactos-yarotows/subsystems/win32/win32k/eng/mapping.c [iso-8859-1]
(original)
+++ branches/reactos-yarotows/subsystems/win32/win32k/eng/mapping.c [iso-8859-1] Sat Jun
5 17:58:01 2010
@@ -25,10 +25,10 @@
typedef struct _FILEVIEW
{
- ULARGE_INTEGER LastWriteTime;
+ LARGE_INTEGER LastWriteTime;
PVOID pvKView;
PVOID pvViewFD;
- ULONG cjView;
+ SIZE_T cjView;
PVOID pSection;
} FILEVIEW, *PFILEVIEW;
@@ -60,7 +60,6 @@
EngCreateSection(
IN ULONG fl,
IN SIZE_T cjSize,
- HANDLE hFile,
IN ULONG ulTag)
{
NTSTATUS Status;
@@ -79,7 +78,7 @@
&liSize,
PAGE_READWRITE,
SEC_COMMIT,
- hFile,
+ NULL,
NULL);
if (!NT_SUCCESS(Status))
{
@@ -219,7 +218,7 @@
if (cjSize == 0) return NULL;
/* Allocate a section object */
- pSection = EngCreateSection(fl, cjSize, NULL, ulTag);
+ pSection = EngCreateSection(fl, cjSize, ulTag);
/* Map the section in session space */
Status = MmMapViewInSessionSpace(pSection->pvSectionObject,
@@ -251,8 +250,10 @@
HANDLE hRootDir;
UNICODE_STRING ustrFileName;
IO_STATUS_BLOCK IoStatusBlock;
+ FILE_BASIC_INFORMATION FileInformation;
HANDLE hFile;
NTSTATUS Status;
+ LARGE_INTEGER liSize;
if (fl & FVF_FONTFILE)
{
@@ -297,18 +298,41 @@
NULL,
0);
- /* Check for auto size */
- if (cjSizeOfModule == 0)
- {
- }
-
- /* Allocate a section object */
- pFileView->pSection = EngCreateSection(fl, cjSizeOfModule, hFile,
'1234');
+ Status = ZwQueryInformationFile(hFile,
+ &IoStatusBlock,
+ &FileInformation,
+ sizeof(FILE_BASIC_INFORMATION),
+ FileBasicInformation);
+ if (NT_SUCCESS(Status))
+ {
+ pFileView->LastWriteTime = FileInformation.LastWriteTime;
+ }
+
+ /* Create a section from the file */
+ liSize.QuadPart = cjSizeOfModule;
+ Status = MmCreateSection(&pFileView->pSection,
+ SECTION_ALL_ACCESS,
+ NULL,
+ cjSizeOfModule ? &liSize : NULL,
+ fl & FVF_READONLY ? PAGE_EXECUTE_READ :
PAGE_EXECUTE_READWRITE,
+ SEC_COMMIT,
+ hFile,
+ NULL);
/* Close the file handle */
ZwClose(hFile);
- pFileView->cjView = cjSizeOfModule;
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to create a section Status=0x%x\n", Status);
+ EngFreeMem(pFileView);
+ return NULL;
+ }
+
+
+ pFileView->pvKView = NULL;
+ pFileView->pvViewFD = NULL;
+ pFileView->cjView = 0;
return pFileView;
}
@@ -338,26 +362,23 @@
OUT PULONG pulSize)
{
PFILEVIEW pFileView = (PFILEVIEW)h;
- PENGSECTION pSection = pFileView->pSection;
- NTSTATUS Status;
+ NTSTATUS Status;
+
+ pFileView->cjView = 0;
/* Map the section in session space */
- Status = MmMapViewInSessionSpace(pSection->pvSectionObject,
- &pSection->pvMappedBase,
- &pSection->cjViewSize);
- if (NT_SUCCESS(Status))
- {
- *pulSize = pSection->cjViewSize;
- }
- else
+ Status = MmMapViewInSessionSpace(pFileView->pSection,
+ &pFileView->pvKView,
+ &pFileView->cjView);
+ if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to map a section Status=0x%x\n", Status);
*pulSize = 0;
- EngFreeSectionMem(pSection, NULL);
return NULL;
}
- return pSection->pvMappedBase;
+ *pulSize = pFileView->cjView;
+ return pFileView->pvKView;
}
VOID
@@ -365,10 +386,18 @@
EngFreeModule(IN HANDLE h)
{
PFILEVIEW pFileView = (PFILEVIEW)h;
- PENGSECTION pSection = pFileView->pSection;
-
- /* Free the section */
- EngFreeSectionMem(pSection, pSection->pvMappedBase);
+ NTSTATUS Status;
+
+ /* Unmap the section */
+ Status = MmUnmapViewInSessionSpace(pFileView->pvKView);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("MmUnmapViewInSessionSpace failed: 0x%lx\n", Status);
+ ASSERT(FALSE);
+ }
+
+ /* Dereference the section */
+ ObDereferenceObject(pFileView->pSection);
/* Free the file view memory */
EngFreeMem(pFileView);