Author: tkreuzer
Date: Mon May 7 22:41:10 2012
New Revision: 56536
URL:
http://svn.reactos.org/svn/reactos?rev=56536&view=rev
Log:
[WIN32K]
- Implement EngMapSectionView and EngUnmapSectionView. Use EngUnmapSectionView in
SURFACE_Cleanup.
Added:
trunk/reactos/win32ss/gdi/eng/mapping.h (with props)
Modified:
trunk/reactos/win32ss/gdi/eng/eng.h
trunk/reactos/win32ss/gdi/eng/mapping.c
trunk/reactos/win32ss/gdi/eng/surface.c
trunk/reactos/win32ss/win32kp.h
Modified: trunk/reactos/win32ss/gdi/eng/eng.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/eng.h?rev=…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/eng.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/eng.h [iso-8859-1] Mon May 7 22:41:10 2012
@@ -25,18 +25,4 @@
VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );
ULONGLONG APIENTRY EngGetTickCount(VOID);
-BOOL
-APIENTRY
-EngFreeSectionMem(
- IN PVOID pvSection OPTIONAL,
- IN PVOID pvMappedBase OPTIONAL);
-
-PVOID
-APIENTRY
-EngAllocSectionMem(
- OUT PVOID *ppvSection,
- IN ULONG fl,
- IN SIZE_T cjSize,
- IN ULONG ulTag);
-
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG
Delta, ULONG iFormat);
Modified: trunk/reactos/win32ss/gdi/eng/mapping.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/mapping.c?…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/mapping.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/mapping.c [iso-8859-1] Mon May 7 22:41:10 2012
@@ -15,44 +15,76 @@
#define MmMapViewInSessionSpace MmMapViewInSystemSpace
#define MmUnmapViewInSessionSpace MmUnmapViewInSystemSpace
-typedef struct _ENGSECTION
-{
- PVOID pvSectionObject;
- PVOID pvMappedBase;
- SIZE_T cjViewSize;
- ULONG ulTag;
-} ENGSECTION, *PENGSECTION;
-
-typedef struct _FILEVIEW
-{
- LARGE_INTEGER LastWriteTime;
- PVOID pvKView;
- PVOID pvViewFD;
- SIZE_T cjView;
- PVOID pSection;
-} FILEVIEW, *PFILEVIEW;
-
-typedef struct _FONTFILEVIEW
-{
- FILEVIEW;
- DWORD reserved[2];
- PWSTR pwszPath;
- SIZE_T ulRegionSize;
- ULONG cKRefCount;
- ULONG cRefCountFD;
- PVOID pvSpoolerBase;
- DWORD dwSpoolerPid;
-} FONTFILEVIEW, *PFONTFILEVIEW;
-
-enum
-{
- FVF_SYSTEMROOT = 1,
- FVF_READONLY = 2,
- FVF_FONTFILE = 4,
-};
-
HANDLE ghSystem32Directory;
HANDLE ghRootDirectory;
+
+PVOID
+NTAPI
+EngMapSectionView(
+ _In_ HANDLE hSection,
+ _In_ SIZE_T cjSize,
+ _In_ ULONG cjOffset,
+ _Out_ PHANDLE phSecure)
+{
+ LARGE_INTEGER liSectionOffset;
+ PVOID pvBaseAddress;
+ NTSTATUS Status;
+
+ /* Align the offset at allocation granularity and compensate for the size */
+ liSectionOffset.QuadPart = cjOffset & ~(MM_ALLOCATION_GRANULARITY - 1);
+ cjSize += cjOffset & (MM_ALLOCATION_GRANULARITY - 1);
+
+ /* Map the section */
+ Status = ZwMapViewOfSection(hSection,
+ NtCurrentProcess(),
+ &pvBaseAddress,
+ 0,
+ cjSize,
+ &liSectionOffset,
+ &cjSize,
+ ViewShare,
+ 0,
+ PAGE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("ZwMapViewOfSection failed (0x%lx)\n", Status);
+ return NULL;
+ }
+
+ /* Secure the section memory */
+ *phSecure = EngSecureMem(pvBaseAddress, cjSize);
+ if (!*phSecure)
+ {
+ ZwUnmapViewOfSection(NtCurrentProcess(), pvBaseAddress);
+ return NULL;
+ }
+
+ /* Return the address where the requested data starts */
+ return (PUCHAR)pvBaseAddress + (cjOffset & (MM_ALLOCATION_GRANULARITY - 1));
+}
+
+VOID
+NTAPI
+EngUnmapSectionView(
+ _In_ PVOID pvBits,
+ _In_ ULONG cjOffset,
+ _In_ HANDLE hSecure)
+{
+ NTSTATUS Status;
+
+ /* Unsecure the memory */
+ EngUnsecureMem(hSecure);
+
+ /* Calculate the real start of the section view */
+ pvBits = (PUCHAR)pvBits - (cjOffset & (MM_ALLOCATION_GRANULARITY - 1));
+
+ /* Unmap the section view */
+ Status = MmUnmapViewOfSection(PsGetCurrentProcess(), pvBits);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Could not unmap section view!\n");
+ }
+}
PVOID
@@ -156,7 +188,7 @@
}
else
{
- DPRINT1("Failed to unmap a section @ &p Status=0x%x\n",
+ DPRINT1("Failed to unmap a section @ &p Status=0x%x\n",
pSection->pvMappedBase, Status);
}
}
Added: trunk/reactos/win32ss/gdi/eng/mapping.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/mapping.h?…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/mapping.h (added)
+++ trunk/reactos/win32ss/gdi/eng/mapping.h [iso-8859-1] Mon May 7 22:41:10 2012
@@ -1,0 +1,88 @@
+
+typedef struct _ENGSECTION
+{
+ PVOID pvSectionObject;
+ PVOID pvMappedBase;
+ SIZE_T cjViewSize;
+ ULONG ulTag;
+} ENGSECTION, *PENGSECTION;
+
+typedef struct _FILEVIEW
+{
+ LARGE_INTEGER LastWriteTime;
+ PVOID pvKView;
+ PVOID pvViewFD;
+ SIZE_T cjView;
+ PVOID pSection;
+} FILEVIEW, *PFILEVIEW;
+
+typedef struct _FONTFILEVIEW
+{
+ FILEVIEW;
+ DWORD reserved[2];
+ PWSTR pwszPath;
+ SIZE_T ulRegionSize;
+ ULONG cKRefCount;
+ ULONG cRefCountFD;
+ PVOID pvSpoolerBase;
+ DWORD dwSpoolerPid;
+} FONTFILEVIEW, *PFONTFILEVIEW;
+
+enum
+{
+ FVF_SYSTEMROOT = 1,
+ FVF_READONLY = 2,
+ FVF_FONTFILE = 4,
+};
+
+PVOID
+NTAPI
+EngMapSectionView(
+ _In_ HANDLE hSection,
+ _In_ SIZE_T cjSize,
+ _In_ ULONG cjOffset,
+ _Out_ PHANDLE phSecure);
+
+VOID
+NTAPI
+EngUnmapSectionView(
+ _In_ PVOID pvBits,
+ _In_ ULONG cjOffset,
+ _In_ HANDLE hSecure);
+
+PVOID
+NTAPI
+EngCreateSection(
+ IN ULONG fl,
+ IN SIZE_T cjSize,
+ IN ULONG ulTag);
+
+BOOL
+APIENTRY
+EngMapSection(
+ IN PVOID pvSection,
+ IN BOOL bMap,
+ IN HANDLE hProcess,
+ OUT PVOID* pvBaseAddress);
+
+PVOID
+APIENTRY
+EngAllocSectionMem(
+ OUT PVOID *ppvSection,
+ IN ULONG fl,
+ IN SIZE_T cjSize,
+ IN ULONG ulTag);
+
+BOOL
+APIENTRY
+EngFreeSectionMem(
+ IN PVOID pvSection OPTIONAL,
+ IN PVOID pvMappedBase OPTIONAL);
+
+PFILEVIEW
+NTAPI
+EngLoadModuleEx(
+ LPWSTR pwsz,
+ ULONG cjSizeOfModule,
+ FLONG fl);
+
Propchange: trunk/reactos/win32ss/gdi/eng/mapping.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/win32ss/gdi/eng/surface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/surface.c?…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/surface.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/surface.c [iso-8859-1] Mon May 7 22:41:10 2012
@@ -68,7 +68,6 @@
{
PSURFACE psurf = (PSURFACE)ObjectBody;
PVOID pvBits = psurf->SurfObj.pvBits;
- NTSTATUS Status;
/* Check if the surface has bits */
if (pvBits)
@@ -79,20 +78,8 @@
/* Check if it is a DIB section */
if (psurf->hDIBSection)
{
- /* Unsecure the memory */
- EngUnsecureMem(psurf->hSecure);
-
- /* Calculate the real start of the section */
- pvBits = (PVOID)((ULONG_PTR)pvBits - psurf->dwOffset);
-
- /* Unmap the section */
- Status = MmUnmapViewOfSection(PsGetCurrentProcess(), pvBits);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Could not unmap section view!\n");
- // Should we BugCheck here?
- ASSERT(FALSE);
- }
+ /* Unmap the section view */
+ EngUnmapSectionView(pvBits, psurf->dwOffset, psurf->hSecure);
}
else if (psurf->SurfObj.fjBitmap & BMF_USERMEM)
{
Modified: trunk/reactos/win32ss/win32kp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/win32kp.h?rev=5653…
==============================================================================
--- trunk/reactos/win32ss/win32kp.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/win32kp.h [iso-8859-1] Mon May 7 22:41:10 2012
@@ -49,6 +49,7 @@
#include "gdi/eng/xlateobj.h"
#include "gdi/eng/floatobj.h"
#include "gdi/eng/mouse.h"
+#include "gdi/eng/mapping.h"
#include "gdi/ntgdi/xformobj.h"
#include "gdi/ntgdi/brush.h"
#include "gdi/ntgdi/color.h"