#include <win32k.h>
#include <debug.h>
Go to the source code of this file.
◆ NDEBUG
◆ _Function_class_()
_Function_class_ |
( |
RTL_HEAP_COMMIT_ROUTINE |
| ) |
|
Definition at line 29 of file usrheap.c.
38{
44 PVOID UserCommitAddress;
45
47
48 if (W32Process !=
NULL)
49 {
50
53 {
55 {
56 UserBase =
Mapping->UserMapping;
57 break;
58 }
59
61 }
62
64 }
65 else
66 {
69
70
72
73
77 &UserBase,
78 0,
79 0,
85
88 }
89
90
93
94
96 &UserCommitAddress,
97 0,
101
103 {
104
107 }
108
109 if (W32Process ==
NULL)
110 {
112 UserBase);
113 }
114
116}
NTSTATUS NTAPI MmUnmapViewOfSection(IN PEPROCESS Process, IN PVOID BaseAddress)
#define NT_SUCCESS(StatCode)
static PVOID Mapping[EMS_PHYSICAL_PAGES]
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T CommitSize
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
#define NtCurrentProcess()
_In_ ULONG _In_ ULONG Offset
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
NTSTATUS NTAPI MmMapViewOfSection(IN PVOID SectionObject, IN PEPROCESS Process, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
W32HEAP_USER_MAPPING HeapMappings
PVOID GlobalUserHeapSection
#define PsGetCurrentProcess
_Inout_ PVOID * CommitAddress
◆ IntUserHeapCreate()
Definition at line 119 of file usrheap.c.
122{
129
131
132
135 &MappedView,
136 0,
137 0,
145
147 &MappedView,
148 0,
152
154 MappedView);
155
158
159
160
164 Parameters.CommitRoutine = IntUserHeapCommitRoutine;
165
169#endif
171 *SystemMappedBase,
176
177 return pHeap;
178}
_Must_inspect_result_ _Outptr_ PVOID * SectionObject
#define HEAP_FREE_CHECKING_ENABLED
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)
#define HEAP_TAIL_CHECKING_ENABLED
#define HEAP_NO_SERIALIZE
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
Referenced by UserCreateHeap().
◆ MapGlobalUserHeap()
Definition at line 266 of file usrheap.c.
269{
274
277
278 TRACE_CH(UserProcess,
"MapGlobalUserHeap called for process 0x%p\n",
Process);
279
281 if (W32Process ==
NULL)
282 {
283 ERR_CH(UserProcess,
"MapGlobalUserHeap - We don't have a Win32 process!\n");
285 }
286
287 TRACE_CH(UserProcess,
"MapGlobalUserHeap - We got a Win32 process, find for existing global user heap mapping...\n");
288
289
291
292
294 {
295 HeapMapping->
Count++;
296
297 TRACE_CH(UserProcess,
"MapGlobalUserHeap - A mapping was found, return it.\n");
298
301
303 }
304
305 TRACE_CH(UserProcess,
"MapGlobalUserHeap - No mapping was found, let's map...\n");
306
307
311 &UserBase,
312 0,
313 0,
320 {
321 ERR_CH(UserProcess,
"MapGlobalUserHeap - Failed to map the global heap! 0x%x\n",
Status);
323 }
324
325 TRACE_CH(UserProcess,
"MapGlobalUserHeap -- Mapped kernel global heap 0x%p to user space at 0x%p\n",
327
328
333 HeapMapping->
Count = 1;
334
337
339}
#define ERR_CH(ch, fmt,...)
#define TRACE_CH(ch, fmt,...)
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
static GENERIC_MAPPING UserMapping
struct _W32HEAP_USER_MAPPING * Next
Referenced by InitProcessCallback().
◆ UnmapGlobalUserHeap()
Definition at line 236 of file usrheap.c.
237{
241
242 TRACE_CH(UserProcess,
"IntUnmapDesktopView called for process 0x%p\n",
Process);
243
245 if (W32Process ==
NULL)
246 {
247 ERR_CH(UserProcess,
"UnmapGlobalUserHeap - We don't have a Win32 process!\n");
249 }
250
251
254
255
256 if (--HeapMapping->
Count == 0)
257 {
258 TRACE_CH(UserProcess,
"UnmapGlobalUserHeap - Unmapping\n");
260 }
261
263}
◆ UserCreateHeap()
Definition at line 181 of file usrheap.c.
184{
188
190
191
195 &SizeHeap,
200
202 {
205 }
206
208 SystemBase,
211 {
214
217 }
218
219
221 SystemBase,
223
225 {
228
230 }
231
232 return pHeap;
233}
NTSTATUS NTAPI MmMapViewInSessionSpace(IN PVOID Section, OUT PVOID *MappedBase, IN OUT PSIZE_T ViewSize)
#define SECTION_ALL_ACCESS
NTSTATUS NTAPI MmCreateSection(OUT PVOID *Section, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL, IN PFILE_OBJECT FileObject OPTIONAL)
#define STATUS_UNSUCCESSFUL
static PWIN32HEAP IntUserHeapCreate(IN PVOID SectionObject, IN PVOID *SystemMappedBase, IN ULONG HeapSize)
struct _WIN32HEAP * PWIN32HEAP
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
#define ObDereferenceObject
Referenced by DriverEntry(), and UserInitializeDesktop().
◆ GlobalUserHeap
◆ GlobalUserHeapSection