ReactOS 0.4.15-dev-8102-g108db8f
ExCallback.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS kernel-mode tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Kernel-Mode Test Suite Executive Callback test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8#include <kmt_test.h>
9
10static
12(NTAPI
16)
17//= (PVOID)0x809af1f4 // 2003 sp1 x86
18//= (PVOID)0x80a7f04a // 2003 sp1 x86 checked
19;
20
21static
23(NTAPI
25 IN PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock
26)
27//= (PVOID)0x80918bb5 // 2003 sp1 x86
28//= (PVOID)0x80a355f0 // 2003 sp1 x86 checked
29;
30
33
34static
41{
42 ok(0, "Callback function unexpectedly called\n");
43 return STATUS_SUCCESS;
44}
45
46static
47VOID
49{
50 UNICODE_STRING ExAllocateCallBackName = RTL_CONSTANT_STRING(L"ExAllocateCallBack");
51 UNICODE_STRING ExFreeCallBackName = RTL_CONSTANT_STRING(L"ExFreeCallBack");
52 PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock;
54
56 ExAllocateCallBack = MmGetSystemRoutineAddress(&ExAllocateCallBackName);
57 if (!ExFreeCallBack)
58 ExFreeCallBack = MmGetSystemRoutineAddress(&ExFreeCallBackName);
59
61 "ExAllocateCallBack and/or ExFreeCallBack unavailable\n"))
62 return;
63
65 ok(CallbackBlock != NULL, "CallbackBlock = NULL\n");
66
67 if (skip(CallbackBlock != NULL, "Allocating callback failed\n"))
68 return;
69
71 ok_eq_pointer(CallbackBlock->Context, &CallbackContext);
72 ok_eq_hex(KmtGetPoolTag(CallbackBlock), 'brbC');
73
74 ExFreeCallBack(CallbackBlock);
75}
76
77static
78VOID
84{
85 INT *InvocationCount = CallbackContext;
86
87 ok_irql(PASSIVE_LEVEL);
88
89 (*InvocationCount)++;
92}
93
94START_TEST(ExCallback)
95{
97 PCALLBACK_OBJECT CallbackObject;
99 UNICODE_STRING CallbackName = RTL_CONSTANT_STRING(L"\\Callback\\KmtestExCallbackTestCallback");
100 PVOID CallbackRegistration;
101 INT InvocationCount = 0;
102
104
105 /* TODO: Parameter tests */
106 /* TODO: Test the three predefined callbacks */
107 /* TODO: Test opening an existing callback */
108 /* TODO: Test AllowMultipleCallbacks */
109 /* TODO: Test calling multiple callbacks */
110 /* TODO: Test registering the same function twice */
111 /* TODO: Test callback object fields */
112 /* TODO: Test callback registration fields */
114 &CallbackName,
116 NULL,
117 NULL);
118
119 CallbackObject = KmtInvalidPointer;
120 Status = ExCreateCallback(&CallbackObject,
122 TRUE,
123 TRUE);
125 ok(CallbackObject != NULL && CallbackObject != KmtInvalidPointer,
126 "CallbackObject = %p", CallbackObject);
127
128 if (skip(NT_SUCCESS(Status), "Creating callback failed\n"))
129 return;
130
131 CallbackRegistration = ExRegisterCallback(CallbackObject,
133 &InvocationCount);
134 ok(CallbackRegistration != NULL, "CallbackRegistration = NULL\n");
135
136 if (!skip(CallbackRegistration != NULL, "Registering callback failed\n"))
137 {
138 ok_eq_hex(KmtGetPoolTag(CallbackRegistration), 'eRBC');
139 ok_eq_int(InvocationCount, 0);
140 ExNotifyCallback(CallbackObject,
143 ok_eq_int(InvocationCount, 1);
144 ExNotifyCallback(CallbackObject,
147 ok_eq_int(InvocationCount, 2);
148
149 ExUnregisterCallback(CallbackRegistration);
150 }
151
152 ObDereferenceObject(CallbackObject);
153}
static NTSTATUS NTAPI ExCallbackFunction(IN PVOID CallbackContext, IN PVOID Argument1 OPTIONAL, IN PVOID Argument2 OPTIONAL)
Definition: ExCallback.c:37
static VOID TestPrivateFunctions(VOID)
Definition: ExCallback.c:48
static IN PVOID Context
Definition: ExCallback.c:19
static INT CallbackArgument1
Definition: ExCallback.c:31
static INT CallbackArgument2
Definition: ExCallback.c:32
#define VOID
Definition: acefi.h:82
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#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_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
_In_ PVOID Argument2
Definition: classpnp.h:721
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define KmtInvalidPointer
Definition: kmt_test.h:280
ULONG KmtGetPoolTag(PVOID Memory)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
struct _EX_CALLBACK_ROUTINE_BLOCK * PEX_CALLBACK_ROUTINE_BLOCK
VOID NTAPI ExUnregisterCallback(IN PVOID CallbackRegistrationHandle)
Definition: callback.c:636
VOID NTAPI ExNotifyCallback(IN PCALLBACK_OBJECT CallbackObject, IN PVOID Argument1, IN PVOID Argument2)
Definition: callback.c:467
PVOID NTAPI ExRegisterCallback(IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, IN PVOID CallbackContext)
Definition: callback.c:556
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
VOID NTAPI ExFreeCallBack(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock)
Definition: callback.c:77
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack(IN PEX_CALLBACK_FUNCTION Function, IN PVOID Context)
Definition: callback.c:54
#define L(x)
Definition: ntvdm.h:50
#define STATUS_SUCCESS
Definition: shellext.h:65
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3604
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:60
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696
EX_CALLBACK_FUNCTION * PEX_CALLBACK_FUNCTION
Definition: cmtypes.h:698
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034
#define ObDereferenceObject
Definition: obfuncs.h:203