-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMemoryTest.cpp
55 lines (47 loc) · 1.22 KB
/
MemoryTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1998-2013, DataCore Software Corporation. All rights reserved.
*
* Details about the Windows Kernel API are based on the documentation
* available at https://learn.microsoft.com/en-us/windows-hardware/drivers/
*/
/*
* Memory Tests
*/
#include "stdafx.h"
namespace DdkUnitTest
{
TEST_CLASS(DdkMemoryTest)
{
public:
TEST_METHOD_INITIALIZE(DdkMemoryTestInit)
{
DdkThreadInit();
}
TEST_METHOD(DdkMemoryPhysAddr)
{
LARGE_INTEGER addr = MmGetPhysicalAddress((PVOID)0x123456789I64);
Assert::IsTrue(addr.QuadPart == 0x123456789I64);
}
TEST_METHOD(DdkMemoryGetSystemRoutine)
{
UNICODE_STRING u = RTL_CONSTANT_STRING(L"RtlGetVersion");
PVOID addr = MmGetSystemRoutineAddress(&u);
Assert::IsNotNull(addr);
Assert::AreEqual((PVOID)&RtlGetVersion, addr);
}
TEST_METHOD(DdkMemoryGetSystemRoutineFail)
{
UNICODE_STRING u = RTL_CONSTANT_STRING(L"RtlGetVersion2");
PVOID addr = MmGetSystemRoutineAddress(&u);
Assert::IsNull(addr);
}
TEST_METHOD(DdkMemoryGetSystemRoutineDdk)
{
UNICODE_STRING u = RTL_CONSTANT_STRING(L"DdkThreadInit");
PVOID addr = MmGetSystemRoutineAddress(&u);
Assert::IsNull(addr);
}
};
}