3 * Device Interface functions test
5 * Copyright 2004 Filip Navara <xnavara@volny.cz>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; see the file COPYING.LIB.
19 * If not, write to the Free Software Foundation,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 /* INCLUDES *******************************************************************/
25 #include <ddk/ntddk.h>
26 #include <ndk/iotypes.h>
32 /* PRIVATE FUNCTIONS **********************************************************/
35 (*IoGetDeviceInterfaces_Func
)(
36 IN CONST GUID
*InterfaceClassGuid
,
37 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL
,
39 OUT PWSTR
*SymbolicLinkList
);
42 ReactOS_IoGetDeviceInterfaces(
43 IN CONST GUID
*InterfaceClassGuid
,
44 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL
,
46 OUT PWSTR
*SymbolicLinkList
);
48 VOID
DeviceInterfaceTest_Func()
51 PWSTR SymbolicLinkList
;
52 PWSTR SymbolicLinkListPtr
;
53 GUID Guid
= {0x378de44c, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
55 Status
= IoGetDeviceInterfaces_Func(
61 if (!NT_SUCCESS(Status
))
64 "[PnP Test] IoGetDeviceInterfaces failed with status 0x%X\n",
69 DPRINT("[PnP Test] IoGetDeviceInterfaces results:\n");
70 for (SymbolicLinkListPtr
= SymbolicLinkList
;
71 SymbolicLinkListPtr
[0] != 0 && SymbolicLinkListPtr
[1] != 0;
72 SymbolicLinkListPtr
+= wcslen(SymbolicLinkListPtr
) + 1)
74 DPRINT("[PnP Test] %S\n", SymbolicLinkListPtr
);
78 DPRINT("[PnP Test] Trying to get aliases\n");
80 for (SymbolicLinkListPtr
= SymbolicLinkList
;
81 SymbolicLinkListPtr
[0] != 0 && SymbolicLinkListPtr
[1] != 0;
82 SymbolicLinkListPtr
+= wcslen(SymbolicLinkListPtr
) + 1)
84 UNICODE_STRING SymbolicLink
;
85 UNICODE_STRING AliasSymbolicLink
;
87 SymbolicLink
.Buffer
= SymbolicLinkListPtr
;
88 SymbolicLink
.Length
= SymbolicLink
.MaximumLength
= wcslen(SymbolicLinkListPtr
);
89 RtlInitUnicodeString(&AliasSymbolicLink
, NULL
);
90 IoGetDeviceInterfaceAlias(
94 if (AliasSymbolicLink
.Buffer
!= NULL
)
96 DPRINT("[PnP Test] Original: %S\n", SymbolicLinkListPtr
);
97 DPRINT("[PnP Test] Alias: %S\n", AliasSymbolicLink
.Buffer
);
102 ExFreePool(SymbolicLinkList
);
105 VOID
RegisterDI_Test()
107 GUID Guid
= {0x378de44c, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
108 DEVICE_OBJECT DeviceObject
;
109 EXTENDED_DEVOBJ_EXTENSION DeviceObjectExtension
;
110 DEVICE_NODE DeviceNode
;
111 UNICODE_STRING SymbolicLinkName
;
114 RtlInitUnicodeString(&SymbolicLinkName
, L
"");
116 // Prepare our surrogate of a Device Object
117 DeviceObject
.DeviceObjectExtension
= (PDEVOBJ_EXTENSION
)&DeviceObjectExtension
;
119 // 1. DeviceNode = NULL
120 DeviceObjectExtension
.DeviceNode
= NULL
;
121 Status
= IoRegisterDeviceInterface(&DeviceObject
, &Guid
, NULL
,
124 ok(Status
== STATUS_INVALID_DEVICE_REQUEST
,
125 "IoRegisterDeviceInterface returned 0x%08lX\n", Status
);
127 // 2. DeviceNode->InstancePath is of a null length
128 DeviceObjectExtension
.DeviceNode
= &DeviceNode
;
129 DeviceNode
.InstancePath
.Length
= 0;
130 Status
= IoRegisterDeviceInterface(&DeviceObject
, &Guid
, NULL
,
133 ok(Status
== STATUS_INVALID_DEVICE_REQUEST
,
134 "IoRegisterDeviceInterface returned 0x%08lX\n", Status
);
137 VOID
NtoskrnlIoDeviceInterface()
141 // Test IoRegisterDeviceInterface() failures now
145 DPRINT("Calling DeviceInterfaceTest_Func with native functions\n");
146 IoGetDeviceInterfaces_Func = IoGetDeviceInterfaces;
147 DeviceInterfaceTest_Func();
148 DPRINT("Calling DeviceInterfaceTest_Func with ReactOS functions\n");
149 IoGetDeviceInterfaces_Func = ReactOS_IoGetDeviceInterfaces;
150 DeviceInterfaceTest_Func();
153 FinishTest("NTOSKRNL Io Device Interface Test");