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
)
1747 return CR_CALL_NOT_IMPLEMENTED
;
1762 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
1771 return CR_REGISTRY_ERROR
;
1773 /* FIXME: Set security key */
1784 PNP_DeleteRegistryKey(
1787 LPWSTR pszParentKey
,
1792 return CR_CALL_NOT_IMPLEMENTED
;
1801 DWORD
*pulClassCount
,
1807 UNREFERENCED_PARAMETER(hBinding
);
1808 UNREFERENCED_PARAMETER(ulFlags
);
1810 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1815 if (dwError
!= ERROR_SUCCESS
)
1816 return CR_INVALID_DATA
;
1818 dwError
= RegQueryInfoKeyW(hKey
,
1831 if (dwError
!= ERROR_SUCCESS
)
1832 return CR_INVALID_DATA
;
1843 LPWSTR pszClassGuid
,
1845 PNP_RPC_STRING_LEN
*pulLength
,
1848 WCHAR szKeyName
[MAX_PATH
];
1849 CONFIGRET ret
= CR_SUCCESS
;
1853 UNREFERENCED_PARAMETER(hBinding
);
1854 UNREFERENCED_PARAMETER(ulFlags
);
1856 DPRINT("PNP_GetClassName() called\n");
1858 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
1859 if (lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
1860 lstrcatW(szKeyName
, pszClassGuid
);
1862 return CR_INVALID_DATA
;
1864 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1869 return CR_REGISTRY_ERROR
;
1871 dwSize
= *pulLength
* sizeof(WCHAR
);
1872 if (RegQueryValueExW(hKey
,
1880 ret
= CR_REGISTRY_ERROR
;
1884 *pulLength
= dwSize
/ sizeof(WCHAR
);
1889 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
1900 LPWSTR pszClassGuid
,
1903 CONFIGRET ret
= CR_SUCCESS
;
1905 UNREFERENCED_PARAMETER(hBinding
);
1907 DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid
, ulFlags
);
1909 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
1911 if (SHDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
1912 ret
= CR_REGISTRY_ERROR
;
1916 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
1917 ret
= CR_REGISTRY_ERROR
;
1920 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
1929 PNP_GetInterfaceDeviceAlias(
1931 LPWSTR pszInterfaceDevice
,
1932 GUID
*AliasInterfaceGuid
,
1933 LPWSTR pszAliasInterfaceDevice
,
1934 PNP_RPC_STRING_LEN
*pulLength
,
1935 PNP_RPC_STRING_LEN
*pulTransferLen
,
1939 return CR_CALL_NOT_IMPLEMENTED
;
1946 PNP_GetInterfaceDeviceList(
1948 GUID
*InterfaceGuid
,
1951 PNP_RPC_BUFFER_SIZE
*pulLength
,
1955 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
1956 DWORD ret
= CR_SUCCESS
;
1958 UNREFERENCED_PARAMETER(hBinding
);
1960 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1963 PlugPlayData
.Flags
= ulFlags
;
1964 PlugPlayData
.FilterGuid
= InterfaceGuid
;
1965 PlugPlayData
.Buffer
= Buffer
;
1966 PlugPlayData
.BufferSize
= *pulLength
;
1968 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
1969 (PVOID
)&PlugPlayData
,
1970 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
1971 if (NT_SUCCESS(Status
))
1973 *pulLength
= PlugPlayData
.BufferSize
;
1977 ret
= NtStatusToCrError(Status
);
1980 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
1988 PNP_GetInterfaceDeviceListSize(
1990 PNP_RPC_BUFFER_SIZE
*pulLen
,
1991 GUID
*InterfaceGuid
,
1996 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
1997 DWORD ret
= CR_SUCCESS
;
1999 UNREFERENCED_PARAMETER(hBinding
);
2001 DPRINT("PNP_GetInterfaceDeviceListSize() called\n");
2003 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2006 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2007 PlugPlayData
.Buffer
= NULL
;
2008 PlugPlayData
.BufferSize
= 0;
2009 PlugPlayData
.Flags
= ulFlags
;
2011 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2012 (PVOID
)&PlugPlayData
,
2013 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2014 if (NT_SUCCESS(Status
))
2016 *pulLen
= PlugPlayData
.BufferSize
;
2020 ret
= NtStatusToCrError(Status
);
2023 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2031 PNP_RegisterDeviceClassAssociation(
2034 GUID
*InterfaceGuid
,
2035 LPWSTR pszReference
,
2037 PNP_RPC_STRING_LEN
*pulLength
,
2038 PNP_RPC_STRING_LEN
*pulTransferLen
,
2042 return CR_CALL_NOT_IMPLEMENTED
;
2049 PNP_UnregisterDeviceClassAssociation(
2051 LPWSTR pszInterfaceDevice
,
2055 return CR_CALL_NOT_IMPLEMENTED
;
2062 PNP_GetClassRegProp(
2064 LPWSTR pszClassGuid
,
2066 DWORD
*pulRegDataType
,
2068 PNP_RPC_STRING_LEN
*pulTransferLen
,
2069 PNP_RPC_STRING_LEN
*pulLength
,
2072 CONFIGRET ret
= CR_SUCCESS
;
2073 LPWSTR lpValueName
= NULL
;
2074 HKEY hInstKey
= NULL
;
2075 HKEY hPropKey
= NULL
;
2078 UNREFERENCED_PARAMETER(hBinding
);
2080 DPRINT("PNP_GetClassRegProp() called\n");
2082 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
2084 ret
= CR_INVALID_POINTER
;
2090 ret
= CR_INVALID_FLAG
;
2094 if (*pulLength
< *pulTransferLen
)
2095 *pulLength
= *pulTransferLen
;
2097 *pulTransferLen
= 0;
2101 case CM_CRP_SECURITY
:
2102 lpValueName
= L
"Security";
2105 case CM_CRP_DEVTYPE
:
2106 lpValueName
= L
"DeviceType";
2109 case CM_CRP_EXCLUSIVE
:
2110 lpValueName
= L
"Exclusive";
2113 case CM_CRP_CHARACTERISTICS
:
2114 lpValueName
= L
"DeviceCharacteristics";
2118 ret
= CR_INVALID_PROPERTY
;
2122 DPRINT("Value name: %S\n", lpValueName
);
2124 lError
= RegOpenKeyExW(hClassKey
,
2129 if (lError
!= ERROR_SUCCESS
)
2132 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2136 lError
= RegOpenKeyExW(hInstKey
,
2141 if (lError
!= ERROR_SUCCESS
)
2144 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2148 lError
= RegQueryValueExW(hPropKey
,
2154 if (lError
!= ERROR_SUCCESS
)
2156 if (lError
== ERROR_MORE_DATA
)
2158 ret
= CR_BUFFER_SMALL
;
2163 ret
= CR_NO_SUCH_VALUE
;
2168 if (ret
== CR_SUCCESS
)
2169 *pulTransferLen
= *pulLength
;
2171 if (hPropKey
!= NULL
)
2172 RegCloseKey(hPropKey
);
2174 if (hInstKey
!= NULL
)
2175 RegCloseKey(hInstKey
);
2177 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret
);
2186 PNP_SetClassRegProp(
2188 LPWSTR pszClassGuid
,
2192 PNP_PROP_SIZE ulLength
,
2195 CONFIGRET ret
= CR_SUCCESS
;
2196 LPWSTR lpValueName
= NULL
;
2201 UNREFERENCED_PARAMETER(hBinding
);
2203 DPRINT("PNP_SetClassRegProp() called\n");
2206 return CR_INVALID_FLAG
;
2210 case CM_CRP_SECURITY
:
2211 lpValueName
= L
"Security";
2214 case CM_CRP_DEVTYPE
:
2215 lpValueName
= L
"DeviceType";
2218 case CM_CRP_EXCLUSIVE
:
2219 lpValueName
= L
"Exclusive";
2222 case CM_CRP_CHARACTERISTICS
:
2223 lpValueName
= L
"DeviceCharacteristics";
2227 return CR_INVALID_PROPERTY
;
2230 lError
= RegOpenKeyExW(hClassKey
,
2235 if (lError
!= ERROR_SUCCESS
)
2237 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2241 /* FIXME: Set security descriptor */
2242 lError
= RegCreateKeyExW(hInstKey
,
2246 REG_OPTION_NON_VOLATILE
,
2251 if (lError
!= ERROR_SUCCESS
)
2253 ret
= CR_REGISTRY_ERROR
;
2259 if (RegDeleteValueW(hPropKey
,
2261 ret
= CR_REGISTRY_ERROR
;
2265 if (RegSetValueExW(hPropKey
,
2271 ret
= CR_REGISTRY_ERROR
;
2275 if (hPropKey
!= NULL
)
2276 RegCloseKey(hPropKey
);
2278 if (hInstKey
!= NULL
)
2279 RegCloseKey(hInstKey
);
2286 CreateDeviceInstance(LPWSTR pszDeviceID
)
2288 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
2289 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
2290 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
2291 HKEY hKeyEnumerator
;
2297 /* Split the instance ID */
2298 SplitDeviceInstanceID(pszDeviceID
,
2303 /* Open or create the enumerator key */
2304 lError
= RegCreateKeyExW(hEnumKey
,
2308 REG_OPTION_NON_VOLATILE
,
2313 if (lError
!= ERROR_SUCCESS
)
2315 return CR_REGISTRY_ERROR
;
2318 /* Open or create the device key */
2319 lError
= RegCreateKeyExW(hKeyEnumerator
,
2323 REG_OPTION_NON_VOLATILE
,
2329 /* Close the enumerator key */
2330 RegCloseKey(hKeyEnumerator
);
2332 if (lError
!= ERROR_SUCCESS
)
2334 return CR_REGISTRY_ERROR
;
2337 /* Try to open the instance key and fail if it exists */
2338 lError
= RegOpenKeyExW(hKeyDevice
,
2343 if (lError
== ERROR_SUCCESS
)
2345 DPRINT1("Instance %S already exists!\n", szInstance
);
2346 RegCloseKey(hKeyInstance
);
2347 RegCloseKey(hKeyDevice
);
2348 return CR_ALREADY_SUCH_DEVINST
;
2351 /* Create a new instance key */
2352 lError
= RegCreateKeyExW(hKeyDevice
,
2356 REG_OPTION_NON_VOLATILE
,
2362 /* Close the device key */
2363 RegCloseKey(hKeyDevice
);
2365 if (lError
!= ERROR_SUCCESS
)
2367 return CR_REGISTRY_ERROR
;
2370 /* Create the 'Control' sub key */
2371 lError
= RegCreateKeyExW(hKeyInstance
,
2375 REG_OPTION_NON_VOLATILE
,
2380 if (lError
== ERROR_SUCCESS
)
2382 RegCloseKey(hKeyControl
);
2385 RegCloseKey(hKeyInstance
);
2387 return (lError
== ERROR_SUCCESS
) ? CR_SUCCESS
: CR_REGISTRY_ERROR
;
2397 LPWSTR pszParentDeviceID
,
2398 PNP_RPC_STRING_LEN ulLength
,
2401 CONFIGRET ret
= CR_SUCCESS
;
2403 DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID
);
2405 if (ulFlags
& CM_CREATE_DEVNODE_GENERATE_ID
)
2407 WCHAR szGeneratedInstance
[MAX_DEVICE_ID_LEN
];
2408 DWORD dwInstanceNumber
;
2410 /* Generated ID is: Root\<Device ID>\<Instance number> */
2411 dwInstanceNumber
= 0;
2414 swprintf(szGeneratedInstance
, L
"Root\\%ls\\%04lu",
2415 pszDeviceID
, dwInstanceNumber
);
2417 /* Try to create a device instance with this ID */
2418 ret
= CreateDeviceInstance(szGeneratedInstance
);
2422 while (ret
== CR_ALREADY_SUCH_DEVINST
);
2424 if (ret
== CR_SUCCESS
)
2426 /* pszDeviceID is an out parameter too for generated IDs */
2427 if (wcslen(szGeneratedInstance
) > ulLength
)
2429 ret
= CR_BUFFER_SMALL
;
2433 wcscpy(pszDeviceID
, szGeneratedInstance
);
2439 /* Create the device instance */
2440 ret
= CreateDeviceInstance(pszDeviceID
);
2443 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret
);
2450 MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination
,
2451 LPWSTR pszDeviceInstanceSource
)
2453 DPRINT("MoveDeviceInstance: not implemented\n");
2455 return CR_CALL_NOT_IMPLEMENTED
;
2460 SetupDeviceInstance(LPWSTR pszDeviceInstance
,
2463 DPRINT("SetupDeviceInstance: not implemented\n");
2465 return CR_CALL_NOT_IMPLEMENTED
;
2470 EnableDeviceInstance(LPWSTR pszDeviceInstance
)
2472 PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
;
2473 CONFIGRET ret
= CR_SUCCESS
;
2476 DPRINT("Enable device instance %S\n", pszDeviceInstance
);
2478 RtlInitUnicodeString(&ResetDeviceData
.DeviceInstance
, pszDeviceInstance
);
2479 Status
= NtPlugPlayControl(PlugPlayControlResetDevice
, &ResetDeviceData
, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
));
2480 if (!NT_SUCCESS(Status
))
2481 ret
= NtStatusToCrError(Status
);
2488 DisableDeviceInstance(LPWSTR pszDeviceInstance
)
2490 DPRINT("DisableDeviceInstance: not implemented\n");
2492 return CR_CALL_NOT_IMPLEMENTED
;
2497 ReenumerateDeviceInstance(
2498 _In_ LPWSTR pszDeviceInstance
,
2501 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData
;
2502 CONFIGRET ret
= CR_SUCCESS
;
2505 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
2506 pszDeviceInstance
, ulFlags
);
2508 if (ulFlags
& ~CM_REENUMERATE_BITS
)
2509 return CR_INVALID_FLAG
;
2511 if (ulFlags
& CM_REENUMERATE_RETRY_INSTALLATION
)
2513 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
2516 RtlInitUnicodeString(&EnumerateDeviceData
.DeviceInstance
,
2518 EnumerateDeviceData
.Flags
= 0;
2520 Status
= NtPlugPlayControl(PlugPlayControlEnumerateDevice
,
2521 &EnumerateDeviceData
,
2522 sizeof(PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA
));
2523 if (!NT_SUCCESS(Status
))
2524 ret
= NtStatusToCrError(Status
);
2533 PNP_DeviceInstanceAction(
2537 LPWSTR pszDeviceInstance1
,
2538 LPWSTR pszDeviceInstance2
)
2540 CONFIGRET ret
= CR_SUCCESS
;
2542 UNREFERENCED_PARAMETER(hBinding
);
2544 DPRINT("PNP_DeviceInstanceAction() called\n");
2548 case PNP_DEVINST_MOVE
:
2549 ret
= MoveDeviceInstance(pszDeviceInstance1
,
2550 pszDeviceInstance2
);
2553 case PNP_DEVINST_SETUP
:
2554 ret
= SetupDeviceInstance(pszDeviceInstance1
,
2558 case PNP_DEVINST_ENABLE
:
2559 ret
= EnableDeviceInstance(pszDeviceInstance1
);
2562 case PNP_DEVINST_DISABLE
:
2563 ret
= DisableDeviceInstance(pszDeviceInstance1
);
2566 case PNP_DEVINST_REENUMERATE
:
2567 ret
= ReenumerateDeviceInstance(pszDeviceInstance1
,
2572 DPRINT1("Unknown device action %lu: not implemented\n", ulAction
);
2573 ret
= CR_CALL_NOT_IMPLEMENTED
;
2576 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
2585 PNP_GetDeviceStatus(
2592 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
2593 CONFIGRET ret
= CR_SUCCESS
;
2596 UNREFERENCED_PARAMETER(hBinding
);
2597 UNREFERENCED_PARAMETER(ulFlags
);
2599 DPRINT("PNP_GetDeviceStatus() called\n");
2601 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2603 PlugPlayData
.Operation
= 0; /* Get status */
2605 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
2606 (PVOID
)&PlugPlayData
,
2607 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
2608 if (NT_SUCCESS(Status
))
2610 *pulStatus
= PlugPlayData
.DeviceStatus
;
2611 *pulProblem
= PlugPlayData
.DeviceProblem
;
2615 ret
= NtStatusToCrError(Status
);
2618 DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret
);
2627 PNP_SetDeviceProblem(
2634 return CR_CALL_NOT_IMPLEMENTED
;
2644 PPNP_VETO_TYPE pVetoType
,
2650 return CR_CALL_NOT_IMPLEMENTED
;
2656 PNP_UninstallDevInst(
2662 return CR_CALL_NOT_IMPLEMENTED
;
2667 CheckForDeviceId(LPWSTR lpDeviceIdList
,
2673 lpPtr
= lpDeviceIdList
;
2676 dwLength
= wcslen(lpPtr
);
2677 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
2680 lpPtr
+= (dwLength
+ 1);
2688 AppendDeviceId(LPWSTR lpDeviceIdList
,
2689 LPDWORD lpDeviceIdListSize
,
2695 dwLen
= wcslen(lpDeviceId
);
2696 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
2698 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
2700 dwPos
+= (dwLen
+ 1);
2702 lpDeviceIdList
[dwPos
] = 0;
2704 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
2717 CONFIGRET ret
= CR_SUCCESS
;
2720 DWORD dwDeviceIdListSize
;
2721 DWORD dwNewDeviceIdSize
;
2722 WCHAR
* pszDeviceIdList
= NULL
;
2724 UNREFERENCED_PARAMETER(hBinding
);
2726 DPRINT("PNP_AddID() called\n");
2727 DPRINT(" DeviceInstance: %S\n", pszDeviceID
);
2728 DPRINT(" DeviceId: %S\n", pszID
);
2729 DPRINT(" Flags: %lx\n", ulFlags
);
2731 if (RegOpenKeyExW(hEnumKey
,
2734 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
2735 &hDeviceKey
) != ERROR_SUCCESS
)
2737 DPRINT("Failed to open the device key!\n");
2738 return CR_INVALID_DEVNODE
;
2741 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
2743 if (RegQueryValueExW(hDeviceKey
,
2748 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2750 DPRINT("Failed to query the desired ID string!\n");
2751 ret
= CR_REGISTRY_ERROR
;
2755 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
2756 if (!dwNewDeviceIdSize
)
2758 ret
= CR_INVALID_POINTER
;
2762 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
2764 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
2765 if (!pszDeviceIdList
)
2767 DPRINT("Failed to allocate memory for the desired ID string!\n");
2768 ret
= CR_OUT_OF_MEMORY
;
2772 if (RegQueryValueExW(hDeviceKey
,
2776 (LPBYTE
)pszDeviceIdList
,
2777 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2779 DPRINT("Failed to query the desired ID string!\n");
2780 ret
= CR_REGISTRY_ERROR
;
2784 /* Check whether the device ID is already in use */
2785 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
2787 DPRINT("Device ID was found in the ID string!\n");
2792 /* Append the Device ID */
2793 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
2795 if (RegSetValueExW(hDeviceKey
,
2799 (LPBYTE
)pszDeviceIdList
,
2800 dwDeviceIdListSize
) != ERROR_SUCCESS
)
2802 DPRINT("Failed to set the desired ID string!\n");
2803 ret
= CR_REGISTRY_ERROR
;
2807 RegCloseKey(hDeviceKey
);
2808 if (pszDeviceIdList
)
2809 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
2811 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
2826 return CR_CALL_NOT_IMPLEMENTED
;
2836 PPNP_VETO_TYPE pVetoType
,
2842 return CR_CALL_NOT_IMPLEMENTED
;
2849 PNP_RequestDeviceEject(
2852 PPNP_VETO_TYPE pVetoType
,
2858 return CR_CALL_NOT_IMPLEMENTED
;
2865 PNP_IsDockStationPresent(
2873 CONFIGRET ret
= CR_SUCCESS
;
2875 UNREFERENCED_PARAMETER(hBinding
);
2877 DPRINT1("PNP_IsDockStationPresent() called\n");
2881 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
2885 &hKey
) != ERROR_SUCCESS
)
2886 return CR_REGISTRY_ERROR
;
2888 dwSize
= sizeof(DWORD
);
2889 if (RegQueryValueExW(hKey
,
2894 &dwSize
) != ERROR_SUCCESS
)
2895 ret
= CR_REGISTRY_ERROR
;
2899 if (ret
== CR_SUCCESS
)
2901 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
2903 ret
= CR_REGISTRY_ERROR
;
2905 else if (dwValue
!= 0)
2911 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
2924 return CR_CALL_NOT_IMPLEMENTED
;
2937 PPNP_VETO_TYPE pVetoType
,
2942 CONFIGRET ret
= CR_SUCCESS
;
2943 WCHAR szKeyName
[MAX_PATH
];
2948 UNREFERENCED_PARAMETER(hBinding
);
2950 DPRINT("PNP_HwProfFlags() called\n");
2955 L
"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
2960 L
"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
2964 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2968 &hKey
) != ERROR_SUCCESS
)
2969 return CR_REGISTRY_ERROR
;
2971 if (ulAction
== PNP_GET_HWPROFFLAGS
)
2973 if (RegOpenKeyExW(hKey
,
2977 &hDeviceKey
) != ERROR_SUCCESS
)
2983 dwSize
= sizeof(DWORD
);
2984 if (RegQueryValueExW(hDeviceKey
,
2989 &dwSize
) != ERROR_SUCCESS
)
2994 RegCloseKey(hDeviceKey
);
2997 else if (ulAction
== PNP_SET_HWPROFFLAGS
)
2999 /* FIXME: not implemented yet */
3000 ret
= CR_CALL_NOT_IMPLEMENTED
;
3015 HWPROFILEINFO
*pHWProfileInfo
,
3016 DWORD ulProfileInfoSize
,
3019 WCHAR szProfileName
[5];
3020 HKEY hKeyConfig
= NULL
;
3021 HKEY hKeyProfiles
= NULL
;
3022 HKEY hKeyProfile
= NULL
;
3023 DWORD dwDisposition
;
3026 CONFIGRET ret
= CR_SUCCESS
;
3028 UNREFERENCED_PARAMETER(hBinding
);
3030 DPRINT("PNP_GetHwProfInfo() called\n");
3032 if (ulProfileInfoSize
== 0)
3034 ret
= CR_INVALID_DATA
;
3040 ret
= CR_INVALID_FLAG
;
3044 /* Initialize the profile information */
3045 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3046 pHWProfileInfo
->HWPI_szFriendlyName
[0] = 0;
3047 pHWProfileInfo
->HWPI_dwFlags
= 0;
3049 /* Open the 'IDConfigDB' key */
3050 lError
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
3051 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
3054 REG_OPTION_NON_VOLATILE
,
3059 if (lError
!= ERROR_SUCCESS
)
3061 ret
= CR_REGISTRY_ERROR
;
3065 /* Open the 'Hardware Profiles' subkey */
3066 lError
= RegCreateKeyExW(hKeyConfig
,
3067 L
"Hardware Profiles",
3070 REG_OPTION_NON_VOLATILE
,
3071 KEY_ENUMERATE_SUB_KEYS
| KEY_QUERY_VALUE
,
3075 if (lError
!= ERROR_SUCCESS
)
3077 ret
= CR_REGISTRY_ERROR
;
3081 if (ulIndex
== (ULONG
)-1)
3083 dwSize
= sizeof(ULONG
);
3084 lError
= RegQueryValueExW(hKeyConfig
,
3088 (LPBYTE
)&pHWProfileInfo
->HWPI_ulHWProfile
,
3090 if (lError
!= ERROR_SUCCESS
)
3092 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3093 ret
= CR_REGISTRY_ERROR
;
3099 /* FIXME: not implemented yet */
3100 ret
= CR_CALL_NOT_IMPLEMENTED
;
3104 swprintf(szProfileName
, L
"%04lu", pHWProfileInfo
->HWPI_ulHWProfile
);
3106 lError
= RegOpenKeyExW(hKeyProfiles
,
3111 if (lError
!= ERROR_SUCCESS
)
3113 ret
= CR_REGISTRY_ERROR
;
3117 dwSize
= sizeof(pHWProfileInfo
->HWPI_szFriendlyName
);
3118 lError
= RegQueryValueExW(hKeyProfile
,
3122 (LPBYTE
)&pHWProfileInfo
->HWPI_szFriendlyName
,
3124 if (lError
!= ERROR_SUCCESS
)
3126 ret
= CR_REGISTRY_ERROR
;
3131 if (hKeyProfile
!= NULL
)
3132 RegCloseKey(hKeyProfile
);
3134 if (hKeyProfiles
!= NULL
)
3135 RegCloseKey(hKeyProfiles
);
3137 if (hKeyConfig
!= NULL
)
3138 RegCloseKey(hKeyConfig
);
3147 PNP_AddEmptyLogConf(
3151 DWORD
*pulLogConfTag
,
3155 return CR_CALL_NOT_IMPLEMENTED
;
3165 DWORD ulLogConfType
,
3170 return CR_CALL_NOT_IMPLEMENTED
;
3177 PNP_GetFirstLogConf(
3180 DWORD ulLogConfType
,
3181 DWORD
*pulLogConfTag
,
3185 return CR_CALL_NOT_IMPLEMENTED
;
3195 DWORD ulLogConfType
,
3201 return CR_CALL_NOT_IMPLEMENTED
;
3208 PNP_GetLogConfPriority(
3217 return CR_CALL_NOT_IMPLEMENTED
;
3228 DWORD ulLogConfType
,
3229 RESOURCEID ResourceID
,
3230 DWORD
*pulResourceTag
,
3232 PNP_RPC_BUFFER_SIZE ResourceLen
,
3236 return CR_CALL_NOT_IMPLEMENTED
;
3247 DWORD ulLogConfType
,
3248 RESOURCEID ResourceID
,
3249 DWORD ulResourceTag
,
3250 DWORD
*pulPreviousResType
,
3251 DWORD
*pulPreviousResTag
,
3255 return CR_CALL_NOT_IMPLEMENTED
;
3266 DWORD ulLogConfType
,
3267 RESOURCEID ResourceID
,
3268 DWORD ulResourceTag
,
3269 DWORD
*pulNextResType
,
3270 DWORD
*pulNextResTag
,
3274 return CR_CALL_NOT_IMPLEMENTED
;
3285 DWORD ulLogConfType
,
3286 RESOURCEID ResourceID
,
3287 DWORD ulResourceTag
,
3289 PNP_RPC_BUFFER_SIZE BufferLen
,
3293 return CR_CALL_NOT_IMPLEMENTED
;
3300 PNP_GetResDesDataSize(
3304 DWORD ulLogConfType
,
3305 RESOURCEID ResourceID
,
3306 DWORD ulResourceTag
,
3311 return CR_CALL_NOT_IMPLEMENTED
;
3322 DWORD ulLogConfType
,
3323 RESOURCEID CurrentResourceID
,
3324 RESOURCEID NewResourceID
,
3325 DWORD ulResourceTag
,
3327 PNP_RPC_BUFFER_SIZE ResourceLen
,
3331 return CR_CALL_NOT_IMPLEMENTED
;
3338 PNP_DetectResourceConflict(
3341 RESOURCEID ResourceID
,
3343 PNP_RPC_BUFFER_SIZE ResourceLen
,
3344 BOOL
*pbConflictDetected
,
3347 DPRINT("PNP_DetectResourceConflict()\n");
3349 if (pbConflictDetected
!= NULL
)
3350 *pbConflictDetected
= FALSE
;
3352 return CR_CALL_NOT_IMPLEMENTED
;
3359 PNP_QueryResConfList(
3362 RESOURCEID ResourceID
,
3364 PNP_RPC_BUFFER_SIZE ResourceLen
,
3366 PNP_RPC_BUFFER_SIZE BufferLen
,
3370 return CR_CALL_NOT_IMPLEMENTED
;
3379 DWORD ulHardwareProfile
,
3383 return CR_CALL_NOT_IMPLEMENTED
;
3390 PNP_QueryArbitratorFreeData(
3395 RESOURCEID ResourceID
,
3398 return CR_CALL_NOT_IMPLEMENTED
;
3405 PNP_QueryArbitratorFreeSize(
3409 RESOURCEID ResourceID
,
3412 if (pulSize
!= NULL
)
3415 return CR_CALL_NOT_IMPLEMENTED
;
3426 return CR_CALL_NOT_IMPLEMENTED
;
3433 PNP_RegisterNotification(
3439 PNOTIFY_DATA pNotifyData
;
3442 DPRINT1("PNP_RegisterNotification(%p 0x%lx %p)\n",
3443 hBinding
, ulFlags
, pulNotify
);
3446 pNotifyData
= RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(NOTIFY_DATA
));
3447 if (pNotifyData
== NULL
)
3448 return CR_OUT_OF_MEMORY
;
3450 *pulNotify
= (DWORD
)pNotifyData
;
3462 PNP_UnregisterNotification(
3466 DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
3467 hBinding
, ulNotify
);
3471 return CR_CALL_NOT_IMPLEMENTED
;
3481 PNP_GetCustomDevProp(
3484 LPWSTR CustomPropName
,
3485 DWORD
*pulRegDataType
,
3487 PNP_RPC_STRING_LEN
*pulTransferLen
,
3488 PNP_RPC_STRING_LEN
*pulLength
,
3491 HKEY hDeviceKey
= NULL
;
3492 HKEY hParamKey
= NULL
;
3494 CONFIGRET ret
= CR_SUCCESS
;
3496 UNREFERENCED_PARAMETER(hBinding
);
3498 DPRINT("PNP_GetCustomDevProp() called\n");
3500 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
3502 ret
= CR_INVALID_POINTER
;
3506 if (ulFlags
& ~CM_CUSTOMDEVPROP_BITS
)
3508 ret
= CR_INVALID_FLAG
;
3512 if (*pulLength
< *pulTransferLen
)
3513 *pulLength
= *pulTransferLen
;
3515 *pulTransferLen
= 0;
3517 lError
= RegOpenKeyExW(hEnumKey
,
3522 if (lError
!= ERROR_SUCCESS
)
3524 ret
= CR_REGISTRY_ERROR
;
3528 lError
= RegOpenKeyExW(hDeviceKey
,
3529 L
"Device Parameters",
3533 if (lError
!= ERROR_SUCCESS
)
3535 ret
= CR_REGISTRY_ERROR
;
3539 lError
= RegQueryValueExW(hParamKey
,
3545 if (lError
!= ERROR_SUCCESS
)
3547 if (lError
== ERROR_MORE_DATA
)
3549 ret
= CR_BUFFER_SMALL
;
3554 ret
= CR_NO_SUCH_VALUE
;
3559 if (ret
== CR_SUCCESS
)
3560 *pulTransferLen
= *pulLength
;