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/ntifs.h>
26 #include <ndk/iotypes.h>
32 /* PRIVATE FUNCTIONS **********************************************************/
35 (NTAPI
*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(
61 ok(NT_SUCCESS(Status
),
62 "IoGetDeviceInterfaces failed with status 0x%X\n",
63 (unsigned int)Status
);
64 if (!NT_SUCCESS(Status
))
69 DPRINT("IoGetDeviceInterfaces results:\n");
70 for (SymbolicLinkListPtr
= SymbolicLinkList
;
71 SymbolicLinkListPtr
[0] != 0 && SymbolicLinkListPtr
[1] != 0;
72 SymbolicLinkListPtr
+= wcslen(SymbolicLinkListPtr
) + 1)
74 DPRINT1("Symbolic Link: %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(HANDLE KeyHandle
)
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
;
116 RtlInitUnicodeString(&SymbolicLinkName
, L
"");
118 // Prepare our surrogate of a Device Object
119 DeviceObject
.DeviceObjectExtension
= (PDEVOBJ_EXTENSION
)&DeviceObjectExtension
;
121 // 1. DeviceNode = NULL
122 DeviceObjectExtension
.DeviceNode
= NULL
;
123 Status
= IoRegisterDeviceInterface(&DeviceObject
, &Guid
, NULL
,
126 ok(Status
== STATUS_INVALID_DEVICE_REQUEST
,
127 "IoRegisterDeviceInterface returned 0x%08lX\n", Status
);
129 // 2. DeviceNode->InstancePath is of a null length
130 DeviceObjectExtension
.DeviceNode
= &DeviceNode
;
131 DeviceNode
.InstancePath
.Length
= 0;
132 Status
= IoRegisterDeviceInterface(&DeviceObject
, &Guid
, NULL
,
135 ok(Status
== STATUS_INVALID_DEVICE_REQUEST
,
136 "IoRegisterDeviceInterface returned 0x%08lX\n", Status
);
138 DeviceInterfaceTest_Func();
140 FinishTest(KeyHandle
, L
"IoDeviceInterfaceTest");