ReactOS 0.4.15-dev-8096-ga0eec98
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
21static VOID NTAPI
23{
24 _AssertFalse(MockExFreePoolCalled);
25 _AssertEqualValue(TestMdl, Block);
27}
28
30
31static PMDL NTAPI
33 PVOID Base,
35{
36 _AssertFalse(MockMmCreateMdlCalled);
37 _AssertEqualValue(TestBaseAddress, Base);
38 _AssertEqualValue(TestNumberOfBytesToLock, Length);
40 return TestMdl;
41}
42
44
45static VOID NTAPI
49{
51 _AssertEqualValue(TestMdl, Mdl);
52 _AssertEqualValue(UserMode, AccessMode);
53 _AssertEqualValue(IoWriteAccess, Operation);
55}
56
58
59static VOID FASTCALL
61{
63 _AssertEqualValue(TestProcessObject, Object);
65}
66
68
69static NTSTATUS NTAPI
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
89static void RunTest()
90{
91 ULONG NumberOfBytesLocked;
93
97 &NumberOfBytesLocked,
103 _AssertEqualValue(STATUS_SUCCESS, status);
105 _AssertTrue(MockMmCreateMdlCalled);
107 _AssertTrue(MockExFreePoolCalled);
109 _AssertEqualValue(TestNumberOfBytesToLock, NumberOfBytesLocked);
110}
111
112_Dispatcher(VirtualmemoryTest, "Virtual memory")
unsigned char BOOLEAN
#define TestBaseAddress
Definition: VirtualMemory.c:15
static VOID FASTCALL MockObDereferenceObject(PVOID Object)
Definition: VirtualMemory.c:60
static VOID NTAPI MockMmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation)
Definition: VirtualMemory.c:46
#define TestProcessObject
Definition: VirtualMemory.c:14
static VOID NTAPI MockExFreePool(PVOID Block)
Definition: VirtualMemory.c:22
#define TestProcessHandle
Definition: VirtualMemory.c:13
#define TestNumberOfBytesToLock
Definition: VirtualMemory.c:16
#define TestMdl
Definition: VirtualMemory.c:17
static BOOLEAN MockExFreePoolCalled
Definition: VirtualMemory.c:19
static BOOLEAN MockMmProbeAndLockPagesCalled
Definition: VirtualMemory.c:43
static void RunTest()
Definition: VirtualMemory.c:89
static PMDL NTAPI MockMmCreateMdl(PMDL Mdl, PVOID Base, ULONG Length)
Definition: VirtualMemory.c:32
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 BOOLEAN MockMmCreateMdlCalled
Definition: VirtualMemory.c:29
static BOOLEAN MockObReferenceObjectByHandleCalled
Definition: VirtualMemory.c:67
static BOOLEAN MockObDereferenceObjectCalled
Definition: VirtualMemory.c:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
FP_OP Operation
Definition: fpcontrol.c:150
ULONG Handle
Definition: gdb_input.c:15
#define PROCESS_VM_WRITE
Definition: pstypes.h:162
ObjectType
Definition: metafile.c:81
#define UserMode
Definition: asm.h:35
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2439
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define FASTCALL
Definition: nt_native.h:50
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static NTSTATUS MiLockVirtualMemory(IN OUT PVOID *BaseAddress, IN OUT PSIZE_T RegionSize, IN ULONG MapType)
Definition: virtual.c:3381
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: ps.c:97
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
enum _LOCK_OPERATION LOCK_OPERATION
@ IoWriteAccess
Definition: ketypes.h:864
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
_In_ ACCESS_MASK _In_opt_ POBJECT_TYPE _In_ KPROCESSOR_MODE _Out_ PVOID _Out_opt_ POBJECT_HANDLE_INFORMATION HandleInformation
Definition: obfuncs.h:44