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 szRootDeviceId
[] = 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
);
194 /* PUBLIC FUNCTIONS **********************************************************/
202 UNREFERENCED_PARAMETER(hBinding
);
213 UNREFERENCED_PARAMETER(hBinding
);
225 UNREFERENCED_PARAMETER(hBinding
);
240 UNREFERENCED_PARAMETER(hBinding
);
241 UNREFERENCED_PARAMETER(ulFlags
);
243 *pulState
= CM_GLOBAL_STATE_CAN_DO_UI
| CM_GLOBAL_STATE_SERVICES_AVAILABLE
;
254 UNREFERENCED_PARAMETER(hBinding
);
256 DPRINT("PNP_InitDetection() called\n");
269 DWORD ReturnValue
= CR_FAILURE
;
272 UNREFERENCED_PARAMETER(hBinding
);
273 UNREFERENCED_PARAMETER(Admin
);
275 DPRINT("PNP_ReportLogOn(%u, %u) called\n", Admin
, ProcessId
);
277 /* Get the users token */
278 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, TRUE
, ProcessId
);
282 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
288 CloseHandle(hUserToken
);
292 if (!OpenProcessToken(hProcess
, TOKEN_ASSIGN_PRIMARY
| TOKEN_DUPLICATE
| TOKEN_QUERY
, &hUserToken
))
294 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
298 /* Trigger the installer thread */
300 SetEvent(hInstallEvent
);
302 ReturnValue
= CR_SUCCESS
;
306 CloseHandle(hProcess
);
315 PNP_ValidateDeviceInstance(
320 CONFIGRET ret
= CR_SUCCESS
;
321 HKEY hDeviceKey
= NULL
;
323 UNREFERENCED_PARAMETER(hBinding
);
324 UNREFERENCED_PARAMETER(ulFlags
);
326 DPRINT("PNP_ValidateDeviceInstance(%S %lx) called\n",
329 if (RegOpenKeyExW(hEnumKey
,
335 DPRINT("Could not open the Device Key!\n");
336 ret
= CR_NO_SUCH_DEVNODE
;
340 /* FIXME: add more tests */
343 if (hDeviceKey
!= NULL
)
344 RegCloseKey(hDeviceKey
);
346 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret
);
355 PNP_GetRootDeviceInstance(
358 PNP_RPC_STRING_LEN ulLength
)
360 CONFIGRET ret
= CR_SUCCESS
;
362 UNREFERENCED_PARAMETER(hBinding
);
364 DPRINT("PNP_GetRootDeviceInstance() called\n");
368 ret
= CR_INVALID_POINTER
;
371 if (ulLength
< lstrlenW(szRootDeviceId
) + 1)
373 ret
= CR_BUFFER_SMALL
;
381 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret
);
390 PNP_GetRelatedDeviceInstance(
392 DWORD ulRelationship
,
394 LPWSTR pRelatedDeviceId
,
395 PNP_RPC_STRING_LEN
*pulLength
,
398 PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData
;
399 CONFIGRET ret
= CR_SUCCESS
;
402 UNREFERENCED_PARAMETER(hBinding
);
403 UNREFERENCED_PARAMETER(ulFlags
);
405 DPRINT("PNP_GetRelatedDeviceInstance() called\n");
406 DPRINT(" Relationship %ld\n", ulRelationship
);
407 DPRINT(" DeviceId %S\n", pDeviceID
);
409 RtlInitUnicodeString(&PlugPlayData
.TargetDeviceInstance
,
412 PlugPlayData
.Relation
= ulRelationship
;
414 PlugPlayData
.RelatedDeviceInstanceLength
= *pulLength
;
415 PlugPlayData
.RelatedDeviceInstance
= pRelatedDeviceId
;
417 Status
= NtPlugPlayControl(PlugPlayControlGetRelatedDevice
,
418 (PVOID
)&PlugPlayData
,
419 sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
));
420 if (!NT_SUCCESS(Status
))
422 ret
= NtStatusToCrError(Status
);
425 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret
);
426 if (ret
== CR_SUCCESS
)
428 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData
.RelatedDeviceInstance
);
438 PNP_EnumerateSubKeys(
443 PNP_RPC_STRING_LEN ulLength
,
444 PNP_RPC_STRING_LEN
*pulRequiredLen
,
447 CONFIGRET ret
= CR_SUCCESS
;
451 UNREFERENCED_PARAMETER(hBinding
);
452 UNREFERENCED_PARAMETER(ulFlags
);
454 DPRINT("PNP_EnumerateSubKeys() called\n");
458 case PNP_ENUMERATOR_SUBKEYS
:
462 case PNP_CLASS_SUBKEYS
:
470 *pulRequiredLen
= ulLength
;
471 dwError
= RegEnumKeyExW(hKey
,
479 if (dwError
!= ERROR_SUCCESS
)
481 ret
= (dwError
== ERROR_NO_MORE_ITEMS
) ? CR_NO_SUCH_VALUE
: CR_FAILURE
;
488 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret
);
496 GetRelationsInstanceList(
497 _In_ PWSTR pszDevice
,
499 _Inout_ PWSTR pszBuffer
,
500 _Inout_ PDWORD pulLength
)
502 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
504 CONFIGRET ret
= CR_SUCCESS
;
506 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
509 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
511 PlugPlayData
.Relations
= 3;
513 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
515 PlugPlayData
.Relations
= 2;
517 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
519 PlugPlayData
.Relations
= 1;
521 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
523 PlugPlayData
.Relations
= 0;
526 PlugPlayData
.BufferSize
= *pulLength
* sizeof(WCHAR
);
527 PlugPlayData
.Buffer
= pszBuffer
;
529 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
530 (PVOID
)&PlugPlayData
,
531 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
532 if (NT_SUCCESS(Status
))
534 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
538 ret
= NtStatusToCrError(Status
);
547 GetServiceInstanceList(
548 _In_ PWSTR pszService
,
549 _Inout_ PWSTR pszBuffer
,
550 _Inout_ PDWORD pulLength
)
552 WCHAR szPathBuffer
[512];
554 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
555 DWORD dwValues
, dwSize
, dwIndex
, dwUsedLength
, dwPathLength
;
558 CONFIGRET ret
= CR_SUCCESS
;
560 /* Open the device key */
561 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
562 L
"System\\CurrentControlSet\\Services",
566 if (dwError
!= ERROR_SUCCESS
)
568 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
569 return CR_REGISTRY_ERROR
;
572 dwError
= RegOpenKeyExW(hServicesKey
,
577 if (dwError
!= ERROR_SUCCESS
)
579 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
580 ret
= CR_REGISTRY_ERROR
;
584 dwError
= RegOpenKeyExW(hServiceKey
,
589 if (dwError
!= ERROR_SUCCESS
)
591 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
592 ret
= CR_REGISTRY_ERROR
;
596 /* Retrieve the number of device instances */
597 dwSize
= sizeof(DWORD
);
598 dwError
= RegQueryValueExW(hEnumKey
,
604 if (dwError
!= ERROR_SUCCESS
)
606 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
610 DPRINT("dwValues %lu\n", dwValues
);
615 for (dwIndex
= 0; dwIndex
< dwValues
; dwIndex
++)
617 wsprintf(szName
, L
"%lu", dwIndex
);
619 dwSize
= sizeof(szPathBuffer
);
620 dwError
= RegQueryValueExW(hEnumKey
,
624 (LPBYTE
)szPathBuffer
,
626 if (dwError
!= ERROR_SUCCESS
)
629 DPRINT("Path: %S\n", szPathBuffer
);
631 dwPathLength
= wcslen(szPathBuffer
) + 1;
632 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
634 ret
= CR_BUFFER_SMALL
;
638 wcscpy(pPtr
, szPathBuffer
);
639 dwUsedLength
+= dwPathLength
;
640 pPtr
+= dwPathLength
;
642 *pPtr
= UNICODE_NULL
;
646 if (hEnumKey
!= NULL
)
647 RegCloseKey(hEnumKey
);
649 if (hServiceKey
!= NULL
)
650 RegCloseKey(hServiceKey
);
652 if (hServicesKey
!= NULL
)
653 RegCloseKey(hServicesKey
);
655 if (ret
== CR_SUCCESS
)
656 *pulLength
= dwUsedLength
+ 1;
666 GetDeviceInstanceList(
667 _In_ PWSTR pszDevice
,
668 _Inout_ PWSTR pszBuffer
,
669 _Inout_ PDWORD pulLength
)
671 WCHAR szInstanceBuffer
[MAX_DEVICE_ID_LEN
];
672 WCHAR szPathBuffer
[512];
674 DWORD dwInstanceLength
, dwPathLength
, dwUsedLength
;
675 DWORD dwIndex
, dwError
;
677 CONFIGRET ret
= CR_SUCCESS
;
679 /* Open the device key */
680 dwError
= RegOpenKeyExW(hEnumKey
,
683 KEY_ENUMERATE_SUB_KEYS
,
685 if (dwError
!= ERROR_SUCCESS
)
687 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
688 return CR_REGISTRY_ERROR
;
694 for (dwIndex
= 0; ; dwIndex
++)
696 dwInstanceLength
= MAX_DEVICE_ID_LEN
;
697 dwError
= RegEnumKeyExW(hDeviceKey
,
705 if (dwError
!= ERROR_SUCCESS
)
708 wsprintf(szPathBuffer
, L
"%s\\%s", pszDevice
, szInstanceBuffer
);
709 DPRINT("Path: %S\n", szPathBuffer
);
711 dwPathLength
= wcslen(szPathBuffer
) + 1;
712 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
714 ret
= CR_BUFFER_SMALL
;
718 wcscpy(pPtr
, szPathBuffer
);
719 dwUsedLength
+= dwPathLength
;
720 pPtr
+= dwPathLength
;
722 *pPtr
= UNICODE_NULL
;
725 RegCloseKey(hDeviceKey
);
727 if (ret
== CR_SUCCESS
)
728 *pulLength
= dwUsedLength
+ 1;
737 GetEnumeratorInstanceList(
738 _In_ PWSTR pszEnumerator
,
739 _Inout_ PWSTR pszBuffer
,
740 _Inout_ PDWORD pulLength
)
742 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
743 WCHAR szPathBuffer
[512];
746 DWORD dwIndex
, dwDeviceLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
748 CONFIGRET ret
= CR_SUCCESS
;
750 /* Open the enumerator key */
751 dwError
= RegOpenKeyExW(hEnumKey
,
754 KEY_ENUMERATE_SUB_KEYS
,
756 if (dwError
!= ERROR_SUCCESS
)
758 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
759 return CR_REGISTRY_ERROR
;
763 dwRemainingLength
= *pulLength
;
766 for (dwIndex
= 0; ; dwIndex
++)
768 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
769 dwError
= RegEnumKeyExW(hEnumeratorKey
,
777 if (dwError
!= ERROR_SUCCESS
)
780 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
781 DPRINT("Path: %S\n", szPathBuffer
);
783 dwPathLength
= dwRemainingLength
;
784 ret
= GetDeviceInstanceList(szPathBuffer
,
787 if (ret
!= CR_SUCCESS
)
790 dwUsedLength
+= dwPathLength
- 1;
791 dwRemainingLength
+= dwPathLength
- 1;
792 pPtr
+= dwPathLength
- 1;
795 RegCloseKey(hEnumeratorKey
);
797 if (ret
== CR_SUCCESS
)
798 *pulLength
= dwUsedLength
+ 1;
809 _Inout_ PWSTR pszBuffer
,
810 _Inout_ PDWORD pulLength
)
812 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
814 DWORD dwIndex
, dwEnumeratorLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
816 CONFIGRET ret
= CR_SUCCESS
;
819 dwRemainingLength
= *pulLength
;
822 for (dwIndex
= 0; ; dwIndex
++)
824 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
825 dwError
= RegEnumKeyExW(hEnumKey
,
829 NULL
, NULL
, NULL
, NULL
);
830 if (dwError
!= ERROR_SUCCESS
)
833 dwPathLength
= dwRemainingLength
;
834 ret
= GetEnumeratorInstanceList(szEnumeratorBuffer
,
837 if (ret
!= CR_SUCCESS
)
840 dwUsedLength
+= dwPathLength
- 1;
841 dwRemainingLength
+= dwPathLength
- 1;
842 pPtr
+= dwPathLength
- 1;
845 if (ret
== CR_SUCCESS
)
846 *pulLength
= dwUsedLength
+ 1;
861 PNP_RPC_STRING_LEN
*pulLength
,
864 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
865 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
866 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
867 CONFIGRET ret
= CR_SUCCESS
;
869 DPRINT("PNP_GetDeviceList() called\n");
871 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
872 return CR_INVALID_FLAG
;
874 if (pulLength
== NULL
)
875 return CR_INVALID_POINTER
;
877 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
879 return CR_INVALID_POINTER
;
882 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
883 CM_GETIDLIST_FILTER_POWERRELATIONS
|
884 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
885 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
887 ret
= GetRelationsInstanceList(pszFilter
,
892 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
894 ret
= GetServiceInstanceList(pszFilter
,
898 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
900 SplitDeviceInstanceID(pszFilter
,
905 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
907 ret
= GetDeviceInstanceList(pszFilter
,
913 ret
= GetEnumeratorInstanceList(pszFilter
,
918 else /* CM_GETIDLIST_FILTER_NONE */
920 ret
= GetAllInstanceList(Buffer
,
930 GetRelationsInstanceListSize(
931 _In_ PWSTR pszDevice
,
933 _Inout_ PDWORD pulLength
)
935 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
937 CONFIGRET ret
= CR_SUCCESS
;
939 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
942 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
944 PlugPlayData
.Relations
= 3;
946 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
948 PlugPlayData
.Relations
= 2;
950 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
952 PlugPlayData
.Relations
= 1;
954 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
956 PlugPlayData
.Relations
= 0;
959 PlugPlayData
.BufferSize
= 0;
960 PlugPlayData
.Buffer
= NULL
;
962 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
963 (PVOID
)&PlugPlayData
,
964 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
965 if (NT_SUCCESS(Status
))
967 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
971 ret
= NtStatusToCrError(Status
);
980 GetServiceInstanceListSize(
981 _In_ PWSTR pszService
,
982 _Out_ PDWORD pulLength
)
984 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
985 DWORD dwValues
, dwMaxValueLength
, dwSize
;
987 CONFIGRET ret
= CR_SUCCESS
;
989 /* Open the device key */
990 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
991 L
"System\\CurrentControlSet\\Services",
995 if (dwError
!= ERROR_SUCCESS
)
997 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
998 return CR_REGISTRY_ERROR
;
1001 dwError
= RegOpenKeyExW(hServicesKey
,
1006 if (dwError
!= ERROR_SUCCESS
)
1008 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
1009 ret
= CR_REGISTRY_ERROR
;
1013 dwError
= RegOpenKeyExW(hServiceKey
,
1018 if (dwError
!= ERROR_SUCCESS
)
1020 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
1021 ret
= CR_REGISTRY_ERROR
;
1025 /* Retrieve the number of device instances */
1026 dwSize
= sizeof(DWORD
);
1027 dwError
= RegQueryValueExW(hEnumKey
,
1033 if (dwError
!= ERROR_SUCCESS
)
1035 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
1039 /* Retrieve the maximum instance name length */
1040 dwError
= RegQueryInfoKeyW(hEnumKey
,
1052 if (dwError
!= ERROR_SUCCESS
)
1054 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1055 dwMaxValueLength
= MAX_DEVICE_ID_LEN
;
1058 DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues
, dwMaxValueLength
/ sizeof(WCHAR
));
1060 /* Return the largest possible buffer size */
1061 *pulLength
= dwValues
* dwMaxValueLength
/ sizeof(WCHAR
) + 2;
1064 if (hEnumKey
!= NULL
)
1065 RegCloseKey(hEnumKey
);
1067 if (hServiceKey
!= NULL
)
1068 RegCloseKey(hServiceKey
);
1070 if (hServicesKey
!= NULL
)
1071 RegCloseKey(hServicesKey
);
1079 GetDeviceInstanceListSize(
1080 _In_ LPCWSTR pszDevice
,
1081 _Out_ PULONG pulLength
)
1084 DWORD dwSubKeys
, dwMaxSubKeyLength
;
1087 /* Open the device key */
1088 dwError
= RegOpenKeyExW(hEnumKey
,
1093 if (dwError
!= ERROR_SUCCESS
)
1095 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
1096 return CR_REGISTRY_ERROR
;
1099 /* Retrieve the number of device instances and the maximum name length */
1100 dwError
= RegQueryInfoKeyW(hDeviceKey
,
1112 if (dwError
!= ERROR_SUCCESS
)
1114 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1116 dwMaxSubKeyLength
= 0;
1119 /* Close the device key */
1120 RegCloseKey(hDeviceKey
);
1122 /* Return the largest possible buffer size */
1123 *pulLength
= dwSubKeys
* (wcslen(pszDevice
) + 1 + dwMaxSubKeyLength
+ 1);
1131 GetEnumeratorInstanceListSize(
1132 _In_ LPCWSTR pszEnumerator
,
1133 _Out_ PULONG pulLength
)
1135 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
1136 WCHAR szPathBuffer
[512];
1137 HKEY hEnumeratorKey
;
1138 DWORD dwIndex
, dwDeviceLength
, dwBufferLength
;
1140 CONFIGRET ret
= CR_SUCCESS
;
1144 /* Open the enumerator key */
1145 dwError
= RegOpenKeyExW(hEnumKey
,
1148 KEY_ENUMERATE_SUB_KEYS
,
1150 if (dwError
!= ERROR_SUCCESS
)
1152 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
1153 return CR_REGISTRY_ERROR
;
1156 for (dwIndex
= 0; ; dwIndex
++)
1158 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
1159 dwError
= RegEnumKeyExW(hEnumeratorKey
,
1167 if (dwError
!= ERROR_SUCCESS
)
1170 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
1171 DPRINT("Path: %S\n", szPathBuffer
);
1173 ret
= GetDeviceInstanceListSize(szPathBuffer
, &dwBufferLength
);
1174 if (ret
!= CR_SUCCESS
)
1180 *pulLength
+= dwBufferLength
;
1183 /* Close the enumerator key */
1184 RegCloseKey(hEnumeratorKey
);
1192 GetAllInstanceListSize(
1193 _Out_ PULONG pulLength
)
1195 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
1196 DWORD dwIndex
, dwEnumeratorLength
, dwBufferLength
;
1198 CONFIGRET ret
= CR_SUCCESS
;
1200 for (dwIndex
= 0; ; dwIndex
++)
1202 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
1203 dwError
= RegEnumKeyExW(hEnumKey
,
1206 &dwEnumeratorLength
,
1207 NULL
, NULL
, NULL
, NULL
);
1208 if (dwError
!= ERROR_SUCCESS
)
1211 /* Get the size of all device instances for the enumerator */
1212 ret
= GetEnumeratorInstanceListSize(szEnumeratorBuffer
,
1214 if (ret
!= CR_SUCCESS
)
1217 *pulLength
+= dwBufferLength
;
1227 PNP_GetDeviceListSize(
1230 PNP_RPC_BUFFER_SIZE
*pulLength
,
1233 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
1234 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
1235 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
1236 CONFIGRET ret
= CR_SUCCESS
;
1238 DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
1239 hBinding
, pszFilter
, pulLength
, ulFlags
);
1241 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
1242 return CR_INVALID_FLAG
;
1244 if (pulLength
== NULL
)
1245 return CR_INVALID_POINTER
;
1247 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
1248 (pszFilter
== NULL
))
1249 return CR_INVALID_POINTER
;
1254 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
1255 CM_GETIDLIST_FILTER_POWERRELATIONS
|
1256 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
1257 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
1259 ret
= GetRelationsInstanceListSize(pszFilter
,
1263 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
1265 ret
= GetServiceInstanceListSize(pszFilter
,
1268 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
1270 SplitDeviceInstanceID(pszFilter
,
1275 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
1277 ret
= GetDeviceInstanceListSize(pszFilter
,
1282 ret
= GetEnumeratorInstanceListSize(pszFilter
,
1286 else /* CM_GETIDLIST_FILTER_NONE */
1288 ret
= GetAllInstanceListSize(pulLength
);
1291 /* Add one character for the terminating double UNICODE_NULL */
1292 if (ret
== CR_SUCCESS
)
1308 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData
;
1309 CONFIGRET ret
= CR_SUCCESS
;
1312 UNREFERENCED_PARAMETER(hBinding
);
1313 UNREFERENCED_PARAMETER(ulFlags
);
1315 DPRINT("PNP_GetDepth() called\n");
1317 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1320 Status
= NtPlugPlayControl(PlugPlayControlGetDeviceDepth
,
1321 (PVOID
)&PlugPlayData
,
1322 sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
));
1323 if (NT_SUCCESS(Status
))
1325 *pulDepth
= PlugPlayData
.Depth
;
1329 ret
= NtStatusToCrError(Status
);
1332 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret
);
1341 PNP_GetDeviceRegProp(
1345 DWORD
*pulRegDataType
,
1347 PNP_PROP_SIZE
*pulTransferLen
,
1348 PNP_PROP_SIZE
*pulLength
,
1351 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData
;
1352 CONFIGRET ret
= CR_SUCCESS
;
1353 LPWSTR lpValueName
= NULL
;
1358 UNREFERENCED_PARAMETER(hBinding
);
1360 DPRINT("PNP_GetDeviceRegProp() called\n");
1362 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
1364 ret
= CR_INVALID_POINTER
;
1370 ret
= CR_INVALID_FLAG
;
1374 /* FIXME: Check pDeviceID */
1376 if (*pulLength
< *pulTransferLen
)
1377 *pulLength
= *pulTransferLen
;
1379 *pulTransferLen
= 0;
1383 case CM_DRP_DEVICEDESC
:
1384 lpValueName
= L
"DeviceDesc";
1387 case CM_DRP_HARDWAREID
:
1388 lpValueName
= L
"HardwareID";
1391 case CM_DRP_COMPATIBLEIDS
:
1392 lpValueName
= L
"CompatibleIDs";
1395 case CM_DRP_SERVICE
:
1396 lpValueName
= L
"Service";
1400 lpValueName
= L
"Class";
1403 case CM_DRP_CLASSGUID
:
1404 lpValueName
= L
"ClassGUID";
1408 lpValueName
= L
"Driver";
1411 case CM_DRP_CONFIGFLAGS
:
1412 lpValueName
= L
"ConfigFlags";
1416 lpValueName
= L
"Mfg";
1419 case CM_DRP_FRIENDLYNAME
:
1420 lpValueName
= L
"FriendlyName";
1423 case CM_DRP_LOCATION_INFORMATION
:
1424 lpValueName
= L
"LocationInformation";
1427 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
1428 PlugPlayData
.Property
= PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
;
1431 case CM_DRP_CAPABILITIES
:
1432 lpValueName
= L
"Capabilities";
1435 case CM_DRP_UI_NUMBER
:
1436 PlugPlayData
.Property
= PNP_PROPERTY_UI_NUMBER
;
1439 case CM_DRP_UPPERFILTERS
:
1440 lpValueName
= L
"UpperFilters";
1443 case CM_DRP_LOWERFILTERS
:
1444 lpValueName
= L
"LowerFilters";
1447 case CM_DRP_BUSTYPEGUID
:
1448 PlugPlayData
.Property
= PNP_PROPERTY_BUSTYPEGUID
;
1451 case CM_DRP_LEGACYBUSTYPE
:
1452 PlugPlayData
.Property
= PNP_PROPERTY_LEGACYBUSTYPE
;
1455 case CM_DRP_BUSNUMBER
:
1456 PlugPlayData
.Property
= PNP_PROPERTY_BUSNUMBER
;
1459 case CM_DRP_ENUMERATOR_NAME
:
1460 PlugPlayData
.Property
= PNP_PROPERTY_ENUMERATOR_NAME
;
1463 case CM_DRP_SECURITY
:
1464 lpValueName
= L
"Security";
1467 case CM_DRP_DEVTYPE
:
1468 lpValueName
= L
"DeviceType";
1471 case CM_DRP_EXCLUSIVE
:
1472 lpValueName
= L
"Exclusive";
1475 case CM_DRP_CHARACTERISTICS
:
1476 lpValueName
= L
"DeviceCharacteristics";
1479 case CM_DRP_ADDRESS
:
1480 PlugPlayData
.Property
= PNP_PROPERTY_ADDRESS
;
1483 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1484 lpValueName
= L
"UINumberDescFormat";
1487 case CM_DRP_DEVICE_POWER_DATA
:
1488 PlugPlayData
.Property
= PNP_PROPERTY_POWER_DATA
;
1491 case CM_DRP_REMOVAL_POLICY
:
1492 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY
;
1495 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT
:
1496 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
;
1499 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1500 lpValueName
= L
"RemovalPolicy";
1503 case CM_DRP_INSTALL_STATE
:
1504 PlugPlayData
.Property
= PNP_PROPERTY_INSTALL_STATE
;
1507 #if (WINVER >= _WIN32_WINNT_WS03)
1508 case CM_DRP_LOCATION_PATHS
:
1509 PlugPlayData
.Property
= PNP_PROPERTY_LOCATION_PATHS
;
1513 #if (WINVER >= _WIN32_WINNT_WIN7)
1514 case CM_DRP_BASE_CONTAINERID
:
1515 PlugPlayData
.Property
= PNP_PROPERTY_CONTAINERID
;
1520 ret
= CR_INVALID_PROPERTY
;
1524 DPRINT("Value name: %S\n", lpValueName
);
1528 /* Retrieve information from the Registry */
1529 lError
= RegOpenKeyExW(hEnumKey
,
1534 if (lError
!= ERROR_SUCCESS
)
1538 ret
= CR_INVALID_DEVNODE
;
1542 lError
= RegQueryValueExW(hKey
,
1548 if (lError
!= ERROR_SUCCESS
)
1550 if (lError
== ERROR_MORE_DATA
)
1552 ret
= CR_BUFFER_SMALL
;
1557 ret
= CR_NO_SUCH_VALUE
;
1563 /* Retrieve information from the Device Node */
1564 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1566 PlugPlayData
.Buffer
= Buffer
;
1567 PlugPlayData
.BufferSize
= *pulLength
;
1569 Status
= NtPlugPlayControl(PlugPlayControlProperty
,
1570 (PVOID
)&PlugPlayData
,
1571 sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
));
1572 if (NT_SUCCESS(Status
))
1574 *pulLength
= PlugPlayData
.BufferSize
;
1578 ret
= NtStatusToCrError(Status
);
1584 *pulTransferLen
= (ret
== CR_SUCCESS
) ? *pulLength
: 0;
1589 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret
);
1598 PNP_SetDeviceRegProp(
1604 PNP_PROP_SIZE ulLength
,
1607 CONFIGRET ret
= CR_SUCCESS
;
1608 LPWSTR lpValueName
= NULL
;
1611 UNREFERENCED_PARAMETER(hBinding
);
1612 UNREFERENCED_PARAMETER(ulFlags
);
1614 DPRINT("PNP_SetDeviceRegProp() called\n");
1616 DPRINT("DeviceId: %S\n", pDeviceId
);
1617 DPRINT("Property: %lu\n", ulProperty
);
1618 DPRINT("DataType: %lu\n", ulDataType
);
1619 DPRINT("Length: %lu\n", ulLength
);
1623 case CM_DRP_DEVICEDESC
:
1624 lpValueName
= L
"DeviceDesc";
1627 case CM_DRP_HARDWAREID
:
1628 lpValueName
= L
"HardwareID";
1631 case CM_DRP_COMPATIBLEIDS
:
1632 lpValueName
= L
"CompatibleIDs";
1635 case CM_DRP_SERVICE
:
1636 lpValueName
= L
"Service";
1640 lpValueName
= L
"Class";
1643 case CM_DRP_CLASSGUID
:
1644 lpValueName
= L
"ClassGUID";
1648 lpValueName
= L
"Driver";
1651 case CM_DRP_CONFIGFLAGS
:
1652 lpValueName
= L
"ConfigFlags";
1656 lpValueName
= L
"Mfg";
1659 case CM_DRP_FRIENDLYNAME
:
1660 lpValueName
= L
"FriendlyName";
1663 case CM_DRP_LOCATION_INFORMATION
:
1664 lpValueName
= L
"LocationInformation";
1667 case CM_DRP_UPPERFILTERS
:
1668 lpValueName
= L
"UpperFilters";
1671 case CM_DRP_LOWERFILTERS
:
1672 lpValueName
= L
"LowerFilters";
1675 case CM_DRP_SECURITY
:
1676 lpValueName
= L
"Security";
1679 case CM_DRP_DEVTYPE
:
1680 lpValueName
= L
"DeviceType";
1683 case CM_DRP_EXCLUSIVE
:
1684 lpValueName
= L
"Exclusive";
1687 case CM_DRP_CHARACTERISTICS
:
1688 lpValueName
= L
"DeviceCharacteristics";
1691 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1692 lpValueName
= L
"UINumberDescFormat";
1695 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1696 lpValueName
= L
"RemovalPolicy";
1700 return CR_INVALID_PROPERTY
;
1703 DPRINT("Value name: %S\n", lpValueName
);
1705 if (RegOpenKeyExW(hEnumKey
,
1710 return CR_INVALID_DEVNODE
;
1714 if (RegDeleteValueW(hKey
,
1716 ret
= CR_REGISTRY_ERROR
;
1720 if (RegSetValueExW(hKey
,
1726 ret
= CR_REGISTRY_ERROR
;
1731 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret
);
1740 PNP_GetClassInstance(
1743 LPWSTR pszClassInstance
,
1744 PNP_RPC_STRING_LEN ulLength
)
1746 WCHAR szClassGuid
[40];
1747 WCHAR szClassInstance
[5];
1748 HKEY hDeviceClassKey
= NULL
;
1749 HKEY hClassInstanceKey
;
1750 ULONG ulTransferLength
, ulDataLength
;
1751 DWORD dwDataType
, dwDisposition
, i
;
1753 CONFIGRET ret
= CR_SUCCESS
;
1755 DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
1756 hBinding
, pDeviceId
, pszClassInstance
, ulLength
);
1758 ulTransferLength
= ulLength
;
1759 ret
= PNP_GetDeviceRegProp(hBinding
,
1763 (BYTE
*)pszClassInstance
,
1767 if (ret
== CR_SUCCESS
)
1770 ulTransferLength
= sizeof(szClassGuid
);
1771 ulDataLength
= sizeof(szClassGuid
);
1772 ret
= PNP_GetDeviceRegProp(hBinding
,
1776 (BYTE
*)szClassGuid
,
1780 if (ret
!= CR_SUCCESS
)
1782 DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret
);
1786 dwError
= RegOpenKeyExW(hClassKey
,
1791 if (dwError
!= ERROR_SUCCESS
)
1793 DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError
);
1798 for (i
= 0; i
< 10000; i
++)
1800 wsprintf(szClassInstance
, L
"%04lu", i
);
1802 dwError
= RegCreateKeyExW(hDeviceClassKey
,
1806 REG_OPTION_NON_VOLATILE
,
1811 if (dwError
== ERROR_SUCCESS
)
1813 RegCloseKey(hClassInstanceKey
);
1815 if (dwDisposition
== REG_CREATED_NEW_KEY
)
1817 wsprintf(pszClassInstance
,
1822 ulDataLength
= (wcslen(pszClassInstance
) + 1) * sizeof(WCHAR
);
1823 ret
= PNP_SetDeviceRegProp(hBinding
,
1827 (BYTE
*)pszClassInstance
,
1830 if (ret
!= CR_SUCCESS
)
1832 DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret
);
1833 RegDeleteKeyW(hDeviceClassKey
,
1843 if (hDeviceClassKey
!= NULL
)
1844 RegCloseKey(hDeviceClassKey
);
1861 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
1870 return CR_REGISTRY_ERROR
;
1872 /* FIXME: Set security key */
1883 PNP_DeleteRegistryKey(
1886 LPWSTR pszParentKey
,
1891 return CR_CALL_NOT_IMPLEMENTED
;
1900 DWORD
*pulClassCount
,
1906 UNREFERENCED_PARAMETER(hBinding
);
1907 UNREFERENCED_PARAMETER(ulFlags
);
1909 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1914 if (dwError
!= ERROR_SUCCESS
)
1915 return CR_INVALID_DATA
;
1917 dwError
= RegQueryInfoKeyW(hKey
,
1930 if (dwError
!= ERROR_SUCCESS
)
1931 return CR_INVALID_DATA
;
1942 LPWSTR pszClassGuid
,
1944 PNP_RPC_STRING_LEN
*pulLength
,
1947 WCHAR szKeyName
[MAX_PATH
];
1948 CONFIGRET ret
= CR_SUCCESS
;
1952 UNREFERENCED_PARAMETER(hBinding
);
1953 UNREFERENCED_PARAMETER(ulFlags
);
1955 DPRINT("PNP_GetClassName() called\n");
1957 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
1958 if (lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
1959 lstrcatW(szKeyName
, pszClassGuid
);
1961 return CR_INVALID_DATA
;
1963 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1968 return CR_REGISTRY_ERROR
;
1970 dwSize
= *pulLength
* sizeof(WCHAR
);
1971 if (RegQueryValueExW(hKey
,
1979 ret
= CR_REGISTRY_ERROR
;
1983 *pulLength
= dwSize
/ sizeof(WCHAR
);
1988 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
1999 LPWSTR pszClassGuid
,
2002 CONFIGRET ret
= CR_SUCCESS
;
2004 UNREFERENCED_PARAMETER(hBinding
);
2006 DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid
, ulFlags
);
2008 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
2010 if (SHDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2011 ret
= CR_REGISTRY_ERROR
;
2015 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2016 ret
= CR_REGISTRY_ERROR
;
2019 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
2028 PNP_GetInterfaceDeviceAlias(
2030 LPWSTR pszInterfaceDevice
,
2031 GUID
*AliasInterfaceGuid
,
2032 LPWSTR pszAliasInterfaceDevice
,
2033 PNP_RPC_STRING_LEN
*pulLength
,
2034 PNP_RPC_STRING_LEN
*pulTransferLen
,
2038 return CR_CALL_NOT_IMPLEMENTED
;
2045 PNP_GetInterfaceDeviceList(
2047 GUID
*InterfaceGuid
,
2050 PNP_RPC_BUFFER_SIZE
*pulLength
,
2054 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2055 DWORD ret
= CR_SUCCESS
;
2057 UNREFERENCED_PARAMETER(hBinding
);
2059 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2062 PlugPlayData
.Flags
= ulFlags
;
2063 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2064 PlugPlayData
.Buffer
= Buffer
;
2065 PlugPlayData
.BufferSize
= *pulLength
;
2067 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2068 (PVOID
)&PlugPlayData
,
2069 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2070 if (NT_SUCCESS(Status
))
2072 *pulLength
= PlugPlayData
.BufferSize
;
2076 ret
= NtStatusToCrError(Status
);
2079 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2087 PNP_GetInterfaceDeviceListSize(
2089 PNP_RPC_BUFFER_SIZE
*pulLen
,
2090 GUID
*InterfaceGuid
,
2095 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2096 DWORD ret
= CR_SUCCESS
;
2098 UNREFERENCED_PARAMETER(hBinding
);
2100 DPRINT("PNP_GetInterfaceDeviceListSize() called\n");
2102 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2105 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2106 PlugPlayData
.Buffer
= NULL
;
2107 PlugPlayData
.BufferSize
= 0;
2108 PlugPlayData
.Flags
= ulFlags
;
2110 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2111 (PVOID
)&PlugPlayData
,
2112 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2113 if (NT_SUCCESS(Status
))
2115 *pulLen
= PlugPlayData
.BufferSize
;
2119 ret
= NtStatusToCrError(Status
);
2122 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2130 PNP_RegisterDeviceClassAssociation(
2133 GUID
*InterfaceGuid
,
2134 LPWSTR pszReference
,
2136 PNP_RPC_STRING_LEN
*pulLength
,
2137 PNP_RPC_STRING_LEN
*pulTransferLen
,
2141 return CR_CALL_NOT_IMPLEMENTED
;
2148 PNP_UnregisterDeviceClassAssociation(
2150 LPWSTR pszInterfaceDevice
,
2154 return CR_CALL_NOT_IMPLEMENTED
;
2161 PNP_GetClassRegProp(
2163 LPWSTR pszClassGuid
,
2165 DWORD
*pulRegDataType
,
2167 PNP_RPC_STRING_LEN
*pulTransferLen
,
2168 PNP_RPC_STRING_LEN
*pulLength
,
2171 CONFIGRET ret
= CR_SUCCESS
;
2172 LPWSTR lpValueName
= NULL
;
2173 HKEY hInstKey
= NULL
;
2174 HKEY hPropKey
= NULL
;
2177 UNREFERENCED_PARAMETER(hBinding
);
2179 DPRINT("PNP_GetClassRegProp() called\n");
2181 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
2183 ret
= CR_INVALID_POINTER
;
2189 ret
= CR_INVALID_FLAG
;
2193 if (*pulLength
< *pulTransferLen
)
2194 *pulLength
= *pulTransferLen
;
2196 *pulTransferLen
= 0;
2200 case CM_CRP_SECURITY
:
2201 lpValueName
= L
"Security";
2204 case CM_CRP_DEVTYPE
:
2205 lpValueName
= L
"DeviceType";
2208 case CM_CRP_EXCLUSIVE
:
2209 lpValueName
= L
"Exclusive";
2212 case CM_CRP_CHARACTERISTICS
:
2213 lpValueName
= L
"DeviceCharacteristics";
2217 ret
= CR_INVALID_PROPERTY
;
2221 DPRINT("Value name: %S\n", lpValueName
);
2223 lError
= RegOpenKeyExW(hClassKey
,
2228 if (lError
!= ERROR_SUCCESS
)
2231 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2235 lError
= RegOpenKeyExW(hInstKey
,
2240 if (lError
!= ERROR_SUCCESS
)
2243 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2247 lError
= RegQueryValueExW(hPropKey
,
2253 if (lError
!= ERROR_SUCCESS
)
2255 if (lError
== ERROR_MORE_DATA
)
2257 ret
= CR_BUFFER_SMALL
;
2262 ret
= CR_NO_SUCH_VALUE
;
2267 if (ret
== CR_SUCCESS
)
2268 *pulTransferLen
= *pulLength
;
2270 if (hPropKey
!= NULL
)
2271 RegCloseKey(hPropKey
);
2273 if (hInstKey
!= NULL
)
2274 RegCloseKey(hInstKey
);
2276 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret
);
2285 PNP_SetClassRegProp(
2287 LPWSTR pszClassGuid
,
2291 PNP_PROP_SIZE ulLength
,
2294 CONFIGRET ret
= CR_SUCCESS
;
2295 LPWSTR lpValueName
= NULL
;
2300 UNREFERENCED_PARAMETER(hBinding
);
2302 DPRINT("PNP_SetClassRegProp() called\n");
2305 return CR_INVALID_FLAG
;
2309 case CM_CRP_SECURITY
:
2310 lpValueName
= L
"Security";
2313 case CM_CRP_DEVTYPE
:
2314 lpValueName
= L
"DeviceType";
2317 case CM_CRP_EXCLUSIVE
:
2318 lpValueName
= L
"Exclusive";
2321 case CM_CRP_CHARACTERISTICS
:
2322 lpValueName
= L
"DeviceCharacteristics";
2326 return CR_INVALID_PROPERTY
;
2329 lError
= RegOpenKeyExW(hClassKey
,
2334 if (lError
!= ERROR_SUCCESS
)
2336 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2340 /* FIXME: Set security descriptor */
2341 lError
= RegCreateKeyExW(hInstKey
,
2345 REG_OPTION_NON_VOLATILE
,
2350 if (lError
!= ERROR_SUCCESS
)
2352 ret
= CR_REGISTRY_ERROR
;
2358 if (RegDeleteValueW(hPropKey
,
2360 ret
= CR_REGISTRY_ERROR
;
2364 if (RegSetValueExW(hPropKey
,
2370 ret
= CR_REGISTRY_ERROR
;
2374 if (hPropKey
!= NULL
)
2375 RegCloseKey(hPropKey
);
2377 if (hInstKey
!= NULL
)
2378 RegCloseKey(hInstKey
);
2385 CreateDeviceInstance(LPWSTR pszDeviceID
)
2387 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
2388 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
2389 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
2390 HKEY hKeyEnumerator
;
2396 /* Split the instance ID */
2397 SplitDeviceInstanceID(pszDeviceID
,
2402 /* Open or create the enumerator key */
2403 lError
= RegCreateKeyExW(hEnumKey
,
2407 REG_OPTION_NON_VOLATILE
,
2412 if (lError
!= ERROR_SUCCESS
)
2414 return CR_REGISTRY_ERROR
;
2417 /* Open or create the device key */
2418 lError
= RegCreateKeyExW(hKeyEnumerator
,
2422 REG_OPTION_NON_VOLATILE
,
2428 /* Close the enumerator key */
2429 RegCloseKey(hKeyEnumerator
);
2431 if (lError
!= ERROR_SUCCESS
)
2433 return CR_REGISTRY_ERROR
;
2436 /* Try to open the instance key and fail if it exists */
2437 lError
= RegOpenKeyExW(hKeyDevice
,
2442 if (lError
== ERROR_SUCCESS
)
2444 DPRINT1("Instance %S already exists!\n", szInstance
);
2445 RegCloseKey(hKeyInstance
);
2446 RegCloseKey(hKeyDevice
);
2447 return CR_ALREADY_SUCH_DEVINST
;
2450 /* Create a new instance key */
2451 lError
= RegCreateKeyExW(hKeyDevice
,
2455 REG_OPTION_NON_VOLATILE
,
2461 /* Close the device key */
2462 RegCloseKey(hKeyDevice
);
2464 if (lError
!= ERROR_SUCCESS
)
2466 return CR_REGISTRY_ERROR
;
2469 /* Create the 'Control' sub key */
2470 lError
= RegCreateKeyExW(hKeyInstance
,
2474 REG_OPTION_NON_VOLATILE
,
2479 if (lError
== ERROR_SUCCESS
)
2481 RegCloseKey(hKeyControl
);
2484 RegCloseKey(hKeyInstance
);
2486 return (lError
== ERROR_SUCCESS
) ? CR_SUCCESS
: CR_REGISTRY_ERROR
;
2496 LPWSTR pszParentDeviceID
,
2497 PNP_RPC_STRING_LEN ulLength
,
2500 CONFIGRET ret
= CR_SUCCESS
;
2502 DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID
);
2504 if (ulFlags
& CM_CREATE_DEVNODE_GENERATE_ID
)
2506 WCHAR szGeneratedInstance
[MAX_DEVICE_ID_LEN
];
2507 DWORD dwInstanceNumber
;
2509 /* Generated ID is: Root\<Device ID>\<Instance number> */
2510 dwInstanceNumber
= 0;
2513 swprintf(szGeneratedInstance
, L
"Root\\%ls\\%04lu",
2514 pszDeviceID
, dwInstanceNumber
);
2516 /* Try to create a device instance with this ID */
2517 ret
= CreateDeviceInstance(szGeneratedInstance
);
2521 while (ret
== CR_ALREADY_SUCH_DEVINST
);
2523 if (ret
== CR_SUCCESS
)
2525 /* pszDeviceID is an out parameter too for generated IDs */
2526 if (wcslen(szGeneratedInstance
) > ulLength
)
2528 ret
= CR_BUFFER_SMALL
;
2532 wcscpy(pszDeviceID
, szGeneratedInstance
);
2538 /* Create the device instance */
2539 ret
= CreateDeviceInstance(pszDeviceID
);
2542 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret
);
2549 MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination
,
2550 LPWSTR pszDeviceInstanceSource
)
2552 DPRINT("MoveDeviceInstance: not implemented\n");
2554 return CR_CALL_NOT_IMPLEMENTED
;
2559 SetupDeviceInstance(LPWSTR pszDeviceInstance
,
2562 DPRINT("SetupDeviceInstance: not implemented\n");
2564 return CR_CALL_NOT_IMPLEMENTED
;
2569 EnableDeviceInstance(LPWSTR pszDeviceInstance
)
2571 PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
;
2572 CONFIGRET ret
= CR_SUCCESS
;
2575 DPRINT("Enable device instance %S\n", pszDeviceInstance
);
2577 RtlInitUnicodeString(&ResetDeviceData
.DeviceInstance
, pszDeviceInstance
);
2578 Status
= NtPlugPlayControl(PlugPlayControlResetDevice
, &ResetDeviceData
, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
));
2579 if (!NT_SUCCESS(Status
))
2580 ret
= NtStatusToCrError(Status
);
2587 DisableDeviceInstance(LPWSTR pszDeviceInstance
)
2589 DPRINT("DisableDeviceInstance: not implemented\n");
2591 return CR_CALL_NOT_IMPLEMENTED
;
2596 ReenumerateDeviceInstance(
2597 _In_ LPWSTR pszDeviceInstance
,
2600 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData
;
2601 CONFIGRET ret
= CR_SUCCESS
;
2604 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
2605 pszDeviceInstance
, ulFlags
);
2607 if (ulFlags
& ~CM_REENUMERATE_BITS
)
2608 return CR_INVALID_FLAG
;
2610 if (ulFlags
& CM_REENUMERATE_RETRY_INSTALLATION
)
2612 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
2615 RtlInitUnicodeString(&EnumerateDeviceData
.DeviceInstance
,
2617 EnumerateDeviceData
.Flags
= 0;
2619 Status
= NtPlugPlayControl(PlugPlayControlEnumerateDevice
,
2620 &EnumerateDeviceData
,
2621 sizeof(PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA
));
2622 if (!NT_SUCCESS(Status
))
2623 ret
= NtStatusToCrError(Status
);
2632 PNP_DeviceInstanceAction(
2636 LPWSTR pszDeviceInstance1
,
2637 LPWSTR pszDeviceInstance2
)
2639 CONFIGRET ret
= CR_SUCCESS
;
2641 UNREFERENCED_PARAMETER(hBinding
);
2643 DPRINT("PNP_DeviceInstanceAction() called\n");
2647 case PNP_DEVINST_MOVE
:
2648 ret
= MoveDeviceInstance(pszDeviceInstance1
,
2649 pszDeviceInstance2
);
2652 case PNP_DEVINST_SETUP
:
2653 ret
= SetupDeviceInstance(pszDeviceInstance1
,
2657 case PNP_DEVINST_ENABLE
:
2658 ret
= EnableDeviceInstance(pszDeviceInstance1
);
2661 case PNP_DEVINST_DISABLE
:
2662 ret
= DisableDeviceInstance(pszDeviceInstance1
);
2665 case PNP_DEVINST_REENUMERATE
:
2666 ret
= ReenumerateDeviceInstance(pszDeviceInstance1
,
2671 DPRINT1("Unknown device action %lu: not implemented\n", ulAction
);
2672 ret
= CR_CALL_NOT_IMPLEMENTED
;
2675 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
2684 PNP_GetDeviceStatus(
2691 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
2692 CONFIGRET ret
= CR_SUCCESS
;
2695 UNREFERENCED_PARAMETER(hBinding
);
2696 UNREFERENCED_PARAMETER(ulFlags
);
2698 DPRINT("PNP_GetDeviceStatus() called\n");
2700 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2702 PlugPlayData
.Operation
= 0; /* Get status */
2704 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
2705 (PVOID
)&PlugPlayData
,
2706 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
2707 if (NT_SUCCESS(Status
))
2709 *pulStatus
= PlugPlayData
.DeviceStatus
;
2710 *pulProblem
= PlugPlayData
.DeviceProblem
;
2714 ret
= NtStatusToCrError(Status
);
2717 DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret
);
2726 PNP_SetDeviceProblem(
2733 return CR_CALL_NOT_IMPLEMENTED
;
2743 PPNP_VETO_TYPE pVetoType
,
2749 return CR_CALL_NOT_IMPLEMENTED
;
2755 PNP_UninstallDevInst(
2761 return CR_CALL_NOT_IMPLEMENTED
;
2766 CheckForDeviceId(LPWSTR lpDeviceIdList
,
2772 lpPtr
= lpDeviceIdList
;
2775 dwLength
= wcslen(lpPtr
);
2776 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
2779 lpPtr
+= (dwLength
+ 1);
2787 AppendDeviceId(LPWSTR lpDeviceIdList
,
2788 LPDWORD lpDeviceIdListSize
,
2794 dwLen
= wcslen(lpDeviceId
);
2795 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
2797 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
2799 dwPos
+= (dwLen
+ 1);
2801 lpDeviceIdList
[dwPos
] = 0;
2803 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
2816 CONFIGRET ret
= CR_SUCCESS
;
2819 DWORD dwDeviceIdListSize
;
2820 DWORD dwNewDeviceIdSize
;
2821 WCHAR
* pszDeviceIdList
= NULL
;
2823 UNREFERENCED_PARAMETER(hBinding
);
2825 DPRINT("PNP_AddID() called\n");
2826 DPRINT(" DeviceInstance: %S\n", pszDeviceID
);
2827 DPRINT(" DeviceId: %S\n", pszID
);
2828 DPRINT(" Flags: %lx\n", ulFlags
);
2830 if (RegOpenKeyExW(hEnumKey
,
2833 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
2834 &hDeviceKey
) != ERROR_SUCCESS
)
2836 DPRINT("Failed to open the device key!\n");
2837 return CR_INVALID_DEVNODE
;
2840 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
2842 if (RegQueryValueExW(hDeviceKey
,
2847 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2849 DPRINT("Failed to query the desired ID string!\n");
2850 ret
= CR_REGISTRY_ERROR
;
2854 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
2855 if (!dwNewDeviceIdSize
)
2857 ret
= CR_INVALID_POINTER
;
2861 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
2863 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
2864 if (!pszDeviceIdList
)
2866 DPRINT("Failed to allocate memory for the desired ID string!\n");
2867 ret
= CR_OUT_OF_MEMORY
;
2871 if (RegQueryValueExW(hDeviceKey
,
2875 (LPBYTE
)pszDeviceIdList
,
2876 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2878 DPRINT("Failed to query the desired ID string!\n");
2879 ret
= CR_REGISTRY_ERROR
;
2883 /* Check whether the device ID is already in use */
2884 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
2886 DPRINT("Device ID was found in the ID string!\n");
2891 /* Append the Device ID */
2892 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
2894 if (RegSetValueExW(hDeviceKey
,
2898 (LPBYTE
)pszDeviceIdList
,
2899 dwDeviceIdListSize
) != ERROR_SUCCESS
)
2901 DPRINT("Failed to set the desired ID string!\n");
2902 ret
= CR_REGISTRY_ERROR
;
2906 RegCloseKey(hDeviceKey
);
2907 if (pszDeviceIdList
)
2908 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
2910 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
2925 return CR_CALL_NOT_IMPLEMENTED
;
2935 PPNP_VETO_TYPE pVetoType
,
2941 return CR_CALL_NOT_IMPLEMENTED
;
2948 PNP_RequestDeviceEject(
2951 PPNP_VETO_TYPE pVetoType
,
2957 return CR_CALL_NOT_IMPLEMENTED
;
2964 PNP_IsDockStationPresent(
2972 CONFIGRET ret
= CR_SUCCESS
;
2974 UNREFERENCED_PARAMETER(hBinding
);
2976 DPRINT1("PNP_IsDockStationPresent() called\n");
2980 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
2984 &hKey
) != ERROR_SUCCESS
)
2985 return CR_REGISTRY_ERROR
;
2987 dwSize
= sizeof(DWORD
);
2988 if (RegQueryValueExW(hKey
,
2993 &dwSize
) != ERROR_SUCCESS
)
2994 ret
= CR_REGISTRY_ERROR
;
2998 if (ret
== CR_SUCCESS
)
3000 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
3002 ret
= CR_REGISTRY_ERROR
;
3004 else if (dwValue
!= 0)
3010 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
3023 return CR_CALL_NOT_IMPLEMENTED
;
3036 PPNP_VETO_TYPE pVetoType
,
3041 CONFIGRET ret
= CR_SUCCESS
;
3042 WCHAR szKeyName
[MAX_PATH
];
3047 UNREFERENCED_PARAMETER(hBinding
);
3049 DPRINT("PNP_HwProfFlags() called\n");
3054 L
"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
3059 L
"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
3063 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
3067 &hKey
) != ERROR_SUCCESS
)
3068 return CR_REGISTRY_ERROR
;
3070 if (ulAction
== PNP_GET_HWPROFFLAGS
)
3072 if (RegOpenKeyExW(hKey
,
3076 &hDeviceKey
) != ERROR_SUCCESS
)
3082 dwSize
= sizeof(DWORD
);
3083 if (RegQueryValueExW(hDeviceKey
,
3088 &dwSize
) != ERROR_SUCCESS
)
3093 RegCloseKey(hDeviceKey
);
3096 else if (ulAction
== PNP_SET_HWPROFFLAGS
)
3098 /* FIXME: not implemented yet */
3099 ret
= CR_CALL_NOT_IMPLEMENTED
;
3114 HWPROFILEINFO
*pHWProfileInfo
,
3115 DWORD ulProfileInfoSize
,
3118 WCHAR szProfileName
[5];
3119 HKEY hKeyConfig
= NULL
;
3120 HKEY hKeyProfiles
= NULL
;
3121 HKEY hKeyProfile
= NULL
;
3122 DWORD dwDisposition
;
3125 CONFIGRET ret
= CR_SUCCESS
;
3127 UNREFERENCED_PARAMETER(hBinding
);
3129 DPRINT("PNP_GetHwProfInfo() called\n");
3131 if (ulProfileInfoSize
== 0)
3133 ret
= CR_INVALID_DATA
;
3139 ret
= CR_INVALID_FLAG
;
3143 /* Initialize the profile information */
3144 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3145 pHWProfileInfo
->HWPI_szFriendlyName
[0] = 0;
3146 pHWProfileInfo
->HWPI_dwFlags
= 0;
3148 /* Open the 'IDConfigDB' key */
3149 lError
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
3150 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
3153 REG_OPTION_NON_VOLATILE
,
3158 if (lError
!= ERROR_SUCCESS
)
3160 ret
= CR_REGISTRY_ERROR
;
3164 /* Open the 'Hardware Profiles' subkey */
3165 lError
= RegCreateKeyExW(hKeyConfig
,
3166 L
"Hardware Profiles",
3169 REG_OPTION_NON_VOLATILE
,
3170 KEY_ENUMERATE_SUB_KEYS
| KEY_QUERY_VALUE
,
3174 if (lError
!= ERROR_SUCCESS
)
3176 ret
= CR_REGISTRY_ERROR
;
3180 if (ulIndex
== (ULONG
)-1)
3182 dwSize
= sizeof(ULONG
);
3183 lError
= RegQueryValueExW(hKeyConfig
,
3187 (LPBYTE
)&pHWProfileInfo
->HWPI_ulHWProfile
,
3189 if (lError
!= ERROR_SUCCESS
)
3191 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3192 ret
= CR_REGISTRY_ERROR
;
3198 /* FIXME: not implemented yet */
3199 ret
= CR_CALL_NOT_IMPLEMENTED
;
3203 swprintf(szProfileName
, L
"%04lu", pHWProfileInfo
->HWPI_ulHWProfile
);
3205 lError
= RegOpenKeyExW(hKeyProfiles
,
3210 if (lError
!= ERROR_SUCCESS
)
3212 ret
= CR_REGISTRY_ERROR
;
3216 dwSize
= sizeof(pHWProfileInfo
->HWPI_szFriendlyName
);
3217 lError
= RegQueryValueExW(hKeyProfile
,
3221 (LPBYTE
)&pHWProfileInfo
->HWPI_szFriendlyName
,
3223 if (lError
!= ERROR_SUCCESS
)
3225 ret
= CR_REGISTRY_ERROR
;
3230 if (hKeyProfile
!= NULL
)
3231 RegCloseKey(hKeyProfile
);
3233 if (hKeyProfiles
!= NULL
)
3234 RegCloseKey(hKeyProfiles
);
3236 if (hKeyConfig
!= NULL
)
3237 RegCloseKey(hKeyConfig
);
3246 PNP_AddEmptyLogConf(
3250 DWORD
*pulLogConfTag
,
3254 return CR_CALL_NOT_IMPLEMENTED
;
3264 DWORD ulLogConfType
,
3269 return CR_CALL_NOT_IMPLEMENTED
;
3276 PNP_GetFirstLogConf(
3279 DWORD ulLogConfType
,
3280 DWORD
*pulLogConfTag
,
3284 return CR_CALL_NOT_IMPLEMENTED
;
3294 DWORD ulLogConfType
,
3300 return CR_CALL_NOT_IMPLEMENTED
;
3307 PNP_GetLogConfPriority(
3316 return CR_CALL_NOT_IMPLEMENTED
;
3327 DWORD ulLogConfType
,
3328 RESOURCEID ResourceID
,
3329 DWORD
*pulResourceTag
,
3331 PNP_RPC_BUFFER_SIZE ResourceLen
,
3335 return CR_CALL_NOT_IMPLEMENTED
;
3346 DWORD ulLogConfType
,
3347 RESOURCEID ResourceID
,
3348 DWORD ulResourceTag
,
3349 DWORD
*pulPreviousResType
,
3350 DWORD
*pulPreviousResTag
,
3354 return CR_CALL_NOT_IMPLEMENTED
;
3365 DWORD ulLogConfType
,
3366 RESOURCEID ResourceID
,
3367 DWORD ulResourceTag
,
3368 DWORD
*pulNextResType
,
3369 DWORD
*pulNextResTag
,
3373 return CR_CALL_NOT_IMPLEMENTED
;
3384 DWORD ulLogConfType
,
3385 RESOURCEID ResourceID
,
3386 DWORD ulResourceTag
,
3388 PNP_RPC_BUFFER_SIZE BufferLen
,
3392 return CR_CALL_NOT_IMPLEMENTED
;
3399 PNP_GetResDesDataSize(
3403 DWORD ulLogConfType
,
3404 RESOURCEID ResourceID
,
3405 DWORD ulResourceTag
,
3410 return CR_CALL_NOT_IMPLEMENTED
;
3421 DWORD ulLogConfType
,
3422 RESOURCEID CurrentResourceID
,
3423 RESOURCEID NewResourceID
,
3424 DWORD ulResourceTag
,
3426 PNP_RPC_BUFFER_SIZE ResourceLen
,
3430 return CR_CALL_NOT_IMPLEMENTED
;
3437 PNP_DetectResourceConflict(
3440 RESOURCEID ResourceID
,
3442 PNP_RPC_BUFFER_SIZE ResourceLen
,
3443 BOOL
*pbConflictDetected
,
3446 DPRINT("PNP_DetectResourceConflict()\n");
3448 if (pbConflictDetected
!= NULL
)
3449 *pbConflictDetected
= FALSE
;
3451 return CR_CALL_NOT_IMPLEMENTED
;
3458 PNP_QueryResConfList(
3461 RESOURCEID ResourceID
,
3463 PNP_RPC_BUFFER_SIZE ResourceLen
,
3465 PNP_RPC_BUFFER_SIZE BufferLen
,
3469 return CR_CALL_NOT_IMPLEMENTED
;
3478 DWORD ulHardwareProfile
,
3481 return CR_CALL_NOT_IMPLEMENTED
;
3488 PNP_QueryArbitratorFreeData(
3493 RESOURCEID ResourceID
,
3496 return CR_CALL_NOT_IMPLEMENTED
;
3503 PNP_QueryArbitratorFreeSize(
3507 RESOURCEID ResourceID
,
3510 if (pulSize
!= NULL
)
3513 return CR_CALL_NOT_IMPLEMENTED
;
3524 return CR_CALL_NOT_IMPLEMENTED
;
3531 PNP_RegisterNotification(
3535 BYTE
*pNotificationFilter
,
3536 DWORD ulNotificationFilterSize
,
3543 PNOTIFY_DATA pNotifyData
;
3546 DPRINT1("PNP_RegisterNotification(%p %lx %lx %p %lu 0x%lx %p %lx %p)\n",
3547 hBinding
, ulUnknown2
, ulUnknown3
, pNotificationFilter
,
3548 ulNotificationFilterSize
, ulFlags
, pulNotify
, ulUnknown8
, pulUnknown9
);
3550 if (pNotificationFilter
== NULL
||
3551 pulNotify
== NULL
||
3552 pulUnknown9
== NULL
)
3553 return CR_INVALID_POINTER
;
3556 return CR_INVALID_FLAG
;
3559 pNotifyData
= RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(NOTIFY_DATA
));
3560 if (pNotifyData
== NULL
)
3561 return CR_OUT_OF_MEMORY
;
3563 *pulNotify
= (DWORD
)pNotifyData
;
3575 PNP_UnregisterNotification(
3579 DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
3580 hBinding
, ulNotify
);
3584 return CR_CALL_NOT_IMPLEMENTED
;
3594 PNP_GetCustomDevProp(
3597 LPWSTR CustomPropName
,
3598 DWORD
*pulRegDataType
,
3600 PNP_RPC_STRING_LEN
*pulTransferLen
,
3601 PNP_RPC_STRING_LEN
*pulLength
,
3604 HKEY hDeviceKey
= NULL
;
3605 HKEY hParamKey
= NULL
;
3607 CONFIGRET ret
= CR_SUCCESS
;
3609 UNREFERENCED_PARAMETER(hBinding
);
3611 DPRINT("PNP_GetCustomDevProp() called\n");
3613 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
3615 ret
= CR_INVALID_POINTER
;
3619 if (ulFlags
& ~CM_CUSTOMDEVPROP_BITS
)
3621 ret
= CR_INVALID_FLAG
;
3625 if (*pulLength
< *pulTransferLen
)
3626 *pulLength
= *pulTransferLen
;
3628 *pulTransferLen
= 0;
3630 lError
= RegOpenKeyExW(hEnumKey
,
3635 if (lError
!= ERROR_SUCCESS
)
3637 ret
= CR_REGISTRY_ERROR
;
3641 lError
= RegOpenKeyExW(hDeviceKey
,
3642 L
"Device Parameters",
3646 if (lError
!= ERROR_SUCCESS
)
3648 ret
= CR_REGISTRY_ERROR
;
3652 lError
= RegQueryValueExW(hParamKey
,
3658 if (lError
!= ERROR_SUCCESS
)
3660 if (lError
== ERROR_MORE_DATA
)
3662 ret
= CR_BUFFER_SMALL
;
3667 ret
= CR_NO_SUCH_VALUE
;
3672 if (ret
== CR_SUCCESS
)
3673 *pulTransferLen
= *pulLength
;
3675 if (hParamKey
!= NULL
)
3676 RegCloseKey(hParamKey
);
3678 if (hDeviceKey
!= NULL
)
3679 RegCloseKey(hDeviceKey
);
3681 DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret
);
3690 PNP_GetVersionInternal(
3694 UNREFERENCED_PARAMETER(hBinding
);
3704 PNP_GetBlockedDriverInfo(
3707 PNP_RPC_BUFFER_SIZE
*pulTransferLen
,
3708 PNP_RPC_BUFFER_SIZE
*pulLength
,
3712 return CR_CALL_NOT_IMPLEMENTED
;
3719 PNP_GetServerSideDeviceInstallFlags(
3721 DWORD
*pulSSDIFlags
,
3724 UNREFERENCED_PARAMETER(hBinding
);
3726 DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
3727 hBinding
, pulSSDIFlags
, ulFlags
);
3729 if (pulSSDIFlags
== NULL
)
3730 return CR_INVALID_POINTER
;
3733 return CR_INVALID_FLAG
;
3745 PNP_GetObjectPropKeys(
3749 LPWSTR PropertyCultureName
,
3750 PNP_PROP_COUNT
*PropertyCount
,
3751 PNP_PROP_COUNT
*TransferLen
,
3752 DEVPROPKEY
*PropertyKeys
,
3756 return CR_CALL_NOT_IMPLEMENTED
;
3767 LPWSTR PropertyCultureName
,
3768 const DEVPROPKEY
*PropertyKey
,
3769 DEVPROPTYPE
*PropertyType
,
3770 PNP_PROP_SIZE
*PropertySize
,
3771 PNP_PROP_SIZE
*TransferLen
,
3772 BYTE
*PropertyBuffer
,
3776 return CR_CALL_NOT_IMPLEMENTED
;
3787 LPWSTR PropertyCultureName
,
3788 const DEVPROPKEY
*PropertyKey
,
3789 DEVPROPTYPE PropertyType
,
3790 PNP_PROP_SIZE PropertySize
,
3791 BYTE
*PropertyBuffer
,
3795 return CR_CALL_NOT_IMPLEMENTED
;
3806 return CR_CALL_NOT_IMPLEMENTED
;
3813 PNP_ApplyPowerSettings(
3817 return CR_CALL_NOT_IMPLEMENTED
;
3824 PNP_DriverStoreAddDriverPackage(
3828 return CR_CALL_NOT_IMPLEMENTED
;
3835 PNP_DriverStoreDeleteDriverPackage(
3839 return CR_CALL_NOT_IMPLEMENTED
;
3846 PNP_RegisterServiceNotification(
3850 return CR_CALL_NOT_IMPLEMENTED
;
3857 PNP_SetActiveService(
3863 return CR_CALL_NOT_IMPLEMENTED
;
3870 PNP_DeleteServiceDevices(
3874 return CR_CALL_NOT_IMPLEMENTED
;