sync with trunk (r48253)
[reactos.git] / ntoskrnl / mm / procsup.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/mm/procsup.c
5 * PURPOSE: Memory functions related to Processes
6 *
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS *****************************************************************/
17
18 NTSTATUS
19 NTAPI
20 MmDeleteProcessAddressSpace(PEPROCESS Process)
21 {
22 PVOID Address;
23 PMEMORY_AREA MemoryArea;
24
25 DPRINT("MmDeleteProcessAddressSpace(Process %x (%s))\n", Process,
26 Process->ImageFileName);
27
28 MmLockAddressSpace(&Process->Vm);
29
30 while ((MemoryArea = (PMEMORY_AREA)Process->Vm.WorkingSetExpansionLinks.Flink) != NULL)
31 {
32 switch (MemoryArea->Type)
33 {
34 case MEMORY_AREA_SECTION_VIEW:
35 Address = (PVOID)MemoryArea->StartingAddress;
36 MmUnlockAddressSpace(&Process->Vm);
37 MmUnmapViewOfSection(Process, Address);
38 MmLockAddressSpace(&Process->Vm);
39 break;
40
41 case MEMORY_AREA_VIRTUAL_MEMORY:
42 MmFreeVirtualMemory(Process, MemoryArea);
43 break;
44
45 case MEMORY_AREA_OWNED_BY_ARM3:
46 MmFreeMemoryArea(&Process->Vm,
47 MemoryArea,
48 NULL,
49 NULL);
50 break;
51
52 default:
53 KeBugCheck(MEMORY_MANAGEMENT);
54 }
55 }
56
57 MmUnlockAddressSpace(&Process->Vm);
58
59 DPRINT("Finished MmReleaseMmInfo()\n");
60 return(STATUS_SUCCESS);
61 }
62