Author: tkreuzer Date: Sat Oct 18 21:05:41 2008 New Revision: 36824
URL: http://svn.reactos.org/svn/reactos?rev=36824&view=rev Log: Win32 structure cleanup (WIP): - replace hKernelHeap and HeapLimit from DESKTOPINFO with pvDesktopBase and pvDesktopLimit- replace hDesktopHeap with pheapDesktop in DESKTOP - use PWIN32HEAP for the heap handle and use this and only this as the handle. - Use the real base address for pvDesktopBase, instead of a copy of the heap handle
Modified: trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/include/desktop.h trunk/reactos/subsystems/win32/win32k/include/win32.h trunk/reactos/subsystems/win32/win32k/misc/usrheap.c trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c trunk/reactos/subsystems/win32/win32k/ntuser/misc.c trunk/reactos/subsystems/win32/win32k/w32k.h
Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntus... ============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -40,8 +40,6 @@ PVOID pvDesktopBase; PVOID pvDesktopLimit;
- HANDLE hKernelHeap; - ULONG_PTR HeapLimit; HWND hTaskManWindow; HWND hProgmanWindow; HWND hShellWindow;
Modified: trunk/reactos/subsystems/win32/win32k/include/desktop.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/desktop.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/desktop.h [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -25,7 +25,7 @@
LIST_ENTRY ShellHookWindows;
- HANDLE hDesktopHeap; + PWIN32HEAP pheapDesktop; PSECTION_OBJECT DesktopHeapSection; PDESKTOPINFO DesktopInfo; } DESKTOP, *PDESKTOP; @@ -139,7 +139,7 @@ DesktopHeapAlloc(IN PDESKTOP Desktop, IN SIZE_T Bytes) { - return RtlAllocateHeap(Desktop->DesktopInfo->hKernelHeap, + return RtlAllocateHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, Bytes); } @@ -148,7 +148,7 @@ DesktopHeapFree(IN PDESKTOP Desktop, IN PVOID lpMem) { - return RtlFreeHeap(Desktop->DesktopInfo->hKernelHeap, + return RtlFreeHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, lpMem); } @@ -160,7 +160,7 @@ { #if 0 /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */ - return RtlReAllocateHeap(Desktop->DesktopInfo->hKernelHeap, + return RtlReAllocateHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, lpMem, Bytes); @@ -168,14 +168,14 @@ SIZE_T PrevSize; PVOID pNew;
- PrevSize = RtlSizeHeap(Desktop->DesktopInfo->hKernelHeap, + PrevSize = RtlSizeHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, lpMem);
if (PrevSize == Bytes) return lpMem;
- pNew = RtlAllocateHeap(Desktop->DesktopInfo->hKernelHeap, + pNew = RtlAllocateHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, Bytes); if (pNew != NULL) @@ -187,7 +187,7 @@ lpMem, Bytes);
- RtlFreeHeap(Desktop->DesktopInfo->hKernelHeap, + RtlFreeHeap(Desktop->pheapDesktop, HEAP_NO_SERIALIZE, lpMem); } @@ -202,20 +202,20 @@ PW32HEAP_USER_MAPPING Mapping; PTHREADINFO pti; PW32PROCESS W32Process; - HANDLE hDesktopHeap; + PWIN32HEAP pheapDesktop; ULONG_PTR Delta = 0;
pti = PsGetCurrentThreadWin32Thread(); if (!pti->Desktop) return 0;
- hDesktopHeap = pti->Desktop->hDesktopHeap; + pheapDesktop = pti->Desktop->pheapDesktop;
W32Process = PsGetCurrentProcessWin32Process(); Mapping = W32Process->HeapMappings.Next; while (Mapping != NULL) { - if (Mapping->KernelMapping == (PVOID)hDesktopHeap) + if (Mapping->KernelMapping == (PVOID)pheapDesktop) { Delta = (ULONG_PTR)Mapping->KernelMapping - (ULONG_PTR)Mapping->UserMapping; break;
Modified: trunk/reactos/subsystems/win32/win32k/include/win32.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/win32.h [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -1,5 +1,7 @@ #ifndef __INCLUDE_NAPI_WIN32_H #define __INCLUDE_NAPI_WIN32_H + +typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
#include <pshpack1.h>
Modified: trunk/reactos/subsystems/win32/win32k/misc/usrheap.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/mis... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/misc/usrheap.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/misc/usrheap.c [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -102,7 +102,7 @@ return Status; }
-static HANDLE +static PWIN32HEAP IntUserHeapCreate(IN PSECTION_OBJECT SectionObject, IN PVOID *SystemMappedBase, IN ULONG HeapSize) @@ -111,7 +111,7 @@ LARGE_INTEGER Offset; SIZE_T ViewSize = PAGE_SIZE; RTL_HEAP_PARAMETERS Parameters = {0}; - HANDLE hHeap; + PVOID pHeap; NTSTATUS Status;
Offset.QuadPart = 0; @@ -150,23 +150,23 @@ Parameters.InitialReserve = (SIZE_T)HeapSize; Parameters.CommitRoutine = IntUserHeapCommitRoutine;
- hHeap = RtlCreateHeap(HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, + pHeap = RtlCreateHeap(HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, *SystemMappedBase, (SIZE_T)HeapSize, ViewSize, NULL, &Parameters);
- return hHeap; + return pHeap; }
-HANDLE +PWIN32HEAP UserCreateHeap(OUT PSECTION_OBJECT *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize) { LARGE_INTEGER SizeHeap; - HANDLE hHeap = NULL; + PWIN32HEAP pHeap = NULL; NTSTATUS Status;
SizeHeap.QuadPart = HeapSize; @@ -200,11 +200,11 @@ }
/* create the heap */ - hHeap = IntUserHeapCreate(*SectionObject, + pHeap = IntUserHeapCreate(*SectionObject, SystemBase, HeapSize);
- if (hHeap == NULL) + if (pHeap == NULL) { ObDereferenceObject(*SectionObject); *SectionObject = NULL; @@ -212,5 +212,5 @@ SetLastNtError(STATUS_UNSUCCESSFUL); }
- return hHeap; + return pHeap; }
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/desktop.c [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -981,10 +981,10 @@ if (!NT_SUCCESS(Status)) RETURN(NULL);
DesktopObject->DesktopHeapSection = NULL; - DesktopObject->hDesktopHeap = UserCreateHeap(&DesktopObject->DesktopHeapSection, + DesktopObject->pheapDesktop = UserCreateHeap(&DesktopObject->DesktopHeapSection, &DesktopHeapSystemBase, HeapLimit); - if (DesktopObject->hDesktopHeap == NULL) + if (DesktopObject->pheapDesktop == NULL) { ObDereferenceObject(DesktopObject); DPRINT1("Failed to create desktop heap!\n"); @@ -994,7 +994,7 @@ DesktopInfoSize = FIELD_OFFSET(DESKTOPINFO, szDesktopName[(lpszDesktopName->Length / sizeof(WCHAR)) + 1]);
- DesktopObject->DesktopInfo = RtlAllocateHeap(DesktopObject->hDesktopHeap, + DesktopObject->DesktopInfo = RtlAllocateHeap(DesktopObject->pheapDesktop, HEAP_NO_SERIALIZE, DesktopInfoSize);
@@ -1008,8 +1008,8 @@ RtlZeroMemory(DesktopObject->DesktopInfo, DesktopInfoSize);
- DesktopObject->DesktopInfo->hKernelHeap = DesktopObject->hDesktopHeap; - DesktopObject->DesktopInfo->HeapLimit = HeapLimit; + DesktopObject->DesktopInfo->pvDesktopBase = DesktopHeapSystemBase; + DesktopObject->DesktopInfo->pvDesktopLimit = (PVOID)HeapLimit; RtlCopyMemory(DesktopObject->DesktopInfo->szDesktopName, lpszDesktopName->Buffer, lpszDesktopName->Length); @@ -1745,7 +1745,7 @@ HeapMapping = *PrevLink; while (HeapMapping != NULL) { - if (HeapMapping->KernelMapping == (PVOID)DesktopObject->hDesktopHeap) + if (HeapMapping->KernelMapping == (PVOID)DesktopObject->pheapDesktop) { if (--HeapMapping->Count == 0) { @@ -1798,7 +1798,7 @@ HeapMapping = *PrevLink; while (HeapMapping != NULL) { - if (HeapMapping->KernelMapping == (PVOID)DesktopObject->hDesktopHeap) + if (HeapMapping->KernelMapping == (PVOID)DesktopObject->pheapDesktop) { HeapMapping->Count++; return STATUS_SUCCESS; @@ -1809,7 +1809,7 @@ }
/* we're the first, map the heap */ - DPRINT("Noone mapped the desktop heap %p yet, so - map it!\n", DesktopObject->hDesktopHeap); + DPRINT("Noone mapped the desktop heap %p yet, so - map it!\n", DesktopObject->pheapDesktop); Offset.QuadPart = 0; Status = MmMapViewOfSection(DesktopObject->DesktopHeapSection, PsGetCurrentProcess(), @@ -1838,7 +1838,7 @@ }
HeapMapping->Next = NULL; - HeapMapping->KernelMapping = (PVOID)DesktopObject->hDesktopHeap; + HeapMapping->KernelMapping = (PVOID)DesktopObject->pheapDesktop; HeapMapping->UserMapping = UserBase; HeapMapping->Limit = ViewSize; HeapMapping->Count = 1; @@ -1853,7 +1853,7 @@ if (ti->Desktop == NULL) { ti->Desktop = DesktopObject->DesktopInfo; - ti->DesktopHeapBase = DesktopObject->hDesktopHeap; + ti->DesktopHeapBase = DesktopObject->pheapDesktop; ti->DesktopHeapLimit = ViewSize; } }
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/misc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/misc.c [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -462,8 +462,8 @@ if (W32Thread->Desktop != NULL) { ti->Desktop = W32Thread->Desktop->DesktopInfo; - ti->DesktopHeapBase = W32Thread->Desktop->DesktopInfo->hKernelHeap; - ti->DesktopHeapLimit = W32Thread->Desktop->DesktopInfo->HeapLimit; + ti->DesktopHeapBase = W32Thread->Desktop->DesktopInfo->pvDesktopBase; + ti->DesktopHeapLimit = (ULONG_PTR)W32Thread->Desktop->DesktopInfo->pvDesktopLimit; } else {
Modified: trunk/reactos/subsystems/win32/win32k/w32k.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/w32... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/w32k.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/w32k.h [iso-8859-1] Sat Oct 18 21:05:41 2008 @@ -71,7 +71,7 @@ /* User heap */ extern HANDLE GlobalUserHeap;
-HANDLE +PWIN32HEAP UserCreateHeap(OUT PSECTION_OBJECT *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize);