- Fix epic naming fail (DhcpEnabled -> EnableDHCP
[reactos.git] / rostests / drivers / kmtest / deviface_test.c
1 /*
2 * PnP Test
3 * Device Interface functions test
4 *
5 * Copyright 2004 Filip Navara <xnavara@volny.cz>
6 *
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.
11 *
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.
16 *
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.
21 */
22
23 /* INCLUDES *******************************************************************/
24
25 #include <ddk/ntifs.h>
26 #include <ndk/iotypes.h>
27 #include "kmtest.h"
28
29 #define NDEBUG
30 #include "debug.h"
31
32 /* PRIVATE FUNCTIONS **********************************************************/
33
34 NTSTATUS
35 (NTAPI *IoGetDeviceInterfaces_Func)(
36 IN CONST GUID *InterfaceClassGuid,
37 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
38 IN ULONG Flags,
39 OUT PWSTR *SymbolicLinkList);
40
41 NTSTATUS NTAPI
42 ReactOS_IoGetDeviceInterfaces(
43 IN CONST GUID *InterfaceClassGuid,
44 IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
45 IN ULONG Flags,
46 OUT PWSTR *SymbolicLinkList);
47
48 VOID DeviceInterfaceTest_Func()
49 {
50 NTSTATUS Status;
51 PWSTR SymbolicLinkList;
52 PWSTR SymbolicLinkListPtr;
53 GUID Guid = {0x378de44c, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
54
55 Status = IoGetDeviceInterfaces(
56 &Guid,
57 NULL,
58 0,
59 &SymbolicLinkList);
60
61 ok(NT_SUCCESS(Status),
62 "IoGetDeviceInterfaces failed with status 0x%X\n",
63 (unsigned int)Status);
64 if (!NT_SUCCESS(Status))
65 {
66 return;
67 }
68
69 DPRINT("IoGetDeviceInterfaces results:\n");
70 for (SymbolicLinkListPtr = SymbolicLinkList;
71 SymbolicLinkListPtr[0] != 0 && SymbolicLinkListPtr[1] != 0;
72 SymbolicLinkListPtr += wcslen(SymbolicLinkListPtr) + 1)
73 {
74 DPRINT1("Symbolic Link: %S\n", SymbolicLinkListPtr);
75 }
76
77 #if 0
78 DPRINT("[PnP Test] Trying to get aliases\n");
79
80 for (SymbolicLinkListPtr = SymbolicLinkList;
81 SymbolicLinkListPtr[0] != 0 && SymbolicLinkListPtr[1] != 0;
82 SymbolicLinkListPtr += wcslen(SymbolicLinkListPtr) + 1)
83 {
84 UNICODE_STRING SymbolicLink;
85 UNICODE_STRING AliasSymbolicLink;
86
87 SymbolicLink.Buffer = SymbolicLinkListPtr;
88 SymbolicLink.Length = SymbolicLink.MaximumLength = wcslen(SymbolicLinkListPtr);
89 RtlInitUnicodeString(&AliasSymbolicLink, NULL);
90 IoGetDeviceInterfaceAlias(
91 &SymbolicLink,
92 &AliasGuid,
93 &AliasSymbolicLink);
94 if (AliasSymbolicLink.Buffer != NULL)
95 {
96 DPRINT("[PnP Test] Original: %S\n", SymbolicLinkListPtr);
97 DPRINT("[PnP Test] Alias: %S\n", AliasSymbolicLink.Buffer);
98 }
99 }
100 #endif
101
102 ExFreePool(SymbolicLinkList);
103 }
104
105 VOID RegisterDI_Test(HANDLE KeyHandle)
106 {
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;
112 NTSTATUS Status;
113
114 StartTest();
115
116 RtlInitUnicodeString(&SymbolicLinkName, L"");
117
118 // Prepare our surrogate of a Device Object
119 DeviceObject.DeviceObjectExtension = (PDEVOBJ_EXTENSION)&DeviceObjectExtension;
120
121 // 1. DeviceNode = NULL
122 DeviceObjectExtension.DeviceNode = NULL;
123 Status = IoRegisterDeviceInterface(&DeviceObject, &Guid, NULL,
124 &SymbolicLinkName);
125
126 ok(Status == STATUS_INVALID_DEVICE_REQUEST,
127 "IoRegisterDeviceInterface returned 0x%08lX\n", Status);
128
129 // 2. DeviceNode->InstancePath is of a null length
130 DeviceObjectExtension.DeviceNode = &DeviceNode;
131 DeviceNode.InstancePath.Length = 0;
132 Status = IoRegisterDeviceInterface(&DeviceObject, &Guid, NULL,
133 &SymbolicLinkName);
134
135 ok(Status == STATUS_INVALID_DEVICE_REQUEST,
136 "IoRegisterDeviceInterface returned 0x%08lX\n", Status);
137
138 DeviceInterfaceTest_Func();
139
140 FinishTest(KeyHandle, L"IoDeviceInterfaceTest");
141 }