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
);
197 _In_ LPWSTR pDeviceID
,
198 _Out_ DWORD
*pulStatus
,
199 _Out_ DWORD
*pulProblem
)
201 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
202 CONFIGRET ret
= CR_SUCCESS
;
205 DPRINT("GetDeviceStatus(%S %p %p)\n",
206 pDeviceID
, pulStatus
, pulProblem
);
208 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
210 PlugPlayData
.Operation
= 0; /* Get status */
212 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
213 (PVOID
)&PlugPlayData
,
214 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
215 if (NT_SUCCESS(Status
))
217 *pulStatus
= PlugPlayData
.DeviceStatus
;
218 *pulProblem
= PlugPlayData
.DeviceProblem
;
222 ret
= NtStatusToCrError(Status
);
229 /* PUBLIC FUNCTIONS **********************************************************/
237 UNREFERENCED_PARAMETER(hBinding
);
248 UNREFERENCED_PARAMETER(hBinding
);
260 UNREFERENCED_PARAMETER(hBinding
);
275 UNREFERENCED_PARAMETER(hBinding
);
276 UNREFERENCED_PARAMETER(ulFlags
);
278 *pulState
= CM_GLOBAL_STATE_CAN_DO_UI
| CM_GLOBAL_STATE_SERVICES_AVAILABLE
;
289 UNREFERENCED_PARAMETER(hBinding
);
291 DPRINT("PNP_InitDetection() called\n");
304 DWORD ReturnValue
= CR_FAILURE
;
307 UNREFERENCED_PARAMETER(hBinding
);
308 UNREFERENCED_PARAMETER(Admin
);
310 DPRINT("PNP_ReportLogOn(%u, %u) called\n", Admin
, ProcessId
);
312 /* Get the users token */
313 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, TRUE
, ProcessId
);
317 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
323 CloseHandle(hUserToken
);
327 if (!OpenProcessToken(hProcess
, TOKEN_ASSIGN_PRIMARY
| TOKEN_DUPLICATE
| TOKEN_QUERY
, &hUserToken
))
329 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
333 /* Trigger the installer thread */
335 SetEvent(hInstallEvent
);
337 ReturnValue
= CR_SUCCESS
;
341 CloseHandle(hProcess
);
350 PNP_ValidateDeviceInstance(
355 CONFIGRET ret
= CR_SUCCESS
;
356 HKEY hDeviceKey
= NULL
;
358 UNREFERENCED_PARAMETER(hBinding
);
359 UNREFERENCED_PARAMETER(ulFlags
);
361 DPRINT("PNP_ValidateDeviceInstance(%S %lx) called\n",
364 if (RegOpenKeyExW(hEnumKey
,
370 DPRINT("Could not open the Device Key!\n");
371 ret
= CR_NO_SUCH_DEVNODE
;
375 /* FIXME: add more tests */
378 if (hDeviceKey
!= NULL
)
379 RegCloseKey(hDeviceKey
);
381 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret
);
390 PNP_GetRootDeviceInstance(
393 PNP_RPC_STRING_LEN ulLength
)
395 CONFIGRET ret
= CR_SUCCESS
;
397 UNREFERENCED_PARAMETER(hBinding
);
399 DPRINT("PNP_GetRootDeviceInstance() called\n");
403 ret
= CR_INVALID_POINTER
;
406 if (ulLength
< lstrlenW(szRootDeviceId
) + 1)
408 ret
= CR_BUFFER_SMALL
;
416 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret
);
425 PNP_GetRelatedDeviceInstance(
427 DWORD ulRelationship
,
429 LPWSTR pRelatedDeviceId
,
430 PNP_RPC_STRING_LEN
*pulLength
,
433 PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData
;
434 CONFIGRET ret
= CR_SUCCESS
;
437 UNREFERENCED_PARAMETER(hBinding
);
438 UNREFERENCED_PARAMETER(ulFlags
);
440 DPRINT("PNP_GetRelatedDeviceInstance() called\n");
441 DPRINT(" Relationship %ld\n", ulRelationship
);
442 DPRINT(" DeviceId %S\n", pDeviceID
);
444 RtlInitUnicodeString(&PlugPlayData
.TargetDeviceInstance
,
447 PlugPlayData
.Relation
= ulRelationship
;
449 PlugPlayData
.RelatedDeviceInstanceLength
= *pulLength
;
450 PlugPlayData
.RelatedDeviceInstance
= pRelatedDeviceId
;
452 Status
= NtPlugPlayControl(PlugPlayControlGetRelatedDevice
,
453 (PVOID
)&PlugPlayData
,
454 sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
));
455 if (!NT_SUCCESS(Status
))
457 ret
= NtStatusToCrError(Status
);
460 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret
);
461 if (ret
== CR_SUCCESS
)
463 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData
.RelatedDeviceInstance
);
473 PNP_EnumerateSubKeys(
478 PNP_RPC_STRING_LEN ulLength
,
479 PNP_RPC_STRING_LEN
*pulRequiredLen
,
482 CONFIGRET ret
= CR_SUCCESS
;
486 UNREFERENCED_PARAMETER(hBinding
);
487 UNREFERENCED_PARAMETER(ulFlags
);
489 DPRINT("PNP_EnumerateSubKeys() called\n");
493 case PNP_ENUMERATOR_SUBKEYS
:
497 case PNP_CLASS_SUBKEYS
:
505 *pulRequiredLen
= ulLength
;
506 dwError
= RegEnumKeyExW(hKey
,
514 if (dwError
!= ERROR_SUCCESS
)
516 ret
= (dwError
== ERROR_NO_MORE_ITEMS
) ? CR_NO_SUCH_VALUE
: CR_FAILURE
;
523 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret
);
531 GetRelationsInstanceList(
532 _In_ PWSTR pszDevice
,
534 _Inout_ PWSTR pszBuffer
,
535 _Inout_ PDWORD pulLength
)
537 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
539 CONFIGRET ret
= CR_SUCCESS
;
541 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
544 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
546 PlugPlayData
.Relations
= 3;
548 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
550 PlugPlayData
.Relations
= 2;
552 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
554 PlugPlayData
.Relations
= 1;
556 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
558 PlugPlayData
.Relations
= 0;
561 PlugPlayData
.BufferSize
= *pulLength
* sizeof(WCHAR
);
562 PlugPlayData
.Buffer
= pszBuffer
;
564 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
565 (PVOID
)&PlugPlayData
,
566 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
567 if (NT_SUCCESS(Status
))
569 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
573 ret
= NtStatusToCrError(Status
);
582 GetServiceInstanceList(
583 _In_ PWSTR pszService
,
584 _Inout_ PWSTR pszBuffer
,
585 _Inout_ PDWORD pulLength
)
587 WCHAR szPathBuffer
[512];
589 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
590 DWORD dwValues
, dwSize
, dwIndex
, dwUsedLength
, dwPathLength
;
593 CONFIGRET ret
= CR_SUCCESS
;
595 /* Open the device key */
596 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
597 L
"System\\CurrentControlSet\\Services",
601 if (dwError
!= ERROR_SUCCESS
)
603 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
604 return CR_REGISTRY_ERROR
;
607 dwError
= RegOpenKeyExW(hServicesKey
,
612 if (dwError
!= ERROR_SUCCESS
)
614 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
615 ret
= CR_REGISTRY_ERROR
;
619 dwError
= RegOpenKeyExW(hServiceKey
,
624 if (dwError
!= ERROR_SUCCESS
)
626 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
627 ret
= CR_REGISTRY_ERROR
;
631 /* Retrieve the number of device instances */
632 dwSize
= sizeof(DWORD
);
633 dwError
= RegQueryValueExW(hEnumKey
,
639 if (dwError
!= ERROR_SUCCESS
)
641 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
645 DPRINT("dwValues %lu\n", dwValues
);
650 for (dwIndex
= 0; dwIndex
< dwValues
; dwIndex
++)
652 wsprintf(szName
, L
"%lu", dwIndex
);
654 dwSize
= sizeof(szPathBuffer
);
655 dwError
= RegQueryValueExW(hEnumKey
,
659 (LPBYTE
)szPathBuffer
,
661 if (dwError
!= ERROR_SUCCESS
)
664 DPRINT("Path: %S\n", szPathBuffer
);
666 dwPathLength
= wcslen(szPathBuffer
) + 1;
667 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
669 ret
= CR_BUFFER_SMALL
;
673 wcscpy(pPtr
, szPathBuffer
);
674 dwUsedLength
+= dwPathLength
;
675 pPtr
+= dwPathLength
;
677 *pPtr
= UNICODE_NULL
;
681 if (hEnumKey
!= NULL
)
682 RegCloseKey(hEnumKey
);
684 if (hServiceKey
!= NULL
)
685 RegCloseKey(hServiceKey
);
687 if (hServicesKey
!= NULL
)
688 RegCloseKey(hServicesKey
);
690 if (ret
== CR_SUCCESS
)
691 *pulLength
= dwUsedLength
+ 1;
701 GetDeviceInstanceList(
702 _In_ PWSTR pszDevice
,
703 _Inout_ PWSTR pszBuffer
,
704 _Inout_ PDWORD pulLength
)
706 WCHAR szInstanceBuffer
[MAX_DEVICE_ID_LEN
];
707 WCHAR szPathBuffer
[512];
709 DWORD dwInstanceLength
, dwPathLength
, dwUsedLength
;
710 DWORD dwIndex
, dwError
;
712 CONFIGRET ret
= CR_SUCCESS
;
714 /* Open the device key */
715 dwError
= RegOpenKeyExW(hEnumKey
,
718 KEY_ENUMERATE_SUB_KEYS
,
720 if (dwError
!= ERROR_SUCCESS
)
722 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
723 return CR_REGISTRY_ERROR
;
729 for (dwIndex
= 0; ; dwIndex
++)
731 dwInstanceLength
= MAX_DEVICE_ID_LEN
;
732 dwError
= RegEnumKeyExW(hDeviceKey
,
740 if (dwError
!= ERROR_SUCCESS
)
743 wsprintf(szPathBuffer
, L
"%s\\%s", pszDevice
, szInstanceBuffer
);
744 DPRINT("Path: %S\n", szPathBuffer
);
746 dwPathLength
= wcslen(szPathBuffer
) + 1;
747 if (dwUsedLength
+ dwPathLength
+ 1 > *pulLength
)
749 ret
= CR_BUFFER_SMALL
;
753 wcscpy(pPtr
, szPathBuffer
);
754 dwUsedLength
+= dwPathLength
;
755 pPtr
+= dwPathLength
;
757 *pPtr
= UNICODE_NULL
;
760 RegCloseKey(hDeviceKey
);
762 if (ret
== CR_SUCCESS
)
763 *pulLength
= dwUsedLength
+ 1;
772 GetEnumeratorInstanceList(
773 _In_ PWSTR pszEnumerator
,
774 _Inout_ PWSTR pszBuffer
,
775 _Inout_ PDWORD pulLength
)
777 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
778 WCHAR szPathBuffer
[512];
781 DWORD dwIndex
, dwDeviceLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
783 CONFIGRET ret
= CR_SUCCESS
;
785 /* Open the enumerator key */
786 dwError
= RegOpenKeyExW(hEnumKey
,
789 KEY_ENUMERATE_SUB_KEYS
,
791 if (dwError
!= ERROR_SUCCESS
)
793 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
794 return CR_REGISTRY_ERROR
;
798 dwRemainingLength
= *pulLength
;
801 for (dwIndex
= 0; ; dwIndex
++)
803 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
804 dwError
= RegEnumKeyExW(hEnumeratorKey
,
812 if (dwError
!= ERROR_SUCCESS
)
815 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
816 DPRINT("Path: %S\n", szPathBuffer
);
818 dwPathLength
= dwRemainingLength
;
819 ret
= GetDeviceInstanceList(szPathBuffer
,
822 if (ret
!= CR_SUCCESS
)
825 dwUsedLength
+= dwPathLength
- 1;
826 dwRemainingLength
+= dwPathLength
- 1;
827 pPtr
+= dwPathLength
- 1;
830 RegCloseKey(hEnumeratorKey
);
832 if (ret
== CR_SUCCESS
)
833 *pulLength
= dwUsedLength
+ 1;
844 _Inout_ PWSTR pszBuffer
,
845 _Inout_ PDWORD pulLength
)
847 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
849 DWORD dwIndex
, dwEnumeratorLength
, dwUsedLength
, dwRemainingLength
, dwPathLength
;
851 CONFIGRET ret
= CR_SUCCESS
;
854 dwRemainingLength
= *pulLength
;
857 for (dwIndex
= 0; ; dwIndex
++)
859 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
860 dwError
= RegEnumKeyExW(hEnumKey
,
864 NULL
, NULL
, NULL
, NULL
);
865 if (dwError
!= ERROR_SUCCESS
)
868 dwPathLength
= dwRemainingLength
;
869 ret
= GetEnumeratorInstanceList(szEnumeratorBuffer
,
872 if (ret
!= CR_SUCCESS
)
875 dwUsedLength
+= dwPathLength
- 1;
876 dwRemainingLength
+= dwPathLength
- 1;
877 pPtr
+= dwPathLength
- 1;
880 if (ret
== CR_SUCCESS
)
881 *pulLength
= dwUsedLength
+ 1;
896 PNP_RPC_STRING_LEN
*pulLength
,
899 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
900 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
901 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
902 CONFIGRET ret
= CR_SUCCESS
;
904 DPRINT("PNP_GetDeviceList() called\n");
906 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
907 return CR_INVALID_FLAG
;
909 if (pulLength
== NULL
)
910 return CR_INVALID_POINTER
;
912 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
914 return CR_INVALID_POINTER
;
917 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
918 CM_GETIDLIST_FILTER_POWERRELATIONS
|
919 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
920 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
922 ret
= GetRelationsInstanceList(pszFilter
,
927 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
929 ret
= GetServiceInstanceList(pszFilter
,
933 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
935 SplitDeviceInstanceID(pszFilter
,
940 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
942 ret
= GetDeviceInstanceList(pszFilter
,
948 ret
= GetEnumeratorInstanceList(pszFilter
,
953 else /* CM_GETIDLIST_FILTER_NONE */
955 ret
= GetAllInstanceList(Buffer
,
965 GetRelationsInstanceListSize(
966 _In_ PWSTR pszDevice
,
968 _Inout_ PDWORD pulLength
)
970 PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA PlugPlayData
;
972 CONFIGRET ret
= CR_SUCCESS
;
974 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
977 if (ulFlags
& CM_GETIDLIST_FILTER_BUSRELATIONS
)
979 PlugPlayData
.Relations
= 3;
981 else if (ulFlags
& CM_GETIDLIST_FILTER_POWERRELATIONS
)
983 PlugPlayData
.Relations
= 2;
985 else if (ulFlags
& CM_GETIDLIST_FILTER_REMOVALRELATIONS
)
987 PlugPlayData
.Relations
= 1;
989 else if (ulFlags
& CM_GETIDLIST_FILTER_EJECTRELATIONS
)
991 PlugPlayData
.Relations
= 0;
994 PlugPlayData
.BufferSize
= 0;
995 PlugPlayData
.Buffer
= NULL
;
997 Status
= NtPlugPlayControl(PlugPlayControlQueryDeviceRelations
,
998 (PVOID
)&PlugPlayData
,
999 sizeof(PLUGPLAY_CONTROL_DEVICE_RELATIONS_DATA
));
1000 if (NT_SUCCESS(Status
))
1002 *pulLength
= PlugPlayData
.BufferSize
/ sizeof(WCHAR
);
1006 ret
= NtStatusToCrError(Status
);
1015 GetServiceInstanceListSize(
1016 _In_ PWSTR pszService
,
1017 _Out_ PDWORD pulLength
)
1019 HKEY hServicesKey
= NULL
, hServiceKey
= NULL
, hEnumKey
= NULL
;
1020 DWORD dwValues
, dwMaxValueLength
, dwSize
;
1022 CONFIGRET ret
= CR_SUCCESS
;
1024 /* Open the device key */
1025 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1026 L
"System\\CurrentControlSet\\Services",
1030 if (dwError
!= ERROR_SUCCESS
)
1032 DPRINT("Failed to open the services key (Error %lu)\n", dwError
);
1033 return CR_REGISTRY_ERROR
;
1036 dwError
= RegOpenKeyExW(hServicesKey
,
1041 if (dwError
!= ERROR_SUCCESS
)
1043 DPRINT("Failed to open the service key (Error %lu)\n", dwError
);
1044 ret
= CR_REGISTRY_ERROR
;
1048 dwError
= RegOpenKeyExW(hServiceKey
,
1053 if (dwError
!= ERROR_SUCCESS
)
1055 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError
);
1056 ret
= CR_REGISTRY_ERROR
;
1060 /* Retrieve the number of device instances */
1061 dwSize
= sizeof(DWORD
);
1062 dwError
= RegQueryValueExW(hEnumKey
,
1068 if (dwError
!= ERROR_SUCCESS
)
1070 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError
);
1074 /* Retrieve the maximum instance name length */
1075 dwError
= RegQueryInfoKeyW(hEnumKey
,
1087 if (dwError
!= ERROR_SUCCESS
)
1089 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1090 dwMaxValueLength
= MAX_DEVICE_ID_LEN
;
1093 DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues
, dwMaxValueLength
/ sizeof(WCHAR
));
1095 /* Return the largest possible buffer size */
1096 *pulLength
= dwValues
* dwMaxValueLength
/ sizeof(WCHAR
) + 2;
1099 if (hEnumKey
!= NULL
)
1100 RegCloseKey(hEnumKey
);
1102 if (hServiceKey
!= NULL
)
1103 RegCloseKey(hServiceKey
);
1105 if (hServicesKey
!= NULL
)
1106 RegCloseKey(hServicesKey
);
1114 GetDeviceInstanceListSize(
1115 _In_ LPCWSTR pszDevice
,
1116 _Out_ PULONG pulLength
)
1119 DWORD dwSubKeys
, dwMaxSubKeyLength
;
1122 /* Open the device key */
1123 dwError
= RegOpenKeyExW(hEnumKey
,
1128 if (dwError
!= ERROR_SUCCESS
)
1130 DPRINT("Failed to open the device key (Error %lu)\n", dwError
);
1131 return CR_REGISTRY_ERROR
;
1134 /* Retrieve the number of device instances and the maximum name length */
1135 dwError
= RegQueryInfoKeyW(hDeviceKey
,
1147 if (dwError
!= ERROR_SUCCESS
)
1149 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError
);
1151 dwMaxSubKeyLength
= 0;
1154 /* Close the device key */
1155 RegCloseKey(hDeviceKey
);
1157 /* Return the largest possible buffer size */
1158 *pulLength
= dwSubKeys
* (wcslen(pszDevice
) + 1 + dwMaxSubKeyLength
+ 1);
1166 GetEnumeratorInstanceListSize(
1167 _In_ LPCWSTR pszEnumerator
,
1168 _Out_ PULONG pulLength
)
1170 WCHAR szDeviceBuffer
[MAX_DEVICE_ID_LEN
];
1171 WCHAR szPathBuffer
[512];
1172 HKEY hEnumeratorKey
;
1173 DWORD dwIndex
, dwDeviceLength
, dwBufferLength
;
1175 CONFIGRET ret
= CR_SUCCESS
;
1179 /* Open the enumerator key */
1180 dwError
= RegOpenKeyExW(hEnumKey
,
1183 KEY_ENUMERATE_SUB_KEYS
,
1185 if (dwError
!= ERROR_SUCCESS
)
1187 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError
);
1188 return CR_REGISTRY_ERROR
;
1191 for (dwIndex
= 0; ; dwIndex
++)
1193 dwDeviceLength
= MAX_DEVICE_ID_LEN
;
1194 dwError
= RegEnumKeyExW(hEnumeratorKey
,
1202 if (dwError
!= ERROR_SUCCESS
)
1205 wsprintf(szPathBuffer
, L
"%s\\%s", pszEnumerator
, szDeviceBuffer
);
1206 DPRINT("Path: %S\n", szPathBuffer
);
1208 ret
= GetDeviceInstanceListSize(szPathBuffer
, &dwBufferLength
);
1209 if (ret
!= CR_SUCCESS
)
1215 *pulLength
+= dwBufferLength
;
1218 /* Close the enumerator key */
1219 RegCloseKey(hEnumeratorKey
);
1227 GetAllInstanceListSize(
1228 _Out_ PULONG pulLength
)
1230 WCHAR szEnumeratorBuffer
[MAX_DEVICE_ID_LEN
];
1231 DWORD dwIndex
, dwEnumeratorLength
, dwBufferLength
;
1233 CONFIGRET ret
= CR_SUCCESS
;
1235 for (dwIndex
= 0; ; dwIndex
++)
1237 dwEnumeratorLength
= MAX_DEVICE_ID_LEN
;
1238 dwError
= RegEnumKeyExW(hEnumKey
,
1241 &dwEnumeratorLength
,
1242 NULL
, NULL
, NULL
, NULL
);
1243 if (dwError
!= ERROR_SUCCESS
)
1246 /* Get the size of all device instances for the enumerator */
1247 ret
= GetEnumeratorInstanceListSize(szEnumeratorBuffer
,
1249 if (ret
!= CR_SUCCESS
)
1252 *pulLength
+= dwBufferLength
;
1262 PNP_GetDeviceListSize(
1265 PNP_RPC_BUFFER_SIZE
*pulLength
,
1268 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
1269 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
1270 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
1271 CONFIGRET ret
= CR_SUCCESS
;
1273 DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
1274 hBinding
, pszFilter
, pulLength
, ulFlags
);
1276 if (ulFlags
& ~CM_GETIDLIST_FILTER_BITS
)
1277 return CR_INVALID_FLAG
;
1279 if (pulLength
== NULL
)
1280 return CR_INVALID_POINTER
;
1282 if ((ulFlags
!= CM_GETIDLIST_FILTER_NONE
) &&
1283 (pszFilter
== NULL
))
1284 return CR_INVALID_POINTER
;
1289 (CM_GETIDLIST_FILTER_BUSRELATIONS
|
1290 CM_GETIDLIST_FILTER_POWERRELATIONS
|
1291 CM_GETIDLIST_FILTER_REMOVALRELATIONS
|
1292 CM_GETIDLIST_FILTER_EJECTRELATIONS
))
1294 ret
= GetRelationsInstanceListSize(pszFilter
,
1298 else if (ulFlags
& CM_GETIDLIST_FILTER_SERVICE
)
1300 ret
= GetServiceInstanceListSize(pszFilter
,
1303 else if (ulFlags
& CM_GETIDLIST_FILTER_ENUMERATOR
)
1305 SplitDeviceInstanceID(pszFilter
,
1310 if (*szEnumerator
!= UNICODE_NULL
&& *szDevice
!= UNICODE_NULL
)
1312 ret
= GetDeviceInstanceListSize(pszFilter
,
1317 ret
= GetEnumeratorInstanceListSize(pszFilter
,
1321 else /* CM_GETIDLIST_FILTER_NONE */
1323 ret
= GetAllInstanceListSize(pulLength
);
1326 /* Add one character for the terminating double UNICODE_NULL */
1327 if (ret
== CR_SUCCESS
)
1343 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData
;
1344 CONFIGRET ret
= CR_SUCCESS
;
1347 UNREFERENCED_PARAMETER(hBinding
);
1348 UNREFERENCED_PARAMETER(ulFlags
);
1350 DPRINT("PNP_GetDepth() called\n");
1352 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1355 Status
= NtPlugPlayControl(PlugPlayControlGetDeviceDepth
,
1356 (PVOID
)&PlugPlayData
,
1357 sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
));
1358 if (NT_SUCCESS(Status
))
1360 *pulDepth
= PlugPlayData
.Depth
;
1364 ret
= NtStatusToCrError(Status
);
1367 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret
);
1376 PNP_GetDeviceRegProp(
1380 DWORD
*pulRegDataType
,
1382 PNP_PROP_SIZE
*pulTransferLen
,
1383 PNP_PROP_SIZE
*pulLength
,
1386 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData
;
1387 CONFIGRET ret
= CR_SUCCESS
;
1388 LPWSTR lpValueName
= NULL
;
1393 UNREFERENCED_PARAMETER(hBinding
);
1395 DPRINT("PNP_GetDeviceRegProp() called\n");
1397 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
1399 ret
= CR_INVALID_POINTER
;
1405 ret
= CR_INVALID_FLAG
;
1409 /* FIXME: Check pDeviceID */
1411 if (*pulLength
< *pulTransferLen
)
1412 *pulLength
= *pulTransferLen
;
1414 *pulTransferLen
= 0;
1418 case CM_DRP_DEVICEDESC
:
1419 lpValueName
= L
"DeviceDesc";
1422 case CM_DRP_HARDWAREID
:
1423 lpValueName
= L
"HardwareID";
1426 case CM_DRP_COMPATIBLEIDS
:
1427 lpValueName
= L
"CompatibleIDs";
1430 case CM_DRP_SERVICE
:
1431 lpValueName
= L
"Service";
1435 lpValueName
= L
"Class";
1438 case CM_DRP_CLASSGUID
:
1439 lpValueName
= L
"ClassGUID";
1443 lpValueName
= L
"Driver";
1446 case CM_DRP_CONFIGFLAGS
:
1447 lpValueName
= L
"ConfigFlags";
1451 lpValueName
= L
"Mfg";
1454 case CM_DRP_FRIENDLYNAME
:
1455 lpValueName
= L
"FriendlyName";
1458 case CM_DRP_LOCATION_INFORMATION
:
1459 lpValueName
= L
"LocationInformation";
1462 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
1463 PlugPlayData
.Property
= PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
;
1466 case CM_DRP_CAPABILITIES
:
1467 lpValueName
= L
"Capabilities";
1470 case CM_DRP_UI_NUMBER
:
1471 PlugPlayData
.Property
= PNP_PROPERTY_UI_NUMBER
;
1474 case CM_DRP_UPPERFILTERS
:
1475 lpValueName
= L
"UpperFilters";
1478 case CM_DRP_LOWERFILTERS
:
1479 lpValueName
= L
"LowerFilters";
1482 case CM_DRP_BUSTYPEGUID
:
1483 PlugPlayData
.Property
= PNP_PROPERTY_BUSTYPEGUID
;
1486 case CM_DRP_LEGACYBUSTYPE
:
1487 PlugPlayData
.Property
= PNP_PROPERTY_LEGACYBUSTYPE
;
1490 case CM_DRP_BUSNUMBER
:
1491 PlugPlayData
.Property
= PNP_PROPERTY_BUSNUMBER
;
1494 case CM_DRP_ENUMERATOR_NAME
:
1495 PlugPlayData
.Property
= PNP_PROPERTY_ENUMERATOR_NAME
;
1498 case CM_DRP_SECURITY
:
1499 lpValueName
= L
"Security";
1502 case CM_DRP_DEVTYPE
:
1503 lpValueName
= L
"DeviceType";
1506 case CM_DRP_EXCLUSIVE
:
1507 lpValueName
= L
"Exclusive";
1510 case CM_DRP_CHARACTERISTICS
:
1511 lpValueName
= L
"DeviceCharacteristics";
1514 case CM_DRP_ADDRESS
:
1515 PlugPlayData
.Property
= PNP_PROPERTY_ADDRESS
;
1518 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1519 lpValueName
= L
"UINumberDescFormat";
1522 case CM_DRP_DEVICE_POWER_DATA
:
1523 PlugPlayData
.Property
= PNP_PROPERTY_POWER_DATA
;
1526 case CM_DRP_REMOVAL_POLICY
:
1527 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY
;
1530 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT
:
1531 PlugPlayData
.Property
= PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
;
1534 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1535 lpValueName
= L
"RemovalPolicy";
1538 case CM_DRP_INSTALL_STATE
:
1539 PlugPlayData
.Property
= PNP_PROPERTY_INSTALL_STATE
;
1542 #if (WINVER >= _WIN32_WINNT_WS03)
1543 case CM_DRP_LOCATION_PATHS
:
1544 PlugPlayData
.Property
= PNP_PROPERTY_LOCATION_PATHS
;
1548 #if (WINVER >= _WIN32_WINNT_WIN7)
1549 case CM_DRP_BASE_CONTAINERID
:
1550 PlugPlayData
.Property
= PNP_PROPERTY_CONTAINERID
;
1555 ret
= CR_INVALID_PROPERTY
;
1559 DPRINT("Value name: %S\n", lpValueName
);
1563 /* Retrieve information from the Registry */
1564 lError
= RegOpenKeyExW(hEnumKey
,
1569 if (lError
!= ERROR_SUCCESS
)
1573 ret
= CR_INVALID_DEVNODE
;
1577 lError
= RegQueryValueExW(hKey
,
1583 if (lError
!= ERROR_SUCCESS
)
1585 if (lError
== ERROR_MORE_DATA
)
1587 ret
= CR_BUFFER_SMALL
;
1592 ret
= CR_NO_SUCH_VALUE
;
1598 /* Retrieve information from the Device Node */
1599 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1601 PlugPlayData
.Buffer
= Buffer
;
1602 PlugPlayData
.BufferSize
= *pulLength
;
1604 Status
= NtPlugPlayControl(PlugPlayControlProperty
,
1605 (PVOID
)&PlugPlayData
,
1606 sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
));
1607 if (NT_SUCCESS(Status
))
1609 *pulLength
= PlugPlayData
.BufferSize
;
1613 ret
= NtStatusToCrError(Status
);
1619 *pulTransferLen
= (ret
== CR_SUCCESS
) ? *pulLength
: 0;
1624 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret
);
1633 PNP_SetDeviceRegProp(
1639 PNP_PROP_SIZE ulLength
,
1642 CONFIGRET ret
= CR_SUCCESS
;
1643 LPWSTR lpValueName
= NULL
;
1646 UNREFERENCED_PARAMETER(hBinding
);
1647 UNREFERENCED_PARAMETER(ulFlags
);
1649 DPRINT("PNP_SetDeviceRegProp() called\n");
1651 DPRINT("DeviceId: %S\n", pDeviceId
);
1652 DPRINT("Property: %lu\n", ulProperty
);
1653 DPRINT("DataType: %lu\n", ulDataType
);
1654 DPRINT("Length: %lu\n", ulLength
);
1658 case CM_DRP_DEVICEDESC
:
1659 lpValueName
= L
"DeviceDesc";
1662 case CM_DRP_HARDWAREID
:
1663 lpValueName
= L
"HardwareID";
1666 case CM_DRP_COMPATIBLEIDS
:
1667 lpValueName
= L
"CompatibleIDs";
1670 case CM_DRP_SERVICE
:
1671 lpValueName
= L
"Service";
1675 lpValueName
= L
"Class";
1678 case CM_DRP_CLASSGUID
:
1679 lpValueName
= L
"ClassGUID";
1683 lpValueName
= L
"Driver";
1686 case CM_DRP_CONFIGFLAGS
:
1687 lpValueName
= L
"ConfigFlags";
1691 lpValueName
= L
"Mfg";
1694 case CM_DRP_FRIENDLYNAME
:
1695 lpValueName
= L
"FriendlyName";
1698 case CM_DRP_LOCATION_INFORMATION
:
1699 lpValueName
= L
"LocationInformation";
1702 case CM_DRP_UPPERFILTERS
:
1703 lpValueName
= L
"UpperFilters";
1706 case CM_DRP_LOWERFILTERS
:
1707 lpValueName
= L
"LowerFilters";
1710 case CM_DRP_SECURITY
:
1711 lpValueName
= L
"Security";
1714 case CM_DRP_DEVTYPE
:
1715 lpValueName
= L
"DeviceType";
1718 case CM_DRP_EXCLUSIVE
:
1719 lpValueName
= L
"Exclusive";
1722 case CM_DRP_CHARACTERISTICS
:
1723 lpValueName
= L
"DeviceCharacteristics";
1726 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
1727 lpValueName
= L
"UINumberDescFormat";
1730 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
1731 lpValueName
= L
"RemovalPolicy";
1735 return CR_INVALID_PROPERTY
;
1738 DPRINT("Value name: %S\n", lpValueName
);
1740 if (RegOpenKeyExW(hEnumKey
,
1745 return CR_INVALID_DEVNODE
;
1749 if (RegDeleteValueW(hKey
,
1751 ret
= CR_REGISTRY_ERROR
;
1755 if (RegSetValueExW(hKey
,
1761 ret
= CR_REGISTRY_ERROR
;
1766 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret
);
1775 PNP_GetClassInstance(
1778 LPWSTR pszClassInstance
,
1779 PNP_RPC_STRING_LEN ulLength
)
1781 WCHAR szClassGuid
[40];
1782 WCHAR szClassInstance
[5];
1783 HKEY hDeviceClassKey
= NULL
;
1784 HKEY hClassInstanceKey
;
1785 ULONG ulTransferLength
, ulDataLength
;
1786 DWORD dwDataType
, dwDisposition
, i
;
1788 CONFIGRET ret
= CR_SUCCESS
;
1790 DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
1791 hBinding
, pDeviceId
, pszClassInstance
, ulLength
);
1793 ulTransferLength
= ulLength
;
1794 ret
= PNP_GetDeviceRegProp(hBinding
,
1798 (BYTE
*)pszClassInstance
,
1802 if (ret
== CR_SUCCESS
)
1805 ulTransferLength
= sizeof(szClassGuid
);
1806 ulDataLength
= sizeof(szClassGuid
);
1807 ret
= PNP_GetDeviceRegProp(hBinding
,
1811 (BYTE
*)szClassGuid
,
1815 if (ret
!= CR_SUCCESS
)
1817 DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret
);
1821 dwError
= RegOpenKeyExW(hClassKey
,
1826 if (dwError
!= ERROR_SUCCESS
)
1828 DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError
);
1833 for (i
= 0; i
< 10000; i
++)
1835 wsprintf(szClassInstance
, L
"%04lu", i
);
1837 dwError
= RegCreateKeyExW(hDeviceClassKey
,
1841 REG_OPTION_NON_VOLATILE
,
1846 if (dwError
== ERROR_SUCCESS
)
1848 RegCloseKey(hClassInstanceKey
);
1850 if (dwDisposition
== REG_CREATED_NEW_KEY
)
1852 wsprintf(pszClassInstance
,
1857 ulDataLength
= (wcslen(pszClassInstance
) + 1) * sizeof(WCHAR
);
1858 ret
= PNP_SetDeviceRegProp(hBinding
,
1862 (BYTE
*)pszClassInstance
,
1865 if (ret
!= CR_SUCCESS
)
1867 DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret
);
1868 RegDeleteKeyW(hDeviceClassKey
,
1878 if (hDeviceClassKey
!= NULL
)
1879 RegCloseKey(hDeviceClassKey
);
1896 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
1905 return CR_REGISTRY_ERROR
;
1907 /* FIXME: Set security key */
1918 PNP_DeleteRegistryKey(
1921 LPWSTR pszParentKey
,
1926 return CR_CALL_NOT_IMPLEMENTED
;
1935 DWORD
*pulClassCount
,
1941 UNREFERENCED_PARAMETER(hBinding
);
1942 UNREFERENCED_PARAMETER(ulFlags
);
1944 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1949 if (dwError
!= ERROR_SUCCESS
)
1950 return CR_INVALID_DATA
;
1952 dwError
= RegQueryInfoKeyW(hKey
,
1965 if (dwError
!= ERROR_SUCCESS
)
1966 return CR_INVALID_DATA
;
1977 LPWSTR pszClassGuid
,
1979 PNP_RPC_STRING_LEN
*pulLength
,
1982 WCHAR szKeyName
[MAX_PATH
];
1983 CONFIGRET ret
= CR_SUCCESS
;
1987 UNREFERENCED_PARAMETER(hBinding
);
1988 UNREFERENCED_PARAMETER(ulFlags
);
1990 DPRINT("PNP_GetClassName() called\n");
1992 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
1993 if (lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
1994 lstrcatW(szKeyName
, pszClassGuid
);
1996 return CR_INVALID_DATA
;
1998 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2003 return CR_REGISTRY_ERROR
;
2005 dwSize
= *pulLength
* sizeof(WCHAR
);
2006 if (RegQueryValueExW(hKey
,
2014 ret
= CR_REGISTRY_ERROR
;
2018 *pulLength
= dwSize
/ sizeof(WCHAR
);
2023 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
2034 LPWSTR pszClassGuid
,
2037 CONFIGRET ret
= CR_SUCCESS
;
2039 UNREFERENCED_PARAMETER(hBinding
);
2041 DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid
, ulFlags
);
2043 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
2045 if (SHDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2046 ret
= CR_REGISTRY_ERROR
;
2050 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
2051 ret
= CR_REGISTRY_ERROR
;
2054 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
2063 PNP_GetInterfaceDeviceAlias(
2065 LPWSTR pszInterfaceDevice
,
2066 GUID
*AliasInterfaceGuid
,
2067 LPWSTR pszAliasInterfaceDevice
,
2068 PNP_RPC_STRING_LEN
*pulLength
,
2069 PNP_RPC_STRING_LEN
*pulTransferLen
,
2073 return CR_CALL_NOT_IMPLEMENTED
;
2080 PNP_GetInterfaceDeviceList(
2082 GUID
*InterfaceGuid
,
2085 PNP_RPC_BUFFER_SIZE
*pulLength
,
2089 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2090 DWORD ret
= CR_SUCCESS
;
2092 UNREFERENCED_PARAMETER(hBinding
);
2094 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2097 PlugPlayData
.Flags
= ulFlags
;
2098 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2099 PlugPlayData
.Buffer
= Buffer
;
2100 PlugPlayData
.BufferSize
= *pulLength
;
2102 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2103 (PVOID
)&PlugPlayData
,
2104 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2105 if (NT_SUCCESS(Status
))
2107 *pulLength
= PlugPlayData
.BufferSize
;
2111 ret
= NtStatusToCrError(Status
);
2114 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2122 PNP_GetInterfaceDeviceListSize(
2124 PNP_RPC_BUFFER_SIZE
*pulLen
,
2125 GUID
*InterfaceGuid
,
2130 PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA PlugPlayData
;
2131 DWORD ret
= CR_SUCCESS
;
2133 UNREFERENCED_PARAMETER(hBinding
);
2135 DPRINT("PNP_GetInterfaceDeviceListSize() called\n");
2137 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
2140 PlugPlayData
.FilterGuid
= InterfaceGuid
;
2141 PlugPlayData
.Buffer
= NULL
;
2142 PlugPlayData
.BufferSize
= 0;
2143 PlugPlayData
.Flags
= ulFlags
;
2145 Status
= NtPlugPlayControl(PlugPlayControlGetInterfaceDeviceList
,
2146 (PVOID
)&PlugPlayData
,
2147 sizeof(PLUGPLAY_CONTROL_INTERFACE_DEVICE_LIST_DATA
));
2148 if (NT_SUCCESS(Status
))
2150 *pulLen
= PlugPlayData
.BufferSize
;
2154 ret
= NtStatusToCrError(Status
);
2157 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret
);
2165 PNP_RegisterDeviceClassAssociation(
2168 GUID
*InterfaceGuid
,
2169 LPWSTR pszReference
,
2171 PNP_RPC_STRING_LEN
*pulLength
,
2172 PNP_RPC_STRING_LEN
*pulTransferLen
,
2176 return CR_CALL_NOT_IMPLEMENTED
;
2183 PNP_UnregisterDeviceClassAssociation(
2185 LPWSTR pszInterfaceDevice
,
2189 return CR_CALL_NOT_IMPLEMENTED
;
2196 PNP_GetClassRegProp(
2198 LPWSTR pszClassGuid
,
2200 DWORD
*pulRegDataType
,
2202 PNP_RPC_STRING_LEN
*pulTransferLen
,
2203 PNP_RPC_STRING_LEN
*pulLength
,
2206 CONFIGRET ret
= CR_SUCCESS
;
2207 LPWSTR lpValueName
= NULL
;
2208 HKEY hInstKey
= NULL
;
2209 HKEY hPropKey
= NULL
;
2212 UNREFERENCED_PARAMETER(hBinding
);
2214 DPRINT("PNP_GetClassRegProp() called\n");
2216 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
2218 ret
= CR_INVALID_POINTER
;
2224 ret
= CR_INVALID_FLAG
;
2228 if (*pulLength
< *pulTransferLen
)
2229 *pulLength
= *pulTransferLen
;
2231 *pulTransferLen
= 0;
2235 case CM_CRP_SECURITY
:
2236 lpValueName
= L
"Security";
2239 case CM_CRP_DEVTYPE
:
2240 lpValueName
= L
"DeviceType";
2243 case CM_CRP_EXCLUSIVE
:
2244 lpValueName
= L
"Exclusive";
2247 case CM_CRP_CHARACTERISTICS
:
2248 lpValueName
= L
"DeviceCharacteristics";
2252 ret
= CR_INVALID_PROPERTY
;
2256 DPRINT("Value name: %S\n", lpValueName
);
2258 lError
= RegOpenKeyExW(hClassKey
,
2263 if (lError
!= ERROR_SUCCESS
)
2266 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2270 lError
= RegOpenKeyExW(hInstKey
,
2275 if (lError
!= ERROR_SUCCESS
)
2278 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2282 lError
= RegQueryValueExW(hPropKey
,
2288 if (lError
!= ERROR_SUCCESS
)
2290 if (lError
== ERROR_MORE_DATA
)
2292 ret
= CR_BUFFER_SMALL
;
2297 ret
= CR_NO_SUCH_VALUE
;
2302 if (ret
== CR_SUCCESS
)
2303 *pulTransferLen
= *pulLength
;
2305 if (hPropKey
!= NULL
)
2306 RegCloseKey(hPropKey
);
2308 if (hInstKey
!= NULL
)
2309 RegCloseKey(hInstKey
);
2311 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret
);
2320 PNP_SetClassRegProp(
2322 LPWSTR pszClassGuid
,
2326 PNP_PROP_SIZE ulLength
,
2329 CONFIGRET ret
= CR_SUCCESS
;
2330 LPWSTR lpValueName
= NULL
;
2335 UNREFERENCED_PARAMETER(hBinding
);
2337 DPRINT("PNP_SetClassRegProp() called\n");
2340 return CR_INVALID_FLAG
;
2344 case CM_CRP_SECURITY
:
2345 lpValueName
= L
"Security";
2348 case CM_CRP_DEVTYPE
:
2349 lpValueName
= L
"DeviceType";
2352 case CM_CRP_EXCLUSIVE
:
2353 lpValueName
= L
"Exclusive";
2356 case CM_CRP_CHARACTERISTICS
:
2357 lpValueName
= L
"DeviceCharacteristics";
2361 return CR_INVALID_PROPERTY
;
2364 lError
= RegOpenKeyExW(hClassKey
,
2369 if (lError
!= ERROR_SUCCESS
)
2371 ret
= CR_NO_SUCH_REGISTRY_KEY
;
2375 /* FIXME: Set security descriptor */
2376 lError
= RegCreateKeyExW(hInstKey
,
2380 REG_OPTION_NON_VOLATILE
,
2385 if (lError
!= ERROR_SUCCESS
)
2387 ret
= CR_REGISTRY_ERROR
;
2393 if (RegDeleteValueW(hPropKey
,
2395 ret
= CR_REGISTRY_ERROR
;
2399 if (RegSetValueExW(hPropKey
,
2405 ret
= CR_REGISTRY_ERROR
;
2409 if (hPropKey
!= NULL
)
2410 RegCloseKey(hPropKey
);
2412 if (hInstKey
!= NULL
)
2413 RegCloseKey(hInstKey
);
2420 CreateDeviceInstance(LPWSTR pszDeviceID
)
2422 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
2423 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
2424 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
2425 HKEY hKeyEnumerator
;
2431 /* Split the instance ID */
2432 SplitDeviceInstanceID(pszDeviceID
,
2437 /* Open or create the enumerator key */
2438 lError
= RegCreateKeyExW(hEnumKey
,
2442 REG_OPTION_NON_VOLATILE
,
2447 if (lError
!= ERROR_SUCCESS
)
2449 return CR_REGISTRY_ERROR
;
2452 /* Open or create the device key */
2453 lError
= RegCreateKeyExW(hKeyEnumerator
,
2457 REG_OPTION_NON_VOLATILE
,
2463 /* Close the enumerator key */
2464 RegCloseKey(hKeyEnumerator
);
2466 if (lError
!= ERROR_SUCCESS
)
2468 return CR_REGISTRY_ERROR
;
2471 /* Try to open the instance key and fail if it exists */
2472 lError
= RegOpenKeyExW(hKeyDevice
,
2477 if (lError
== ERROR_SUCCESS
)
2479 DPRINT1("Instance %S already exists!\n", szInstance
);
2480 RegCloseKey(hKeyInstance
);
2481 RegCloseKey(hKeyDevice
);
2482 return CR_ALREADY_SUCH_DEVINST
;
2485 /* Create a new instance key */
2486 lError
= RegCreateKeyExW(hKeyDevice
,
2490 REG_OPTION_NON_VOLATILE
,
2496 /* Close the device key */
2497 RegCloseKey(hKeyDevice
);
2499 if (lError
!= ERROR_SUCCESS
)
2501 return CR_REGISTRY_ERROR
;
2504 /* Create the 'Control' sub key */
2505 lError
= RegCreateKeyExW(hKeyInstance
,
2509 REG_OPTION_NON_VOLATILE
,
2514 if (lError
== ERROR_SUCCESS
)
2516 RegCloseKey(hKeyControl
);
2519 RegCloseKey(hKeyInstance
);
2521 return (lError
== ERROR_SUCCESS
) ? CR_SUCCESS
: CR_REGISTRY_ERROR
;
2531 LPWSTR pszParentDeviceID
,
2532 PNP_RPC_STRING_LEN ulLength
,
2535 CONFIGRET ret
= CR_SUCCESS
;
2537 DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID
);
2539 if (ulFlags
& CM_CREATE_DEVNODE_GENERATE_ID
)
2541 WCHAR szGeneratedInstance
[MAX_DEVICE_ID_LEN
];
2542 DWORD dwInstanceNumber
;
2544 /* Generated ID is: Root\<Device ID>\<Instance number> */
2545 dwInstanceNumber
= 0;
2548 swprintf(szGeneratedInstance
, L
"Root\\%ls\\%04lu",
2549 pszDeviceID
, dwInstanceNumber
);
2551 /* Try to create a device instance with this ID */
2552 ret
= CreateDeviceInstance(szGeneratedInstance
);
2556 while (ret
== CR_ALREADY_SUCH_DEVINST
);
2558 if (ret
== CR_SUCCESS
)
2560 /* pszDeviceID is an out parameter too for generated IDs */
2561 if (wcslen(szGeneratedInstance
) > ulLength
)
2563 ret
= CR_BUFFER_SMALL
;
2567 wcscpy(pszDeviceID
, szGeneratedInstance
);
2573 /* Create the device instance */
2574 ret
= CreateDeviceInstance(pszDeviceID
);
2577 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret
);
2584 MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination
,
2585 LPWSTR pszDeviceInstanceSource
)
2587 DPRINT("MoveDeviceInstance: not implemented\n");
2589 return CR_CALL_NOT_IMPLEMENTED
;
2594 SetupDeviceInstance(LPWSTR pszDeviceInstance
,
2597 DPRINT("SetupDeviceInstance: not implemented\n");
2599 return CR_CALL_NOT_IMPLEMENTED
;
2604 EnableDeviceInstance(LPWSTR pszDeviceInstance
)
2606 PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
;
2607 CONFIGRET ret
= CR_SUCCESS
;
2610 DPRINT("Enable device instance %S\n", pszDeviceInstance
);
2612 RtlInitUnicodeString(&ResetDeviceData
.DeviceInstance
, pszDeviceInstance
);
2613 Status
= NtPlugPlayControl(PlugPlayControlResetDevice
, &ResetDeviceData
, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
));
2614 if (!NT_SUCCESS(Status
))
2615 ret
= NtStatusToCrError(Status
);
2622 DisableDeviceInstance(LPWSTR pszDeviceInstance
)
2624 DPRINT("DisableDeviceInstance: not implemented\n");
2626 return CR_CALL_NOT_IMPLEMENTED
;
2631 ReenumerateDeviceInstance(
2632 _In_ LPWSTR pszDeviceInstance
,
2635 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData
;
2636 CONFIGRET ret
= CR_SUCCESS
;
2639 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
2640 pszDeviceInstance
, ulFlags
);
2642 if (ulFlags
& ~CM_REENUMERATE_BITS
)
2643 return CR_INVALID_FLAG
;
2645 if (ulFlags
& CM_REENUMERATE_RETRY_INSTALLATION
)
2647 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
2650 RtlInitUnicodeString(&EnumerateDeviceData
.DeviceInstance
,
2652 EnumerateDeviceData
.Flags
= 0;
2654 Status
= NtPlugPlayControl(PlugPlayControlEnumerateDevice
,
2655 &EnumerateDeviceData
,
2656 sizeof(PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA
));
2657 if (!NT_SUCCESS(Status
))
2658 ret
= NtStatusToCrError(Status
);
2667 PNP_DeviceInstanceAction(
2671 LPWSTR pszDeviceInstance1
,
2672 LPWSTR pszDeviceInstance2
)
2674 CONFIGRET ret
= CR_SUCCESS
;
2676 UNREFERENCED_PARAMETER(hBinding
);
2678 DPRINT("PNP_DeviceInstanceAction() called\n");
2682 case PNP_DEVINST_MOVE
:
2683 ret
= MoveDeviceInstance(pszDeviceInstance1
,
2684 pszDeviceInstance2
);
2687 case PNP_DEVINST_SETUP
:
2688 ret
= SetupDeviceInstance(pszDeviceInstance1
,
2692 case PNP_DEVINST_ENABLE
:
2693 ret
= EnableDeviceInstance(pszDeviceInstance1
);
2696 case PNP_DEVINST_DISABLE
:
2697 ret
= DisableDeviceInstance(pszDeviceInstance1
);
2700 case PNP_DEVINST_REENUMERATE
:
2701 ret
= ReenumerateDeviceInstance(pszDeviceInstance1
,
2706 DPRINT1("Unknown device action %lu: not implemented\n", ulAction
);
2707 ret
= CR_CALL_NOT_IMPLEMENTED
;
2710 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
2719 PNP_GetDeviceStatus(
2726 UNREFERENCED_PARAMETER(hBinding
);
2727 UNREFERENCED_PARAMETER(ulFlags
);
2729 DPRINT("PNP_GetDeviceStatus(%p %S %p %p)\n",
2730 hBinding
, pDeviceID
, pulStatus
, pulProblem
, ulFlags
);
2732 return GetDeviceStatus(pDeviceID
, pulStatus
, pulProblem
);
2739 PNP_SetDeviceProblem(
2746 return CR_CALL_NOT_IMPLEMENTED
;
2756 PPNP_VETO_TYPE pVetoType
,
2762 return CR_CALL_NOT_IMPLEMENTED
;
2768 PNP_UninstallDevInst(
2774 return CR_CALL_NOT_IMPLEMENTED
;
2779 CheckForDeviceId(LPWSTR lpDeviceIdList
,
2785 lpPtr
= lpDeviceIdList
;
2788 dwLength
= wcslen(lpPtr
);
2789 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
2792 lpPtr
+= (dwLength
+ 1);
2800 AppendDeviceId(LPWSTR lpDeviceIdList
,
2801 LPDWORD lpDeviceIdListSize
,
2807 dwLen
= wcslen(lpDeviceId
);
2808 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
2810 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
2812 dwPos
+= (dwLen
+ 1);
2814 lpDeviceIdList
[dwPos
] = 0;
2816 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
2829 CONFIGRET ret
= CR_SUCCESS
;
2832 DWORD dwDeviceIdListSize
;
2833 DWORD dwNewDeviceIdSize
;
2834 WCHAR
* pszDeviceIdList
= NULL
;
2836 UNREFERENCED_PARAMETER(hBinding
);
2838 DPRINT("PNP_AddID() called\n");
2839 DPRINT(" DeviceInstance: %S\n", pszDeviceID
);
2840 DPRINT(" DeviceId: %S\n", pszID
);
2841 DPRINT(" Flags: %lx\n", ulFlags
);
2843 if (RegOpenKeyExW(hEnumKey
,
2846 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
2847 &hDeviceKey
) != ERROR_SUCCESS
)
2849 DPRINT("Failed to open the device key!\n");
2850 return CR_INVALID_DEVNODE
;
2853 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
2855 if (RegQueryValueExW(hDeviceKey
,
2860 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2862 DPRINT("Failed to query the desired ID string!\n");
2863 ret
= CR_REGISTRY_ERROR
;
2867 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
2868 if (!dwNewDeviceIdSize
)
2870 ret
= CR_INVALID_POINTER
;
2874 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
2876 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
2877 if (!pszDeviceIdList
)
2879 DPRINT("Failed to allocate memory for the desired ID string!\n");
2880 ret
= CR_OUT_OF_MEMORY
;
2884 if (RegQueryValueExW(hDeviceKey
,
2888 (LPBYTE
)pszDeviceIdList
,
2889 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
2891 DPRINT("Failed to query the desired ID string!\n");
2892 ret
= CR_REGISTRY_ERROR
;
2896 /* Check whether the device ID is already in use */
2897 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
2899 DPRINT("Device ID was found in the ID string!\n");
2904 /* Append the Device ID */
2905 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
2907 if (RegSetValueExW(hDeviceKey
,
2911 (LPBYTE
)pszDeviceIdList
,
2912 dwDeviceIdListSize
) != ERROR_SUCCESS
)
2914 DPRINT("Failed to set the desired ID string!\n");
2915 ret
= CR_REGISTRY_ERROR
;
2919 RegCloseKey(hDeviceKey
);
2920 if (pszDeviceIdList
)
2921 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
2923 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
2938 return CR_CALL_NOT_IMPLEMENTED
;
2948 PPNP_VETO_TYPE pVetoType
,
2954 return CR_CALL_NOT_IMPLEMENTED
;
2961 PNP_RequestDeviceEject(
2964 PPNP_VETO_TYPE pVetoType
,
2970 return CR_CALL_NOT_IMPLEMENTED
;
2977 PNP_IsDockStationPresent(
2985 CONFIGRET ret
= CR_SUCCESS
;
2987 UNREFERENCED_PARAMETER(hBinding
);
2989 DPRINT1("PNP_IsDockStationPresent() called\n");
2993 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
2997 &hKey
) != ERROR_SUCCESS
)
2998 return CR_REGISTRY_ERROR
;
3000 dwSize
= sizeof(DWORD
);
3001 if (RegQueryValueExW(hKey
,
3006 &dwSize
) != ERROR_SUCCESS
)
3007 ret
= CR_REGISTRY_ERROR
;
3011 if (ret
== CR_SUCCESS
)
3013 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
3015 ret
= CR_REGISTRY_ERROR
;
3017 else if (dwValue
!= 0)
3023 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
3036 return CR_CALL_NOT_IMPLEMENTED
;
3049 PPNP_VETO_TYPE pVetoType
,
3054 CONFIGRET ret
= CR_SUCCESS
;
3055 WCHAR szKeyName
[MAX_PATH
];
3060 UNREFERENCED_PARAMETER(hBinding
);
3062 DPRINT("PNP_HwProfFlags() called\n");
3067 L
"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
3072 L
"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
3076 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
3080 &hKey
) != ERROR_SUCCESS
)
3081 return CR_REGISTRY_ERROR
;
3083 if (ulAction
== PNP_GET_HWPROFFLAGS
)
3085 if (RegOpenKeyExW(hKey
,
3089 &hDeviceKey
) != ERROR_SUCCESS
)
3095 dwSize
= sizeof(DWORD
);
3096 if (RegQueryValueExW(hDeviceKey
,
3101 &dwSize
) != ERROR_SUCCESS
)
3106 RegCloseKey(hDeviceKey
);
3109 else if (ulAction
== PNP_SET_HWPROFFLAGS
)
3111 /* FIXME: not implemented yet */
3112 ret
= CR_CALL_NOT_IMPLEMENTED
;
3127 HWPROFILEINFO
*pHWProfileInfo
,
3128 DWORD ulProfileInfoSize
,
3131 WCHAR szProfileName
[5];
3132 HKEY hKeyConfig
= NULL
;
3133 HKEY hKeyProfiles
= NULL
;
3134 HKEY hKeyProfile
= NULL
;
3135 DWORD dwDisposition
;
3138 CONFIGRET ret
= CR_SUCCESS
;
3140 UNREFERENCED_PARAMETER(hBinding
);
3142 DPRINT("PNP_GetHwProfInfo() called\n");
3144 if (ulProfileInfoSize
== 0)
3146 ret
= CR_INVALID_DATA
;
3152 ret
= CR_INVALID_FLAG
;
3156 /* Initialize the profile information */
3157 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3158 pHWProfileInfo
->HWPI_szFriendlyName
[0] = 0;
3159 pHWProfileInfo
->HWPI_dwFlags
= 0;
3161 /* Open the 'IDConfigDB' key */
3162 lError
= RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
3163 L
"System\\CurrentControlSet\\Control\\IDConfigDB",
3166 REG_OPTION_NON_VOLATILE
,
3171 if (lError
!= ERROR_SUCCESS
)
3173 ret
= CR_REGISTRY_ERROR
;
3177 /* Open the 'Hardware Profiles' subkey */
3178 lError
= RegCreateKeyExW(hKeyConfig
,
3179 L
"Hardware Profiles",
3182 REG_OPTION_NON_VOLATILE
,
3183 KEY_ENUMERATE_SUB_KEYS
| KEY_QUERY_VALUE
,
3187 if (lError
!= ERROR_SUCCESS
)
3189 ret
= CR_REGISTRY_ERROR
;
3193 if (ulIndex
== (ULONG
)-1)
3195 dwSize
= sizeof(ULONG
);
3196 lError
= RegQueryValueExW(hKeyConfig
,
3200 (LPBYTE
)&pHWProfileInfo
->HWPI_ulHWProfile
,
3202 if (lError
!= ERROR_SUCCESS
)
3204 pHWProfileInfo
->HWPI_ulHWProfile
= 0;
3205 ret
= CR_REGISTRY_ERROR
;
3211 /* FIXME: not implemented yet */
3212 ret
= CR_CALL_NOT_IMPLEMENTED
;
3216 swprintf(szProfileName
, L
"%04lu", pHWProfileInfo
->HWPI_ulHWProfile
);
3218 lError
= RegOpenKeyExW(hKeyProfiles
,
3223 if (lError
!= ERROR_SUCCESS
)
3225 ret
= CR_REGISTRY_ERROR
;
3229 dwSize
= sizeof(pHWProfileInfo
->HWPI_szFriendlyName
);
3230 lError
= RegQueryValueExW(hKeyProfile
,
3234 (LPBYTE
)&pHWProfileInfo
->HWPI_szFriendlyName
,
3236 if (lError
!= ERROR_SUCCESS
)
3238 ret
= CR_REGISTRY_ERROR
;
3243 if (hKeyProfile
!= NULL
)
3244 RegCloseKey(hKeyProfile
);
3246 if (hKeyProfiles
!= NULL
)
3247 RegCloseKey(hKeyProfiles
);
3249 if (hKeyConfig
!= NULL
)
3250 RegCloseKey(hKeyConfig
);
3259 PNP_AddEmptyLogConf(
3263 DWORD
*pulLogConfTag
,
3267 return CR_CALL_NOT_IMPLEMENTED
;
3277 DWORD ulLogConfType
,
3282 return CR_CALL_NOT_IMPLEMENTED
;
3289 PNP_GetFirstLogConf(
3292 DWORD ulLogConfType
,
3293 DWORD
*pulLogConfTag
,
3297 return CR_CALL_NOT_IMPLEMENTED
;
3307 DWORD ulLogConfType
,
3313 return CR_CALL_NOT_IMPLEMENTED
;
3320 PNP_GetLogConfPriority(
3329 return CR_CALL_NOT_IMPLEMENTED
;
3340 DWORD ulLogConfType
,
3341 RESOURCEID ResourceID
,
3342 DWORD
*pulResourceTag
,
3344 PNP_RPC_BUFFER_SIZE ResourceLen
,
3348 return CR_CALL_NOT_IMPLEMENTED
;
3359 DWORD ulLogConfType
,
3360 RESOURCEID ResourceID
,
3361 DWORD ulResourceTag
,
3362 DWORD
*pulPreviousResType
,
3363 DWORD
*pulPreviousResTag
,
3367 return CR_CALL_NOT_IMPLEMENTED
;
3378 DWORD ulLogConfType
,
3379 RESOURCEID ResourceID
,
3380 DWORD ulResourceTag
,
3381 DWORD
*pulNextResType
,
3382 DWORD
*pulNextResTag
,
3386 return CR_CALL_NOT_IMPLEMENTED
;
3397 DWORD ulLogConfType
,
3398 RESOURCEID ResourceID
,
3399 DWORD ulResourceTag
,
3401 PNP_RPC_BUFFER_SIZE BufferLen
,
3405 return CR_CALL_NOT_IMPLEMENTED
;
3412 PNP_GetResDesDataSize(
3416 DWORD ulLogConfType
,
3417 RESOURCEID ResourceID
,
3418 DWORD ulResourceTag
,
3423 return CR_CALL_NOT_IMPLEMENTED
;
3434 DWORD ulLogConfType
,
3435 RESOURCEID CurrentResourceID
,
3436 RESOURCEID NewResourceID
,
3437 DWORD ulResourceTag
,
3439 PNP_RPC_BUFFER_SIZE ResourceLen
,
3443 return CR_CALL_NOT_IMPLEMENTED
;
3450 PNP_DetectResourceConflict(
3453 RESOURCEID ResourceID
,
3455 PNP_RPC_BUFFER_SIZE ResourceLen
,
3456 BOOL
*pbConflictDetected
,
3459 DPRINT("PNP_DetectResourceConflict()\n");
3461 if (pbConflictDetected
!= NULL
)
3462 *pbConflictDetected
= FALSE
;
3464 return CR_CALL_NOT_IMPLEMENTED
;
3471 PNP_QueryResConfList(
3474 RESOURCEID ResourceID
,
3476 PNP_RPC_BUFFER_SIZE ResourceLen
,
3478 PNP_RPC_BUFFER_SIZE BufferLen
,
3482 return CR_CALL_NOT_IMPLEMENTED
;
3491 DWORD ulHardwareProfile
,
3494 return CR_CALL_NOT_IMPLEMENTED
;
3501 PNP_QueryArbitratorFreeData(
3506 RESOURCEID ResourceID
,
3509 return CR_CALL_NOT_IMPLEMENTED
;
3516 PNP_QueryArbitratorFreeSize(
3520 RESOURCEID ResourceID
,
3523 if (pulSize
!= NULL
)
3526 return CR_CALL_NOT_IMPLEMENTED
;
3537 return CR_CALL_NOT_IMPLEMENTED
;
3544 PNP_RegisterNotification(
3548 BYTE
*pNotificationFilter
,
3549 DWORD ulNotificationFilterSize
,
3555 PDEV_BROADCAST_DEVICEINTERFACE_W pBroadcastDeviceInterface
;
3556 PDEV_BROADCAST_HANDLE pBroadcastDeviceHandle
;
3558 PNOTIFY_DATA pNotifyData
;
3561 DPRINT1("PNP_RegisterNotification(%p %lx '%S' %p %lu 0x%lx %p %lx %p)\n",
3562 hBinding
, ulUnknown2
, pszName
, pNotificationFilter
,
3563 ulNotificationFilterSize
, ulFlags
, pulNotify
, ulUnknown8
, pulUnknown9
);
3565 if (pNotificationFilter
== NULL
||
3566 pulNotify
== NULL
||
3567 pulUnknown9
== NULL
)
3568 return CR_INVALID_POINTER
;
3571 return CR_INVALID_FLAG
;
3573 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_HDR
)) ||
3574 (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_size
< sizeof(DEV_BROADCAST_HDR
)))
3575 return CR_INVALID_DATA
;
3577 if (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
== DBT_DEVTYP_DEVICEINTERFACE
)
3579 DPRINT1("DBT_DEVTYP_DEVICEINTERFACE\n");
3580 pBroadcastDeviceInterface
= (PDEV_BROADCAST_DEVICEINTERFACE_W
)pNotificationFilter
;
3582 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_DEVICEINTERFACE_W
)) ||
3583 (pBroadcastDeviceInterface
->dbcc_size
< sizeof(DEV_BROADCAST_DEVICEINTERFACE_W
)))
3584 return CR_INVALID_DATA
;
3586 else if (((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
== DBT_DEVTYP_HANDLE
)
3588 DPRINT1("DBT_DEVTYP_HANDLE\n");
3589 pBroadcastDeviceHandle
= (PDEV_BROADCAST_HANDLE
)pNotificationFilter
;
3591 if ((ulNotificationFilterSize
< sizeof(DEV_BROADCAST_HANDLE
)) ||
3592 (pBroadcastDeviceHandle
->dbch_size
< sizeof(DEV_BROADCAST_HANDLE
)))
3593 return CR_INVALID_DATA
;
3595 if (ulFlags
& DEVICE_NOTIFY_ALL_INTERFACE_CLASSES
)
3596 return CR_INVALID_FLAG
;
3600 DPRINT1("Invalid device type %lu\n", ((PDEV_BROADCAST_HDR
)pNotificationFilter
)->dbch_devicetype
);
3601 return CR_INVALID_DATA
;
3606 pNotifyData
= RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(NOTIFY_DATA
));
3607 if (pNotifyData
== NULL
)
3608 return CR_OUT_OF_MEMORY
;
3610 *pulNotify
= (DWORD
)pNotifyData
;
3622 PNP_UnregisterNotification(
3626 DPRINT1("PNP_UnregisterNotification(%p 0x%lx)\n",
3627 hBinding
, ulNotify
);
3631 return CR_CALL_NOT_IMPLEMENTED
;
3641 PNP_GetCustomDevProp(
3644 LPWSTR CustomPropName
,
3645 DWORD
*pulRegDataType
,
3647 PNP_RPC_STRING_LEN
*pulTransferLen
,
3648 PNP_RPC_STRING_LEN
*pulLength
,
3651 HKEY hDeviceKey
= NULL
;
3652 HKEY hParamKey
= NULL
;
3654 CONFIGRET ret
= CR_SUCCESS
;
3656 UNREFERENCED_PARAMETER(hBinding
);
3658 DPRINT("PNP_GetCustomDevProp() called\n");
3660 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
3662 ret
= CR_INVALID_POINTER
;
3666 if (ulFlags
& ~CM_CUSTOMDEVPROP_BITS
)
3668 ret
= CR_INVALID_FLAG
;
3672 if (*pulLength
< *pulTransferLen
)
3673 *pulLength
= *pulTransferLen
;
3675 *pulTransferLen
= 0;
3677 lError
= RegOpenKeyExW(hEnumKey
,
3682 if (lError
!= ERROR_SUCCESS
)
3684 ret
= CR_REGISTRY_ERROR
;
3688 lError
= RegOpenKeyExW(hDeviceKey
,
3689 L
"Device Parameters",
3693 if (lError
!= ERROR_SUCCESS
)
3695 ret
= CR_REGISTRY_ERROR
;
3699 lError
= RegQueryValueExW(hParamKey
,
3705 if (lError
!= ERROR_SUCCESS
)
3707 if (lError
== ERROR_MORE_DATA
)
3709 ret
= CR_BUFFER_SMALL
;
3714 ret
= CR_NO_SUCH_VALUE
;
3719 if (ret
== CR_SUCCESS
)
3720 *pulTransferLen
= *pulLength
;
3722 if (hParamKey
!= NULL
)
3723 RegCloseKey(hParamKey
);
3725 if (hDeviceKey
!= NULL
)
3726 RegCloseKey(hDeviceKey
);
3728 DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret
);
3737 PNP_GetVersionInternal(
3741 UNREFERENCED_PARAMETER(hBinding
);
3751 PNP_GetBlockedDriverInfo(
3754 PNP_RPC_BUFFER_SIZE
*pulTransferLen
,
3755 PNP_RPC_BUFFER_SIZE
*pulLength
,
3759 return CR_CALL_NOT_IMPLEMENTED
;
3766 PNP_GetServerSideDeviceInstallFlags(
3768 DWORD
*pulSSDIFlags
,
3771 UNREFERENCED_PARAMETER(hBinding
);
3773 DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
3774 hBinding
, pulSSDIFlags
, ulFlags
);
3776 if (pulSSDIFlags
== NULL
)
3777 return CR_INVALID_POINTER
;
3780 return CR_INVALID_FLAG
;
3792 PNP_GetObjectPropKeys(
3796 LPWSTR PropertyCultureName
,
3797 PNP_PROP_COUNT
*PropertyCount
,
3798 PNP_PROP_COUNT
*TransferLen
,
3799 DEVPROPKEY
*PropertyKeys
,
3803 return CR_CALL_NOT_IMPLEMENTED
;
3814 LPWSTR PropertyCultureName
,
3815 const DEVPROPKEY
*PropertyKey
,
3816 DEVPROPTYPE
*PropertyType
,
3817 PNP_PROP_SIZE
*PropertySize
,
3818 PNP_PROP_SIZE
*TransferLen
,
3819 BYTE
*PropertyBuffer
,
3823 return CR_CALL_NOT_IMPLEMENTED
;
3834 LPWSTR PropertyCultureName
,
3835 const DEVPROPKEY
*PropertyKey
,
3836 DEVPROPTYPE PropertyType
,
3837 PNP_PROP_SIZE PropertySize
,
3838 BYTE
*PropertyBuffer
,
3842 return CR_CALL_NOT_IMPLEMENTED
;
3853 return CR_CALL_NOT_IMPLEMENTED
;
3860 PNP_ApplyPowerSettings(
3864 return CR_CALL_NOT_IMPLEMENTED
;
3871 PNP_DriverStoreAddDriverPackage(
3875 return CR_CALL_NOT_IMPLEMENTED
;
3882 PNP_DriverStoreDeleteDriverPackage(
3886 return CR_CALL_NOT_IMPLEMENTED
;
3893 PNP_RegisterServiceNotification(
3897 return CR_CALL_NOT_IMPLEMENTED
;
3904 PNP_SetActiveService(
3910 return CR_CALL_NOT_IMPLEMENTED
;
3917 PNP_DeleteServiceDevices(
3921 return CR_CALL_NOT_IMPLEMENTED
;