ReactOS  0.4.15-dev-3440-g915569a
VirtualMemory.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: ntoskrnl/tests/tests/VirtualMemory.c
5  * PURPOSE: No purpose listed.
6  *
7  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
8  */
9 
10 #include <ntoskrnl.h>
11 #include "regtests.h"
12 
13 #define TestProcessHandle (HANDLE) 1
14 #define TestProcessObject (PVOID) 0x2
15 #define TestBaseAddress (PVOID) 0x1000
16 #define TestNumberOfBytesToLock 0x2000
17 #define TestMdl (PMDL) 0xD0000000
18 
20 
21 static VOID NTAPI
23 {
24  _AssertFalse(MockExFreePoolCalled);
25  _AssertEqualValue(TestMdl, Block);
27 }
28 
30 
31 static PMDL NTAPI
33  PVOID Base,
34  ULONG Length)
35 {
36  _AssertFalse(MockMmCreateMdlCalled);
37  _AssertEqualValue(TestBaseAddress, Base);
38  _AssertEqualValue(TestNumberOfBytesToLock, Length);
40  return TestMdl;
41 }
42 
44 
45 static VOID NTAPI
49 {
50  _AssertFalse(MockMmProbeAndLockPagesCalled);
51  _AssertEqualValue(TestMdl, Mdl);
52  _AssertEqualValue(UserMode, AccessMode);
53  _AssertEqualValue(IoWriteAccess, Operation);
55 }
56 
58 
59 static VOID FASTCALL
61 {
62  _AssertFalse(MockObDereferenceObjectCalled);
63  _AssertEqualValue(TestProcessObject, Object);
65 }
66 
68 
69 static NTSTATUS NTAPI
74  PVOID* Object,
76 {
78  _AssertEqualValue(TestProcessHandle, Handle);
79  _AssertEqualValue(PROCESS_VM_WRITE, DesiredAccess);
80  _AssertEqualValue(NULL, ObjectType);
81  _AssertEqualValue(UserMode, AccessMode);
82  _AssertNotEqualValue(NULL, Object);
83  _AssertEqualValue(NULL, HandleInformation);
86  return STATUS_SUCCESS;
87 }
88 
89 static void RunTest()
90 {
91  ULONG NumberOfBytesLocked;
93 
97  &NumberOfBytesLocked,
103  _AssertEqualValue(STATUS_SUCCESS, status);
105  _AssertTrue(MockMmCreateMdlCalled);
106  _AssertTrue(MockMmProbeAndLockPagesCalled);
107  _AssertTrue(MockExFreePoolCalled);
108  _AssertTrue(MockObDereferenceObjectCalled);
109  _AssertEqualValue(TestNumberOfBytesToLock, NumberOfBytesLocked);
110 }
111 
112 _Dispatcher(VirtualmemoryTest, "Virtual memory")
ObjectType
Definition: metafile.c:80
_Dispatcher(IPReceiveTest, "IPReceive")
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2654
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define TestProcessHandle
Definition: VirtualMemory.c:13
static BOOLEAN MockObReferenceObjectByHandleCalled
Definition: VirtualMemory.c:67
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2386
static VOID NTAPI MockExFreePool(PVOID Block)
Definition: VirtualMemory.c:22
#define FASTCALL
Definition: nt_native.h:50
static VOID NTAPI MockMmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation)
Definition: VirtualMemory.c:46
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
#define TestProcessObject
Definition: VirtualMemory.c:14
static BOOLEAN MockObDereferenceObjectCalled
Definition: VirtualMemory.c:57
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:395
static void RunTest()
Definition: VirtualMemory.c:89
unsigned char BOOLEAN
#define TestMdl
Definition: VirtualMemory.c:17
#define PROCESS_VM_WRITE
Definition: pstypes.h:162
static VOID FASTCALL MockObDereferenceObject(PVOID Object)
Definition: VirtualMemory.c:60
_In_ ACCESS_MASK _In_opt_ POBJECT_TYPE _In_ KPROCESSOR_MODE _Out_ PVOID _Out_opt_ POBJECT_HANDLE_INFORMATION HandleInformation
Definition: obfuncs.h:40
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
static BOOLEAN MockMmProbeAndLockPagesCalled
Definition: VirtualMemory.c:43
static BOOLEAN MockMmCreateMdlCalled
Definition: VirtualMemory.c:29
static NTSTATUS NTAPI MockObReferenceObjectByHandle(HANDLE Handle, ACCESS_MASK DesiredAccess, POBJECT_TYPE ObjectType, KPROCESSOR_MODE AccessMode, PVOID *Object, POBJECT_HANDLE_INFORMATION HandleInformation)
Definition: VirtualMemory.c:70
static NTSTATUS MiLockVirtualMemory(IN OUT PVOID *BaseAddress, IN OUT PSIZE_T RegionSize, IN ULONG MapType)
Definition: virtual.c:3370
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TestBaseAddress
Definition: VirtualMemory.c:15
enum _LOCK_OPERATION LOCK_OPERATION
#define NULL
Definition: types.h:112
static BOOLEAN MockExFreePoolCalled
Definition: VirtualMemory.c:19
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_In_ HANDLE Handle
Definition: extypes.h:390
unsigned int ULONG
Definition: retypes.h:1
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1467
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TestNumberOfBytesToLock
Definition: VirtualMemory.c:16
static PMDL NTAPI MockMmCreateMdl(PMDL Mdl, PVOID Base, ULONG Length)
Definition: VirtualMemory.c:32
static SERVICE_STATUS status
Definition: service.c:31
ULONG ACCESS_MASK
Definition: nt_native.h:40
Definition: ps.c:97