ReactOS  0.4.11-dev-721-g95bc44e
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 {
38  Bytes);
39 }
40 
41 static __inline BOOL
43 {
46  lpMem);
47 }
48 
49 static __inline PVOID
51  SIZE_T Bytes)
52 {
53 #if 0
54  /* NOTE: ntoskrnl doesn't export RtlReAllocateHeap... */
57  lpMem,
58  Bytes);
59 #else
60  SIZE_T PrevSize;
61  PVOID pNew;
62 
63  PrevSize = RtlSizeHeap(GlobalUserHeap,
65  lpMem);
66 
67  if (PrevSize == Bytes)
68  return lpMem;
69 
72  Bytes);
73  if (pNew != NULL)
74  {
75  if (PrevSize < Bytes)
76  Bytes = PrevSize;
77 
78  RtlCopyMemory(pNew,
79  lpMem,
80  Bytes);
81 
84  lpMem);
85  }
86 
87  return pNew;
88 #endif
89 }
90 
91 static __inline PVOID
93 {
95 
96  /* The first mapping entry is the global user heap mapping */
97  return (PVOID)(((ULONG_PTR)lpMem - (ULONG_PTR)GlobalUserHeap) +
98  (ULONG_PTR)W32Process->HeapMappings.UserMapping);
99 }
100 
101 /* EOF */
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
Definition: fsrtlfuncs.h:860
DWORD *typedef PVOID
Definition: winlogon.h:61
HANDLE GlobalUserHeap
Definition: usrheap.c:25
#define IN
Definition: typedefs.h:38
NTSTATUS UnmapGlobalUserHeap(IN PEPROCESS Process)
Definition: usrheap.c:232
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PVOID GlobalUserHeapSection
Definition: usrheap.c:26
#define HEAP_NO_SERIALIZE
Definition: nt_native.h:1692
struct _WIN32HEAP * PWIN32HEAP
Definition: usrheap.h:3
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_In_ UINT Bytes
Definition: mmcopy.h:9
static __inline BOOL UserHeapFree(PVOID lpMem)
Definition: usrheap.h:42
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2552
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:177
uint32_t ULONG_PTR
Definition: typedefs.h:63
static GENERIC_MAPPING UserMapping
Definition: samrpc.c:48
smooth NULL
Definition: ftsmooth.c:416
W32HEAP_USER_MAPPING HeapMappings
Definition: win32.h:281
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
static __inline PVOID UserHeapReAlloc(PVOID lpMem, SIZE_T Bytes)
Definition: usrheap.h:50
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
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:92
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
Definition: usrheap.c:262
ULONG_PTR SIZE_T
Definition: typedefs.h:78
DWORD *typedef HANDLE
Definition: winlogon.h:61
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
_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:39
#define ULONG_PTR
Definition: config.h:101