3 * Copyright (C) 2005 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: base/services/umpnpmgr/rpcserver.c
24 * PROGRAMMER: Eric Kohl (eric.kohl@reactos.org)
25 * Hervé Poussineau (hpoussin@reactos.org)
26 * Colin Finck (colin@reactos.org)
29 /* INCLUDES *****************************************************************/
37 /* GLOBALS ******************************************************************/
39 static WCHAR szRootDeviceInstanceID
[] = L
"HTREE\\ROOT\\0";
42 /* FUNCTIONS *****************************************************************/
45 RpcServerThread(LPVOID lpParameter
)
48 BOOLEAN RegisteredProtSeq
= FALSE
;
50 UNREFERENCED_PARAMETER(lpParameter
);
52 DPRINT("RpcServerThread() called\n");
55 /* 2k/XP/2k3-compatible protocol sequence/endpoint */
56 Status
= RpcServerUseProtseqEpW(L
"ncacn_np",
59 NULL
); // Security descriptor
60 if (Status
== RPC_S_OK
)
61 RegisteredProtSeq
= TRUE
;
63 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
66 /* Vista/7-compatible protocol sequence/endpoint */
67 Status
= RpcServerUseProtseqEpW(L
"ncacn_np",
70 NULL
); // Security descriptor
71 if (Status
== RPC_S_OK
)
72 RegisteredProtSeq
= TRUE
;
74 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
76 /* Make sure there's a usable endpoint */
77 if (RegisteredProtSeq
== FALSE
)
80 Status
= RpcServerRegisterIf(pnp_v1_0_s_ifspec
,
83 if (Status
!= RPC_S_OK
)
85 DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status
);
89 Status
= RpcServerListen(1,
92 if (Status
!= RPC_S_OK
)
94 DPRINT1("RpcServerListen() failed (Status %lx)\n", Status
);
98 /* ROS HACK (this should never happen...) */
99 DPRINT1("*** Other devices won't be installed correctly. If something\n");
100 DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
102 DPRINT("RpcServerThread() done\n");
108 void __RPC_FAR
* __RPC_USER
midl_user_allocate(SIZE_T len
)
110 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
114 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
116 HeapFree(GetProcessHeap(), 0, ptr
);
120 static CONFIGRET WINAPI
121 NtStatusToCrError(NTSTATUS Status
)
125 case STATUS_NOT_IMPLEMENTED
:
126 return CR_CALL_NOT_IMPLEMENTED
;
128 case STATUS_INVALID_PARAMETER
:
129 return CR_INVALID_DATA
;
131 case STATUS_NO_SUCH_DEVICE
:
132 return CR_NO_SUCH_DEVINST
;
134 case STATUS_ACCESS_DENIED
:
135 return CR_ACCESS_DENIED
;
137 case STATUS_BUFFER_TOO_SMALL
:
138 return CR_BUFFER_SMALL
;
140 case STATUS_OBJECT_NAME_NOT_FOUND
:
141 return CR_NO_SUCH_VALUE
;
150 SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID
,
151 OUT LPWSTR pszEnumerator
,
152 OUT LPWSTR pszDevice
,
153 OUT LPWSTR pszInstance
)
155 WCHAR szLocalDeviceInstanceID
[MAX_DEVICE_ID_LEN
];
156 LPWSTR lpEnumerator
= NULL
;
157 LPWSTR lpDevice
= NULL
;
158 LPWSTR lpInstance
= NULL
;
161 wcscpy(szLocalDeviceInstanceID
, pszDeviceInstanceID
);
167 lpEnumerator
= szLocalDeviceInstanceID
;
169 ptr
= wcschr(lpEnumerator
, L
'\\');
175 ptr
= wcschr(lpDevice
, L
'\\');
183 if (lpEnumerator
!= NULL
)
184 wcscpy(pszEnumerator
, lpEnumerator
);
186 if (lpDevice
!= NULL
)
187 wcscpy(pszDevice
, lpDevice
);
189 if (lpInstance
!= NULL
)
190 wcscpy(pszInstance
, lpInstance
);
197 _In_ LPWSTR pszDeviceID
,
199 _In_ DWORD ulProblem
)
201 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
202 CONFIGRET ret
= CR_SUCCESS
;
205 DPRINT1("ClearDeviceStatus(%S 0x%lx 0x%lx)\n",
206 pszDeviceID
, ulStatus
, ulProblem
);
208 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
210 PlugPlayData
.Operation
= PNP_CLEAR_DEVICE_STATUS
;
211 PlugPlayData
.DeviceStatus
= ulStatus
;
212 PlugPlayData
.DeviceProblem
= ulProblem
;
214 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
215 (PVOID
)&PlugPlayData
,
216 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
217 if (!NT_SUCCESS(Status
))
218 ret
= NtStatusToCrError(Status
);
227 _In_ LPWSTR pszDeviceID
,
228 _Out_ DWORD
*pulStatus
,
229 _Out_ DWORD
*pulProblem
)
231 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
232 CONFIGRET ret
= CR_SUCCESS
;
235 DPRINT("GetDeviceStatus(%S %p %p)\n",
236 pszDeviceID
, pulStatus
, pulProblem
);
238 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
240 PlugPlayData
.Operation
= PNP_GET_DEVICE_STATUS
;
242 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
243 (PVOID
)&PlugPlayData
,
244 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
245 if (NT_SUCCESS(Status
))
247 *pulStatus
= PlugPlayData
.DeviceStatus
;
248 *pulProblem
= PlugPlayData
.DeviceProblem
;
252 ret
= NtStatusToCrError(Status
);
262 _In_ LPWSTR pszDeviceID
,
264 _In_ DWORD ulProblem
)
266 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
267 CONFIGRET ret
= CR_SUCCESS
;
270 DPRINT1("SetDeviceStatus(%S 0x%lx 0x%lx)\n",
271 pszDeviceID
, ulStatus
, ulProblem
);
273 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
275 PlugPlayData
.Operation
= PNP_SET_DEVICE_STATUS
;
276 PlugPlayData
.DeviceStatus
= ulStatus
;
277 PlugPlayData
.DeviceProblem
= ulProblem
;
279 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
280 (PVOID
)&PlugPlayData
,
281 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
282 if (!NT_SUCCESS(Status
))
283 ret
= NtStatusToCrError(Status
);
291 DisableDeviceInstance(
292 _In_ LPWSTR pszDeviceInstance
,
293 _Inout_opt_ PPNP_VETO_TYPE pVetoType
,
294 _Inout_opt_ LPWSTR pszVetoName
,
295 _In_ DWORD ulNameLength
)
297 PLUGPLAY_CONTROL_QUERY_REMOVE_DATA QueryRemoveData
;
298 CONFIGRET ret
= CR_SUCCESS
;
301 DPRINT1("DisableDeviceInstance(%S %p %p %lu)\n",
302 pszDeviceInstance
, pVetoType
, pszVetoName
, ulNameLength
);
304 RtlInitUnicodeString(&QueryRemoveData
.DeviceInstance
,
307 QueryRemoveData
.Flags
= 0;
308 QueryRemoveData
.VetoType
= 0;
309 QueryRemoveData
.VetoName
= pszVetoName
;
310 QueryRemoveData
.NameLength
= ulNameLength
;
312 Status
= NtPlugPlayControl(PlugPlayControlQueryAndRemoveDevice
,
314 sizeof(PLUGPLAY_CONTROL_QUERY_REMOVE_DATA
));
315 if (Status
== STATUS_NO_SUCH_DEVICE
)
317 ret
= CR_INVALID_DEVNODE
;
319 else if (Status
== STATUS_PLUGPLAY_QUERY_VETOED
)
321 if (pVetoType
!= NULL
)
322 *pVetoType
= QueryRemoveData
.VetoType
;
324 ret
= CR_REMOVE_VETOED
;
326 else if (!NT_SUCCESS(Status
))
328 ret
= NtStatusToCrError(Status
);
337 IsValidDeviceInstanceID(
338 _In_ PWSTR pszDeviceInstanceID
)
340 INT nPartLength
[3] = {0, 0, 0};
341 INT nLength
= 0, nParts
= 0;
344 DPRINT("IsValidDeviceInstanceID(%S)\n",
345 pszDeviceInstanceID
);
347 if (pszDeviceInstanceID
== NULL
)
349 DPRINT("Device instance ID is NULL!\n");
353 p
= pszDeviceInstanceID
;
354 while (*p
!= UNICODE_NULL
)
361 DPRINT("Too many separators: %d\n", nParts
);
367 nPartLength
[nParts
]++;
371 if (nLength
>= MAX_DEVICE_ID_LEN
)
373 DPRINT("Too long: %d\n", nLength
);
382 DPRINT("Invalid number of separtors: %d\n", nParts
);
386 if ((nPartLength
[0] == 0) ||
387 (nPartLength
[1] == 0) ||
388 (nPartLength
[2] == 0))
390 DPRINT("Invalid part lengths: %d %d %d\n",
391 nPartLength
[0], nPartLength
[1], nPartLength
[2]);
395 DPRINT("Valid device instance ID!\n");
403 IsRootDeviceInstanceID(
404 _In_ PWSTR pszDeviceInstanceID
)
406 if (_wcsicmp(pszDeviceInstanceID
, szRootDeviceInstanceID
) == 0)
413 /* PUBLIC FUNCTIONS **********************************************************/
421 UNREFERENCED_PARAMETER(hBinding
);
432 UNREFERENCED_PARAMETER(hBinding
);
444 UNREFERENCED_PARAMETER(hBinding
);
446 DPRINT("PNP_GetVersion(%p %p)\n",
463 UNREFERENCED_PARAMETER(hBinding
);
464 UNREFERENCED_PARAMETER(ulFlags
);
466 DPRINT("PNP_GetGlobalState(%p %p 0x%08lx)\n",
467 hBinding
, pulState
, ulFlags
);
469 *pulState
= CM_GLOBAL_STATE_CAN_DO_UI
| CM_GLOBAL_STATE_SERVICES_AVAILABLE
;
481 UNREFERENCED_PARAMETER(hBinding
);
483 DPRINT("PNP_InitDetection(%p)\n",
498 DWORD ReturnValue
= CR_FAILURE
;
501 UNREFERENCED_PARAMETER(hBinding
);
502 UNREFERENCED_PARAMETER(Admin
);
504 DPRINT("PNP_ReportLogOn(%p %u, %u)\n",
505 hBinding
, Admin
, ProcessId
);
507 /* Get the users token */
508 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, TRUE
, ProcessId
);
512 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
518 CloseHandle(hUserToken
);
522 if (!OpenProcessToken(hProcess
, TOKEN_ASSIGN_PRIMARY
| TOKEN_DUPLICATE
| TOKEN_QUERY
, &hUserToken
))
524 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
528 /* Trigger the installer thread */
530 SetEvent(hInstallEvent
);
532 ReturnValue
= CR_SUCCESS
;
536 CloseHandle(hProcess
);
545 PNP_ValidateDeviceInstance(
550 CONFIGRET ret
= CR_SUCCESS
;
551 HKEY hDeviceKey
= NULL
;
553 UNREFERENCED_PARAMETER(hBinding
);
554 UNREFERENCED_PARAMETER(ulFlags
);
556 DPRINT("PNP_ValidateDeviceInstance(%p %S 0x%08lx)\n",
557 hBinding
, pDeviceID
, ulFlags
);
559 if (!IsValidDeviceInstanceID(pDeviceID
))
560 return CR_INVALID_DEVINST
;
562 if (RegOpenKeyExW(hEnumKey
,
568 DPRINT("Could not open the Device Key!\n");
569 ret
= CR_NO_SUCH_DEVNODE
;
573 /* FIXME: add more tests */
576 if (hDeviceKey
!= NULL
)
577 RegCloseKey(hDeviceKey
);
579 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret
);
588 PNP_GetRootDeviceInstance(
591 PNP_RPC_STRING_LEN ulLength
)
593 CONFIGRET ret
= CR_SUCCESS
;
595 UNREFERENCED_PARAMETER(hBinding
);
597 DPRINT("PNP_GetRootDeviceInstance(%p %S %lu)\n",
598 hBinding
, pDeviceID
, ulLength
);
602 ret
= CR_INVALID_POINTER
;
606 if (ulLength
< lstrlenW(szRootDeviceInstanceID
) + 1)
608 ret
= CR_BUFFER_SMALL
;
613 szRootDeviceInstanceID
);
616 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret
);
625 PNP_GetRelatedDeviceInstance(
627 DWORD ulRelationship
,
629 LPWSTR pRelatedDeviceId
,
630 PNP_RPC_STRING_LEN
*pulLength
,
633 PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData
;
634 CONFIGRET ret
= CR_SUCCESS
;
637 UNREFERENCED_PARAMETER(hBinding
);
638 UNREFERENCED_PARAMETER(ulFlags
);
640 DPRINT("PNP_GetRelatedDeviceInstance(%p %lu %S %p %p 0x%lx)\n",
641 hBinding
, ulRelationship
, pDeviceID
, pRelatedDeviceId
,
644 if (!IsValidDeviceInstanceID(pDeviceID
))
645 return CR_INVALID_DEVINST
;
647 RtlInitUnicodeString(&PlugPlayData
.TargetDeviceInstance
,
650 PlugPlayData
.Relation
= ulRelationship
;
652 PlugPlayData
.RelatedDeviceInstanceLength
= *pulLength
;
653 PlugPlayData
.RelatedDeviceInstance
= pRelatedDeviceId
;
655 Status
= NtPlugPlayControl(PlugPlayControlGetRelatedDevice
,
656 (PVOID
)&PlugPlayData
,
657 sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
));
658 if (!NT_SUCCESS(Status
))
660 ret
= NtStatusToCrError(Status
);
663 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret
);
664 if (ret
== CR_SUCCESS
)
666 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData
.RelatedDeviceInstance
);
676 PNP_EnumerateSubKeys(
681 PNP_RPC_STRING_LEN ulLength
,
682 PNP_RPC_STRING_LEN
*pulRequiredLen
,
685 CONFIGRET ret
= CR_SUCCESS
;
689 UNREFERENCED_PARAMETER(hBinding
);
690 UNREFERENCED_PARAMETER(ulFlags
);
692 DPRINT("PNP_EnumerateSubKeys(%p %lu %lu %p %lu %p 0x%08lx)\n",
693 hBinding
, ulBranch
, ulIndex
, Buffer
, ulLength
,
694 pulRequiredLen
, ulFlags
);
698 case PNP_ENUMERATOR_SUBKEYS
:
702 case PNP_CLASS_SUBKEYS
:
710 *pulRequiredLen
= ulLength
;
711 dwError
= RegEnumKeyExW(hKey
,
719 if (dwError
!= ERROR_SUCCESS
)
721 ret
= (dwError
== ERROR_NO_MORE_ITEMS
) ? CR_NO_SUCH_VALUE
: CR_FAILURE
;
728 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret
);
736 GetRelationsInstanceList(
737 _In_ PWSTR pszDevice
,
739 _Inout_ PWSTR pszBuffer
,
740 _Inout_ PDWORD pulLength
)
742 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
744 CONFIGRET ret
= CR_SUCCESS
;
746 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
749 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
751 PlugPlayData
.Relations
= 3;
753 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
755 PlugPlayData
.Relations
= 2;
757 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
759 PlugPlayData
.Relations
= 1;
761 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
763 PlugPlayData
.Relations
= 0;
766 PlugPlayData
.BufferSize
= *pulLength
* sizeof(WCHAR
);
767 PlugPlayData
.Buffer
= pszBuffer
;
769 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
770 (PVOID
)&PlugPlayData
,
771 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
772 if (NT_SUCCESS(Status
))
774 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
778 ret
= NtStatusToCrError(Status
);
787 GetServiceInstanceList(
788 _In_ PWSTR pszService
,
789 _Inout_ PWSTR pszBuffer
,
790 _Inout_ PDWORD pulLength
)
792 WCHAR szPathBuffer
[512];
794 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
795 DWORD dwValues
, dwSize
, dwIndex
, dwUsedLength
, dwPathLength
;
798 CONFIGRET ret
= CR_SUCCESS
;
800 /* Open the device key */
801 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
802 L
"System\\CurrentControlSet\\Services",
806 if (dwError
!= ERROR_SUCCESS
)
808 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
809 return CR_REGISTRY_ERROR
;
812 dwError
= RegOpenKeyExW(hServicesKey
,
817 if (dwError
!= ERROR_SUCCESS
)
819 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
820 ret
= CR_REGISTRY_ERROR
;
824 dwError
= RegOpenKeyExW(hServiceKey
,
829 if (dwError
!= ERROR_SUCCESS
)
831 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
832 ret
= CR_REGISTRY_ERROR
;
836 /* Retrieve the number of device instances */
837 dwSize
= sizeof(DWORD
);
838 dwError
= RegQueryValueExW(hEnumKey
,
844 if (dwError
!= ERROR_SUCCESS
)
846 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
850 DPRINT("dwValues %lu\n", dwValues
);
855 for (dwIndex
= 0; dwIndex
< dwValues
; dwIndex
++)
857 wsprintf(szName
, L
"%lu", dwIndex
);
859 dwSize
= sizeof(szPathBuffer
);
860 dwError
= RegQueryValueExW(hEnumKey
,
864 (LPBYTE
)szPathBuffer
,
866 if (dwError
!= ERROR_SUCCESS
)
869 DPRINT("Path: %S\n", szPathBuffer
);
871 dwPathLength
= wcslen(szPathBuffer
) + 1;
872 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
874 ret
= CR_BUFFER_SMALL
;
878 wcscpy(pPtr
, szPathBuffer
);
879 dwUsedLength
+= dwPathLength
;
880 pPtr
+= dwPathLength
;
882 *pPtr
= UNICODE_NULL
;
886 if (hEnumKey
!= NULL
)
887 RegCloseKey(hEnumKey
);
889 if (hServiceKey
!= NULL
)
890 RegCloseKey(hServiceKey
);
892 if (hServicesKey
!= NULL
)
893 RegCloseKey(hServicesKey
);
895 if (ret
== CR_SUCCESS
)
896 *pulLength
= dwUsedLength
+ 1;
906 GetDeviceInstanceList(
907 _In_ PWSTR pszDevice
,
908 _Inout_ PWSTR pszBuffer
,
909 _Inout_ PDWORD pulLength
)
911 WCHAR szInstanceBuffer
[MAX_DEVICE_ID_LEN
];
912 WCHAR szPathBuffer
[512];
914 DWORD dwInstanceLength
, dwPathLength
, dwUsedLength
;
915 DWORD dwIndex
, dwError
;
917 CONFIGRET ret
= CR_SUCCESS
;
919 /* Open the device key */
920 dwError
= RegOpenKeyExW(hEnumKey
,
923 KEY_ENUMERATE_SUB_KEYS
,
925 if (dwError
!= ERROR_SUCCESS
)
927 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
928 return CR_REGISTRY_ERROR
;
934 for (dwIndex
= 0; ; dwIndex
++)
936 dwInstanceLength
= MAX_DEVICE_ID_LEN
;
937 dwError
= RegEnumKeyExW(hDeviceKey
,
945 if (dwError
!= ERROR_SUCCESS
)
948 wsprintf(szPathBuffer
, L
"%s\\%s", pszDevice
, szInstanceBuffer
);
949 DPRINT("Path: %S\n", szPathBuffer
);
951 dwPathLength
= wcslen(szPathBuffer
) + 1;
952 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
954 ret
= CR_BUFFER_SMALL
;
958 wcscpy(pPtr
, szPathBuffer
);
959 dwUsedLength
+= dwPathLength
;
960 pPtr
+= dwPathLength
;
962 *pPtr
= UNICODE_NULL
;
965 RegCloseKey(hDeviceKey
);
967 if (ret
== CR_SUCCESS
)
968 *pulLength
= dwUsedLength
+ 1;
977 GetEnumeratorInstanceList(
978 _In_ PWSTR pszEnumerator
,
979 _Inout_ PWSTR pszBuffer
,
980 _Inout_ PDWORD pulLength
)
982 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
983 WCHAR szPathBuffer
[512];
986 DWORD dwIndex
, dwDeviceLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
988 CONFIGRET ret
= CR_SUCCESS
;
990 /* Open the enumerator key */
991 dwError
= RegOpenKeyExW(hEnumKey
,
994 KEY_ENUMERATE_SUB_KEYS
,
996 if (dwError
!= ERROR_SUCCESS
)
998 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
999 return CR_REGISTRY_ERROR
;
1003 dwRemainingLength
= *pulLength
;
1006 for (dwIndex
= 0; ; dwIndex
++)
1008 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
1009 dwError
= RegEnumKeyExW(hEnumeratorKey
,
1017 if (dwError
!= ERROR_SUCCESS
)
1020 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
1021 DPRINT("Path: %S\n", szPathBuffer
);
1023 dwPathLength
= dwRemainingLength
;
1024 ret
= GetDeviceInstanceList(szPathBuffer
,
1027 if (ret
!= CR_SUCCESS
)
1030 dwUsedLength
+= dwPathLength
- 1;
1031 dwRemainingLength
+= dwPathLength
- 1;
1032 pPtr
+= dwPathLength
- 1;
1035 RegCloseKey(hEnumeratorKey
);
1037 if (ret
== CR_SUCCESS
)
1038 *pulLength
= dwUsedLength
+ 1;
1049 _Inout_ PWSTR pszBuffer
,
1050 _Inout_ PDWORD pulLength
)
1052 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
1054 DWORD dwIndex
, dwEnumeratorLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
1056 CONFIGRET ret
= CR_SUCCESS
;
1059 dwRemainingLength
= *pulLength
;
1062 for (dwIndex
= 0; ; dwIndex
++)
1064 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
1065 dwError
= RegEnumKeyExW(hEnumKey
,
1068 &dwEnumeratorLength
,
1069 NULL
, NULL
, NULL
, NULL
);
1070 if (dwError
!= ERROR_SUCCESS
)
1073 dwPathLength
= dwRemainingLength
;
1074 ret
= GetEnumeratorInstanceList(szEnumeratorBuffer
,
1077 if (ret
!= CR_SUCCESS
)
1080 dwUsedLength
+= dwPathLength
- 1;
1081 dwRemainingLength
+= dwPathLength
- 1;
1082 pPtr
+= dwPathLength
- 1;
1085 if (ret
== CR_SUCCESS
)
1086 *pulLength
= dwUsedLength
+ 1;
1101 PNP_RPC_STRING_LEN
*pulLength
,
1104 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
1105 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
1106 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
1107 CONFIGRET ret
= CR_SUCCESS
;
1109 DPRINT("PNP_GetDeviceList(%p %S %p %p 0x%08lx)\n",
1110 hBinding
, pszFilter
, Buffer
, pulLength
, ulFlags
);
1112 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
1113 return CR_INVALID_FLAG
;
1115 if (pulLength
== NULL
)
1116 return CR_INVALID_POINTER
;
1118 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
1119 (pszFilter
== NULL
))
1120 return CR_INVALID_POINTER
;
1123 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
1124 CM_GETIDLIST_FILTER_POWERRELATIONS
|
1125 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
1126 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
1128 ret
= GetRelationsInstanceList(pszFilter
,
1133 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
1135 ret
= GetServiceInstanceList(pszFilter
,
1139 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
1141 SplitDeviceInstanceID(pszFilter
,
1146 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
1148 ret
= GetDeviceInstanceList(pszFilter
,
1154 ret
= GetEnumeratorInstanceList(pszFilter
,
1159 else /* CM_GETIDLIST_FILTER_NONE */
1161 ret
= GetAllInstanceList(Buffer
,
1171 GetRelationsInstanceListSize(
1172 _In_ PWSTR pszDevice
,
1174 _Inout_ PDWORD pulLength
)
1176 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
1178 CONFIGRET ret
= CR_SUCCESS
;
1180 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1183 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
1185 PlugPlayData
.Relations
= 3;
1187 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
1189 PlugPlayData
.Relations
= 2;
1191 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
1193 PlugPlayData
.Relations
= 1;
1195 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
1197 PlugPlayData
.Relations
= 0;
1200 PlugPlayData
.BufferSize
= 0;
1201 PlugPlayData
.Buffer
= NULL
;
1203 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
1204 (PVOID
)&PlugPlayData
,
1205 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
1206 if (NT_SUCCESS(Status
))
1208 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
1212 ret
= NtStatusToCrError(Status
);
1221 GetServiceInstanceListSize(
1222 _In_ PWSTR pszService
,
1223 _Out_ PDWORD pulLength
)
1225 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
1226 DWORD dwValues
, dwMaxValueLength
, dwSize
;
1228 CONFIGRET ret
= CR_SUCCESS
;
1230 /* Open the device key */
1231 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1232 L
"System\\CurrentControlSet\\Services",
1236 if (dwError
!= ERROR_SUCCESS
)
1238 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
1239 return CR_REGISTRY_ERROR
;
1242 dwError
= RegOpenKeyExW(hServicesKey
,
1247 if (dwError
!= ERROR_SUCCESS
)
1249 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
1250 ret
= CR_REGISTRY_ERROR
;
1254 dwError
= RegOpenKeyExW(hServiceKey
,
1259 if (dwError
!= ERROR_SUCCESS
)
1261 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
1262 ret
= CR_REGISTRY_ERROR
;
1266 /* Retrieve the number of device instances */
1267 dwSize
= sizeof(DWORD
);
1268 dwError
= RegQueryValueExW(hEnumKey
,
1274 if (dwError
!= ERROR_SUCCESS
)
1276 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
1280 /* Retrieve the maximum instance name length */
1281 dwError
= RegQueryInfoKeyW(hEnumKey
,
1293 if (dwError
!= ERROR_SUCCESS
)
1295 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1296 dwMaxValueLength
= MAX_DEVICE_ID_LEN
;
1299 DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues
, dwMaxValueLength
/ sizeof(WCHAR
));
1301 /* Return the largest possible buffer size */
1302 *pulLength
= dwValues
* dwMaxValueLength
/ sizeof(WCHAR
) + 2;
1305 if (hEnumKey
!= NULL
)
1306 RegCloseKey(hEnumKey
);
1308 if (hServiceKey
!= NULL
)
1309 RegCloseKey(hServiceKey
);
1311 if (hServicesKey
!= NULL
)
1312 RegCloseKey(hServicesKey
);
1320 GetDeviceInstanceListSize(
1321 _In_ LPCWSTR pszDevice
,
1322 _Out_ PULONG pulLength
)
1325 DWORD dwSubKeys
, dwMaxSubKeyLength
;
1328 /* Open the device key */
1329 dwError
= RegOpenKeyExW(hEnumKey
,
1334 if (dwError
!= ERROR_SUCCESS
)
1336 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
1337 return CR_REGISTRY_ERROR
;
1340 /* Retrieve the number of device instances and the maximum name length */
1341 dwError
= RegQueryInfoKeyW(hDeviceKey
,
1353 if (dwError
!= ERROR_SUCCESS
)
1355 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1357 dwMaxSubKeyLength
= 0;
1360 /* Close the device key */
1361 RegCloseKey(hDeviceKey
);
1363 /* Return the largest possible buffer size */
1364 *pulLength
= dwSubKeys
* (wcslen(pszDevice
) + 1 + dwMaxSubKeyLength
+ 1);
1372 GetEnumeratorInstanceListSize(
1373 _In_ LPCWSTR pszEnumerator
,
1374 _Out_ PULONG pulLength
)
1376 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
1377 WCHAR szPathBuffer
[512];
1378 HKEY hEnumeratorKey
;
1379 DWORD dwIndex
, dwDeviceLength
, dwBufferLength
;
1381 CONFIGRET ret
= CR_SUCCESS
;
1385 /* Open the enumerator key */
1386 dwError
= RegOpenKeyExW(hEnumKey
,
1389 KEY_ENUMERATE_SUB_KEYS
,
1391 if (dwError
!= ERROR_SUCCESS
)
1393 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
1394 return CR_REGISTRY_ERROR
;
1397 for (dwIndex
= 0; ; dwIndex
++)
1399 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
1400 dwError
= RegEnumKeyExW(hEnumeratorKey
,
1408 if (dwError
!= ERROR_SUCCESS
)
1411 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
1412 DPRINT("Path: %S\n", szPathBuffer
);
1414 ret
= GetDeviceInstanceListSize(szPathBuffer
, &dwBufferLength
);
1415 if (ret
!= CR_SUCCESS
)
1421 *pulLength
+= dwBufferLength
;
1424 /* Close the enumerator key */
1425 RegCloseKey(hEnumeratorKey
);
1433 GetAllInstanceListSize(
1434 _Out_ PULONG pulLength
)
1436 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
1437 DWORD dwIndex
, dwEnumeratorLength
, dwBufferLength
;
1439 CONFIGRET ret
= CR_SUCCESS
;
1441 for (dwIndex
= 0; ; dwIndex
++)
1443 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
1444 dwError
= RegEnumKeyExW(hEnumKey
,
1447 &dwEnumeratorLength
,
1448 NULL
, NULL
, NULL
, NULL
);
1449 if (dwError
!= ERROR_SUCCESS
)
1452 /* Get the size of all device instances for the enumerator */
1453 ret
= GetEnumeratorInstanceListSize(szEnumeratorBuffer
,
1455 if (ret
!= CR_SUCCESS
)
1458 *pulLength
+= dwBufferLength
;
1468 PNP_GetDeviceListSize(
1471 PNP_RPC_BUFFER_SIZE
*pulLength
,
1474 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
1475 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
1476 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
1477 CONFIGRET ret
= CR_SUCCESS
;
1479 DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%08lx)\n",
1480 hBinding
, pszFilter
, pulLength
, ulFlags
);
1482 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
1483 return CR_INVALID_FLAG
;
1485 if (pulLength
== NULL
)
1486 return CR_INVALID_POINTER
;
1488 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
1489 (pszFilter
== NULL
))
1490 return CR_INVALID_POINTER
;
1495 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
1496 CM_GETIDLIST_FILTER_POWERRELATIONS
|
1497 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
1498 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
1500 ret
= GetRelationsInstanceListSize(pszFilter
,
1504 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
1506 ret
= GetServiceInstanceListSize(pszFilter
,
1509 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
1511 SplitDeviceInstanceID(pszFilter
,
1516 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
1518 ret
= GetDeviceInstanceListSize(pszFilter
,
1523 ret
= GetEnumeratorInstanceListSize(pszFilter
,
1527 else /* CM_GETIDLIST_FILTER_NONE */
1529 ret
= GetAllInstanceListSize(pulLength
);
1532 /* Add one character for the terminating double UNICODE_NULL */
1533 if (ret
== CR_SUCCESS
)
1549 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData
;
1550 CONFIGRET ret
= CR_SUCCESS
;
1553 UNREFERENCED_PARAMETER(hBinding
);
1554 UNREFERENCED_PARAMETER(ulFlags
);
1556 DPRINT("PNP_GetDepth(%p %S %p 0x%08lx)\n",
1557 hBinding
, pszDeviceID
, pulDepth
, ulFlags
);
1559 if (!IsValidDeviceInstanceID(pszDeviceID
))
1560 return CR_INVALID_DEVINST
;
1562 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1565 Status
= NtPlugPlayControl(PlugPlayControlGetDeviceDepth
,
1566 (PVOID
)&PlugPlayData
,
1567 sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
));
1568 if (NT_SUCCESS(Status
))
1570 *pulDepth
= PlugPlayData
.Depth
;
1574 ret
= NtStatusToCrError(Status
);
1577 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret
);
1586 PNP_GetDeviceRegProp(
1590 DWORD
*pulRegDataType
,
1592 PNP_PROP_SIZE
*pulTransferLen
,
1593 PNP_PROP_SIZE
*pulLength
,
1596 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData
;
1597 CONFIGRET ret
= CR_SUCCESS
;
1598 LPWSTR lpValueName
= NULL
;
1603 UNREFERENCED_PARAMETER(hBinding
);
1605 DPRINT("PNP_GetDeviceRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
1606 hBinding
, pDeviceID
, ulProperty
, pulRegDataType
, Buffer
,
1607 pulTransferLen
, pulLength
, ulFlags
);
1609 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
1611 ret
= CR_INVALID_POINTER
;
1617 ret
= CR_INVALID_FLAG
;
1621 /* Check pDeviceID */
1622 if (!IsValidDeviceInstanceID(pDeviceID
))
1624 ret
= CR_INVALID_DEVINST
;
1628 if (*pulLength
< *pulTransferLen
)
1629 *pulLength
= *pulTransferLen
;
1631 *pulTransferLen
= 0;
1635 case CM_DRP_DEVICEDESC
:
1636 lpValueName
= L
"DeviceDesc";
1639 case CM_DRP_HARDWAREID
:
1640 lpValueName
= L
"HardwareID";
1643 case CM_DRP_COMPATIBLEIDS
:
1644 lpValueName
= L
"CompatibleIDs";
1647 case CM_DRP_SERVICE
:
1648 lpValueName
= L
"Service";
1652 lpValueName
= L
"Class";
1655 case CM_DRP_CLASSGUID
:
1656 lpValueName
= L
"ClassGUID";
1660 lpValueName
= L
"Driver";
1663 case CM_DRP_CONFIGFLAGS
:
1664 lpValueName
= L
"ConfigFlags";
1668 lpValueName
= L
"Mfg";
1671 case CM_DRP_FRIENDLYNAME
:
1672 lpValueName
= L
"FriendlyName";
1675 case CM_DRP_LOCATION_INFORMATION
:
1676 lpValueName
= L
"LocationInformation";
1679 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
1680 PlugPlayData
.Property
= PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
;
1683 case CM_DRP_CAPABILITIES
:
1684 lpValueName
= L
"Capabilities";
1687 case CM_DRP_UI_NUMBER
:
1688 PlugPlayData
.Property
= PNP_PROPERTY_UI_NUMBER
;
1691 case CM_DRP_UPPERFILTERS
:
1692 lpValueName
= L
"UpperFilters";
1695 case CM_DRP_LOWERFILTERS
:
1696 lpValueName
= L
"LowerFilters";
1699 case CM_DRP_BUSTYPEGUID
:
1700 PlugPlayData
.Property
= PNP_PROPERTY_BUSTYPEGUID
;
1703 case CM_DRP_LEGACYBUSTYPE
:
1704 PlugPlayData
.Property
= PNP_PROPERTY_LEGACYBUSTYPE
;
1707 case CM_DRP_BUSNUMBER
:
1708 PlugPlayData
.Property
= PNP_PROPERTY_BUSNUMBER
;
1711 case CM_DRP_ENUMERATOR_NAME
:
1712 PlugPlayData
.Property
= PNP_PROPERTY_ENUMERATOR_NAME
;
1715 case CM_DRP_SECURITY
:
1716 lpValueName
= L
"Security";
1719 case CM_DRP_DEVTYPE
:
1720 lpValueName
= L
"DeviceType";
1723 case CM_DRP_EXCLUSIVE
:
1724 lpValueName
= L
"Exclusive";
1727 case CM_DRP_CHARACTERISTICS
:
1728 lpValueName
= L
"DeviceCharacteristics";
1731 case CM_DRP_ADDRESS
:
1732 PlugPlayData
.Property
= PNP_PROPERTY_ADDRESS
;
1735 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1736 lpValueName
= L
"UINumberDescFormat";
1739 case CM_DRP_DEVICE_POWER_DATA
:
1740 PlugPlayData
.Property
= PNP_PROPERTY_POWER_DATA
;
1743 case CM_DRP_REMOVAL_POLICY
:
1744 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY
;
1747 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT
:
1748 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
;
1751 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1752 lpValueName
= L
"RemovalPolicy";
1755 case CM_DRP_INSTALL_STATE
:
1756 PlugPlayData
.Property
= PNP_PROPERTY_INSTALL_STATE
;
1759 #if (WINVER >= _WIN32_WINNT_WS03)
1760 case CM_DRP_LOCATION_PATHS
:
1761 PlugPlayData
.Property
= PNP_PROPERTY_LOCATION_PATHS
;
1765 #if (WINVER >= _WIN32_WINNT_WIN7)
1766 case CM_DRP_BASE_CONTAINERID
:
1767 PlugPlayData
.Property
= PNP_PROPERTY_CONTAINERID
;
1772 ret
= CR_INVALID_PROPERTY
;
1776 DPRINT("Value name: %S\n", lpValueName
);
1780 /* Retrieve information from the Registry */
1781 lError
= RegOpenKeyExW(hEnumKey
,
1786 if (lError
!= ERROR_SUCCESS
)
1790 ret
= CR_INVALID_DEVNODE
;
1794 lError
= RegQueryValueExW(hKey
,
1800 if (lError
!= ERROR_SUCCESS
)
1802 if (lError
== ERROR_MORE_DATA
)
1804 ret
= CR_BUFFER_SMALL
;
1809 ret
= CR_NO_SUCH_VALUE
;
1815 /* Retrieve information from the Device Node */
1816 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1818 PlugPlayData
.Buffer
= Buffer
;
1819 PlugPlayData
.BufferSize
= *pulLength
;
1821 Status
= NtPlugPlayControl(PlugPlayControlProperty
,
1822 (PVOID
)&PlugPlayData
,
1823 sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
));
1824 if (NT_SUCCESS(Status
))
1826 *pulLength
= PlugPlayData
.BufferSize
;
1830 ret
= NtStatusToCrError(Status
);
1836 *pulTransferLen
= (ret
== CR_SUCCESS
) ? *pulLength
: 0;
1841 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret
);
1850 PNP_SetDeviceRegProp(
1856 PNP_PROP_SIZE ulLength
,
1859 CONFIGRET ret
= CR_SUCCESS
;
1860 LPWSTR lpValueName
= NULL
;
1863 UNREFERENCED_PARAMETER(hBinding
);
1864 UNREFERENCED_PARAMETER(ulFlags
);
1866 DPRINT("PNP_SetDeviceRegProp(%p %S %lu %lu %p %lu 0x%08lx)\n",
1867 hBinding
, pDeviceId
, ulProperty
, ulDataType
, Buffer
,
1870 if (!IsValidDeviceInstanceID(pDeviceId
))
1871 return CR_INVALID_DEVINST
;
1875 case CM_DRP_DEVICEDESC
:
1876 lpValueName
= L
"DeviceDesc";
1879 case CM_DRP_HARDWAREID
:
1880 lpValueName
= L
"HardwareID";
1883 case CM_DRP_COMPATIBLEIDS
:
1884 lpValueName
= L
"CompatibleIDs";
1887 case CM_DRP_SERVICE
:
1888 lpValueName
= L
"Service";
1892 lpValueName
= L
"Class";
1895 case CM_DRP_CLASSGUID
:
1896 lpValueName
= L
"ClassGUID";
1900 lpValueName
= L
"Driver";
1903 case CM_DRP_CONFIGFLAGS
:
1904 lpValueName
= L
"ConfigFlags";
1908 lpValueName
= L
"Mfg";
1911 case CM_DRP_FRIENDLYNAME
:
1912 lpValueName
= L
"FriendlyName";
1915 case CM_DRP_LOCATION_INFORMATION
:
1916 lpValueName
= L
"LocationInformation";
1919 case CM_DRP_UPPERFILTERS
:
1920 lpValueName
= L
"UpperFilters";
1923 case CM_DRP_LOWERFILTERS
:
1924 lpValueName
= L
"LowerFilters";
1927 case CM_DRP_SECURITY
:
1928 lpValueName
= L
"Security";
1931 case CM_DRP_DEVTYPE
:
1932 lpValueName
= L
"DeviceType";
1935 case CM_DRP_EXCLUSIVE
:
1936 lpValueName
= L
"Exclusive";
1939 case CM_DRP_CHARACTERISTICS
:
1940 lpValueName
= L
"DeviceCharacteristics";
1943 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1944 lpValueName
= L
"UINumberDescFormat";
1947 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1948 lpValueName
= L
"RemovalPolicy";
1952 return CR_INVALID_PROPERTY
;
1955 DPRINT("Value name: %S\n", lpValueName
);
1957 if (RegOpenKeyExW(hEnumKey
,
1962 return CR_INVALID_DEVNODE
;
1966 if (RegDeleteValueW(hKey
,
1968 ret
= CR_REGISTRY_ERROR
;
1972 if (RegSetValueExW(hKey
,
1978 ret
= CR_REGISTRY_ERROR
;
1983 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret
);
1992 PNP_GetClassInstance(
1995 LPWSTR pszClassInstance
,
1996 PNP_RPC_STRING_LEN ulLength
)
1998 WCHAR szClassGuid
[40];
1999 WCHAR szClassInstance
[5];
2000 HKEY hDeviceClassKey
= NULL
;
2001 HKEY hClassInstanceKey
;
2002 ULONG ulTransferLength
, ulDataLength
;
2003 DWORD dwDataType
, dwDisposition
, i
;
2005 CONFIGRET ret
= CR_SUCCESS
;
2007 DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
2008 hBinding
, pDeviceId
, pszClassInstance
, ulLength
);
2010 if (!IsValidDeviceInstanceID(pDeviceId
))
2011 return CR_INVALID_DEVINST
;
2013 ulTransferLength
= ulLength
;
2014 ret
= PNP_GetDeviceRegProp(hBinding
,
2018 (BYTE
*)pszClassInstance
,
2022 if (ret
== CR_SUCCESS
)
2025 ulTransferLength
= sizeof(szClassGuid
);
2026 ulDataLength
= sizeof(szClassGuid
);
2027 ret
= PNP_GetDeviceRegProp(hBinding
,
2031 (BYTE
*)szClassGuid
,
2035 if (ret
!= CR_SUCCESS
)
2037 DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret
);
2041 dwError
= RegOpenKeyExW(hClassKey
,
2046 if (dwError
!= ERROR_SUCCESS
)
2048 DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError
);
2053 for (i
= 0; i
< 10000; i
++)
2055 wsprintf(szClassInstance
, L
"%04lu", i
);
2057 dwError
= RegCreateKeyExW(hDeviceClassKey
,
2061 REG_OPTION_NON_VOLATILE
,
2066 if (dwError
== ERROR_SUCCESS
)
2068 RegCloseKey(hClassInstanceKey
);
2070 if (dwDisposition
== REG_CREATED_NEW_KEY
)
2072 wsprintf(pszClassInstance
,
2077 ulDataLength
= (wcslen(pszClassInstance
) + 1) * sizeof(WCHAR
);
2078 ret
= PNP_SetDeviceRegProp(hBinding
,
2082 (BYTE
*)pszClassInstance
,
2085 if (ret
!= CR_SUCCESS
)
2087 DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret
);
2088 RegDeleteKeyW(hDeviceClassKey
,
2098 if (hDeviceClassKey
!= NULL
)
2099 RegCloseKey(hDeviceClassKey
);
2114 HKEY hDeviceKey
= NULL
, hParametersKey
= NULL
;
2116 CONFIGRET ret
= CR_SUCCESS
;
2118 UNREFERENCED_PARAMETER(hBinding
);
2119 UNREFERENCED_PARAMETER(samDesired
);
2121 DPRINT("PNP_CreateKey(%p %S 0x%lx 0x%08lx)\n",
2122 hBinding
, pszSubKey
, samDesired
, ulFlags
);
2125 return CR_INVALID_FLAG
;
2127 if (!IsValidDeviceInstanceID(pszSubKey
))
2128 return CR_INVALID_DEVINST
;
2130 dwError
= RegOpenKeyExW(hEnumKey
,
2135 if (dwError
!= ERROR_SUCCESS
)
2137 ret
= CR_INVALID_DEVNODE
;
2141 dwError
= RegCreateKeyExW(hDeviceKey
,
2142 L
"Device Parameters",
2145 REG_OPTION_NON_VOLATILE
,
2150 if (dwError
!= ERROR_SUCCESS
)
2152 ret
= CR_REGISTRY_ERROR
;
2156 /* FIXME: Set key security */
2159 if (hParametersKey
!= NULL
)
2160 RegCloseKey(hParametersKey
);
2162 if (hDeviceKey
!= NULL
)
2163 RegCloseKey(hDeviceKey
);
2172 PNP_DeleteRegistryKey(
2175 LPWSTR pszParentKey
,
2180 return CR_CALL_NOT_IMPLEMENTED
;
2189 DWORD
*pulClassCount
,
2195 UNREFERENCED_PARAMETER(hBinding
);
2196 UNREFERENCED_PARAMETER(ulFlags
);
2198 DPRINT("PNP_GetClassCount(%p %p 0x%08lx)\n",
2199 hBinding
, pulClassCount
, ulFlags
);
2201 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2206 if (dwError
!= ERROR_SUCCESS
)
2207 return CR_INVALID_DATA
;
2209 dwError
= RegQueryInfoKeyW(hKey
,
2222 if (dwError
!= ERROR_SUCCESS
)
2223 return CR_INVALID_DATA
;
2234 LPWSTR pszClassGuid
,
2236 PNP_RPC_STRING_LEN
*pulLength
,
2239 WCHAR szKeyName
[MAX_PATH
];
2240 CONFIGRET ret
= CR_SUCCESS
;
2244 UNREFERENCED_PARAMETER(hBinding
);
2245 UNREFERENCED_PARAMETER(ulFlags
);
2247 DPRINT("PNP_GetClassName(%p %S %p %p 0x%08lx)\n",
2248 hBinding
, pszClassGuid
, Buffer
, pulLength
, ulFlags
);
2250 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
2251 if (lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
2252 lstrcatW(szKeyName
, pszClassGuid
);
2254 return CR_INVALID_DATA
;
2256 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2261 return CR_REGISTRY_ERROR
;
2263 dwSize
= *pulLength
* sizeof(WCHAR
);
2264 if (RegQueryValueExW(hKey
,
2272 ret
= CR_REGISTRY_ERROR
;
2276 *pulLength
= dwSize
/ sizeof(WCHAR
);
2281 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
2292 LPWSTR pszClassGuid
,
2295 CONFIGRET ret
= CR_SUCCESS
;
2297 UNREFERENCED_PARAMETER(hBinding
);
2299 DPRINT("PNP_DeleteClassKey(%p %S 0x%08lx)\n",
2300 hBinding
, pszClassGuid
, ulFlags
);
2302 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
2304 if (SHDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2305 ret
= CR_REGISTRY_ERROR
;
2309 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2310 ret
= CR_REGISTRY_ERROR
;
2313 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
2322 PNP_GetInterfaceDeviceAlias(
2324 LPWSTR pszInterfaceDevice
,
2325 GUID
*AliasInterfaceGuid
,
2326 LPWSTR pszAliasInterfaceDevice
,
2327 PNP_RPC_STRING_LEN
*pulLength
,
2328 PNP_RPC_STRING_LEN
*pulTransferLen
,
2332 return CR_CALL_NOT_IMPLEMENTED
;
2339 PNP_GetInterfaceDeviceList(
2341 GUID
*InterfaceGuid
,
2344 PNP_RPC_BUFFER_SIZE
*pulLength
,
2348 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2349 DWORD ret
= CR_SUCCESS
;
2351 UNREFERENCED_PARAMETER(hBinding
);
2353 DPRINT("PNP_GetInterfaceDeviceList(%p %p %S %p %p 0x%08lx)\n",
2354 hBinding
, InterfaceGuid
, pszDeviceID
, Buffer
, pulLength
, ulFlags
);
2356 if (!IsValidDeviceInstanceID(pszDeviceID
))
2357 return CR_INVALID_DEVINST
;
2359 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2362 PlugPlayData
.Flags
= ulFlags
;
2363 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2364 PlugPlayData
.Buffer
= Buffer
;
2365 PlugPlayData
.BufferSize
= *pulLength
;
2367 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2368 (PVOID
)&PlugPlayData
,
2369 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2370 if (NT_SUCCESS(Status
))
2372 *pulLength
= PlugPlayData
.BufferSize
;
2376 ret
= NtStatusToCrError(Status
);
2379 DPRINT("PNP_GetInterfaceDeviceList() done (returns %lx)\n", ret
);
2387 PNP_GetInterfaceDeviceListSize(
2389 PNP_RPC_BUFFER_SIZE
*pulLen
,
2390 GUID
*InterfaceGuid
,
2395 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2396 DWORD ret
= CR_SUCCESS
;
2398 UNREFERENCED_PARAMETER(hBinding
);
2400 DPRINT("PNP_GetInterfaceDeviceListSize(%p %p %p %S 0x%08lx)\n",
2401 hBinding
, pulLen
, InterfaceGuid
, pszDeviceID
, ulFlags
);
2403 if (!IsValidDeviceInstanceID(pszDeviceID
))
2404 return CR_INVALID_DEVINST
;
2406 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2409 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2410 PlugPlayData
.Buffer
= NULL
;
2411 PlugPlayData
.BufferSize
= 0;
2412 PlugPlayData
.Flags
= ulFlags
;
2414 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2415 (PVOID
)&PlugPlayData
,
2416 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2417 if (NT_SUCCESS(Status
))
2419 *pulLen
= PlugPlayData
.BufferSize
;
2423 ret
= NtStatusToCrError(Status
);
2426 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2434 PNP_RegisterDeviceClassAssociation(
2437 GUID
*InterfaceGuid
,
2438 LPWSTR pszReference
,
2440 PNP_RPC_STRING_LEN
*pulLength
,
2441 PNP_RPC_STRING_LEN
*pulTransferLen
,
2445 return CR_CALL_NOT_IMPLEMENTED
;
2452 PNP_UnregisterDeviceClassAssociation(
2454 LPWSTR pszInterfaceDevice
,
2458 return CR_CALL_NOT_IMPLEMENTED
;
2465 PNP_GetClassRegProp(
2467 LPWSTR pszClassGuid
,
2469 DWORD
*pulRegDataType
,
2471 PNP_RPC_STRING_LEN
*pulTransferLen
,
2472 PNP_RPC_STRING_LEN
*pulLength
,
2475 CONFIGRET ret
= CR_SUCCESS
;
2476 LPWSTR lpValueName
= NULL
;
2477 HKEY hInstKey
= NULL
;
2478 HKEY hPropKey
= NULL
;
2481 UNREFERENCED_PARAMETER(hBinding
);
2483 DPRINT("PNP_GetClassRegProp() called\n");
2485 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
2487 ret
= CR_INVALID_POINTER
;
2493 ret
= CR_INVALID_FLAG
;
2497 if (*pulLength
< *pulTransferLen
)
2498 *pulLength
= *pulTransferLen
;
2500 *pulTransferLen
= 0;
2504 case CM_CRP_SECURITY
:
2505 lpValueName
= L
"Security";
2508 case CM_CRP_DEVTYPE
:
2509 lpValueName
= L
"DeviceType";
2512 case CM_CRP_EXCLUSIVE
:
2513 lpValueName
= L
"Exclusive";
2516 case CM_CRP_CHARACTERISTICS
:
2517 lpValueName
= L
"DeviceCharacteristics";
2521 ret
= CR_INVALID_PROPERTY
;
2525 DPRINT("Value name: %S\n", lpValueName
);
2527 lError
= RegOpenKeyExW(hClassKey
,
2532 if (lError
!= ERROR_SUCCESS
)
2535 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2539 lError
= RegOpenKeyExW(hInstKey
,
2544 if (lError
!= ERROR_SUCCESS
)
2547 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2551 lError
= RegQueryValueExW(hPropKey
,
2557 if (lError
!= ERROR_SUCCESS
)
2559 if (lError
== ERROR_MORE_DATA
)
2561 ret
= CR_BUFFER_SMALL
;
2566 ret
= CR_NO_SUCH_VALUE
;
2571 if (ret
== CR_SUCCESS
)
2572 *pulTransferLen
= *pulLength
;
2574 if (hPropKey
!= NULL
)
2575 RegCloseKey(hPropKey
);
2577 if (hInstKey
!= NULL
)
2578 RegCloseKey(hInstKey
);
2580 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret
);
2589 PNP_SetClassRegProp(
2591 LPWSTR pszClassGuid
,
2595 PNP_PROP_SIZE ulLength
,
2598 CONFIGRET ret
= CR_SUCCESS
;
2599 LPWSTR lpValueName
= NULL
;
2604 UNREFERENCED_PARAMETER(hBinding
);
2606 DPRINT("PNP_SetClassRegProp() called\n");
2609 return CR_INVALID_FLAG
;
2613 case CM_CRP_SECURITY
:
2614 lpValueName
= L
"Security";
2617 case CM_CRP_DEVTYPE
:
2618 lpValueName
= L
"DeviceType";
2621 case CM_CRP_EXCLUSIVE
:
2622 lpValueName
= L
"Exclusive";
2625 case CM_CRP_CHARACTERISTICS
:
2626 lpValueName
= L
"DeviceCharacteristics";
2630 return CR_INVALID_PROPERTY
;
2633 lError
= RegOpenKeyExW(hClassKey
,
2638 if (lError
!= ERROR_SUCCESS
)
2640 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2644 /* FIXME: Set security descriptor */
2645 lError
= RegCreateKeyExW(hInstKey
,
2649 REG_OPTION_NON_VOLATILE
,
2654 if (lError
!= ERROR_SUCCESS
)
2656 ret
= CR_REGISTRY_ERROR
;
2662 if (RegDeleteValueW(hPropKey
,
2664 ret
= CR_REGISTRY_ERROR
;
2668 if (RegSetValueExW(hPropKey
,
2674 ret
= CR_REGISTRY_ERROR
;
2678 if (hPropKey
!= NULL
)
2679 RegCloseKey(hPropKey
);
2681 if (hInstKey
!= NULL
)
2682 RegCloseKey(hInstKey
);
2689 CreateDeviceInstance(LPWSTR pszDeviceID
)
2691 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
2692 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
2693 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
2694 HKEY hKeyEnumerator
;
2700 /* Split the instance ID */
2701 SplitDeviceInstanceID(pszDeviceID
,
2706 /* Open or create the enumerator key */
2707 lError
= RegCreateKeyExW(hEnumKey
,
2711 REG_OPTION_NON_VOLATILE
,
2716 if (lError
!= ERROR_SUCCESS
)
2718 return CR_REGISTRY_ERROR
;
2721 /* Open or create the device key */
2722 lError
= RegCreateKeyExW(hKeyEnumerator
,
2726 REG_OPTION_NON_VOLATILE
,
2732 /* Close the enumerator key */
2733 RegCloseKey(hKeyEnumerator
);
2735 if (lError
!= ERROR_SUCCESS
)
2737 return CR_REGISTRY_ERROR
;
2740 /* Try to open the instance key and fail if it exists */
2741 lError
= RegOpenKeyExW(hKeyDevice
,
2746 if (lError
== ERROR_SUCCESS
)
2748 DPRINT1("Instance %S already exists!\n", szInstance
);
2749 RegCloseKey(hKeyInstance
);
2750 RegCloseKey(hKeyDevice
);
2751 return CR_ALREADY_SUCH_DEVINST
;
2754 /* Create a new instance key */
2755 lError
= RegCreateKeyExW(hKeyDevice
,
2759 REG_OPTION_NON_VOLATILE
,
2765 /* Close the device key */
2766 RegCloseKey(hKeyDevice
);
2768 if (lError
!= ERROR_SUCCESS
)
2770 return CR_REGISTRY_ERROR
;
2773 /* Create the 'Control' sub key */
2774 lError
= RegCreateKeyExW(hKeyInstance
,
2778 REG_OPTION_NON_VOLATILE
,
2783 if (lError
== ERROR_SUCCESS
)
2785 RegCloseKey(hKeyControl
);
2788 RegCloseKey(hKeyInstance
);
2790 return (lError
== ERROR_SUCCESS
) ? CR_SUCCESS
: CR_REGISTRY_ERROR
;
2800 LPWSTR pszParentDeviceID
,
2801 PNP_RPC_STRING_LEN ulLength
,
2804 CONFIGRET ret
= CR_SUCCESS
;
2806 DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
2807 hBinding
, pszParentDeviceID
, pszDeviceID
, ulLength
, ulFlags
);
2809 if (ulFlags
& ~CM_CREATE_DEVNODE_BITS
)
2810 return CR_INVALID_FLAG
;
2812 if (pszDeviceID
== NULL
|| pszParentDeviceID
== NULL
)
2813 return CR_INVALID_POINTER
;
2815 /* Fail, if the parent device is not the root device */
2816 if (!IsRootDeviceInstanceID(pszParentDeviceID
))
2817 return CR_INVALID_DEVINST
;
2819 if (ulFlags
& CM_CREATE_DEVNODE_GENERATE_ID
)
2821 WCHAR szGeneratedInstance
[MAX_DEVICE_ID_LEN
];
2822 DWORD dwInstanceNumber
;
2824 /* Generated ID is: Root\<Device ID>\<Instance number> */
2825 dwInstanceNumber
= 0;
2828 swprintf(szGeneratedInstance
, L
"Root\\%ls\\%04lu",
2829 pszDeviceID
, dwInstanceNumber
);
2831 /* Try to create a device instance with this ID */
2832 ret
= CreateDeviceInstance(szGeneratedInstance
);
2836 while (ret
== CR_ALREADY_SUCH_DEVINST
);
2838 if (ret
== CR_SUCCESS
)
2840 /* pszDeviceID is an out parameter too for generated IDs */
2841 if (wcslen(szGeneratedInstance
) > ulLength
)
2843 ret
= CR_BUFFER_SMALL
;
2847 wcscpy(pszDeviceID
, szGeneratedInstance
);
2853 /* Create the device instance */
2854 ret
= CreateDeviceInstance(pszDeviceID
);
2857 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret
);
2864 SetupDeviceInstance(
2865 _In_ LPWSTR pszDeviceInstance
,
2866 _In_ DWORD ulMinorAction
)
2868 HKEY hDeviceKey
= NULL
;
2869 DWORD dwDisableCount
, dwSize
;
2870 DWORD ulStatus
, ulProblem
;
2872 CONFIGRET ret
= CR_SUCCESS
;
2874 DPRINT1("SetupDeviceInstance(%S 0x%08lx)\n",
2875 pszDeviceInstance
, ulMinorAction
);
2877 if (IsRootDeviceInstanceID(pszDeviceInstance
))
2878 return CR_INVALID_DEVINST
;
2880 if (ulMinorAction
& ~CM_SETUP_BITS
)
2881 return CR_INVALID_FLAG
;
2883 if ((ulMinorAction
== CM_SETUP_DOWNLOAD
) ||
2884 (ulMinorAction
== CM_SETUP_WRITE_LOG_CONFS
))
2887 dwError
= RegOpenKeyExW(hEnumKey
,
2892 if (dwError
!= ERROR_SUCCESS
)
2893 return CR_INVALID_DEVNODE
;
2895 dwSize
= sizeof(dwDisableCount
);
2896 dwError
= RegQueryValueExW(hDeviceKey
,
2900 (LPBYTE
)&dwDisableCount
,
2902 if ((dwError
== ERROR_SUCCESS
) &&
2903 (dwDisableCount
> 0))
2908 GetDeviceStatus(pszDeviceInstance
,
2912 if (ulStatus
& DN_STARTED
)
2917 if (ulStatus
& DN_HAS_PROBLEM
)
2919 ret
= ClearDeviceStatus(pszDeviceInstance
,
2924 if (ret
!= CR_SUCCESS
)
2928 /* FIXME: Start the device */
2931 if (hDeviceKey
!= NULL
)
2932 RegCloseKey(hDeviceKey
);
2939 EnableDeviceInstance(
2940 _In_ LPWSTR pszDeviceInstance
)
2942 PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
;
2943 CONFIGRET ret
= CR_SUCCESS
;
2946 DPRINT("Enable device instance %S\n", pszDeviceInstance
);
2948 RtlInitUnicodeString(&ResetDeviceData
.DeviceInstance
,
2950 Status
= NtPlugPlayControl(PlugPlayControlResetDevice
,
2952 sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
));
2953 if (!NT_SUCCESS(Status
))
2954 ret
= NtStatusToCrError(Status
);
2961 ReenumerateDeviceInstance(
2962 _In_ LPWSTR pszDeviceInstance
,
2963 _In_ ULONG ulMinorAction
)
2965 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData
;
2966 CONFIGRET ret
= CR_SUCCESS
;
2969 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
2970 pszDeviceInstance
, ulMinorAction
);
2972 if (ulMinorAction
& ~CM_REENUMERATE_BITS
)
2973 return CR_INVALID_FLAG
;
2975 if (ulMinorAction
& CM_REENUMERATE_RETRY_INSTALLATION
)
2977 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
2980 RtlInitUnicodeString(&EnumerateDeviceData
.DeviceInstance
,
2982 EnumerateDeviceData
.Flags
= 0;
2984 Status
= NtPlugPlayControl(PlugPlayControlEnumerateDevice
,
2985 &EnumerateDeviceData
,
2986 sizeof(PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA
));
2987 if (!NT_SUCCESS(Status
))
2988 ret
= NtStatusToCrError(Status
);
2997 PNP_DeviceInstanceAction(
2999 DWORD ulMajorAction
,
3000 DWORD ulMinorAction
,
3001 LPWSTR pszDeviceInstance1
,
3002 LPWSTR pszDeviceInstance2
)
3004 CONFIGRET ret
= CR_SUCCESS
;
3006 UNREFERENCED_PARAMETER(hBinding
);
3008 DPRINT("PNP_DeviceInstanceAction(%p %lu 0x%08lx %S %S)\n",
3009 hBinding
, ulMajorAction
, ulMinorAction
,
3010 pszDeviceInstance1
, pszDeviceInstance2
);
3012 switch (ulMajorAction
)
3014 case PNP_DEVINST_SETUP
:
3015 ret
= SetupDeviceInstance(pszDeviceInstance1
,
3019 case PNP_DEVINST_ENABLE
:
3020 ret
= EnableDeviceInstance(pszDeviceInstance1
);
3023 case PNP_DEVINST_REENUMERATE
:
3024 ret
= ReenumerateDeviceInstance(pszDeviceInstance1
,
3029 DPRINT1("Unknown device action %lu: not implemented\n", ulMajorAction
);
3030 ret
= CR_CALL_NOT_IMPLEMENTED
;
3033 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
3042 PNP_GetDeviceStatus(
3049 UNREFERENCED_PARAMETER(hBinding
);
3050 UNREFERENCED_PARAMETER(ulFlags
);
3052 DPRINT("PNP_GetDeviceStatus(%p %S %p %p)\n",
3053 hBinding
, pDeviceID
, pulStatus
, pulProblem
, ulFlags
);
3055 if (!IsValidDeviceInstanceID(pDeviceID
))
3056 return CR_INVALID_DEVINST
;
3058 return GetDeviceStatus(pDeviceID
, pulStatus
, pulProblem
);
3065 PNP_SetDeviceProblem(
3072 return CR_CALL_NOT_IMPLEMENTED
;
3082 PPNP_VETO_TYPE pVetoType
,
3087 UNREFERENCED_PARAMETER(hBinding
);
3089 DPRINT1("PNP_DisableDevInst(%p %S %p %p %lu 0x%08lx)\n",
3090 hBinding
, pDeviceID
, pVetoType
, pszVetoName
, ulNameLength
, ulFlags
);
3092 if (ulFlags
& ~CM_DISABLE_BITS
)
3093 return CR_INVALID_FLAG
;
3095 if (!IsValidDeviceInstanceID(pDeviceID
) ||
3096 IsRootDeviceInstanceID(pDeviceID
))
3097 return CR_INVALID_DEVINST
;
3099 return DisableDeviceInstance(pDeviceID
,
3109 PNP_UninstallDevInst(
3115 return CR_CALL_NOT_IMPLEMENTED
;
3120 CheckForDeviceId(LPWSTR lpDeviceIdList
,
3126 lpPtr
= lpDeviceIdList
;
3129 dwLength
= wcslen(lpPtr
);
3130 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
3133 lpPtr
+= (dwLength
+ 1);
3141 AppendDeviceId(LPWSTR lpDeviceIdList
,
3142 LPDWORD lpDeviceIdListSize
,
3148 dwLen
= wcslen(lpDeviceId
);
3149 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
3151 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
3153 dwPos
+= (dwLen
+ 1);
3155 lpDeviceIdList
[dwPos
] = 0;
3157 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
3170 CONFIGRET ret
= CR_SUCCESS
;
3173 DWORD dwDeviceIdListSize
;
3174 DWORD dwNewDeviceIdSize
;
3175 WCHAR
* pszDeviceIdList
= NULL
;
3177 UNREFERENCED_PARAMETER(hBinding
);
3179 DPRINT("PNP_AddID(%p %S %S 0x%08lx)\n",
3180 hBinding
, pszDeviceID
, pszID
, ulFlags
);
3182 if (RegOpenKeyExW(hEnumKey
,
3185 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
3186 &hDeviceKey
) != ERROR_SUCCESS
)
3188 DPRINT("Failed to open the device key!\n");
3189 return CR_INVALID_DEVNODE
;
3192 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
3194 if (RegQueryValueExW(hDeviceKey
,
3199 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
3201 DPRINT("Failed to query the desired ID string!\n");
3202 ret
= CR_REGISTRY_ERROR
;
3206 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
3207 if (!dwNewDeviceIdSize
)
3209 ret
= CR_INVALID_POINTER
;
3213 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
3215 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
3216 if (!pszDeviceIdList
)
3218 DPRINT("Failed to allocate memory for the desired ID string!\n");
3219 ret
= CR_OUT_OF_MEMORY
;
3223 if (RegQueryValueExW(hDeviceKey
,
3227 (LPBYTE
)pszDeviceIdList
,
3228 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
3230 DPRINT("Failed to query the desired ID string!\n");
3231 ret
= CR_REGISTRY_ERROR
;
3235 /* Check whether the device ID is already in use */
3236 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
3238 DPRINT("Device ID was found in the ID string!\n");
3243 /* Append the Device ID */
3244 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
3246 if (RegSetValueExW(hDeviceKey
,
3250 (LPBYTE
)pszDeviceIdList
,
3251 dwDeviceIdListSize
) != ERROR_SUCCESS
)
3253 DPRINT("Failed to set the desired ID string!\n");
3254 ret
= CR_REGISTRY_ERROR
;
3258 RegCloseKey(hDeviceKey
);
3259 if (pszDeviceIdList
)
3260 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
3262 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
3276 DPRINT("PNP_RegisterDriver(%p %S 0x%lx)\n",
3277 hBinding
, pszDeviceID
, ulFlags
);
3279 if (ulFlags
& ~CM_REGISTER_DEVICE_DRIVER_BITS
)
3280 return CR_INVALID_FLAG
;
3282 if (!IsValidDeviceInstanceID(pszDeviceID
))
3283 return CR_INVALID_DEVINST
;
3285 SetDeviceStatus(pszDeviceID
, 0, 0);
3297 PPNP_VETO_TYPE pVetoType
,
3302 PLUGPLAY_CONTROL_QUERY_REMOVE_DATA PlugPlayData
;
3304 DWORD ret
= CR_SUCCESS
;
3306 DPRINT1("PNP_QueryRemove(%p %S %p %p %lu 0x%lx)\n",
3307 hBinding
, pszDeviceID
, pVetoType
, pszVetoName
,
3308 ulNameLength
, ulFlags
);
3310 if (ulFlags
& ~CM_REMOVE_BITS
)
3311 return CR_INVALID_FLAG
;
3313 if (!IsValidDeviceInstanceID(pszDeviceID
) ||
3314 IsRootDeviceInstanceID(pszDeviceID
))
3315 return CR_INVALID_DEVINST
;
3317 if (pVetoType
!= NULL
)
3318 *pVetoType
= PNP_VetoTypeUnknown
;
3320 if (pszVetoName
!= NULL
&& ulNameLength
> 0)
3321 *pszVetoName
= UNICODE_NULL
;
3323 RtlZeroMemory(&PlugPlayData
, sizeof(PlugPlayData
));
3324 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
3326 PlugPlayData
.VetoName
= pszVetoName
;
3327 PlugPlayData
.NameLength
= ulNameLength
;
3328 // PlugPlayData.Flags =
3330 Status
= NtPlugPlayControl(PlugPlayControlQueryAndRemoveDevice
,
3332 sizeof(PlugPlayData
));
3333 if (!NT_SUCCESS(Status
))
3334 ret
= NtStatusToCrError(Status
);
3343 PNP_RequestDeviceEject(
3346 PPNP_VETO_TYPE pVetoType
,
3351 PLUGPLAY_CONTROL_QUERY_REMOVE_DATA PlugPlayData
;
3353 DWORD ret
= CR_SUCCESS
;
3355 DPRINT1("PNP_RequestDeviceEject(%p %S %p %p %lu 0x%lx)\n",
3356 hBinding
, pszDeviceID
, pVetoType
, pszVetoName
,
3357 ulNameLength
, ulFlags
);
3360 return CR_INVALID_FLAG
;
3362 if (!IsValidDeviceInstanceID(pszDeviceID
))
3363 return CR_INVALID_DEVINST
;
3365 if (pVetoType
!= NULL
)
3366 *pVetoType
= PNP_VetoTypeUnknown
;
3368 if (pszVetoName
!= NULL
&& ulNameLength
> 0)
3369 *pszVetoName
= UNICODE_NULL
;
3371 RtlZeroMemory(&PlugPlayData
, sizeof(PlugPlayData
));
3372 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
3374 PlugPlayData
.VetoName
= pszVetoName
;
3375 PlugPlayData
.NameLength
= ulNameLength
;
3376 // PlugPlayData.Flags =
3378 Status
= NtPlugPlayControl(PlugPlayControlQueryAndRemoveDevice
,
3380 sizeof(PlugPlayData
));
3381 if (!NT_SUCCESS(Status
))
3382 ret
= NtStatusToCrError(Status
);
3391 PNP_IsDockStationPresent(
3399 CONFIGRET ret
= CR_SUCCESS
;
3401 UNREFERENCED_PARAMETER(hBinding
);
3403 DPRINT1("PNP_IsDockStationPresent(%p %p)\n",
3408 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
3412 &hKey
) != ERROR_SUCCESS
)
3413 return CR_REGISTRY_ERROR
;
3415 dwSize
= sizeof(DWORD
);
3416 if (RegQueryValueExW(hKey
,
3421 &dwSize
) != ERROR_SUCCESS
)
3422 ret
= CR_REGISTRY_ERROR
;
3426 if (ret
== CR_SUCCESS
)
3428 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
3430 ret
= CR_REGISTRY_ERROR
;
3432 else if (dwValue
!= 0)
3438 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
3450 WCHAR szDockDeviceInstance
[MAX_DEVICE_ID_LEN
];
3451 PLUGPLAY_CONTROL_RETRIEVE_DOCK_DATA DockData
;
3454 DPRINT("PNP_RequestEjectPC(%p)\n", hBinding
);
3456 /* Retrieve the dock device */
3457 DockData
.DeviceInstanceLength
= ARRAYSIZE(szDockDeviceInstance
);
3458 DockData
.DeviceInstance
= szDockDeviceInstance
;
3460 Status
= NtPlugPlayControl(PlugPlayControlRetrieveDock
,
3463 if (!NT_SUCCESS(Status
))
3464 return NtStatusToCrError(Status
);
3466 /* Eject the dock device */
3467 return PNP_RequestDeviceEject(hBinding
,
3468 szDockDeviceInstance
,
3485 PPNP_VETO_TYPE pVetoType
,
3490 CONFIGRET ret
= CR_SUCCESS
;
3491 WCHAR szKeyName
[MAX_PATH
];
3496 UNREFERENCED_PARAMETER(hBinding
);
3498 DPRINT("PNP_HwProfFlags() called\n");
3500 if (!IsValidDeviceInstanceID(pDeviceID
))
3501 return CR_INVALID_DEVINST
;
3506 L
"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
3511 L
"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
3515 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
3519 &hKey
) != ERROR_SUCCESS
)
3520 return CR_REGISTRY_ERROR
;
3522 if (ulAction
== PNP_GET_HWPROFFLAGS
)
3524 if (RegOpenKeyExW(hKey
,
3528 &hDeviceKey
) != ERROR_SUCCESS
)
3534 dwSize
= sizeof(DWORD
);
3535 if (RegQueryValueExW(hDeviceKey
,
3540 &dwSize
) != ERROR_SUCCESS
)
3545 RegCloseKey(hDeviceKey
);
3548 else if (ulAction
== PNP_SET_HWPROFFLAGS
)
3550 /* FIXME: not implemented yet */
3551 ret
= CR_CALL_NOT_IMPLEMENTED
;
3566 HWPROFILEINFO
*pHWProfileInfo
,
3567 DWORD ulProfileInfoSize
,
3570 WCHAR szProfileName
[5];
3571 HKEY hKeyConfig
= NULL
;
3572 HKEY hKeyProfiles
= NULL
;
3573 HKEY hKeyProfile
= NULL
;
3574 DWORD dwDisposition
;
3577 CONFIGRET ret
= CR_SUCCESS
;
3579 UNREFERENCED_PARAMETER(hBinding
);
3581 DPRINT("PNP_GetHwProfInfo() called\n");
3583 if (ulProfileInfoSize
== 0)
3585 ret
= CR_INVALID_DATA
;
3591 ret
= CR_INVALID_FLAG
;
3595 /* Initialize the profile information */
3596 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3597 pHWProfileInfo
->HWPI_szFriendlyName
[0] = 0;
3598 pHWProfileInfo
->HWPI_dwFlags
= 0;
3600 /* Open the 'IDConfigDB' key */
3601 lError
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
3602 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
3605 REG_OPTION_NON_VOLATILE
,
3610 if (lError
!= ERROR_SUCCESS
)
3612 ret
= CR_REGISTRY_ERROR
;
3616 /* Open the 'Hardware Profiles' subkey */
3617 lError
= RegCreateKeyExW(hKeyConfig
,
3618 L
"Hardware Profiles",
3621 REG_OPTION_NON_VOLATILE
,
3622 KEY_ENUMERATE_SUB_KEYS
| KEY_QUERY_VALUE
,
3626 if (lError
!= ERROR_SUCCESS
)
3628 ret
= CR_REGISTRY_ERROR
;
3632 if (ulIndex
== (ULONG
)-1)
3634 dwSize
= sizeof(ULONG
);
3635 lError
= RegQueryValueExW(hKeyConfig
,
3639 (LPBYTE
)&pHWProfileInfo
->HWPI_ulHWProfile
,
3641 if (lError
!= ERROR_SUCCESS
)
3643 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3644 ret
= CR_REGISTRY_ERROR
;
3650 /* FIXME: not implemented yet */
3651 ret
= CR_CALL_NOT_IMPLEMENTED
;
3655 swprintf(szProfileName
, L
"%04lu", pHWProfileInfo
->HWPI_ulHWProfile
);
3657 lError
= RegOpenKeyExW(hKeyProfiles
,
3662 if (lError
!= ERROR_SUCCESS
)
3664 ret
= CR_REGISTRY_ERROR
;
3668 dwSize
= sizeof(pHWProfileInfo
->HWPI_szFriendlyName
);
3669 lError
= RegQueryValueExW(hKeyProfile
,
3673 (LPBYTE
)&pHWProfileInfo
->HWPI_szFriendlyName
,
3675 if (lError
!= ERROR_SUCCESS
)
3677 ret
= CR_REGISTRY_ERROR
;
3682 if (hKeyProfile
!= NULL
)
3683 RegCloseKey(hKeyProfile
);
3685 if (hKeyProfiles
!= NULL
)
3686 RegCloseKey(hKeyProfiles
);
3688 if (hKeyConfig
!= NULL
)
3689 RegCloseKey(hKeyConfig
);
3698 PNP_AddEmptyLogConf(
3702 DWORD
*pulLogConfTag
,
3706 return CR_CALL_NOT_IMPLEMENTED
;
3716 DWORD ulLogConfType
,
3721 return CR_CALL_NOT_IMPLEMENTED
;
3728 PNP_GetFirstLogConf(
3731 DWORD ulLogConfType
,
3732 DWORD
*pulLogConfTag
,
3736 return CR_CALL_NOT_IMPLEMENTED
;
3746 DWORD ulLogConfType
,
3752 return CR_CALL_NOT_IMPLEMENTED
;
3759 PNP_GetLogConfPriority(
3768 return CR_CALL_NOT_IMPLEMENTED
;
3779 DWORD ulLogConfType
,
3780 RESOURCEID ResourceID
,
3781 DWORD
*pulResourceTag
,
3783 PNP_RPC_BUFFER_SIZE ResourceLen
,
3787 return CR_CALL_NOT_IMPLEMENTED
;
3798 DWORD ulLogConfType
,
3799 RESOURCEID ResourceID
,
3800 DWORD ulResourceTag
,
3801 DWORD
*pulPreviousResType
,
3802 DWORD
*pulPreviousResTag
,
3806 return CR_CALL_NOT_IMPLEMENTED
;
3817 DWORD ulLogConfType
,
3818 RESOURCEID ResourceID
,
3819 DWORD ulResourceTag
,
3820 DWORD
*pulNextResType
,
3821 DWORD
*pulNextResTag
,
3825 return CR_CALL_NOT_IMPLEMENTED
;
3836 DWORD ulLogConfType
,
3837 RESOURCEID ResourceID
,
3838 DWORD ulResourceTag
,
3840 PNP_RPC_BUFFER_SIZE BufferLen
,
3844 return CR_CALL_NOT_IMPLEMENTED
;
3851 PNP_GetResDesDataSize(
3855 DWORD ulLogConfType
,
3856 RESOURCEID ResourceID
,
3857 DWORD ulResourceTag
,
3862 return CR_CALL_NOT_IMPLEMENTED
;
3873 DWORD ulLogConfType
,
3874 RESOURCEID CurrentResourceID
,
3875 RESOURCEID NewResourceID
,
3876 DWORD ulResourceTag
,
3878 PNP_RPC_BUFFER_SIZE ResourceLen
,
3882 return CR_CALL_NOT_IMPLEMENTED
;
3889 PNP_DetectResourceConflict(
3892 RESOURCEID ResourceID
,
3894 PNP_RPC_BUFFER_SIZE ResourceLen
,
3895 BOOL
*pbConflictDetected
,
3898 DPRINT("PNP_DetectResourceConflict()\n");
3900 if (pbConflictDetected
!= NULL
)
3901 *pbConflictDetected
= FALSE
;
3903 return CR_CALL_NOT_IMPLEMENTED
;
3910 PNP_QueryResConfList(
3913 RESOURCEID ResourceID
,
3915 PNP_RPC_BUFFER_SIZE ResourceLen
,
3917 PNP_RPC_BUFFER_SIZE BufferLen
,
3921 return CR_CALL_NOT_IMPLEMENTED
;
3930 DWORD ulHardwareProfile
,
3933 return CR_CALL_NOT_IMPLEMENTED
;
3940 PNP_QueryArbitratorFreeData(
3945 RESOURCEID ResourceID
,
3948 return CR_CALL_NOT_IMPLEMENTED
;
3955 PNP_QueryArbitratorFreeSize(
3959 RESOURCEID ResourceID
,
3962 if (pulSize
!= NULL
)
3965 return CR_CALL_NOT_IMPLEMENTED
;
3976 return CR_CALL_NOT_IMPLEMENTED
;
3983 PNP_RegisterNotification(
3987 BYTE
*pNotificationFilter
,
3988 DWORD ulNotificationFilterSize
,
3994 PDEV_BROADCAST_DEVICEINTERFACE_W pBroadcastDeviceInterface
;
3995 PDEV_BROADCAST_HANDLE pBroadcastDeviceHandle
;
3997 PNOTIFY_DATA pNotifyData
;
4000 DPRINT1("PNP_RegisterNotification(%p %lx '%S' %p %lu 0x%lx %p %lx %p)\n",
4001 hBinding
, ulUnknown2
, pszName
, pNotificationFilter
,
4002 ulNotificationFilterSize
, ulFlags
, pulNotify
, ulUnknown8
, pulUnknown9
);
4004 if (pNotificationFilter
== NULL
||
4005 pulNotify
== NULL
||
4006 pulUnknown9
== NULL
)
4007 return CR_INVALID_POINTER
;
4010 return CR_INVALID_FLAG
;
4012 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_HDR
)) ||
4013 (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_size
< sizeof(DEV_BROADCAST_HDR
)))
4014 return CR_INVALID_DATA
;
4016 if (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
== DBT_DEVTYP_DEVICEINTERFACE
)
4018 DPRINT1("DBT_DEVTYP_DEVICEINTERFACE\n");
4019 pBroadcastDeviceInterface
= (PDEV_BROADCAST_DEVICEINTERFACE_W
)pNotificationFilter
;
4021 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_DEVICEINTERFACE_W
)) ||
4022 (pBroadcastDeviceInterface
->dbcc_size
< sizeof(DEV_BROADCAST_DEVICEINTERFACE_W
)))
4023 return CR_INVALID_DATA
;
4025 else if (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
== DBT_DEVTYP_HANDLE
)
4027 DPRINT1("DBT_DEVTYP_HANDLE\n");
4028 pBroadcastDeviceHandle
= (PDEV_BROADCAST_HANDLE
)pNotificationFilter
;
4030 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_HANDLE
)) ||
4031 (pBroadcastDeviceHandle
->dbch_size
< sizeof(DEV_BROADCAST_HANDLE
)))
4032 return CR_INVALID_DATA
;
4034 if (ulFlags
& DEVICE_NOTIFY_ALL_INTERFACE_CLASSES
)
4035 return CR_INVALID_FLAG
;
4039 DPRINT1("Invalid device type %lu\n", ((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
);
4040 return CR_INVALID_DATA
;
4045 pNotifyData
= RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(NOTIFY_DATA
));
4046 if (pNotifyData
== NULL
)
4047 return CR_OUT_OF_MEMORY
;
4049 *pulNotify
= (DWORD
)pNotifyData
;
4061 PNP_UnregisterNotification(
4065 DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
4066 hBinding
, ulNotify
);
4070 return CR_CALL_NOT_IMPLEMENTED
;
4080 PNP_GetCustomDevProp(
4083 LPWSTR CustomPropName
,
4084 DWORD
*pulRegDataType
,
4086 PNP_RPC_STRING_LEN
*pulTransferLen
,
4087 PNP_RPC_STRING_LEN
*pulLength
,
4090 HKEY hDeviceKey
= NULL
;
4091 HKEY hParamKey
= NULL
;
4093 CONFIGRET ret
= CR_SUCCESS
;
4095 UNREFERENCED_PARAMETER(hBinding
);
4097 DPRINT("PNP_GetCustomDevProp() called\n");
4099 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
4101 ret
= CR_INVALID_POINTER
;
4105 if (ulFlags
& ~CM_CUSTOMDEVPROP_BITS
)
4107 ret
= CR_INVALID_FLAG
;
4111 if (!IsValidDeviceInstanceID(pDeviceID
))
4112 return CR_INVALID_DEVINST
;
4114 if (*pulLength
< *pulTransferLen
)
4115 *pulLength
= *pulTransferLen
;
4117 *pulTransferLen
= 0;
4119 lError
= RegOpenKeyExW(hEnumKey
,
4124 if (lError
!= ERROR_SUCCESS
)
4126 ret
= CR_REGISTRY_ERROR
;
4130 lError
= RegOpenKeyExW(hDeviceKey
,
4131 L
"Device Parameters",
4135 if (lError
!= ERROR_SUCCESS
)
4137 ret
= CR_REGISTRY_ERROR
;
4141 lError
= RegQueryValueExW(hParamKey
,
4147 if (lError
!= ERROR_SUCCESS
)
4149 if (lError
== ERROR_MORE_DATA
)
4151 ret
= CR_BUFFER_SMALL
;
4156 ret
= CR_NO_SUCH_VALUE
;
4161 if (ret
== CR_SUCCESS
)
4162 *pulTransferLen
= *pulLength
;
4164 if (hParamKey
!= NULL
)
4165 RegCloseKey(hParamKey
);
4167 if (hDeviceKey
!= NULL
)
4168 RegCloseKey(hDeviceKey
);
4170 DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret
);
4179 PNP_GetVersionInternal(
4183 UNREFERENCED_PARAMETER(hBinding
);
4193 PNP_GetBlockedDriverInfo(
4196 PNP_RPC_BUFFER_SIZE
*pulTransferLen
,
4197 PNP_RPC_BUFFER_SIZE
*pulLength
,
4201 return CR_CALL_NOT_IMPLEMENTED
;
4208 PNP_GetServerSideDeviceInstallFlags(
4210 DWORD
*pulSSDIFlags
,
4213 UNREFERENCED_PARAMETER(hBinding
);
4215 DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
4216 hBinding
, pulSSDIFlags
, ulFlags
);
4218 if (pulSSDIFlags
== NULL
)
4219 return CR_INVALID_POINTER
;
4222 return CR_INVALID_FLAG
;
4234 PNP_GetObjectPropKeys(
4238 LPWSTR PropertyCultureName
,
4239 PNP_PROP_COUNT
*PropertyCount
,
4240 PNP_PROP_COUNT
*TransferLen
,
4241 DEVPROPKEY
*PropertyKeys
,
4245 return CR_CALL_NOT_IMPLEMENTED
;
4256 LPWSTR PropertyCultureName
,
4257 const DEVPROPKEY
*PropertyKey
,
4258 DEVPROPTYPE
*PropertyType
,
4259 PNP_PROP_SIZE
*PropertySize
,
4260 PNP_PROP_SIZE
*TransferLen
,
4261 BYTE
*PropertyBuffer
,
4265 return CR_CALL_NOT_IMPLEMENTED
;
4276 LPWSTR PropertyCultureName
,
4277 const DEVPROPKEY
*PropertyKey
,
4278 DEVPROPTYPE PropertyType
,
4279 PNP_PROP_SIZE PropertySize
,
4280 BYTE
*PropertyBuffer
,
4284 return CR_CALL_NOT_IMPLEMENTED
;
4295 return CR_CALL_NOT_IMPLEMENTED
;
4302 PNP_ApplyPowerSettings(
4306 return CR_CALL_NOT_IMPLEMENTED
;
4313 PNP_DriverStoreAddDriverPackage(
4317 return CR_CALL_NOT_IMPLEMENTED
;
4324 PNP_DriverStoreDeleteDriverPackage(
4328 return CR_CALL_NOT_IMPLEMENTED
;
4335 PNP_RegisterServiceNotification(
4339 return CR_CALL_NOT_IMPLEMENTED
;
4346 PNP_SetActiveService(
4352 return CR_CALL_NOT_IMPLEMENTED
;
4359 PNP_DeleteServiceDevices(
4363 return CR_CALL_NOT_IMPLEMENTED
;