mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[WIN32K]
A bit of code reorganization: - move a maximum of typedefs into their corresponding headers, - move user heap functionality into a dedicated header, - add a note in some functions that the first heap mapping entry in the W32 process info structure is dedicated for the global user heap mapping, - remove extra-parenthesis in casts. svn path=/trunk/; revision=65863
This commit is contained in:
parent
1c36df367b
commit
f2f466977a
10 changed files with 125 additions and 92 deletions
|
@ -132,6 +132,7 @@ typedef struct _DC
|
|||
PVOID pSurfInfo;
|
||||
POINTL ptlDoBanding;
|
||||
} DC;
|
||||
// typedef struct _DC *PDC;
|
||||
|
||||
extern PDC defaultDCstate;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct _PALETTE
|
|||
ULONG ulBlueShift;
|
||||
HDEV hPDev;
|
||||
PALETTEENTRY apalColors[0];
|
||||
} PALETTE;
|
||||
} PALETTE, *PPALETTE;
|
||||
|
||||
extern PALETTE gpalRGB, gpalBGR, gpalRGB555, gpalRGB565, *gppalMono, *gppalDefault;
|
||||
extern PPALETTE appalSurfaceDefault[];
|
||||
|
|
|
@ -1893,8 +1893,12 @@ IntMapDesktopView(IN PDESKTOP pdesk)
|
|||
|
||||
ppi = PsGetCurrentProcessWin32Process();
|
||||
|
||||
/* Find out if another thread already mapped the desktop heap */
|
||||
PrevLink = &ppi->HeapMappings.Next;
|
||||
/*
|
||||
* Find out if another thread already mapped the desktop heap.
|
||||
* Start the search at the next mapping: skip the first entry
|
||||
* as it must be the global user heap mapping.
|
||||
*/
|
||||
PrevLink = &ppi->HeapMappings.Next;
|
||||
HeapMapping = *PrevLink;
|
||||
while (HeapMapping != NULL)
|
||||
{
|
||||
|
@ -1904,7 +1908,7 @@ IntMapDesktopView(IN PDESKTOP pdesk)
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
PrevLink = &HeapMapping->Next;
|
||||
PrevLink = &HeapMapping->Next;
|
||||
HeapMapping = HeapMapping->Next;
|
||||
}
|
||||
|
||||
|
@ -1929,7 +1933,7 @@ IntMapDesktopView(IN PDESKTOP pdesk)
|
|||
TRACE("ppi 0x%p mapped heap of desktop 0x%p\n", ppi, pdesk);
|
||||
|
||||
/* Add the mapping */
|
||||
HeapMapping = UserHeapAlloc(sizeof(W32HEAP_USER_MAPPING));
|
||||
HeapMapping = UserHeapAlloc(sizeof(*HeapMapping));
|
||||
if (HeapMapping == NULL)
|
||||
{
|
||||
MmUnmapViewOfSection(PsGetCurrentProcess(), UserBase);
|
||||
|
|
|
@ -37,7 +37,7 @@ typedef struct _DESKTOP
|
|||
/* Thread blocking input */
|
||||
PVOID BlockInputThread;
|
||||
LIST_ENTRY ShellHookWindows;
|
||||
} DESKTOP;
|
||||
} DESKTOP, *PDESKTOP;
|
||||
|
||||
// Desktop flags
|
||||
#define DF_TME_HOVER 0x00000400
|
||||
|
@ -259,6 +259,11 @@ DesktopHeapGetUserDelta(VOID)
|
|||
pheapDesktop = pti->rpdesk->pheapDesktop;
|
||||
|
||||
W32Process = PsGetCurrentProcessWin32Process();
|
||||
|
||||
/*
|
||||
* Start the search at the next mapping: skip the first entry
|
||||
* as it must be the global user heap mapping.
|
||||
*/
|
||||
Mapping = W32Process->HeapMappings.Next;
|
||||
while (Mapping != NULL)
|
||||
{
|
||||
|
@ -281,6 +286,11 @@ DesktopHeapAddressToUser(PVOID lpMem)
|
|||
PPROCESSINFO W32Process;
|
||||
|
||||
W32Process = PsGetCurrentProcessWin32Process();
|
||||
|
||||
/*
|
||||
* Start the search at the next mapping: skip the first entry
|
||||
* as it must be the global user heap mapping.
|
||||
*/
|
||||
Mapping = W32Process->HeapMappings.Next;
|
||||
while (Mapping != NULL)
|
||||
{
|
||||
|
@ -303,4 +313,5 @@ BOOL FASTCALL IntPaintDesktop(HDC);
|
|||
BOOL FASTCALL DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *);
|
||||
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *lResult);
|
||||
VOID NTAPI DesktopThreadMain();
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -24,9 +24,6 @@ NTSTATUS GdiProcessDestroy(PEPROCESS Process);
|
|||
NTSTATUS GdiThreadCreate(PETHREAD Thread);
|
||||
NTSTATUS GdiThreadDestroy(PETHREAD Thread);
|
||||
|
||||
HANDLE GlobalUserHeap = NULL;
|
||||
PVOID GlobalUserHeapSection = NULL;
|
||||
|
||||
PSERVERINFO gpsi = NULL; // Global User Server Information.
|
||||
|
||||
SHORT gusLanguageID;
|
||||
|
|
|
@ -24,78 +24,4 @@ VOID FASTCALL UserLeave(VOID);
|
|||
BOOL FASTCALL UserIsEntered(VOID);
|
||||
BOOL FASTCALL UserIsEnteredExclusive(VOID);
|
||||
|
||||
/* User heap */
|
||||
extern HANDLE GlobalUserHeap;
|
||||
|
||||
PWIN32HEAP
|
||||
UserCreateHeap(OUT PVOID *SectionObject,
|
||||
IN OUT PVOID *SystemBase,
|
||||
IN SIZE_T HeapSize);
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapAlloc(SIZE_T Bytes)
|
||||
{
|
||||
return RtlAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
Bytes);
|
||||
}
|
||||
|
||||
static __inline BOOL
|
||||
UserHeapFree(PVOID lpMem)
|
||||
{
|
||||
return RtlFreeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapReAlloc(PVOID lpMem,
|
||||
SIZE_T Bytes)
|
||||
{
|
||||
#if 0
|
||||
/* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
|
||||
return RtlReAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem,
|
||||
Bytes);
|
||||
#else
|
||||
SIZE_T PrevSize;
|
||||
PVOID pNew;
|
||||
|
||||
PrevSize = RtlSizeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
|
||||
if (PrevSize == Bytes)
|
||||
return lpMem;
|
||||
|
||||
pNew = RtlAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
Bytes);
|
||||
if (pNew != NULL)
|
||||
{
|
||||
if (PrevSize < Bytes)
|
||||
Bytes = PrevSize;
|
||||
|
||||
RtlCopyMemory(pNew,
|
||||
lpMem,
|
||||
Bytes);
|
||||
|
||||
RtlFreeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
}
|
||||
|
||||
return pNew;
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapAddressToUser(PVOID lpMem)
|
||||
{
|
||||
PPROCESSINFO W32Process = PsGetCurrentProcessWin32Process();
|
||||
return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
|
||||
(ULONG_PTR)W32Process->HeapMappings.UserMapping);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
HANDLE GlobalUserHeap = NULL;
|
||||
PVOID GlobalUserHeapSection = NULL;
|
||||
|
||||
|
||||
_Function_class_(RTL_HEAP_COMMIT_ROUTINE)
|
||||
_IRQL_requires_same_
|
||||
|
@ -63,7 +66,6 @@ IntUserHeapCommitRoutine(
|
|||
{
|
||||
SIZE_T ViewSize = 0;
|
||||
LARGE_INTEGER Offset;
|
||||
extern PVOID GlobalUserHeapSection;
|
||||
|
||||
/* HACK: This needs to be handled during startup only... */
|
||||
ASSERT(Base == (PVOID)GlobalUserHeap);
|
||||
|
@ -86,8 +88,8 @@ IntUserHeapCommitRoutine(
|
|||
}
|
||||
|
||||
/* Apply the commit address offset to the user base address */
|
||||
Delta = (SIZE_T) ((ULONG_PTR) (*CommitAddress) - (ULONG_PTR) (Base));
|
||||
UserCommitAddress = (PVOID) ((ULONG_PTR) (UserBase) + Delta);
|
||||
Delta = (SIZE_T)((ULONG_PTR)(*CommitAddress) - (ULONG_PTR)Base);
|
||||
UserCommitAddress = (PVOID)((ULONG_PTR)UserBase + Delta);
|
||||
|
||||
/* Perform the actual commit */
|
||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||
|
@ -100,8 +102,8 @@ IntUserHeapCommitRoutine(
|
|||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* Determine the address to return */
|
||||
Delta = (SIZE_T) ((ULONG_PTR) (UserCommitAddress) - (ULONG_PTR) (UserBase));
|
||||
*CommitAddress = (PVOID) ((ULONG_PTR) (Base) + Delta);
|
||||
Delta = (SIZE_T)((ULONG_PTR)UserCommitAddress - (ULONG_PTR)UserBase);
|
||||
*CommitAddress = (PVOID)((ULONG_PTR)Base + Delta);
|
||||
}
|
||||
|
||||
if (W32Process == NULL)
|
||||
|
|
93
reactos/win32ss/user/ntuser/usrheap.h
Normal file
93
reactos/win32ss/user/ntuser/usrheap.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
#pragma once
|
||||
|
||||
typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
|
||||
|
||||
/*
|
||||
typedef struct _W32HEAP_USER_MAPPING
|
||||
{
|
||||
struct _W32HEAP_USER_MAPPING* Next;
|
||||
PVOID KernelMapping;
|
||||
PVOID UserMapping;
|
||||
ULONG_PTR Limit;
|
||||
ULONG Count;
|
||||
} W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
|
||||
*/
|
||||
|
||||
/* User heap */
|
||||
extern HANDLE GlobalUserHeap;
|
||||
extern PVOID GlobalUserHeapSection;
|
||||
|
||||
PWIN32HEAP
|
||||
UserCreateHeap(OUT PVOID *SectionObject,
|
||||
IN OUT PVOID *SystemBase,
|
||||
IN SIZE_T HeapSize);
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapAlloc(SIZE_T Bytes)
|
||||
{
|
||||
return RtlAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
Bytes);
|
||||
}
|
||||
|
||||
static __inline BOOL
|
||||
UserHeapFree(PVOID lpMem)
|
||||
{
|
||||
return RtlFreeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapReAlloc(PVOID lpMem,
|
||||
SIZE_T Bytes)
|
||||
{
|
||||
#if 0
|
||||
/* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
|
||||
return RtlReAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem,
|
||||
Bytes);
|
||||
#else
|
||||
SIZE_T PrevSize;
|
||||
PVOID pNew;
|
||||
|
||||
PrevSize = RtlSizeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
|
||||
if (PrevSize == Bytes)
|
||||
return lpMem;
|
||||
|
||||
pNew = RtlAllocateHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
Bytes);
|
||||
if (pNew != NULL)
|
||||
{
|
||||
if (PrevSize < Bytes)
|
||||
Bytes = PrevSize;
|
||||
|
||||
RtlCopyMemory(pNew,
|
||||
lpMem,
|
||||
Bytes);
|
||||
|
||||
RtlFreeHeap(GlobalUserHeap,
|
||||
HEAP_NO_SERIALIZE,
|
||||
lpMem);
|
||||
}
|
||||
|
||||
return pNew;
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline PVOID
|
||||
UserHeapAddressToUser(PVOID lpMem)
|
||||
{
|
||||
PPROCESSINFO W32Process = PsGetCurrentProcessWin32Process();
|
||||
|
||||
/* The first mapping entry is the global user heap mapping */
|
||||
return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
|
||||
(ULONG_PTR)W32Process->HeapMappings.UserMapping);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -52,7 +52,6 @@ extern HANDLE hModuleWin; // This Win32k Instance.
|
|||
extern PCLS SystemClassList;
|
||||
extern BOOL RegisteredSysClasses;
|
||||
|
||||
typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
|
||||
typedef struct tagMENUSTATE MENUSTATE, *PMENUSTATE;
|
||||
|
||||
#include <pshpack1.h>
|
||||
|
@ -172,6 +171,7 @@ do { \
|
|||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define IntReferenceProcessInfo(ppi) \
|
||||
InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
|
||||
/* Internal NtGdi Headers */
|
||||
typedef struct _DC *PDC;
|
||||
typedef struct _PALETTE *PPALETTE;
|
||||
#include "gdi/ntgdi/gdiobj.h"
|
||||
#include "gdi/ntgdi/palette.h"
|
||||
#include "gdi/eng/surface.h"
|
||||
#include "gdi/eng/pdevobj.h"
|
||||
#include "gdi/eng/ldevobj.h"
|
||||
|
@ -57,7 +57,6 @@ typedef struct _PALETTE *PPALETTE;
|
|||
#include "gdi/ntgdi/brush.h"
|
||||
#include "gdi/ntgdi/color.h"
|
||||
#include "gdi/ntgdi/bitmaps.h"
|
||||
#include "gdi/ntgdi/palette.h"
|
||||
#include "gdi/ntgdi/region.h"
|
||||
#include "gdi/ntgdi/dc.h"
|
||||
#include "gdi/ntgdi/dib.h"
|
||||
|
@ -74,8 +73,8 @@ typedef struct _PALETTE *PPALETTE;
|
|||
#include "reactx/ntddraw/intddraw.h"
|
||||
|
||||
/* Internal NtUser Headers */
|
||||
typedef struct _DESKTOP *PDESKTOP;
|
||||
#include "user/ntuser/win32.h"
|
||||
#include "user/ntuser/usrheap.h"
|
||||
#include "user/ntuser/object.h"
|
||||
#include "user/ntuser/ntuser.h"
|
||||
#include "user/ntuser/shutdown.h"
|
||||
|
|
Loading…
Reference in a new issue