ReactOS  0.4.15-dev-3207-ga415bd4
usrheap.h
Go to the documentation of this file.
1 #pragma once
2 
3 typedef struct _WIN32HEAP WIN32HEAP, *PWIN32HEAP;
4 
5 /*
6 typedef struct _W32HEAP_USER_MAPPING
7 {
8  struct _W32HEAP_USER_MAPPING* Next;
9  PVOID KernelMapping;
10  PVOID UserMapping;
11  ULONG_PTR Limit;
12  ULONG Count;
13 } W32HEAP_USER_MAPPING, *PW32HEAP_USER_MAPPING;
14 */
15 
16 /* User heap */
17 extern HANDLE GlobalUserHeap;
19 
22  IN OUT PVOID *SystemBase,
24 
27 
30  OUT PVOID* KernelMapping,
32 
33 static __inline PVOID
35 {
36  /* User heap has no lock, using global user lock instead. */
40  Bytes);
41 }
42 
43 static __inline BOOL
45 {
46  /* User heap has no lock, using global user lock instead. */
50  lpMem);
51 }
52 
53 static __inline PVOID
55  SIZE_T Bytes)
56 {
57 #if 0
58  /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
61  lpMem,
62  Bytes);
63 #else
64  SIZE_T PrevSize;
65  PVOID pNew;
66 
67  /* User heap has no lock, using global user lock instead. */
69 
70  PrevSize = RtlSizeHeap(GlobalUserHeap,
72  lpMem);
73 
74  if (PrevSize == Bytes)
75  return lpMem;
76 
79  Bytes);
80  if (pNew != NULL)
81  {
82  if (PrevSize < Bytes)
83  Bytes = PrevSize;
84 
85  RtlCopyMemory(pNew,
86  lpMem,
87  Bytes);
88 
91  lpMem);
92  }
93 
94  return pNew;
95 #endif
96 }
97 
98 static __inline PVOID
100 {
102 
103  /* The first mapping entry is the global user heap mapping */
104  return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
105  (ULONG_PTR)W32Process->HeapMappings.UserMapping);
106 }
107 
108 /* EOF */
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
HANDLE GlobalUserHeap
Definition: usrheap.c:25
#define IN
Definition: typedefs.h:39
NTSTATUS UnmapGlobalUserHeap(IN PEPROCESS Process)
Definition: usrheap.c:236
PVOID GlobalUserHeapSection
Definition: usrheap.c:26
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
struct _WIN32HEAP * PWIN32HEAP
Definition: usrheap.h:3
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ UINT Bytes
Definition: mmcopy.h:9
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:44
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:181
uint32_t ULONG_PTR
Definition: typedefs.h:65
static GENERIC_MAPPING UserMapping
Definition: samrpc.c:48
unsigned int BOOL
Definition: ntddk_ex.h:94
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:288
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
static __inline PVOID UserHeapReAlloc(PVOID lpMem, SIZE_T Bytes)
Definition: usrheap.h:54
#define ASSERT(a)
Definition: mode.c:44
struct _WIN32HEAP WIN32HEAP
Definition: usrheap.h:3
NTSYSAPI SIZE_T NTAPI RtlSizeHeap(_In_ PVOID HeapHandle, _In_ ULONG Flags, _In_ PVOID MemoryPointer)
static __inline PVOID UserHeapAddressToUser(PVOID lpMem)
Definition: usrheap.h:99
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
Definition: usrheap.c:266
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define NULL
Definition: types.h:112
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
BOOL FASTCALL UserIsEnteredExclusive(VOID)
Definition: ntuser.c:229
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define OUT
Definition: typedefs.h:40
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2667
#define ULONG_PTR
Definition: config.h:101
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263