ReactOS 0.4.16-dev-1946-g52006dd
kmt_test_kernel.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Kernel-Mode Test Suite test framework kernel declarations
5 * COPYRIGHT: Copyright 2011-2018 Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#ifndef _KMTEST_TEST_KERNEL_H_
9#define _KMTEST_TEST_KERNEL_H_
10
11#if !defined _KMTEST_TEST_H_
12#error include kmt_test.h instead of including kmt_test_kernel.h
13#endif /* !defined _KMTEST_TEST_H_ */
14
19{
20 "Create",
21 "CreateNamedPipe",
22 "Close",
23 "Read",
24 "Write",
25 "QueryInformation",
26 "SetInformation",
27 "QueryEa",
28 "SetEa",
29 "FlushBuffers",
30 "QueryVolumeInformation",
31 "SetVolumeInformation",
32 "DirectoryControl",
33 "FileSystemControl",
34 "DeviceControl",
35 "InternalDeviceControl/Scsi",
36 "Shutdown",
37 "LockControl",
38 "Cleanup",
39 "CreateMailslot",
40 "QuerySecurity",
41 "SetSecurity",
42 "Power",
43 "SystemControl",
44 "DeviceChange",
45 "QueryQuota",
46 "SetQuota",
47 "Pnp/PnpPower"
48};
49
51{
53 if (Irql > NewIrql)
55 else if (Irql < NewIrql)
57}
58
60{
61#if defined(_M_IX86) || defined(_M_AMD64)
62 return (__readeflags() & EFLAGS_INTERRUPT_MASK) != 0;
63#else
64#pragma message(__FILE__ ": warning : 'KmtAreInterruptsEnabled()' is UNIMPLEMENTED for this architecture")
65 // HACK: trivial stub. Used by ok_bool_true(KmtAreInterruptsEnabled(), ...).
66 return FALSE;
67#endif
68}
69
70typedef struct _POOL_HEADER
71{
72 union
73 {
74 struct
75 {
76#ifdef _M_AMD64
81#else
86#endif
87 };
89 };
90#ifdef _M_AMD64
92#endif
93 union
94 {
95#ifdef _M_AMD64
96 PEPROCESS ProcessBilled;
97#else
99#endif
100 struct
101 {
104 };
105 };
107
109{
111
112 /* it's not so easy for allocations of PAGE_SIZE */
113 if (((ULONG_PTR)Memory & (PAGE_SIZE - 1)) == 0)
114 return 'TooL';
115
116 Header = Memory;
117 Header--;
118
119 return Header->PoolTag;
120}
121
123{
125
126 /* it's not so easy for allocations of PAGE_SIZE */
127 if (((ULONG_PTR)Memory & (PAGE_SIZE - 1)) == 0)
128 return 0;
129
130 Header = Memory;
131 Header--;
132
133 return Header->PoolType;
134}
135
137{
138 UNICODE_STRING RoutineNameString;
139 RtlInitUnicodeString(&RoutineNameString, (PWSTR)RoutineName);
140 return MmGetSystemRoutineAddress(&RoutineNameString);
141}
142
144{
147 HANDLE ThreadHandle;
149
151 NULL,
153 NULL,
154 NULL);
155 ThreadHandle = INVALID_HANDLE_VALUE;
156 Status = PsCreateSystemThread(&ThreadHandle,
159 NULL,
160 NULL,
162 StartContext);
164 if (!skip(NT_SUCCESS(Status) && ThreadHandle != NULL && ThreadHandle != INVALID_HANDLE_VALUE, "No thread\n"))
165 {
166 Status = ObReferenceObjectByHandle(ThreadHandle,
171 NULL);
173 ObCloseHandle(ThreadHandle, KernelMode);
174 }
175 return ThreadObject;
176}
177
179{
181
182 if (skip(Thread != NULL, "No thread\n"))
183 return;
184
185 if (Event)
188 Executive,
190 FALSE,
191 NULL);
194}
195
196INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
197
198#endif /* !defined _KMTEST_TEST_KERNEL_H_ */
unsigned char BOOLEAN
#define EFLAGS_INTERRUPT_MASK
Definition: SystemCall.c:11
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define ok_eq_hex(value, expected)
Definition: apitest.h:134
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
Definition: Header.h:9
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
_Out_ PKIRQL Irql
Definition: csq.h:179
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
__INTRIN_INLINE uintptr_t __readeflags(void)
Definition: intrin_x86.h:1688
#define KMT_FORMAT(type, fmt, first)
Definition: kmt_test.h:213
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
PCSTR KmtMajorFunctionNames[]
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
USHORT KmtGetPoolType(PVOID Memory)
BOOLEAN KmtIsVirtualMachine
ULONG KmtGetPoolTag(PVOID Memory)
struct _POOL_HEADER POOL_HEADER
VOID KmtSetIrql(IN KIRQL NewIrql)
BOOLEAN KmtAreInterruptsEnabled(VOID)
BOOLEAN KmtIsCheckedBuild
BOOLEAN KmtIsMultiProcessorBuild
VOID KmtFinishThread(IN PKTHREAD Thread OPTIONAL, IN PKEVENT Event OPTIONAL)
struct _POOL_HEADER * PPOOL_HEADER
#define KmtVSNPrintF
Definition: kmt_test_user.h:35
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:38
@ ThreadObject
Definition: ketypes.h:412
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
POBJECT_TYPE PsThreadType
Definition: thread.c:20
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
unsigned short USHORT
Definition: pedump.c:61
_Requires_lock_held_ SpinLock _Releases_lock_ SpinLock _In_ _IRQL_restores_ KIRQL NewIrql
Definition: ke.h:114
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
USHORT AllocatorBackTraceIndex
USHORT PreviousSize
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3615
uint16_t * PWSTR
Definition: typedefs.h:56
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169
#define IO_NO_INCREMENT
Definition: iotypes.h:598
KSTART_ROUTINE * PKSTART_ROUTINE
Definition: ketypes.h:551
@ Executive
Definition: ketypes.h:467
#define ObDereferenceObject
Definition: obfuncs.h:203
_In_ ULONG _In_opt_ POBJECT_ATTRIBUTES _In_opt_ HANDLE _Out_opt_ PCLIENT_ID _In_ PKSTART_ROUTINE StartRoutine
Definition: psfuncs.h:92