ReactOS 0.4.16-dev-852-gcfcc8d8
IoDeviceInterface.c File Reference
#include <kmt_test.h>
#include <poclass.h>
#include <debug.h>
Include dependency graph for IoDeviceInterface.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID Test_IoOpenDeviceInterfaceRegistryKey (_In_opt_ PCWSTR SymbolicLink)
 
static VOID Test_IoGetDeviceInterfaceAlias (_In_opt_ PCWSTR SymbolicLink)
 
static VOID Test_IoSetDeviceInterfaceState (_In_opt_ PCWSTR SymbolicLink)
 
static VOID Test_IoGetDeviceInterfaces (_In_ const GUID *Guid)
 
static NTSTATUS NTAPI NotificationCallback (_In_ PVOID NotificationStructure, _Inout_opt_ PVOID Context)
 
static VOID Test_IoRegisterPlugPlayNotification (VOID)
 
 START_TEST (IoDeviceInterface)
 

Variables

static const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
 
static const GUID KSCATEGORY_BRIDGE = {0x085AFF00L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUID KSCATEGORY_CAPTURE = {0x65E8773DL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_COMMUNICATIONSTRANSFORM = {0xCF1DDA2CL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_DATACOMPRESSOR = {0x1E84C900L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUID KSCATEGORY_DATADECOMPRESSOR = {0x2721AE20L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUID KSCATEGORY_DATATRANSFORM = {0x2EB07EA0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUID KSCATEGORY_FILESYSTEM = {0x760FED5EL, 0x9357, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_INTERFACETRANSFORM = {0xCF1DDA2DL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_MEDIUMTRANSFORM = {0xCF1DDA2EL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_MIXER = {0xAD809C00L, 0x7B88, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUID KSCATEGORY_RENDER = {0x65E8773EL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
 
static const GUID KSCATEGORY_SPLITTER = {0x0A4252A0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
 
static const GUIDTypes []
 
static UCHAR NotificationContext
 
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE NotificationCallback
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file IoDeviceInterface.c.

Function Documentation

◆ NotificationCallback()

static NTSTATUS NTAPI NotificationCallback ( _In_ PVOID  NotificationStructure,
_Inout_opt_ PVOID  Context 
)
static

Definition at line 197 of file IoDeviceInterface.c.

200{
205
206 ok_irql(PASSIVE_LEVEL);
208 ok_eq_uint(Notification->Version, 1);
209 ok_eq_uint(Notification->Size, sizeof(*Notification));
210
211 /* symbolic link must exist */
212 trace("Interface change: %wZ\n", Notification->SymbolicLinkName);
214 Notification->SymbolicLinkName,
216 NULL,
217 NULL);
220 if (!skip(NT_SUCCESS(Status), "No symbolic link\n"))
221 {
224 }
225 return STATUS_SUCCESS;
226}
static UCHAR NotificationContext
#define ok_eq_pointer(value, expected)
Definition: apitest.h:40
#define ok_eq_hex(value, expected)
Definition: apitest.h:58
#define ok_eq_uint(value, expected)
Definition: apitest.h:42
#define trace
Definition: atltest.h:70
#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 NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define GENERIC_READ
Definition: compat.h:135
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define KernelMode
Definition: asm.h:38
NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject(_Out_ PHANDLE SymbolicLinkHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206

◆ START_TEST()

START_TEST ( IoDeviceInterface  )

Definition at line 250 of file IoDeviceInterface.c.

251{
252 size_t n;
253 for (n = 0; n < RTL_NUMBER_OF(Types); ++n)
254 {
256 }
257 /* Test the invalid case behaviour */
262}
static VOID Test_IoOpenDeviceInterfaceRegistryKey(_In_opt_ PCWSTR SymbolicLink)
static VOID Test_IoGetDeviceInterfaces(_In_ const GUID *Guid)
static VOID Test_IoSetDeviceInterfaceState(_In_opt_ PCWSTR SymbolicLink)
static VOID Test_IoGetDeviceInterfaceAlias(_In_opt_ PCWSTR SymbolicLink)
static VOID Test_IoRegisterPlugPlayNotification(VOID)
static const GUID * Types[]
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
GLdouble n
Definition: glext.h:7729

◆ Test_IoGetDeviceInterfaceAlias()

static VOID Test_IoGetDeviceInterfaceAlias ( _In_opt_ PCWSTR  SymbolicLink)
static

Definition at line 110 of file IoDeviceInterface.c.

112{
114 size_t n;
115
117
118 for (n = 0; n < RTL_NUMBER_OF(Types); ++n)
119 {
120 UNICODE_STRING AliasSymbolicLinkName;
121 NTSTATUS Status = IoGetDeviceInterfaceAlias(&SymbolicLinkName, Types[n], &AliasSymbolicLinkName);
122
123 if (skip(NT_SUCCESS(Status), "IoGetDeviceInterfaceAlias(): fail: %d 0x%x\n", n, Status))
124 continue;
125
126 trace("IoGetDeviceInterfaceAlias(): success: %d %wZ\n", n, &AliasSymbolicLinkName);
127
128 /* Test IoOpenDeviceInterfaceRegistryKey with alias symbolic link too */
129 Test_IoOpenDeviceInterfaceRegistryKey(AliasSymbolicLinkName.Buffer);
130
131 RtlFreeUnicodeString(&AliasSymbolicLinkName);
132 }
133}
static const WCHAR SymbolicLink[]
Definition: interface.c:31
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI IoGetDeviceInterfaceAlias(_In_ PUNICODE_STRING SymbolicLinkName, _In_ CONST GUID *AliasInterfaceClassGuid, _Out_ PUNICODE_STRING AliasSymbolicLinkName)
Returns the alias device interface of the specified device interface instance, if the alias exists.
Definition: deviface.c:758
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING SymbolicLinkName
Definition: wdfdevice.h:3739

Referenced by START_TEST(), and Test_IoGetDeviceInterfaces().

◆ Test_IoGetDeviceInterfaces()

static VOID Test_IoGetDeviceInterfaces ( _In_ const GUID Guid)
static

Definition at line 158 of file IoDeviceInterface.c.

160{
165
167
169 if (skip(NT_SUCCESS(Status), "IoGetDeviceInterfaces failed with status 0x%x for '%wZ'\n", Status, &GuidString))
170 {
172 return;
173 }
174
175 trace("IoGetDeviceInterfaces '%wZ' results:\n", &GuidString);
177
181 {
182 trace("Symbolic Link: %S\n", SymbolicLink);
186 }
187
189}
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
static PWSTR GuidString
Definition: apphelp.c:93
#define UNICODE_NULL
_NullNull_terminated_ WCHAR * PZZWSTR
Definition: ntbasedef.h:428
NTSTATUS NTAPI IoGetDeviceInterfaces(IN CONST GUID *InterfaceClassGuid, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN ULONG Flags, OUT PWSTR *SymbolicLinkList)
Definition: deviface.c:936
uint16_t * PWSTR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
_In_opt_ PDEVICE_OBJECT _In_ ULONG _Outptr_result_nullonfailure_ _At_ * SymbolicLinkList(return==0, __drv_allocatesMem(Mem))) PZZWSTR *SymbolicLinkList
#define DEVICE_INTERFACE_INCLUDE_NONACTIVE
Definition: iofuncs.h:2856

Referenced by START_TEST().

◆ Test_IoOpenDeviceInterfaceRegistryKey()

static VOID Test_IoOpenDeviceInterfaceRegistryKey ( _In_opt_ PCWSTR  SymbolicLink)
static

Definition at line 58 of file IoDeviceInterface.c.

60{
64 size_t n;
65
67 RtlInitUnicodeString(&KeyName, L"ReactOS_kmtest");
68
69 /* It's okay to call this from a user process's thread */
71
72 if (skip(NT_SUCCESS(Status), "IoOpenDeviceInterfaceRegistryKey() failed: 0x%lx\n", Status))
73 return;
74
75 trace("IoOpenDeviceInterfaceRegistryKey() success: 0x%p\n", DeviceInterfaceKey);
76
77 for (n = 0; n < RTL_NUMBER_OF(Types); ++n)
78 {
79 HANDLE DeviceInterfaceSubKey;
81
82 /* Try to create the non-volatile subkey to check whether the parent key is volatile */
84 &KeyName,
87 NULL);
88 Status = ZwCreateKey(&DeviceInterfaceSubKey,
91 0,
92 NULL,
94 NULL);
95
96 if (skip(NT_SUCCESS(Status), "ZwCreateKey() failed to create a subkey: %d 0x%lx\n", n, Status))
97 continue;
98
99 trace("ZwCreateKey(): successfully created subkey: %d 0x%p\n", n, DeviceInterfaceSubKey);
100
101 ZwDeleteKey(DeviceInterfaceSubKey);
102 ZwClose(DeviceInterfaceSubKey);
103 }
104
106}
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey(IN PUNICODE_STRING SymbolicLinkName, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DeviceInterfaceKey)
Definition: deviface.c:595
#define L(x)
Definition: ntvdm.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699
_In_ ACCESS_MASK _Out_ PHANDLE DeviceInterfaceKey
Definition: iofuncs.h:1116

Referenced by START_TEST(), Test_IoGetDeviceInterfaceAlias(), and Test_IoGetDeviceInterfaces().

◆ Test_IoRegisterPlugPlayNotification()

static VOID Test_IoRegisterPlugPlayNotification ( VOID  )
static

Definition at line 230 of file IoDeviceInterface.c.

231{
234
237 (PVOID)&GUID_DEVICE_SYS_BUTTON,
238 KmtDriverObject,
243 if (!skip(NT_SUCCESS(Status), "PlugPlayNotification not registered\n"))
244 {
247 }
248}
static DRIVER_NOTIFICATION_CALLBACK_ROUTINE NotificationCallback
NTSTATUS NTAPI IoRegisterPlugPlayNotification(_In_ IO_NOTIFICATION_EVENT_CATEGORY EventCategory, _In_ ULONG EventCategoryFlags, _In_opt_ PVOID EventCategoryData, _In_ PDRIVER_OBJECT DriverObject, _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, _Inout_opt_ PVOID Context, _Out_ PVOID *NotificationEntry)
Definition: pnpnotify.c:346
NTSTATUS NTAPI IoUnregisterPlugPlayNotification(_In_ PVOID NotificationEntry)
Definition: pnpnotify.c:480
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
@ EventCategoryDeviceInterfaceChange
Definition: iotypes.h:1226
#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES
Definition: iotypes.h:1239

Referenced by START_TEST().

◆ Test_IoSetDeviceInterfaceState()

static VOID Test_IoSetDeviceInterfaceState ( _In_opt_ PCWSTR  SymbolicLink)
static

Definition at line 137 of file IoDeviceInterface.c.

139{
141 size_t n;
142
144
145 for (n = 0; n < RTL_NUMBER_OF(Types); ++n)
146 {
148
149 if (skip(NT_SUCCESS(Status), "IoSetDeviceInterfaceState(): failed to enable interface: %d 0x%x\n", n, Status))
150 continue;
151
152 trace("IoSetDeviceInterfaceState(): successfully enabled interface: %d %wZ\n", n, &SymbolicLinkName);
153 }
154}
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1793

Referenced by START_TEST(), and Test_IoGetDeviceInterfaces().

Variable Documentation

◆ GUID_NULL

const GUID GUID_NULL = {0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
static

Definition at line 24 of file IoDeviceInterface.c.

◆ KSCATEGORY_BRIDGE

const GUID KSCATEGORY_BRIDGE = {0x085AFF00L, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 26 of file IoDeviceInterface.c.

◆ KSCATEGORY_CAPTURE

const GUID KSCATEGORY_CAPTURE = {0x65E8773DL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 27 of file IoDeviceInterface.c.

◆ KSCATEGORY_COMMUNICATIONSTRANSFORM

const GUID KSCATEGORY_COMMUNICATIONSTRANSFORM = {0xCF1DDA2CL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 28 of file IoDeviceInterface.c.

◆ KSCATEGORY_DATACOMPRESSOR

const GUID KSCATEGORY_DATACOMPRESSOR = {0x1E84C900L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 29 of file IoDeviceInterface.c.

◆ KSCATEGORY_DATADECOMPRESSOR

const GUID KSCATEGORY_DATADECOMPRESSOR = {0x2721AE20L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 30 of file IoDeviceInterface.c.

◆ KSCATEGORY_DATATRANSFORM

const GUID KSCATEGORY_DATATRANSFORM = {0x2EB07EA0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 31 of file IoDeviceInterface.c.

◆ KSCATEGORY_FILESYSTEM

const GUID KSCATEGORY_FILESYSTEM = {0x760FED5EL, 0x9357, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 32 of file IoDeviceInterface.c.

◆ KSCATEGORY_INTERFACETRANSFORM

const GUID KSCATEGORY_INTERFACETRANSFORM = {0xCF1DDA2DL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 33 of file IoDeviceInterface.c.

◆ KSCATEGORY_MEDIUMTRANSFORM

const GUID KSCATEGORY_MEDIUMTRANSFORM = {0xCF1DDA2EL, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 34 of file IoDeviceInterface.c.

◆ KSCATEGORY_MIXER

const GUID KSCATEGORY_MIXER = {0xAD809C00L, 0x7B88, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 35 of file IoDeviceInterface.c.

◆ KSCATEGORY_RENDER

const GUID KSCATEGORY_RENDER = {0x65E8773EL, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}}
static

Definition at line 36 of file IoDeviceInterface.c.

◆ KSCATEGORY_SPLITTER

const GUID KSCATEGORY_SPLITTER = {0x0A4252A0L, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}}
static

Definition at line 37 of file IoDeviceInterface.c.

◆ NotificationCallback

DRIVER_NOTIFICATION_CALLBACK_ROUTINE NotificationCallback
static

Definition at line 193 of file IoDeviceInterface.c.

Referenced by Test_IoRegisterPlugPlayNotification().

◆ NotificationContext

UCHAR NotificationContext
static

◆ Types

const GUID* Types[]
static
Initial value:
=
{
}
static const GUID GUID_NULL
static const GUID KSCATEGORY_DATADECOMPRESSOR
static const GUID KSCATEGORY_INTERFACETRANSFORM
static const GUID KSCATEGORY_RENDER
static const GUID KSCATEGORY_SPLITTER
static const GUID KSCATEGORY_FILESYSTEM
static const GUID KSCATEGORY_DATACOMPRESSOR
static const GUID KSCATEGORY_MIXER
static const GUID KSCATEGORY_MEDIUMTRANSFORM
static const GUID KSCATEGORY_CAPTURE
static const GUID KSCATEGORY_COMMUNICATIONSTRANSFORM
static const GUID KSCATEGORY_DATATRANSFORM
static const GUID KSCATEGORY_BRIDGE

Definition at line 39 of file IoDeviceInterface.c.

Referenced by START_TEST(), Test_IoGetDeviceInterfaceAlias(), Test_IoOpenDeviceInterfaceRegistryKey(), and Test_IoSetDeviceInterfaceState().