mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 13:34:53 +00:00
[WIN32K]
- Implement EngMapSectionView and EngUnmapSectionView. Use EngUnmapSectionView in SURFACE_Cleanup. svn path=/trunk/; revision=56536
This commit is contained in:
parent
c0a4db6701
commit
b1305c8589
|
@ -25,18 +25,4 @@ VOID FASTCALL IntGdiAcquireSemaphore ( HSEMAPHORE hsem );
|
||||||
VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );
|
VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );
|
||||||
ULONGLONG APIENTRY EngGetTickCount(VOID);
|
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);
|
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG iFormat);
|
||||||
|
|
|
@ -15,45 +15,77 @@
|
||||||
#define MmMapViewInSessionSpace MmMapViewInSystemSpace
|
#define MmMapViewInSessionSpace MmMapViewInSystemSpace
|
||||||
#define MmUnmapViewInSessionSpace MmUnmapViewInSystemSpace
|
#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 ghSystem32Directory;
|
||||||
HANDLE ghRootDirectory;
|
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
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -156,7 +188,7 @@ EngMapSection(
|
||||||
}
|
}
|
||||||
else
|
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);
|
pSection->pvMappedBase, Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
88
reactos/win32ss/gdi/eng/mapping.h
Normal file
88
reactos/win32ss/gdi/eng/mapping.h
Normal file
|
@ -0,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);
|
||||||
|
|
|
@ -68,7 +68,6 @@ SURFACE_Cleanup(PVOID ObjectBody)
|
||||||
{
|
{
|
||||||
PSURFACE psurf = (PSURFACE)ObjectBody;
|
PSURFACE psurf = (PSURFACE)ObjectBody;
|
||||||
PVOID pvBits = psurf->SurfObj.pvBits;
|
PVOID pvBits = psurf->SurfObj.pvBits;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Check if the surface has bits */
|
/* Check if the surface has bits */
|
||||||
if (pvBits)
|
if (pvBits)
|
||||||
|
@ -79,20 +78,8 @@ SURFACE_Cleanup(PVOID ObjectBody)
|
||||||
/* Check if it is a DIB section */
|
/* Check if it is a DIB section */
|
||||||
if (psurf->hDIBSection)
|
if (psurf->hDIBSection)
|
||||||
{
|
{
|
||||||
/* Unsecure the memory */
|
/* Unmap the section view */
|
||||||
EngUnsecureMem(psurf->hSecure);
|
EngUnmapSectionView(pvBits, psurf->dwOffset, 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (psurf->SurfObj.fjBitmap & BMF_USERMEM)
|
else if (psurf->SurfObj.fjBitmap & BMF_USERMEM)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,7 @@ typedef struct _PALETTE *PPALETTE;
|
||||||
#include "gdi/eng/xlateobj.h"
|
#include "gdi/eng/xlateobj.h"
|
||||||
#include "gdi/eng/floatobj.h"
|
#include "gdi/eng/floatobj.h"
|
||||||
#include "gdi/eng/mouse.h"
|
#include "gdi/eng/mouse.h"
|
||||||
|
#include "gdi/eng/mapping.h"
|
||||||
#include "gdi/ntgdi/xformobj.h"
|
#include "gdi/ntgdi/xformobj.h"
|
||||||
#include "gdi/ntgdi/brush.h"
|
#include "gdi/ntgdi/brush.h"
|
||||||
#include "gdi/ntgdi/color.h"
|
#include "gdi/ntgdi/color.h"
|
||||||
|
|
Loading…
Reference in a new issue