ReactOS  0.4.14-dev-114-gc8cbd56
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 }
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:55
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
#define ok_eq_pointer(value, expected)
static INT CallbackArgument1
Definition: ExCallback.c:31
int32_t INT
Definition: typedefs.h:56
static INT CallbackArgument2
Definition: ExCallback.c:32
_In_ PVOID Argument2
Definition: classpnp.h:680
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693

Referenced by START_TEST().

◆ 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
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define KmtInvalidPointer
Definition: kmt_test.h:275
#define TRUE
Definition: types.h:120
#define ok_eq_int(value, expected)
Definition: kmt_test.h:238
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ExCreateCallback(OUT PCALLBACK_OBJECT *CallbackObject, IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN Create, IN BOOLEAN AllowMultipleCallbacks)
Definition: callback.c:361
static INT CallbackArgument1
Definition: ExCallback.c:31
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
static VOID NTAPI CallbackFunction(IN PVOID CallbackContext, IN PVOID Argument1, IN PVOID Argument2)
Definition: ExCallback.c:80
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ExUnregisterCallback(IN PVOID CallbackRegistrationHandle)
Definition: callback.c:636
static VOID TestPrivateFunctions(VOID)
Definition: ExCallback.c:48
smooth NULL
Definition: ftsmooth.c:416
static INT CallbackArgument2
Definition: ExCallback.c:32
VOID NTAPI ExNotifyCallback(IN PCALLBACK_OBJECT CallbackObject, IN PVOID Argument1, IN PVOID Argument2)
Definition: callback.c:467
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
ULONG KmtGetPoolTag(PVOID Memory)
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
PVOID NTAPI ExRegisterCallback(IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, IN PVOID CallbackContext)
Definition: callback.c:556
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ 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 
55  if (!ExAllocateCallBack)
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 
70  ok_eq_pointer(CallbackBlock->Function, ExCallbackFunction);
71  ok_eq_pointer(CallbackBlock->Context, &CallbackContext);
72  ok_eq_hex(KmtGetPoolTag(CallbackBlock), 'brbC');
73 
74  ExFreeCallBack(CallbackBlock);
75 }
PEX_CALLBACK_ROUTINE_BLOCK NTAPI ExAllocateCallBack(IN PEX_CALLBACK_FUNCTION Function, IN PVOID Context)
Definition: callback.c:54
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR _In_ ULONGLONG _In_ ULONGLONG _In_opt_ PEVENT_FILTER_DESCRIPTOR _Inout_opt_ PVOID CallbackContext
Definition: wmitypes.h:55
#define ok_eq_pointer(value, expected)
int32_t INT
Definition: typedefs.h:56
PEX_CALLBACK_FUNCTION Function
Definition: extypes.h:538
PVOID NTAPI MmGetSystemRoutineAddress(IN PUNICODE_STRING SystemRoutineName)
Definition: sysldr.c:3417
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
static NTSTATUS NTAPI ExCallbackFunction(IN PVOID CallbackContext, IN PVOID Argument1 OPTIONAL, IN PVOID Argument2 OPTIONAL)
Definition: ExCallback.c:37
ULONG KmtGetPoolTag(PVOID Memory)
#define ok(value,...)
Definition: atltest.h:57
VOID NTAPI ExFreeCallBack(IN PEX_CALLBACK_ROUTINE_BLOCK CallbackBlock)
Definition: callback.c:77
#define skip(...)
Definition: atltest.h:64
#define ok_eq_hex(value, expected)
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

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 19 of file ExCallback.c.