ReactOS 0.4.15-dev-7953-g1f49173
HalSystemInfo.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel-Mode Tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Test for HalQuerySystemInformation
5 * COPYRIGHT: Copyright 2020 Thomas Faber (thomas.faber@reactos.org)
6 */
7
8#include <kmt_test.h>
9
10#define NDEBUG
11#include <debug.h>
12
14{
15 { 0x0000, 0x10, 1, NULL },
16 { 0x0020, 0x02, 0, NULL },
17 { 0x0040, 0x04, 1, NULL },
18 { 0x0048, 0x04, 1, NULL },
19 { 0x0070, 0x02, 1, NULL },
20 { 0x0074, 0x03, 1, NULL },
21 { 0x0081, 0x03, 1, NULL },
22 { 0x0087, 0x01, 1, NULL },
23 { 0x0089, 0x01, 1, NULL },
24 { 0x008A, 0x02, 1, NULL },
25 { 0x008F, 0x01, 1, NULL },
26 { 0x0090, 0x02, 1, NULL },
27 { 0x0093, 0x02, 1, NULL },
28 { 0x0096, 0x02, 1, NULL },
29 { 0x00A0, 0x02, 0, NULL },
30 { 0x00C0, 0x20, 1, NULL },
31 { 0x04D0, 0x02, 0, NULL },
32 /* We obviously don't have the expected pointer. Just use a non-null value */
33 { 0x0CF8, 0x08, 1, (PVOID)1 },
34 { 0x0000, 0x00, 0, NULL },
35};
36
37static
38void
40{
43 ULONG AddressListLength;
45
46 /* Query required size and check that it's valid */
47 ReturnedLength = 0x55555555;
49 0,
50 NULL,
53 ok(ReturnedLength % sizeof(*AddressList) == 0, "List size %lu is not a multiple of %Iu\n", ReturnedLength, sizeof(*AddressList));
54 if (skip(ReturnedLength > 0 && ReturnedLength < 0x10000000, "Invalid length\n"))
55 {
56 return;
57 }
58 AddressListLength = ReturnedLength;
60 AddressListLength,
61 'OImK');
62 if (skip(AddressList != NULL, "Failed to alloc %lu bytes\n", AddressListLength))
63 {
64 return;
65 }
66
67 if (ReturnedLength != sizeof(*AddressList))
68 {
69 /* Try with space for exactly one entry and make sure we get
70 * the same return code
71 */
72 RtlFillMemory(AddressList, AddressListLength, 0x55);
73 ReturnedLength = 0x55555555;
75 sizeof(*AddressList),
76 AddressList,
79 ok_eq_ulong(ReturnedLength, AddressListLength);
80 ok_eq_hex(AddressList[0].BadAddrBegin, 0x55555555UL);
81 }
82
83 /* One byte less than required should still return no data */
84 RtlFillMemory(AddressList, AddressListLength, 0x55);
85 ReturnedLength = 0x55555555;
87 AddressListLength - 1,
88 AddressList,
91 ok_eq_ulong(ReturnedLength, AddressListLength);
92 ok_eq_hex(AddressList[0].BadAddrBegin, 0x55555555UL);
93
94 /* Specify required size */
95 RtlFillMemory(AddressList, AddressListLength, 0x55);
96 ReturnedLength = 0x55555555;
98 AddressListLength,
99 AddressList,
102 ok_eq_ulong(ReturnedLength, AddressListLength);
103
104 /* Validate the table against our expectations */
106 for (ULONG i = 0;
107 i < min(ReturnedLength, sizeof(ExpectedList)) / sizeof(*AddressList);
108 i++)
109 {
110 ok(AddressList[i].BadAddrBegin == ExpectedList[i].BadAddrBegin,
111 "[%lu] BadAddrBegin 0x%lx, expected 0x%lx\n",
112 i, AddressList[i].BadAddrBegin, ExpectedList[i].BadAddrBegin);
113 ok(AddressList[i].BadAddrSize == ExpectedList[i].BadAddrSize,
114 "[%lu] BadAddrSize 0x%lx, expected 0x%lx\n",
115 i, AddressList[i].BadAddrSize, ExpectedList[i].BadAddrSize);
116 ok(AddressList[i].OSVersionTrigger == ExpectedList[i].OSVersionTrigger,
117 "[%lu] OSVersionTrigger 0x%lx, expected 0x%lx\n",
118 i, AddressList[i].OSVersionTrigger, ExpectedList[i].OSVersionTrigger);
119 if (ExpectedList[i].IOHandler != NULL)
120 {
121 ok(AddressList[i].IOHandler != NULL,
122 "[%lu] IOHandler = %p\n", i, AddressList[i].IOHandler);
123 }
124 else
125 {
126 ok(AddressList[i].IOHandler == NULL,
127 "[%lu] IOHandler = %p\n", i, AddressList[i].IOHandler);
128 }
129
130 /* If we got an I/O handler, try to call it */
131 if (AddressList[i].IOHandler != NULL)
132 {
133 ULONG Data = 0x55555555;
134
135 /* We don't want to break devices, so call it with an address
136 * outside of its range, and it should return failure
137 */
138 Status = AddressList[i].IOHandler(TRUE,
139 AddressList[i].BadAddrBegin - 1,
140 1,
141 &Data);
143 "[%lu] IOHandler returned 0x%lx\n", i, Status);
144 ok(Data == 0x55555555,
145 "[%lu] IOHandler returned Data 0x%lx\n", i, Data);
146 }
147 }
148 ExFreePoolWithTag(AddressList, 'OImK');
149}
150
151START_TEST(HalSystemInfo)
152{
154}
static HAL_AMLI_BAD_IO_ADDRESS_LIST ExpectedList[]
Definition: HalSystemInfo.c:13
static void TestAMLIllegalIOPortAddresses(void)
Definition: HalSystemInfo.c:39
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_ulong(value, expected)
Definition: apitest.h:63
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define min(a, b)
Definition: monoChain.cc:55
#define STATUS_SUCCESS
Definition: shellext.h:65
PHALIOREADWRITEHANDLER IOHandler
Definition: haltypes.h:382
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define HalQuerySystemInformation
Definition: haltypes.h:294
@ HalQueryAMLIIllegalIOPortAddresses
Definition: haltypes.h:35