5867d29e47e321cf1eaf64c3820f1cb99f9af77f
[reactos.git] / reactos / 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 VOID
19 NTAPI
20 MmCleanProcessAddressSpace(IN PEPROCESS Process)
21 {
22 /* FIXME: Add part of MmDeleteProcessAddressSpace here */
23 }
24
25 NTSTATUS
26 NTAPI
27 MmDeleteProcessAddressSpace(PEPROCESS Process)
28 {
29 PVOID Address;
30 PMEMORY_AREA MemoryArea;
31
32 DPRINT("MmDeleteProcessAddressSpace(Process %x (%s))\n", Process,
33 Process->ImageFileName);
34
35 MmLockAddressSpace(&Process->Vm);
36
37 while ((MemoryArea = (PMEMORY_AREA)Process->Vm.WorkingSetExpansionLinks.Flink) != NULL)
38 {
39 switch (MemoryArea->Type)
40 {
41 case MEMORY_AREA_SECTION_VIEW:
42 Address = (PVOID)MemoryArea->StartingAddress;
43 MmUnlockAddressSpace(&Process->Vm);
44 MmUnmapViewOfSection(Process, Address);
45 MmLockAddressSpace(&Process->Vm);
46 break;
47
48 case MEMORY_AREA_VIRTUAL_MEMORY:
49 MmFreeVirtualMemory(Process, MemoryArea);
50 break;
51
52 case MEMORY_AREA_OWNED_BY_ARM3:
53 MmFreeMemoryArea(&Process->Vm,
54 MemoryArea,
55 NULL,
56 NULL);
57 break;
58
59 default:
60 KeBugCheck(MEMORY_MANAGEMENT);
61 }
62 }
63
64 Mmi386ReleaseMmInfo(Process);
65
66 MmUnlockAddressSpace(&Process->Vm);
67
68 DPRINT("Finished MmReleaseMmInfo()\n");
69 return(STATUS_SUCCESS);
70 }
71