2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite test framework declarations
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
8 #ifndef _KMTEST_TEST_KERNEL_H_
9 #define _KMTEST_TEST_KERNEL_H_
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_ */
15 BOOLEAN KmtIsCheckedBuild
;
16 BOOLEAN KmtIsMultiProcessorBuild
;
17 PCSTR KmtMajorFunctionNames
[] =
29 "QueryVolumeInformation",
30 "SetVolumeInformation",
34 "InternalDeviceControl/Scsi",
49 VOID
KmtSetIrql(IN KIRQL NewIrql
)
51 KIRQL Irql
= KeGetCurrentIrql();
54 else if (Irql
< NewIrql
)
55 KeRaiseIrql(NewIrql
, &Irql
);
58 BOOLEAN
KmtAreInterruptsEnabled(VOID
)
60 return (__readeflags() & (1 << 9)) != 0;
63 typedef struct _POOL_HEADER
70 USHORT PreviousSize
:8;
75 USHORT PreviousSize
:9;
89 PEPROCESS ProcessBilled
;
95 USHORT AllocatorBackTraceIndex
;
99 } POOL_HEADER
, *PPOOL_HEADER
;
101 ULONG
KmtGetPoolTag(PVOID Memory
)
105 /* it's not so easy for allocations of PAGE_SIZE */
106 if (((ULONG_PTR
)Memory
& (PAGE_SIZE
- 1)) == 0)
112 return Header
->PoolTag
;
115 USHORT
KmtGetPoolType(PVOID Memory
)
119 /* it's not so easy for allocations of PAGE_SIZE */
120 if (((ULONG_PTR
)Memory
& (PAGE_SIZE
- 1)) == 0)
126 return Header
->PoolType
;
129 PVOID
KmtGetSystemRoutineAddress(IN PCWSTR RoutineName
)
131 UNICODE_STRING RoutineNameString
;
132 RtlInitUnicodeString(&RoutineNameString
, (PWSTR
)RoutineName
);
133 return MmGetSystemRoutineAddress(&RoutineNameString
);
136 PKTHREAD
KmtStartThread(IN PKSTART_ROUTINE StartRoutine
, IN PVOID StartContext OPTIONAL
)
139 OBJECT_ATTRIBUTES ObjectAttributes
;
141 PVOID ThreadObject
= NULL
;
143 InitializeObjectAttributes(&ObjectAttributes
,
148 ThreadHandle
= INVALID_HANDLE_VALUE
;
149 Status
= PsCreateSystemThread(&ThreadHandle
,
156 ok_eq_hex(Status
, STATUS_SUCCESS
);
157 if (!skip(NT_SUCCESS(Status
) && ThreadHandle
!= NULL
&& ThreadHandle
!= INVALID_HANDLE_VALUE
, "No thread\n"))
159 Status
= ObReferenceObjectByHandle(ThreadHandle
,
165 ok_eq_hex(Status
, STATUS_SUCCESS
);
166 ObCloseHandle(ThreadHandle
, KernelMode
);
171 VOID
KmtFinishThread(IN PKTHREAD Thread OPTIONAL
, IN PKEVENT Event OPTIONAL
)
175 if (skip(Thread
!= NULL
, "No thread\n"))
179 KeSetEvent(Event
, IO_NO_INCREMENT
, TRUE
);
180 Status
= KeWaitForSingleObject(Thread
,
185 ok_eq_hex(Status
, STATUS_SUCCESS
);
186 ObDereferenceObject(Thread
);
189 INT __cdecl
KmtVSNPrintF(PSTR Buffer
, SIZE_T BufferMaxLength
, PCSTR Format
, va_list Arguments
) KMT_FORMAT(ms_printf
, 3, 0);
191 #endif /* !defined _KMTEST_TEST_KERNEL_H_ */