Author: hbelusca
Date: Sun Dec 28 20:50:35 2014
New Revision: 65863
URL:
http://svn.reactos.org/svn/reactos?rev=65863&view=rev
Log:
[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.
Added:
trunk/reactos/win32ss/user/ntuser/usrheap.h (with props)
Modified:
trunk/reactos/win32ss/gdi/ntgdi/dc.h
trunk/reactos/win32ss/gdi/ntgdi/palette.h
trunk/reactos/win32ss/user/ntuser/desktop.c
trunk/reactos/win32ss/user/ntuser/desktop.h
trunk/reactos/win32ss/user/ntuser/main.c
trunk/reactos/win32ss/user/ntuser/ntuser.h
trunk/reactos/win32ss/user/ntuser/usrheap.c
trunk/reactos/win32ss/user/ntuser/win32.h
trunk/reactos/win32ss/win32kp.h
Modified: trunk/reactos/win32ss/gdi/ntgdi/dc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dc.h?rev…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dc.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dc.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -132,6 +132,7 @@
PVOID pSurfInfo;
POINTL ptlDoBanding;
} DC;
+// typedef struct _DC *PDC;
extern PDC defaultDCstate;
Modified: trunk/reactos/win32ss/gdi/ntgdi/palette.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/palette.…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/palette.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/palette.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -44,7 +44,7 @@
ULONG ulBlueShift;
HDEV hPDev;
PALETTEENTRY apalColors[0];
-} PALETTE;
+} PALETTE, *PPALETTE;
extern PALETTE gpalRGB, gpalBGR, gpalRGB555, gpalRGB565, *gppalMono, *gppalDefault;
extern PPALETTE appalSurfaceDefault[];
Modified: trunk/reactos/win32ss/user/ntuser/desktop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/desktop.c [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -1893,8 +1893,12 @@
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 @@
return STATUS_SUCCESS;
}
- PrevLink = &HeapMapping->Next;
+ PrevLink = &HeapMapping->Next;
HeapMapping = HeapMapping->Next;
}
@@ -1929,7 +1933,7 @@
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);
Modified: trunk/reactos/win32ss/user/ntuser/desktop.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/deskto…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/desktop.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -37,7 +37,7 @@
/* Thread blocking input */
PVOID BlockInputThread;
LIST_ENTRY ShellHookWindows;
-} DESKTOP;
+} DESKTOP, *PDESKTOP;
// Desktop flags
#define DF_TME_HOVER 0x00000400
@@ -259,6 +259,11 @@
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 @@
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 DesktopWindowProc(PWND, UINT, WPARAM, LPARAM, LRESULT *);
BOOL FASTCALL UserMessageWindowProc(PWND pwnd, UINT Msg, WPARAM wParam, LPARAM lParam,
LRESULT *lResult);
VOID NTAPI DesktopThreadMain();
+
/* EOF */
Modified: trunk/reactos/win32ss/user/ntuser/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/main.c…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/main.c [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -23,9 +23,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.
Modified: trunk/reactos/win32ss/user/ntuser/ntuser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/ntuser…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/ntuser.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/ntuser.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -24,78 +24,4 @@
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 */
Modified: trunk/reactos/win32ss/user/ntuser/usrheap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/usrhea…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/usrheap.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/usrheap.c [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -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 @@
{
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 @@
}
/* 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 @@
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)
Added: trunk/reactos/win32ss/user/ntuser/usrheap.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/usrhea…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/usrheap.h (added)
+++ trunk/reactos/win32ss/user/ntuser/usrheap.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -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 */
Propchange: trunk/reactos/win32ss/user/ntuser/usrheap.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/win32ss/user/ntuser/win32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/win32.…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/win32.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/win32.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -52,7 +52,6 @@
extern PCLS SystemClassList;
extern BOOL RegisteredSysClasses;
-typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
typedef struct tagMENUSTATE MENUSTATE, *PMENUSTATE;
#include <pshpack1.h>
@@ -172,6 +171,7 @@
} \
} while(0)
+
#define IntReferenceProcessInfo(ppi) \
InterlockedIncrement((volatile LONG*)(&(ppi)->RefCount))
Modified: trunk/reactos/win32ss/win32kp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/win32kp.h?rev=6586…
==============================================================================
--- trunk/reactos/win32ss/win32kp.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/win32kp.h [iso-8859-1] Sun Dec 28 20:50:35 2014
@@ -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 @@
#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 @@
#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"