Author: tkreuzer Date: Mon May 30 17:16:08 2011 New Revision: 52011
URL: http://svn.reactos.org/svn/reactos?rev=52011&view=rev Log: [WIN32K] - Implement InitMappingImpl that initializes ghsemModuleList - Use ZwCreateSection in EngLoadModuleEx. This is overhead in terms of code and runtime, but is neccessary, since we cannot pass a kernel file handle to MmCreateSection and passing a file object pointer is not supported on reactos yet. - Set proper access mask and page protection in EngLoadModuleEx
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/eng/mapping.c branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/mapping.h branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/main/dllmain.c
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/eng/mapping.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyste... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/eng/mapping.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/eng/mapping.c [iso-8859-1] Mon May 30 17:16:08 2011 @@ -14,6 +14,16 @@ HANDLE ghSystem32Directory; HSEMAPHORE ghsemModuleList; LIST_ENTRY gleModulelist = {&gleModulelist, &gleModulelist}; + +INIT_FUNCTION +NTSTATUS +NTAPI +InitMappingImpl(VOID) +{ + ghsemModuleList = EngCreateSemaphore(); + if (!ghsemModuleList) return STATUS_NO_MEMORY; + return STATUS_SUCCESS; +}
PVOID NTAPI @@ -222,11 +232,12 @@ UNICODE_STRING ustrFileName; IO_STATUS_BLOCK IoStatusBlock; FILE_BASIC_INFORMATION FileInformation; - HANDLE hFile = NULL; + HANDLE hFile = NULL, hSection; NTSTATUS Status; LARGE_INTEGER liSize; PLIST_ENTRY ple; - ULONG cjSize; + ULONG cjSize, flPageProtect; + ACCESS_MASK amAccess;
/* Acquire module list lock */ EngAcquireSemaphore(ghsemModuleList); @@ -245,6 +256,18 @@
/* Use system32 root dir or absolute path */ hRootDir = fl & FVF_SYSTEMROOT ? ghSystem32Directory : NULL; + + /* Set access mask and page protection */ + if (fl & FVF_WRITE) + { + amAccess = FILE_READ_DATA|FILE_WRITE_DATA; + flPageProtect = PAGE_EXECUTE_READWRITE; + } + else + { + amAccess = FILE_READ_DATA; + flPageProtect = PAGE_EXECUTE_READ; + }
/* Initialize unicode string and object attributes */ RtlInitUnicodeString(&ustrFileName, pwsz); @@ -256,7 +279,7 @@
/* Now open the file */ Status = ZwCreateFile(&hFile, - FILE_READ_DATA, + amAccess, &ObjectAttributes, &IoStatusBlock, NULL, @@ -328,14 +351,24 @@
/* Create a section from the file */ liSize.QuadPart = cjSizeOfModule; - Status = MmCreateSection(&pFileView->pSection, + Status = ZwCreateSection(&hSection, SECTION_ALL_ACCESS, NULL, cjSizeOfModule ? &liSize : NULL, - fl & FVF_READONLY ? PAGE_EXECUTE_READ : PAGE_EXECUTE_READWRITE, + flPageProtect, SEC_COMMIT, - hFile, - NULL); + hFile); + + if (NT_SUCCESS(Status)) + { + Status = ObReferenceObjectByHandle(hSection, + SECTION_ALL_ACCESS, + MmSectionObjectType, + KernelMode, + &pFileView->pSection, + NULL); + ZwClose(hSection); + }
if (!NT_SUCCESS(Status)) { @@ -362,7 +395,7 @@ EngLoadModule(LPWSTR pwsz) { /* Forward to EngLoadModuleEx */ - return (HANDLE)EngLoadModuleEx(pwsz, 0, FVF_READONLY | FVF_SYSTEMROOT); + return EngLoadModuleEx(pwsz, 0, FVF_SYSTEMROOT); }
HANDLE @@ -372,7 +405,7 @@ IN ULONG cjSizeOfModule) { /* Forward to EngLoadModuleEx */ - return (HANDLE)EngLoadModuleEx(pwsz, cjSizeOfModule, FVF_SYSTEMROOT); + return EngLoadModuleEx(pwsz, cjSizeOfModule, FVF_WRITE|FVF_SYSTEMROOT); }
PVOID
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/mapping.h URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyste... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/mapping.h [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/mapping.h [iso-8859-1] Mon May 30 17:16:08 2011 @@ -38,9 +38,14 @@ enum { FVF_SYSTEMROOT = 1, - FVF_READONLY = 2, + FVF_WRITE = 2, FVF_FONTFILE = 4, }; + +INIT_FUNCTION +NTSTATUS +NTAPI +InitMappingImpl(VOID);
PVOID NTAPI
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/main/dllmain.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyste... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/main/dllmain.c [iso-8859-1] Mon May 30 17:16:08 2011 @@ -138,9 +138,9 @@
DPRINT1("Shell process is exiting (%d)\n", ExitCode);
- UserPostMessage(hwndSAS, - WM_LOGONNOTIFY, - LN_SHELL_EXITED, + UserPostMessage(hwndSAS, + WM_LOGONNOTIFY, + LN_SHELL_EXITED, ExitCode); } } @@ -534,6 +534,7 @@ CreateStockObjects(); CreateSysColorObjects();
+ NT_ROF(InitMappingImpl()); NT_ROF(InitXlateImpl()); NT_ROF(InitPDEVImpl()); NT_ROF(InitLDEVImpl());