ReactOS 0.4.16-dev-297-gc569aee
ExCallback.c File Reference
#include <kmt_test.h>
Include dependency graph for ExCallback.c:

Go to the source code of this file.

Functions

static PEX_CALLBACK_ROUTINE_BLOCK (NTAPI *ExAllocateCallBack)(IN PEX_CALLBACK_FUNCTION Function
 
static VOID (NTAPI *ExFreeCallBack)(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock)
 
static NTSTATUS NTAPI ExCallbackFunction (IN PVOID CallbackContext, IN PVOID Argument1 OPTIONAL, IN PVOID Argument2 OPTIONAL)
 
static VOID TestPrivateFunctions (VOID)
 
static VOID NTAPI CallbackFunction (IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2)
 
 START_TEST (ExCallback)
 

Variables

static IN PVOID Context
 
static INT CallbackArgument1
 
static INT CallbackArgument2
 

Function Documentation

◆ CallbackFunction()

static VOID NTAPI CallbackFunction ( IN PVOID  CallbackContext,
IN PVOID  Argument1,
IN PVOID  Argument2 
)
static

Definition at line 80 of file ExCallback.c.

84{
85 INT *InvocationCount = CallbackContext;
86
87 ok_irql(PASSIVE_LEVEL);
88
89 (*InvocationCount)++;
92}
static INT CallbackArgument1
Definition: ExCallback.c:31
static INT CallbackArgument2
Definition: ExCallback.c:32
#define ok_eq_pointer(value, expected)
Definition: apitest.h:59
_In_ PVOID Argument2
Definition: classpnp.h:721
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
int32_t INT
Definition: typedefs.h:58
_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

◆ ExCallbackFunction()

static NTSTATUS NTAPI ExCallbackFunction ( IN PVOID  CallbackContext,
IN PVOID Argument1  OPTIONAL,
IN PVOID Argument2  OPTIONAL 
)
static

Definition at line 37 of file ExCallback.c.

41{
42 ok(0, "Callback function unexpectedly called\n");
43 return STATUS_SUCCESS;
44}
#define ok(value,...)
Definition: atltest.h:57
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by TestPrivateFunctions().

◆ PEX_CALLBACK_ROUTINE_BLOCK()

static PEX_CALLBACK_ROUTINE_BLOCK ( NTAPI ExAllocateCallBack)
static

◆ START_TEST()

START_TEST ( ExCallback  )

Definition at line 94 of file ExCallback.c.

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 VOID TestPrivateFunctions(VOID)
Definition: ExCallback.c:48
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_int(value, expected)
Definition: apitest.h:60
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
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:33
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
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
#define L(x)
Definition: ntvdm.h:50
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ PCALLBACK_FUNCTION CallbackFunction
Definition: exfuncs.h:1034
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ TestPrivateFunctions()

static VOID TestPrivateFunctions ( VOID  )
static

Definition at line 48 of file ExCallback.c.

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}
static NTSTATUS NTAPI ExCallbackFunction(IN PVOID CallbackContext, IN PVOID Argument1 OPTIONAL, IN PVOID Argument2 OPTIONAL)
Definition: ExCallback.c:37
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
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3604

Referenced by START_TEST().

◆ VOID()

static VOID ( NTAPI ExFreeCallBack)
static

Variable Documentation

◆ CallbackArgument1

INT CallbackArgument1
static

Definition at line 31 of file ExCallback.c.

Referenced by CallbackFunction(), and START_TEST().

◆ CallbackArgument2

INT CallbackArgument2
static

Definition at line 32 of file ExCallback.c.

Referenced by CallbackFunction(), and START_TEST().

◆ Context

Definition at line 15 of file ExCallback.c.