ReactOS 0.4.16-dev-197-g92996da
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
18{
19 "Create",
20 "CreateNamedPipe",
21 "Close",
22 "Read",
23 "Write",
24 "QueryInformation",
25 "SetInformation",
26 "QueryEa",
27 "SetEa",
28 "FlushBuffers",
29 "QueryVolumeInformation",
30 "SetVolumeInformation",
31 "DirectoryControl",
32 "FileSystemControl",
33 "DeviceControl",
34 "InternalDeviceControl/Scsi",
35 "Shutdown",
36 "LockControl",
37 "Cleanup",
38 "CreateMailslot",
39 "QuerySecurity",
40 "SetSecurity",
41 "Power",
42 "SystemControl",
43 "DeviceChange",
44 "QueryQuota",
45 "SetQuota",
46 "Pnp/PnpPower"
47};
48
50{
52 if (Irql > NewIrql)
54 else if (Irql < NewIrql)
56}
57
59{
60 return (__readeflags() & (1 << 9)) != 0;
61}
62
63typedef struct _POOL_HEADER
64{
65 union
66 {
67 struct
68 {
69#ifdef _M_AMD64
74#else
79#endif
80 };
82 };
83#ifdef _M_AMD64
85#endif
86 union
87 {
88#ifdef _M_AMD64
89 PEPROCESS ProcessBilled;
90#else
92#endif
93 struct
94 {
97 };
98 };
100
102{
104
105 /* it's not so easy for allocations of PAGE_SIZE */
106 if (((ULONG_PTR)Memory & (PAGE_SIZE - 1)) == 0)
107 return 'TooL';
108
109 Header = Memory;
110 Header--;
111
112 return Header->PoolTag;
113}
114
116{
118
119 /* it's not so easy for allocations of PAGE_SIZE */
120 if (((ULONG_PTR)Memory & (PAGE_SIZE - 1)) == 0)
121 return 0;
122
123 Header = Memory;
124 Header--;
125
126 return Header->PoolType;
127}
128
130{
131 UNICODE_STRING RoutineNameString;
132 RtlInitUnicodeString(&RoutineNameString, (PWSTR)RoutineName);
133 return MmGetSystemRoutineAddress(&RoutineNameString);
134}
135
137{
140 HANDLE ThreadHandle;
142
144 NULL,
146 NULL,
147 NULL);
148 ThreadHandle = INVALID_HANDLE_VALUE;
149 Status = PsCreateSystemThread(&ThreadHandle,
152 NULL,
153 NULL,
155 StartContext);
157 if (!skip(NT_SUCCESS(Status) && ThreadHandle != NULL && ThreadHandle != INVALID_HANDLE_VALUE, "No thread\n"))
158 {
159 Status = ObReferenceObjectByHandle(ThreadHandle,
164 NULL);
166 ObCloseHandle(ThreadHandle, KernelMode);
167 }
168 return ThreadObject;
169}
170
172{
174
175 if (skip(Thread != NULL, "No thread\n"))
176 return;
177
178 if (Event)
181 Executive,
183 FALSE,
184 NULL);
187}
188
189INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments) KMT_FORMAT(ms_printf, 3, 0);
190
191#endif /* !defined _KMTEST_TEST_KERNEL_H_ */
unsigned char BOOLEAN
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#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:1674
#define KMT_FORMAT(type, fmt, first)
Definition: kmt_test.h:210
PKTHREAD KmtStartThread(IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext OPTIONAL)
PCSTR KmtMajorFunctionNames[]
PVOID KmtGetSystemRoutineAddress(IN PCWSTR RoutineName)
USHORT KmtGetPoolType(PVOID Memory)
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:34
@ 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 PoolTagHash
USHORT AllocatorBackTraceIndex
USHORT PreviousSize
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3604
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:499
@ Executive
Definition: ketypes.h:415
#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:91