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: services/umpnpmgr/umpnpmgr.c
23 * PURPOSE: User-mode Plug and Play manager
24 * PROGRAMMER: Eric Kohl
25 * Hervé Poussineau (hpoussin@reactos.org)
26 * Colin Finck (colin@reactos.org)
29 /* INCLUDES *****************************************************************/
30 //#define HAVE_SLIST_ENTRY_IMPLEMENTED
31 #define WIN32_NO_STATUS
38 #include <umpnpmgr/sysguid.h>
52 /* GLOBALS ******************************************************************/
54 static VOID CALLBACK
ServiceMain(DWORD argc
, LPWSTR
*argv
);
55 static WCHAR ServiceName
[] = L
"PlugPlay";
56 static SERVICE_TABLE_ENTRYW ServiceTable
[] =
58 {ServiceName
, ServiceMain
},
62 static SERVICE_STATUS_HANDLE ServiceStatusHandle
;
63 static SERVICE_STATUS ServiceStatus
;
65 static WCHAR szRootDeviceId
[] = L
"HTREE\\ROOT\\0";
67 static HKEY hEnumKey
= NULL
;
68 static HKEY hClassKey
= NULL
;
70 static HANDLE hUserToken
= NULL
;
71 static HANDLE hInstallEvent
= NULL
;
72 static HANDLE hNoPendingInstalls
= NULL
;
74 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
75 static SLIST_HEADER DeviceInstallListHead
;
77 static LIST_ENTRY DeviceInstallListHead
;
79 static HANDLE hDeviceInstallListNotEmpty
;
83 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
84 SLIST_ENTRY ListEntry
;
89 } DeviceInstallParams
;
91 /* FUNCTIONS *****************************************************************/
94 RpcServerThread(LPVOID lpParameter
)
97 BOOLEAN RegisteredProtSeq
= FALSE
;
99 UNREFERENCED_PARAMETER(lpParameter
);
101 DPRINT("RpcServerThread() called\n");
104 /* XP-compatible protocol sequence/endpoint */
105 Status
= RpcServerUseProtseqEpW(L
"ncacn_np",
108 NULL
); // Security descriptor
109 if (Status
== RPC_S_OK
)
110 RegisteredProtSeq
= TRUE
;
112 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
115 /* Vista-compatible protocol sequence/endpoint */
116 Status
= RpcServerUseProtseqEpW(L
"ncacn_np",
119 NULL
); // Security descriptor
120 if (Status
== RPC_S_OK
)
121 RegisteredProtSeq
= TRUE
;
123 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
125 /* Make sure there's a usable endpoint */
126 if (RegisteredProtSeq
== FALSE
)
129 Status
= RpcServerRegisterIf(pnp_v1_0_s_ifspec
,
132 if (Status
!= RPC_S_OK
)
134 DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status
);
138 Status
= RpcServerListen(1,
141 if (Status
!= RPC_S_OK
)
143 DPRINT1("RpcServerListen() failed (Status %lx)\n", Status
);
147 /* ROS HACK (this should never happen...) */
148 DPRINT1("*** Other devices won't be installed correctly. If something\n");
149 DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
151 DPRINT("RpcServerThread() done\n");
157 void __RPC_FAR
* __RPC_USER
midl_user_allocate(SIZE_T len
)
159 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
163 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
165 HeapFree(GetProcessHeap(), 0, ptr
);
169 static CONFIGRET WINAPI
170 NtStatusToCrError(NTSTATUS Status
)
174 case STATUS_NO_SUCH_DEVICE
:
175 return CR_NO_SUCH_DEVINST
;
178 /* FIXME: add more mappings */
179 DPRINT1("Unable to map status 0x%08lx\n", Status
);
186 DWORD
PNP_Disconnect(
189 UNREFERENCED_PARAMETER(hBinding
);
198 UNREFERENCED_PARAMETER(hBinding
);
204 DWORD
PNP_GetVersion(
208 UNREFERENCED_PARAMETER(hBinding
);
216 DWORD
PNP_GetGlobalState(
221 UNREFERENCED_PARAMETER(hBinding
);
222 UNREFERENCED_PARAMETER(ulFlags
);
224 *pulState
= CM_GLOBAL_STATE_CAN_DO_UI
| CM_GLOBAL_STATE_SERVICES_AVAILABLE
;
230 DWORD
PNP_InitDetection(
233 UNREFERENCED_PARAMETER(hBinding
);
235 DPRINT("PNP_InitDetection() called\n");
241 DWORD
PNP_ReportLogOn(
246 DWORD ReturnValue
= CR_FAILURE
;
249 UNREFERENCED_PARAMETER(hBinding
);
250 UNREFERENCED_PARAMETER(Admin
);
252 DPRINT("PNP_ReportLogOn(%u, %u) called\n", Admin
, ProcessId
);
254 /* Get the users token */
255 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, TRUE
, ProcessId
);
259 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
265 CloseHandle(hUserToken
);
269 if(!OpenProcessToken(hProcess
, TOKEN_ASSIGN_PRIMARY
| TOKEN_DUPLICATE
| TOKEN_QUERY
, &hUserToken
))
271 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
275 /* Trigger the installer thread */
277 SetEvent(hInstallEvent
);
279 ReturnValue
= CR_SUCCESS
;
283 CloseHandle(hProcess
);
290 DWORD
PNP_ValidateDeviceInstance(
295 CONFIGRET ret
= CR_SUCCESS
;
296 HKEY hDeviceKey
= NULL
;
298 UNREFERENCED_PARAMETER(hBinding
);
299 UNREFERENCED_PARAMETER(ulFlags
);
301 DPRINT("PNP_ValidateDeviceInstance(%S %lx) called\n",
304 if (RegOpenKeyExW(hEnumKey
,
310 DPRINT("Could not open the Device Key!\n");
311 ret
= CR_NO_SUCH_DEVNODE
;
315 /* FIXME: add more tests */
318 if (hDeviceKey
!= NULL
)
319 RegCloseKey(hDeviceKey
);
321 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret
);
328 DWORD
PNP_GetRootDeviceInstance(
331 PNP_RPC_STRING_LEN ulLength
)
333 CONFIGRET ret
= CR_SUCCESS
;
335 UNREFERENCED_PARAMETER(hBinding
);
337 DPRINT("PNP_GetRootDeviceInstance() called\n");
341 ret
= CR_INVALID_POINTER
;
344 if (ulLength
< lstrlenW(szRootDeviceId
) + 1)
346 ret
= CR_BUFFER_SMALL
;
354 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret
);
361 DWORD
PNP_GetRelatedDeviceInstance(
363 DWORD ulRelationship
,
365 LPWSTR pRelatedDeviceId
,
366 PNP_RPC_STRING_LEN
*pulLength
,
369 PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData
;
370 CONFIGRET ret
= CR_SUCCESS
;
373 UNREFERENCED_PARAMETER(hBinding
);
374 UNREFERENCED_PARAMETER(ulFlags
);
376 DPRINT("PNP_GetRelatedDeviceInstance() called\n");
377 DPRINT(" Relationship %ld\n", ulRelationship
);
378 DPRINT(" DeviceId %S\n", pDeviceID
);
380 RtlInitUnicodeString(&PlugPlayData
.TargetDeviceInstance
,
383 PlugPlayData
.Relation
= ulRelationship
;
385 PlugPlayData
.RelatedDeviceInstanceLength
= *pulLength
;
386 PlugPlayData
.RelatedDeviceInstance
= pRelatedDeviceId
;
388 Status
= NtPlugPlayControl(PlugPlayControlGetRelatedDevice
,
389 (PVOID
)&PlugPlayData
,
390 sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
));
391 if (!NT_SUCCESS(Status
))
393 ret
= NtStatusToCrError(Status
);
396 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret
);
397 if (ret
== CR_SUCCESS
)
399 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData
.RelatedDeviceInstance
);
407 DWORD
PNP_EnumerateSubKeys(
412 PNP_RPC_STRING_LEN ulLength
,
413 PNP_RPC_STRING_LEN
*pulRequiredLen
,
416 CONFIGRET ret
= CR_SUCCESS
;
420 UNREFERENCED_PARAMETER(hBinding
);
421 UNREFERENCED_PARAMETER(ulFlags
);
423 DPRINT("PNP_EnumerateSubKeys() called\n");
427 case PNP_ENUMERATOR_SUBKEYS
:
431 case PNP_CLASS_SUBKEYS
:
439 *pulRequiredLen
= ulLength
;
440 dwError
= RegEnumKeyExW(hKey
,
448 if (dwError
!= ERROR_SUCCESS
)
450 ret
= (dwError
== ERROR_NO_MORE_ITEMS
) ? CR_NO_SUCH_VALUE
: CR_FAILURE
;
457 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret
);
464 DWORD
PNP_GetDeviceList(
468 PNP_RPC_STRING_LEN
*pulLength
,
472 return CR_CALL_NOT_IMPLEMENTED
;
477 DWORD
PNP_GetDeviceListSize(
480 PNP_RPC_BUFFER_SIZE
*pulLen
,
484 return CR_CALL_NOT_IMPLEMENTED
;
495 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData
;
496 CONFIGRET ret
= CR_SUCCESS
;
499 UNREFERENCED_PARAMETER(hBinding
);
500 UNREFERENCED_PARAMETER(ulFlags
);
502 DPRINT("PNP_GetDepth() called\n");
504 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
507 Status
= NtPlugPlayControl(PlugPlayControlGetDeviceDepth
,
508 (PVOID
)&PlugPlayData
,
509 sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
));
510 if (NT_SUCCESS(Status
))
512 *pulDepth
= PlugPlayData
.Depth
;
516 ret
= NtStatusToCrError(Status
);
519 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret
);
526 DWORD
PNP_GetDeviceRegProp(
530 DWORD
*pulRegDataType
,
532 PNP_PROP_SIZE
*pulTransferLen
,
533 PNP_PROP_SIZE
*pulLength
,
536 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData
;
537 CONFIGRET ret
= CR_SUCCESS
;
538 LPWSTR lpValueName
= NULL
;
543 UNREFERENCED_PARAMETER(hBinding
);
545 DPRINT("PNP_GetDeviceRegProp() called\n");
547 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
549 ret
= CR_INVALID_POINTER
;
555 ret
= CR_INVALID_FLAG
;
559 /* FIXME: Check pDeviceID */
561 if (*pulLength
< *pulTransferLen
)
562 *pulLength
= *pulTransferLen
;
568 case CM_DRP_DEVICEDESC
:
569 lpValueName
= L
"DeviceDesc";
572 case CM_DRP_HARDWAREID
:
573 lpValueName
= L
"HardwareID";
576 case CM_DRP_COMPATIBLEIDS
:
577 lpValueName
= L
"CompatibleIDs";
581 lpValueName
= L
"Service";
585 lpValueName
= L
"Class";
588 case CM_DRP_CLASSGUID
:
589 lpValueName
= L
"ClassGUID";
593 lpValueName
= L
"Driver";
596 case CM_DRP_CONFIGFLAGS
:
597 lpValueName
= L
"ConfigFlags";
601 lpValueName
= L
"Mfg";
604 case CM_DRP_FRIENDLYNAME
:
605 lpValueName
= L
"FriendlyName";
608 case CM_DRP_LOCATION_INFORMATION
:
609 lpValueName
= L
"LocationInformation";
612 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
616 case CM_DRP_CAPABILITIES
:
617 lpValueName
= L
"Capabilities";
620 case CM_DRP_UI_NUMBER
:
624 case CM_DRP_UPPERFILTERS
:
625 lpValueName
= L
"UpperFilters";
628 case CM_DRP_LOWERFILTERS
:
629 lpValueName
= L
"LowerFilters";
632 case CM_DRP_BUSTYPEGUID
:
636 case CM_DRP_LEGACYBUSTYPE
:
640 case CM_DRP_BUSNUMBER
:
644 case CM_DRP_ENUMERATOR_NAME
:
648 case CM_DRP_SECURITY
:
649 lpValueName
= L
"Security";
653 lpValueName
= L
"DeviceType";
656 case CM_DRP_EXCLUSIVE
:
657 lpValueName
= L
"Exclusive";
660 case CM_DRP_CHARACTERISTICS
:
661 lpValueName
= L
"DeviceCharacteristics";
668 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
669 lpValueName
= L
"UINumberDescFormat";
672 case CM_DRP_DEVICE_POWER_DATA
:
676 case CM_DRP_REMOVAL_POLICY
:
680 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT
:
684 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
685 lpValueName
= L
"RemovalPolicy";
688 case CM_DRP_INSTALL_STATE
:
692 #if (WINVER >= _WIN32_WINNT_WS03)
693 case CM_DRP_LOCATION_PATHS
:
698 #if (WINVER >= _WIN32_WINNT_WIN7)
699 case CM_DRP_BASE_CONTAINERID
:
705 ret
= CR_INVALID_PROPERTY
;
709 DPRINT("Value name: %S\n", lpValueName
);
713 /* Retrieve information from the Registry */
714 lError
= RegOpenKeyExW(hEnumKey
,
719 if (lError
!= ERROR_SUCCESS
)
723 ret
= CR_INVALID_DEVNODE
;
727 lError
= RegQueryValueExW(hKey
,
733 if (lError
!= ERROR_SUCCESS
)
735 if (lError
== ERROR_MORE_DATA
)
737 ret
= CR_BUFFER_SMALL
;
742 ret
= CR_NO_SUCH_VALUE
;
748 /* Retrieve information from the Device Node */
749 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
751 PlugPlayData
.Buffer
= Buffer
;
752 PlugPlayData
.BufferSize
= *pulLength
;
756 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
757 PlugPlayData
.Property
= 0xb; // DevicePropertyPhysicalDeviceObjectName;
760 case CM_DRP_UI_NUMBER
:
761 PlugPlayData
.Property
= 0x11; // DevicePropertyUINumber;
764 case CM_DRP_BUSTYPEGUID
:
765 PlugPlayData
.Property
= 0xc; // DevicePropertyBusTypeGuid;
768 case CM_DRP_LEGACYBUSTYPE
:
769 PlugPlayData
.Property
= 0xd; // DevicePropertyLegacyBusType;
772 case CM_DRP_BUSNUMBER
:
773 PlugPlayData
.Property
= 0xe; // DevicePropertyBusNumber;
776 case CM_DRP_ENUMERATOR_NAME
:
777 PlugPlayData
.Property
= 0xf; // DevicePropertyEnumeratorName;
781 PlugPlayData
.Property
= 0x10; // DevicePropertyAddress;
785 /* FIXME: This property is not supported by IoGetDeviceProperty */
786 case CM_DRP_DEVICE_POWER_DATA
:
789 case CM_DRP_REMOVAL_POLICY
:
790 PlugPlayData
.Property
= 0x12; // DevicePropertyRemovalPolicy
794 /* FIXME: This property is not supported by IoGetDeviceProperty */
795 case CM_DRP_REMOVAL_POLICY_HW_DEFAULT
:
798 case CM_DRP_INSTALL_STATE
:
799 PlugPlayData
.Property
= 0x12; // DevicePropertyInstallState;
803 /* FIXME: This property is not supported by IoGetDeviceProperty */
804 #if (WINVER >= _WIN32_WINNT_WS03)
805 case CM_DRP_LOCATION_PATHS
:
809 #if (WINVER >= _WIN32_WINNT_WIN7)
810 case CM_DRP_BASE_CONTAINERID
:
811 PlugPlayData
.Property
= 0x16; // DevicePropertyContainerID;
816 return CR_INVALID_PROPERTY
;
819 Status
= NtPlugPlayControl(PlugPlayControlProperty
,
820 (PVOID
)&PlugPlayData
,
821 sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
));
822 if (NT_SUCCESS(Status
))
824 *pulLength
= PlugPlayData
.BufferSize
;
828 ret
= NtStatusToCrError(Status
);
833 *pulTransferLen
= (ret
== CR_SUCCESS
) ? *pulLength
: 0;
838 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret
);
845 DWORD
PNP_SetDeviceRegProp(
851 PNP_PROP_SIZE ulLength
,
854 CONFIGRET ret
= CR_SUCCESS
;
855 LPWSTR lpValueName
= NULL
;
858 UNREFERENCED_PARAMETER(hBinding
);
859 UNREFERENCED_PARAMETER(ulFlags
);
861 DPRINT("PNP_SetDeviceRegProp() called\n");
863 DPRINT("DeviceId: %S\n", pDeviceId
);
864 DPRINT("Property: %lu\n", ulProperty
);
865 DPRINT("DataType: %lu\n", ulDataType
);
866 DPRINT("Length: %lu\n", ulLength
);
870 case CM_DRP_DEVICEDESC
:
871 lpValueName
= L
"DeviceDesc";
874 case CM_DRP_HARDWAREID
:
875 lpValueName
= L
"HardwareID";
878 case CM_DRP_COMPATIBLEIDS
:
879 lpValueName
= L
"CompatibleIDs";
883 lpValueName
= L
"Service";
887 lpValueName
= L
"Class";
890 case CM_DRP_CLASSGUID
:
891 lpValueName
= L
"ClassGUID";
895 lpValueName
= L
"Driver";
898 case CM_DRP_CONFIGFLAGS
:
899 lpValueName
= L
"ConfigFlags";
903 lpValueName
= L
"Mfg";
906 case CM_DRP_FRIENDLYNAME
:
907 lpValueName
= L
"FriendlyName";
910 case CM_DRP_LOCATION_INFORMATION
:
911 lpValueName
= L
"LocationInformation";
914 case CM_DRP_UPPERFILTERS
:
915 lpValueName
= L
"UpperFilters";
918 case CM_DRP_LOWERFILTERS
:
919 lpValueName
= L
"LowerFilters";
922 case CM_DRP_SECURITY
:
923 lpValueName
= L
"Security";
927 lpValueName
= L
"DeviceType";
930 case CM_DRP_EXCLUSIVE
:
931 lpValueName
= L
"Exclusive";
934 case CM_DRP_CHARACTERISTICS
:
935 lpValueName
= L
"DeviceCharacteristics";
938 case CM_DRP_UI_NUMBER_DESC_FORMAT
:
939 lpValueName
= L
"UINumberDescFormat";
942 case CM_DRP_REMOVAL_POLICY_OVERRIDE
:
943 lpValueName
= L
"RemovalPolicy";
947 return CR_INVALID_PROPERTY
;
950 DPRINT("Value name: %S\n", lpValueName
);
952 if (RegOpenKeyExW(hEnumKey
,
957 return CR_INVALID_DEVNODE
;
961 if (RegDeleteValueW(hKey
,
963 ret
= CR_REGISTRY_ERROR
;
967 if (RegSetValueExW(hKey
,
973 ret
= CR_REGISTRY_ERROR
;
978 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret
);
985 DWORD
PNP_GetClassInstance(
988 LPWSTR pszClassInstance
,
989 PNP_RPC_STRING_LEN ulLength
)
992 return CR_CALL_NOT_IMPLEMENTED
;
1005 if (RegCreateKeyExW(HKEY_LOCAL_MACHINE
,
1014 return CR_REGISTRY_ERROR
;
1016 /* FIXME: Set security key */
1025 DWORD
PNP_DeleteRegistryKey(
1028 LPWSTR pszParentKey
,
1033 return CR_CALL_NOT_IMPLEMENTED
;
1038 DWORD
PNP_GetClassCount(
1040 DWORD
*pulClassCount
,
1046 UNREFERENCED_PARAMETER(hBinding
);
1047 UNREFERENCED_PARAMETER(ulFlags
);
1049 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1054 if (dwError
!= ERROR_SUCCESS
)
1055 return CR_INVALID_DATA
;
1057 dwError
= RegQueryInfoKeyW(hKey
,
1070 if (dwError
!= ERROR_SUCCESS
)
1071 return CR_INVALID_DATA
;
1078 DWORD
PNP_GetClassName(
1080 LPWSTR pszClassGuid
,
1082 PNP_RPC_STRING_LEN
*pulLength
,
1085 WCHAR szKeyName
[MAX_PATH
];
1086 CONFIGRET ret
= CR_SUCCESS
;
1090 UNREFERENCED_PARAMETER(hBinding
);
1091 UNREFERENCED_PARAMETER(ulFlags
);
1093 DPRINT("PNP_GetClassName() called\n");
1095 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
1096 if(lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
1097 lstrcatW(szKeyName
, pszClassGuid
);
1098 else return CR_INVALID_DATA
;
1100 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
1105 return CR_REGISTRY_ERROR
;
1107 dwSize
= *pulLength
* sizeof(WCHAR
);
1108 if (RegQueryValueExW(hKey
,
1116 ret
= CR_REGISTRY_ERROR
;
1120 *pulLength
= dwSize
/ sizeof(WCHAR
);
1125 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
1132 DWORD
PNP_DeleteClassKey(
1134 LPWSTR pszClassGuid
,
1137 CONFIGRET ret
= CR_SUCCESS
;
1139 UNREFERENCED_PARAMETER(hBinding
);
1141 DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid
, ulFlags
);
1143 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
1145 if (RegDeleteTreeW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
1146 ret
= CR_REGISTRY_ERROR
;
1150 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
1151 ret
= CR_REGISTRY_ERROR
;
1154 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
1161 DWORD
PNP_GetInterfaceDeviceAlias(
1163 LPWSTR pszInterfaceDevice
,
1164 GUID
*AliasInterfaceGuid
,
1165 LPWSTR pszAliasInterfaceDevice
,
1166 PNP_RPC_STRING_LEN
*pulLength
,
1167 PNP_RPC_STRING_LEN
*pulTransferLen
,
1171 return CR_CALL_NOT_IMPLEMENTED
;
1176 DWORD
PNP_GetInterfaceDeviceList(
1178 GUID
*InterfaceGuid
,
1181 PNP_RPC_BUFFER_SIZE
*pulLength
,
1185 return CR_CALL_NOT_IMPLEMENTED
;
1190 DWORD
PNP_GetInterfaceDeviceListSize(
1192 PNP_RPC_BUFFER_SIZE
*pulLen
,
1193 GUID
*InterfaceGuid
,
1198 return CR_CALL_NOT_IMPLEMENTED
;
1203 DWORD
PNP_RegisterDeviceClassAssociation(
1206 GUID
*InterfaceGuid
,
1207 LPWSTR pszReference
,
1209 PNP_RPC_STRING_LEN
*pulLength
,
1210 PNP_RPC_STRING_LEN
*pulTransferLen
,
1214 return CR_CALL_NOT_IMPLEMENTED
;
1219 DWORD
PNP_UnregisterDeviceClassAssociation(
1221 LPWSTR pszInterfaceDevice
,
1225 return CR_CALL_NOT_IMPLEMENTED
;
1230 DWORD
PNP_GetClassRegProp(
1232 LPWSTR pszClassGuid
,
1234 DWORD
*pulRegDataType
,
1236 PNP_RPC_STRING_LEN
*pulTransferLen
,
1237 PNP_RPC_STRING_LEN
*pulLength
,
1240 CONFIGRET ret
= CR_SUCCESS
;
1241 LPWSTR lpValueName
= NULL
;
1242 HKEY hInstKey
= NULL
;
1243 HKEY hPropKey
= NULL
;
1246 UNREFERENCED_PARAMETER(hBinding
);
1248 DPRINT("PNP_GetClassRegProp() called\n");
1250 if (pulTransferLen
== NULL
|| pulLength
== NULL
)
1252 ret
= CR_INVALID_POINTER
;
1258 ret
= CR_INVALID_FLAG
;
1262 if (*pulLength
< *pulTransferLen
)
1263 *pulLength
= *pulTransferLen
;
1265 *pulTransferLen
= 0;
1269 case CM_CRP_SECURITY
:
1270 lpValueName
= L
"Security";
1273 case CM_CRP_DEVTYPE
:
1274 lpValueName
= L
"DeviceType";
1277 case CM_CRP_EXCLUSIVE
:
1278 lpValueName
= L
"Exclusive";
1281 case CM_CRP_CHARACTERISTICS
:
1282 lpValueName
= L
"DeviceCharacteristics";
1286 ret
= CR_INVALID_PROPERTY
;
1290 DPRINT("Value name: %S\n", lpValueName
);
1292 lError
= RegOpenKeyExW(hClassKey
,
1297 if (lError
!= ERROR_SUCCESS
)
1300 ret
= CR_NO_SUCH_REGISTRY_KEY
;
1304 lError
= RegOpenKeyExW(hInstKey
,
1309 if (lError
!= ERROR_SUCCESS
)
1312 ret
= CR_NO_SUCH_REGISTRY_KEY
;
1316 lError
= RegQueryValueExW(hPropKey
,
1322 if (lError
!= ERROR_SUCCESS
)
1324 if (lError
== ERROR_MORE_DATA
)
1326 ret
= CR_BUFFER_SMALL
;
1331 ret
= CR_NO_SUCH_VALUE
;
1336 *pulTransferLen
= (ret
== CR_SUCCESS
) ? *pulLength
: 0;
1338 if (hPropKey
!= NULL
)
1339 RegCloseKey(hPropKey
);
1341 if (hInstKey
!= NULL
)
1342 RegCloseKey(hInstKey
);
1344 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret
);
1351 DWORD
PNP_SetClassRegProp(
1353 LPWSTR pszClassGuid
,
1357 PNP_PROP_SIZE ulLength
,
1360 CONFIGRET ret
= CR_SUCCESS
;
1361 LPWSTR lpValueName
= NULL
;
1366 UNREFERENCED_PARAMETER(hBinding
);
1368 DPRINT("PNP_SetClassRegProp() called\n");
1371 return CR_INVALID_FLAG
;
1375 case CM_CRP_SECURITY
:
1376 lpValueName
= L
"Security";
1379 case CM_CRP_DEVTYPE
:
1380 lpValueName
= L
"DeviceType";
1383 case CM_CRP_EXCLUSIVE
:
1384 lpValueName
= L
"Exclusive";
1387 case CM_CRP_CHARACTERISTICS
:
1388 lpValueName
= L
"DeviceCharacteristics";
1392 return CR_INVALID_PROPERTY
;
1395 lError
= RegOpenKeyExW(hClassKey
,
1400 if (lError
!= ERROR_SUCCESS
)
1402 ret
= CR_NO_SUCH_REGISTRY_KEY
;
1406 /* FIXME: Set security descriptor */
1407 lError
= RegCreateKeyExW(hInstKey
,
1411 REG_OPTION_NON_VOLATILE
,
1416 if (lError
!= ERROR_SUCCESS
)
1418 ret
= CR_REGISTRY_ERROR
;
1424 if (RegDeleteValueW(hPropKey
,
1426 ret
= CR_REGISTRY_ERROR
;
1430 if (RegSetValueExW(hPropKey
,
1436 ret
= CR_REGISTRY_ERROR
;
1440 if (hPropKey
!= NULL
)
1441 RegCloseKey(hPropKey
);
1443 if (hInstKey
!= NULL
)
1444 RegCloseKey(hInstKey
);
1451 SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID
,
1452 OUT LPWSTR pszEnumerator
,
1453 OUT LPWSTR pszDevice
,
1454 OUT LPWSTR pszInstance
)
1456 WCHAR szLocalDeviceInstanceID
[MAX_DEVICE_ID_LEN
];
1457 LPWSTR lpEnumerator
= NULL
;
1458 LPWSTR lpDevice
= NULL
;
1459 LPWSTR lpInstance
= NULL
;
1462 wcscpy(szLocalDeviceInstanceID
, pszDeviceInstanceID
);
1468 lpEnumerator
= szLocalDeviceInstanceID
;
1470 ptr
= wcschr(lpEnumerator
, L
'\\');
1476 ptr
= wcschr(lpDevice
, L
'\\');
1484 if (lpEnumerator
!= NULL
)
1485 wcscpy(pszEnumerator
, lpEnumerator
);
1487 if (lpDevice
!= NULL
)
1488 wcscpy(pszDevice
, lpDevice
);
1490 if (lpInstance
!= NULL
)
1491 wcscpy(pszInstance
, lpInstance
);
1496 CreateDeviceInstance(LPWSTR pszDeviceID
)
1498 WCHAR szEnumerator
[MAX_DEVICE_ID_LEN
];
1499 WCHAR szDevice
[MAX_DEVICE_ID_LEN
];
1500 WCHAR szInstance
[MAX_DEVICE_ID_LEN
];
1501 HKEY hKeyEnumerator
;
1507 /* Split the instance ID */
1508 SplitDeviceInstanceID(pszDeviceID
,
1513 /* Open or create the enumerator key */
1514 lError
= RegCreateKeyExW(hEnumKey
,
1518 REG_OPTION_NON_VOLATILE
,
1523 if (lError
!= ERROR_SUCCESS
)
1525 return CR_REGISTRY_ERROR
;
1528 /* Open or create the device key */
1529 lError
= RegCreateKeyExW(hKeyEnumerator
,
1533 REG_OPTION_NON_VOLATILE
,
1539 /* Close the enumerator key */
1540 RegCloseKey(hKeyEnumerator
);
1542 if (lError
!= ERROR_SUCCESS
)
1544 return CR_REGISTRY_ERROR
;
1547 /* Try to open the instance key and fail if it exists */
1548 lError
= RegOpenKeyExW(hKeyDevice
,
1553 if (lError
== ERROR_SUCCESS
)
1555 DPRINT1("Instance %S already exists!\n", szInstance
);
1556 RegCloseKey(hKeyInstance
);
1557 RegCloseKey(hKeyDevice
);
1558 return CR_ALREADY_SUCH_DEVINST
;
1561 /* Create a new instance key */
1562 lError
= RegCreateKeyExW(hKeyDevice
,
1566 REG_OPTION_NON_VOLATILE
,
1572 /* Close the device key */
1573 RegCloseKey(hKeyDevice
);
1575 if (lError
!= ERROR_SUCCESS
)
1577 return CR_REGISTRY_ERROR
;
1580 /* Create the 'Control' sub key */
1581 lError
= RegCreateKeyExW(hKeyInstance
,
1585 REG_OPTION_NON_VOLATILE
,
1590 if (lError
== ERROR_SUCCESS
)
1592 RegCloseKey(hKeyControl
);
1595 RegCloseKey(hKeyInstance
);
1597 return (lError
== ERROR_SUCCESS
) ? CR_SUCCESS
: CR_REGISTRY_ERROR
;
1602 DWORD
PNP_CreateDevInst(
1605 LPWSTR pszParentDeviceID
,
1606 PNP_RPC_STRING_LEN ulLength
,
1609 CONFIGRET ret
= CR_SUCCESS
;
1611 DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID
);
1613 if (ulFlags
& CM_CREATE_DEVNODE_GENERATE_ID
)
1616 DPRINT1("CM_CREATE_DEVNODE_GENERATE_ID support not implemented yet!\n", ret
);
1617 ret
= CR_CALL_NOT_IMPLEMENTED
;
1621 /* Create the device instance */
1622 ret
= CreateDeviceInstance(pszDeviceID
);
1625 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret
);
1632 MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination
,
1633 LPWSTR pszDeviceInstanceSource
)
1635 DPRINT("MoveDeviceInstance: not implemented\n");
1637 return CR_CALL_NOT_IMPLEMENTED
;
1642 SetupDeviceInstance(LPWSTR pszDeviceInstance
,
1645 DPRINT("SetupDeviceInstance: not implemented\n");
1647 return CR_CALL_NOT_IMPLEMENTED
;
1652 EnableDeviceInstance(LPWSTR pszDeviceInstance
)
1654 PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData
;
1655 CONFIGRET ret
= CR_SUCCESS
;
1658 DPRINT("Enable device instance\n");
1660 RtlInitUnicodeString(&ResetDeviceData
.DeviceInstance
, pszDeviceInstance
);
1661 Status
= NtPlugPlayControl(PlugPlayControlResetDevice
, &ResetDeviceData
, sizeof(PLUGPLAY_CONTROL_RESET_DEVICE_DATA
));
1662 if (!NT_SUCCESS(Status
))
1663 ret
= NtStatusToCrError(Status
);
1670 DisableDeviceInstance(LPWSTR pszDeviceInstance
)
1672 DPRINT("DisableDeviceInstance: not implemented\n");
1674 return CR_CALL_NOT_IMPLEMENTED
;
1679 ReenumerateDeviceInstance(LPWSTR pszDeviceInstance
)
1681 DPRINT("ReenumerateDeviceInstance: not implemented\n");
1683 return CR_CALL_NOT_IMPLEMENTED
;
1688 DWORD
PNP_DeviceInstanceAction(
1692 LPWSTR pszDeviceInstance1
,
1693 LPWSTR pszDeviceInstance2
)
1695 CONFIGRET ret
= CR_SUCCESS
;
1697 UNREFERENCED_PARAMETER(hBinding
);
1699 DPRINT("PNP_DeviceInstanceAction() called\n");
1703 case PNP_DEVINST_MOVE
:
1704 ret
= MoveDeviceInstance(pszDeviceInstance1
,
1705 pszDeviceInstance2
);
1708 case PNP_DEVINST_SETUP
:
1709 ret
= SetupDeviceInstance(pszDeviceInstance1
,
1713 case PNP_DEVINST_ENABLE
:
1714 ret
= EnableDeviceInstance(pszDeviceInstance1
);
1717 case PNP_DEVINST_DISABLE
:
1718 ret
= DisableDeviceInstance(pszDeviceInstance1
);
1721 case PNP_DEVINST_REENUMERATE
:
1722 ret
= ReenumerateDeviceInstance(pszDeviceInstance1
);
1726 DPRINT1("Unknown device action %lu: not implemented\n", ulAction
);
1727 ret
= CR_CALL_NOT_IMPLEMENTED
;
1730 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
1737 DWORD
PNP_GetDeviceStatus(
1744 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
1745 CONFIGRET ret
= CR_SUCCESS
;
1748 UNREFERENCED_PARAMETER(hBinding
);
1749 UNREFERENCED_PARAMETER(ulFlags
);
1751 DPRINT("PNP_GetDeviceStatus() called\n");
1753 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1755 PlugPlayData
.Operation
= 0; /* Get status */
1757 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
1758 (PVOID
)&PlugPlayData
,
1759 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
1760 if (NT_SUCCESS(Status
))
1762 *pulStatus
= PlugPlayData
.DeviceStatus
;
1763 *pulProblem
= PlugPlayData
.DeviceProblem
;
1767 ret
= NtStatusToCrError(Status
);
1770 DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret
);
1777 DWORD
PNP_SetDeviceProblem(
1784 return CR_CALL_NOT_IMPLEMENTED
;
1789 DWORD
PNP_DisableDevInst(
1792 PPNP_VETO_TYPE pVetoType
,
1798 return CR_CALL_NOT_IMPLEMENTED
;
1802 DWORD
PNP_UninstallDevInst(
1808 return CR_CALL_NOT_IMPLEMENTED
;
1813 CheckForDeviceId(LPWSTR lpDeviceIdList
,
1819 lpPtr
= lpDeviceIdList
;
1822 dwLength
= wcslen(lpPtr
);
1823 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
1826 lpPtr
+= (dwLength
+ 1);
1834 AppendDeviceId(LPWSTR lpDeviceIdList
,
1835 LPDWORD lpDeviceIdListSize
,
1841 dwLen
= wcslen(lpDeviceId
);
1842 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
1844 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
1846 dwPos
+= (dwLen
+ 1);
1848 lpDeviceIdList
[dwPos
] = 0;
1850 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
1861 CONFIGRET ret
= CR_SUCCESS
;
1864 DWORD dwDeviceIdListSize
;
1865 DWORD dwNewDeviceIdSize
;
1866 WCHAR
* pszDeviceIdList
= NULL
;
1868 UNREFERENCED_PARAMETER(hBinding
);
1870 DPRINT("PNP_AddID() called\n");
1871 DPRINT(" DeviceInstance: %S\n", pszDeviceID
);
1872 DPRINT(" DeviceId: %S\n", pszID
);
1873 DPRINT(" Flags: %lx\n", ulFlags
);
1875 if (RegOpenKeyExW(hEnumKey
,
1878 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
1879 &hDeviceKey
) != ERROR_SUCCESS
)
1881 DPRINT("Failed to open the device key!\n");
1882 return CR_INVALID_DEVNODE
;
1885 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
1887 if (RegQueryValueExW(hDeviceKey
,
1892 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
1894 DPRINT("Failed to query the desired ID string!\n");
1895 ret
= CR_REGISTRY_ERROR
;
1899 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
1900 if (!dwNewDeviceIdSize
)
1902 ret
= CR_INVALID_POINTER
;
1906 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
1908 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
1909 if (!pszDeviceIdList
)
1911 DPRINT("Failed to allocate memory for the desired ID string!\n");
1912 ret
= CR_OUT_OF_MEMORY
;
1916 if (RegQueryValueExW(hDeviceKey
,
1920 (LPBYTE
)pszDeviceIdList
,
1921 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
1923 DPRINT("Failed to query the desired ID string!\n");
1924 ret
= CR_REGISTRY_ERROR
;
1928 /* Check whether the device ID is already in use */
1929 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
1931 DPRINT("Device ID was found in the ID string!\n");
1936 /* Append the Device ID */
1937 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
1939 if (RegSetValueExW(hDeviceKey
,
1943 (LPBYTE
)pszDeviceIdList
,
1944 dwDeviceIdListSize
) != ERROR_SUCCESS
)
1946 DPRINT("Failed to set the desired ID string!\n");
1947 ret
= CR_REGISTRY_ERROR
;
1951 RegCloseKey(hDeviceKey
);
1952 if (pszDeviceIdList
)
1953 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
1955 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
1962 DWORD
PNP_RegisterDriver(
1968 return CR_CALL_NOT_IMPLEMENTED
;
1973 DWORD
PNP_QueryRemove(
1976 PPNP_VETO_TYPE pVetoType
,
1982 return CR_CALL_NOT_IMPLEMENTED
;
1987 DWORD
PNP_RequestDeviceEject(
1990 PPNP_VETO_TYPE pVetoType
,
1996 return CR_CALL_NOT_IMPLEMENTED
;
2001 PNP_IsDockStationPresent(handle_t hBinding
,
2008 CONFIGRET ret
= CR_SUCCESS
;
2010 UNREFERENCED_PARAMETER(hBinding
);
2012 DPRINT1("PNP_IsDockStationPresent() called\n");
2016 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
2020 &hKey
) != ERROR_SUCCESS
)
2021 return CR_REGISTRY_ERROR
;
2023 dwSize
= sizeof(DWORD
);
2024 if (RegQueryValueExW(hKey
,
2029 &dwSize
) != ERROR_SUCCESS
)
2030 ret
= CR_REGISTRY_ERROR
;
2034 if (ret
== CR_SUCCESS
)
2036 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
2038 ret
= CR_REGISTRY_ERROR
;
2040 else if (dwValue
!= 0)
2046 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
2053 DWORD
PNP_RequestEjectPC(
2057 return CR_CALL_NOT_IMPLEMENTED
;
2062 DWORD
PNP_HwProfFlags(
2068 PPNP_VETO_TYPE pVetoType
,
2073 CONFIGRET ret
= CR_SUCCESS
;
2074 WCHAR szKeyName
[MAX_PATH
];
2079 UNREFERENCED_PARAMETER(hBinding
);
2081 DPRINT("PNP_HwProfFlags() called\n");
2086 L
"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
2091 L
"System\\CurrentControlSet\\HardwareProfiles\\%04u\\System\\CurrentControlSet\\Enum",
2095 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2099 &hKey
) != ERROR_SUCCESS
)
2100 return CR_REGISTRY_ERROR
;
2102 if (ulAction
== PNP_GET_HWPROFFLAGS
)
2104 if (RegOpenKeyExW(hKey
,
2108 &hDeviceKey
) != ERROR_SUCCESS
)
2114 dwSize
= sizeof(DWORD
);
2115 if (!RegQueryValueExW(hDeviceKey
,
2120 &dwSize
) != ERROR_SUCCESS
)
2125 RegCloseKey(hDeviceKey
);
2128 else if (ulAction
== PNP_SET_HWPROFFLAGS
)
2130 /* FIXME: not implemented yet */
2131 ret
= CR_CALL_NOT_IMPLEMENTED
;
2141 DWORD
PNP_GetHwProfInfo(
2144 HWPROFILEINFO
*pHWProfileInfo
,
2145 DWORD ulProfileInfoSize
,
2149 return CR_CALL_NOT_IMPLEMENTED
;
2154 DWORD
PNP_AddEmptyLogConf(
2158 DWORD
*pulLogConfTag
,
2162 return CR_CALL_NOT_IMPLEMENTED
;
2167 DWORD
PNP_FreeLogConf(
2170 DWORD ulLogConfType
,
2175 return CR_CALL_NOT_IMPLEMENTED
;
2180 DWORD
PNP_GetFirstLogConf(
2183 DWORD ulLogConfType
,
2184 DWORD
*pulLogConfTag
,
2188 return CR_CALL_NOT_IMPLEMENTED
;
2193 DWORD
PNP_GetNextLogConf(
2196 DWORD ulLogConfType
,
2202 return CR_CALL_NOT_IMPLEMENTED
;
2207 DWORD
PNP_GetLogConfPriority(
2216 return CR_CALL_NOT_IMPLEMENTED
;
2221 DWORD
PNP_AddResDes(
2225 DWORD ulLogConfType
,
2226 RESOURCEID ResourceID
,
2227 DWORD
*pulResourceTag
,
2229 PNP_RPC_BUFFER_SIZE ResourceLen
,
2233 return CR_CALL_NOT_IMPLEMENTED
;
2238 DWORD
PNP_FreeResDes(
2242 DWORD ulLogConfType
,
2243 RESOURCEID ResourceID
,
2244 DWORD ulResourceTag
,
2245 DWORD
*pulPreviousResType
,
2246 DWORD
*pulPreviousResTag
,
2250 return CR_CALL_NOT_IMPLEMENTED
;
2255 DWORD
PNP_GetNextResDes(
2259 DWORD ulLogConfType
,
2260 RESOURCEID ResourceID
,
2261 DWORD ulResourceTag
,
2262 DWORD
*pulNextResType
,
2263 DWORD
*pulNextResTag
,
2267 return CR_CALL_NOT_IMPLEMENTED
;
2272 DWORD
PNP_GetResDesData(
2276 DWORD ulLogConfType
,
2277 RESOURCEID ResourceID
,
2278 DWORD ulResourceTag
,
2280 PNP_RPC_BUFFER_SIZE BufferLen
,
2284 return CR_CALL_NOT_IMPLEMENTED
;
2289 DWORD
PNP_GetResDesDataSize(
2293 DWORD ulLogConfType
,
2294 RESOURCEID ResourceID
,
2295 DWORD ulResourceTag
,
2300 return CR_CALL_NOT_IMPLEMENTED
;
2305 DWORD
PNP_ModifyResDes(
2309 DWORD ulLogConfType
,
2310 RESOURCEID CurrentResourceID
,
2311 RESOURCEID NewResourceID
,
2312 DWORD ulResourceTag
,
2314 PNP_RPC_BUFFER_SIZE ResourceLen
,
2318 return CR_CALL_NOT_IMPLEMENTED
;
2323 DWORD
PNP_DetectResourceConflict(
2326 RESOURCEID ResourceID
,
2328 PNP_RPC_BUFFER_SIZE ResourceLen
,
2329 BOOL
*pbConflictDetected
,
2333 return CR_CALL_NOT_IMPLEMENTED
;
2338 DWORD
PNP_QueryResConfList(
2341 RESOURCEID ResourceID
,
2343 PNP_RPC_BUFFER_SIZE ResourceLen
,
2345 PNP_RPC_BUFFER_SIZE BufferLen
,
2349 return CR_CALL_NOT_IMPLEMENTED
;
2354 DWORD
PNP_SetHwProf(
2356 DWORD ulHardwareProfile
,
2360 return CR_CALL_NOT_IMPLEMENTED
;
2365 DWORD
PNP_QueryArbitratorFreeData(
2370 RESOURCEID ResourceID
,
2374 return CR_CALL_NOT_IMPLEMENTED
;
2379 DWORD
PNP_QueryArbitratorFreeSize(
2383 RESOURCEID ResourceID
,
2387 return CR_CALL_NOT_IMPLEMENTED
;
2397 return CR_CALL_NOT_IMPLEMENTED
;
2402 DWORD
PNP_RegisterNotification(
2406 return CR_CALL_NOT_IMPLEMENTED
;
2411 DWORD
PNP_UnregisterNotification(
2415 return CR_CALL_NOT_IMPLEMENTED
;
2420 DWORD
PNP_GetCustomDevProp(
2423 LPWSTR CustomPropName
,
2424 DWORD
*pulRegDataType
,
2426 PNP_RPC_STRING_LEN
*pulTransferLen
,
2427 PNP_RPC_STRING_LEN
*pulLength
,
2431 return CR_CALL_NOT_IMPLEMENTED
;
2436 DWORD
PNP_GetVersionInternal(
2441 return CR_CALL_NOT_IMPLEMENTED
;
2446 DWORD
PNP_GetBlockedDriverInfo(
2449 PNP_RPC_BUFFER_SIZE
*pulTransferLen
,
2450 PNP_RPC_BUFFER_SIZE
*pulLength
,
2454 return CR_CALL_NOT_IMPLEMENTED
;
2459 DWORD
PNP_GetServerSideDeviceInstallFlags(
2461 DWORD
*pulSSDIFlags
,
2465 return CR_CALL_NOT_IMPLEMENTED
;
2470 DWORD
PNP_GetObjectPropKeys(
2474 LPWSTR PropertyCultureName
,
2475 PNP_PROP_COUNT
*PropertyCount
,
2476 PNP_PROP_COUNT
*TransferLen
,
2477 DEVPROPKEY
*PropertyKeys
,
2481 return CR_CALL_NOT_IMPLEMENTED
;
2486 DWORD
PNP_GetObjectProp(
2490 LPWSTR PropertyCultureName
,
2491 const DEVPROPKEY
*PropertyKey
,
2492 DEVPROPTYPE
*PropertyType
,
2493 PNP_PROP_SIZE
*PropertySize
,
2494 PNP_PROP_SIZE
*TransferLen
,
2495 BYTE
*PropertyBuffer
,
2499 return CR_CALL_NOT_IMPLEMENTED
;
2504 DWORD
PNP_SetObjectProp(
2508 LPWSTR PropertyCultureName
,
2509 const DEVPROPKEY
*PropertyKey
,
2510 DEVPROPTYPE PropertyType
,
2511 PNP_PROP_SIZE PropertySize
,
2512 BYTE
*PropertyBuffer
,
2516 return CR_CALL_NOT_IMPLEMENTED
;
2521 DWORD
PNP_InstallDevInst(
2525 return CR_CALL_NOT_IMPLEMENTED
;
2530 DWORD
PNP_ApplyPowerSettings(
2534 return CR_CALL_NOT_IMPLEMENTED
;
2539 DWORD
PNP_DriverStoreAddDriverPackage(
2543 return CR_CALL_NOT_IMPLEMENTED
;
2548 DWORD
PNP_DriverStoreDeleteDriverPackage(
2552 return CR_CALL_NOT_IMPLEMENTED
;
2557 DWORD
PNP_RegisterServiceNotification(
2561 return CR_CALL_NOT_IMPLEMENTED
;
2566 DWORD
PNP_SetActiveService(
2570 return CR_CALL_NOT_IMPLEMENTED
;
2575 DWORD
PNP_DeleteServiceDevices(
2579 return CR_CALL_NOT_IMPLEMENTED
;
2584 InstallDevice(PCWSTR DeviceInstance
, BOOL ShowWizard
)
2586 BOOL DeviceInstalled
= FALSE
;
2589 HANDLE hPipe
= INVALID_HANDLE_VALUE
;
2590 LPVOID Environment
= NULL
;
2591 PROCESS_INFORMATION ProcessInfo
;
2592 STARTUPINFOW StartupInfo
;
2596 /* The following lengths are constant (see below), they cannot overflow */
2597 WCHAR CommandLine
[116];
2598 WCHAR InstallEventName
[73];
2600 WCHAR UuidString
[39];
2602 DPRINT("InstallDevice(%S, %d)\n", DeviceInstance
, ShowWizard
);
2604 ZeroMemory(&ProcessInfo
, sizeof(ProcessInfo
));
2606 if (RegOpenKeyExW(hEnumKey
,
2610 &DeviceKey
) == ERROR_SUCCESS
)
2612 if (RegQueryValueExW(DeviceKey
,
2617 NULL
) == ERROR_SUCCESS
)
2619 DPRINT("No need to install: %S\n", DeviceInstance
);
2620 RegCloseKey(DeviceKey
);
2624 RegCloseKey(DeviceKey
);
2627 DPRINT1("Installing: %S\n", DeviceInstance
);
2629 /* Create a random UUID for the named pipe */
2630 UuidCreate(&RandomUuid
);
2631 swprintf(UuidString
, L
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
2632 RandomUuid
.Data1
, RandomUuid
.Data2
, RandomUuid
.Data3
,
2633 RandomUuid
.Data4
[0], RandomUuid
.Data4
[1], RandomUuid
.Data4
[2],
2634 RandomUuid
.Data4
[3], RandomUuid
.Data4
[4], RandomUuid
.Data4
[5],
2635 RandomUuid
.Data4
[6], RandomUuid
.Data4
[7]);
2637 /* Create the named pipe */
2638 wcscpy(PipeName
, L
"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
2639 wcscat(PipeName
, UuidString
);
2640 hPipe
= CreateNamedPipeW(PipeName
, PIPE_ACCESS_OUTBOUND
, PIPE_TYPE_BYTE
, 1, 512, 512, 0, NULL
);
2642 if(hPipe
== INVALID_HANDLE_VALUE
)
2644 DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError());
2648 /* Launch rundll32 to call ClientSideInstallW */
2649 wcscpy(CommandLine
, L
"rundll32.exe newdev.dll,ClientSideInstall ");
2650 wcscat(CommandLine
, PipeName
);
2652 ZeroMemory(&StartupInfo
, sizeof(StartupInfo
));
2653 StartupInfo
.cb
= sizeof(StartupInfo
);
2657 /* newdev has to run under the environment of the current user */
2658 if(!CreateEnvironmentBlock(&Environment
, hUserToken
, FALSE
))
2660 DPRINT1("CreateEnvironmentBlock failed with error %d\n", GetLastError());
2664 if(!CreateProcessAsUserW(hUserToken
, NULL
, CommandLine
, NULL
, NULL
, FALSE
, CREATE_UNICODE_ENVIRONMENT
, Environment
, NULL
, &StartupInfo
, &ProcessInfo
))
2666 DPRINT1("CreateProcessAsUserW failed with error %u\n", GetLastError());
2672 /* FIXME: This is probably not correct, I guess newdev should never be run with SYSTEM privileges.
2674 Still, we currently do that in 2nd stage setup and probably Console mode as well, so allow it here.
2675 (ShowWizard is only set to FALSE for these two modes) */
2676 ASSERT(!ShowWizard
);
2678 if(!CreateProcessW(NULL
, CommandLine
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &StartupInfo
, &ProcessInfo
))
2680 DPRINT1("CreateProcessW failed with error %u\n", GetLastError());
2685 /* Wait for the function to connect to our pipe */
2686 if(!ConnectNamedPipe(hPipe
, NULL
))
2688 DPRINT1("ConnectNamedPipe failed with error %u\n", GetLastError());
2692 /* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */
2693 wcscpy(InstallEventName
, L
"Global\\PNP_Device_Install_Event_0.");
2694 wcscat(InstallEventName
, UuidString
);
2696 Value
= sizeof(InstallEventName
);
2697 WriteFile(hPipe
, &Value
, sizeof(Value
), &BytesWritten
, NULL
);
2698 WriteFile(hPipe
, InstallEventName
, Value
, &BytesWritten
, NULL
);
2700 /* I couldn't figure out what the following value means under WinXP. It's usually 0 in my tests, but was also 5 once.
2701 Therefore the following line is entirely ReactOS-specific. We use the value here to pass the ShowWizard variable. */
2702 WriteFile(hPipe
, &ShowWizard
, sizeof(ShowWizard
), &BytesWritten
, NULL
);
2704 Value
= (wcslen(DeviceInstance
) + 1) * sizeof(WCHAR
);
2705 WriteFile(hPipe
, &Value
, sizeof(Value
), &BytesWritten
, NULL
);
2706 WriteFile(hPipe
, DeviceInstance
, Value
, &BytesWritten
, NULL
);
2708 /* Wait for newdev.dll to finish processing */
2709 WaitForSingleObject(ProcessInfo
.hProcess
, INFINITE
);
2711 /* The following check for success is probably not compatible to Windows, but should do its job */
2712 if(!GetExitCodeProcess(ProcessInfo
.hProcess
, &Value
))
2714 DPRINT1("GetExitCodeProcess failed with error %u\n", GetLastError());
2718 DeviceInstalled
= Value
;
2721 if(hPipe
!= INVALID_HANDLE_VALUE
)
2725 DestroyEnvironmentBlock(Environment
);
2727 if(ProcessInfo
.hProcess
)
2728 CloseHandle(ProcessInfo
.hProcess
);
2730 if(ProcessInfo
.hThread
)
2731 CloseHandle(ProcessInfo
.hThread
);
2733 DPRINT1("Success? %d\n", DeviceInstalled
);
2735 return DeviceInstalled
;
2751 return ERROR_INVALID_PARAMETER
;
2754 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
2755 if (rc
!= ERROR_SUCCESS
)
2757 if (dwType
!= REG_SZ
)
2758 return ERROR_FILE_NOT_FOUND
;
2759 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
2761 return ERROR_NOT_ENOUGH_MEMORY
;
2762 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
2763 if (rc
!= ERROR_SUCCESS
)
2765 HeapFree(GetProcessHeap(), 0, Value
);
2768 /* NULL-terminate the string */
2769 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
2772 return ERROR_SUCCESS
;
2780 DWORD regType
, active
, size
;
2784 rc
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\Setup", 0, KEY_QUERY_VALUE
, &hKey
);
2785 if (rc
!= ERROR_SUCCESS
)
2788 size
= sizeof(DWORD
);
2789 rc
= RegQueryValueExW(hKey
, L
"SystemSetupInProgress", NULL
, ®Type
, (LPBYTE
)&active
, &size
);
2790 if (rc
!= ERROR_SUCCESS
)
2792 if (regType
!= REG_DWORD
|| size
!= sizeof(DWORD
))
2795 ret
= (active
!= 0);
2801 DPRINT("System setup in progress? %S\n", ret
? L
"YES" : L
"NO");
2810 HKEY ControlKey
= NULL
;
2811 LPWSTR SystemStartOptions
= NULL
;
2812 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
2813 BOOL ConsoleBoot
= FALSE
;
2818 L
"SYSTEM\\CurrentControlSet\\Control",
2823 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
2824 if (rc
!= ERROR_SUCCESS
)
2827 /* Check for CMDCONS in SystemStartOptions */
2828 CurrentOption
= SystemStartOptions
;
2829 while (CurrentOption
)
2831 NextOption
= wcschr(CurrentOption
, L
' ');
2833 *NextOption
= L
'\0';
2834 if (_wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
2836 DPRINT("Found %S. Switching to console boot\n", CurrentOption
);
2840 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
2844 if (ControlKey
!= NULL
)
2845 RegCloseKey(ControlKey
);
2846 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
2851 /* Loop to install all queued devices installations */
2853 DeviceInstallThread(LPVOID lpParameter
)
2855 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2856 PSLIST_ENTRY ListEntry
;
2858 PLIST_ENTRY ListEntry
;
2860 DeviceInstallParams
* Params
;
2863 UNREFERENCED_PARAMETER(lpParameter
);
2865 WaitForSingleObject(hInstallEvent
, INFINITE
);
2867 showWizard
= !SetupIsActive() && !IsConsoleBoot();
2871 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2872 ListEntry
= InterlockedPopEntrySList(&DeviceInstallListHead
);
2874 if ((BOOL
)IsListEmpty(&DeviceInstallListHead
))
2877 ListEntry
= RemoveHeadList(&DeviceInstallListHead
);
2879 if (ListEntry
== NULL
)
2881 SetEvent(hNoPendingInstalls
);
2882 WaitForSingleObject(hDeviceInstallListNotEmpty
, INFINITE
);
2886 ResetEvent(hNoPendingInstalls
);
2887 Params
= CONTAINING_RECORD(ListEntry
, DeviceInstallParams
, ListEntry
);
2888 InstallDevice(Params
->DeviceIds
, showWizard
);
2897 PnpEventThread(LPVOID lpParameter
)
2899 PPLUGPLAY_EVENT_BLOCK PnpEvent
;
2902 RPC_STATUS RpcStatus
;
2904 UNREFERENCED_PARAMETER(lpParameter
);
2906 PnpEventSize
= 0x1000;
2907 PnpEvent
= HeapAlloc(GetProcessHeap(), 0, PnpEventSize
);
2908 if (PnpEvent
== NULL
)
2909 return ERROR_OUTOFMEMORY
;
2913 DPRINT("Calling NtGetPlugPlayEvent()\n");
2915 /* Wait for the next pnp event */
2916 Status
= NtGetPlugPlayEvent(0, 0, PnpEvent
, PnpEventSize
);
2918 /* Resize the buffer for the PnP event if it's too small. */
2919 if (Status
== STATUS_BUFFER_TOO_SMALL
)
2921 PnpEventSize
+= 0x400;
2922 HeapFree(GetProcessHeap(), 0, PnpEvent
);
2923 PnpEvent
= HeapAlloc(GetProcessHeap(), 0, PnpEventSize
);
2924 if (PnpEvent
== NULL
)
2925 return ERROR_OUTOFMEMORY
;
2929 if (!NT_SUCCESS(Status
))
2931 DPRINT("NtGetPlugPlayEvent() failed (Status %lx)\n", Status
);
2935 /* Process the pnp event */
2936 DPRINT("Received PnP Event\n");
2937 if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_ENUMERATED
, &RpcStatus
))
2939 DeviceInstallParams
* Params
;
2941 DWORD DeviceIdLength
;
2943 DPRINT1("Device enumerated: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2945 DeviceIdLength
= lstrlenW(PnpEvent
->TargetDevice
.DeviceIds
);
2948 /* Queue device install (will be dequeued by DeviceInstallThread */
2949 len
= FIELD_OFFSET(DeviceInstallParams
, DeviceIds
) + (DeviceIdLength
+ 1) * sizeof(WCHAR
);
2950 Params
= HeapAlloc(GetProcessHeap(), 0, len
);
2953 wcscpy(Params
->DeviceIds
, PnpEvent
->TargetDevice
.DeviceIds
);
2954 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2955 InterlockedPushEntrySList(&DeviceInstallListHead
, &Params
->ListEntry
);
2957 InsertTailList(&DeviceInstallListHead
, &Params
->ListEntry
);
2959 SetEvent(hDeviceInstallListNotEmpty
);
2963 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_ARRIVAL
, &RpcStatus
))
2965 DPRINT1("Device arrival: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2968 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_EJECT_VETOED
, &RpcStatus
))
2970 DPRINT1("Eject vetoed: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2972 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_KERNEL_INITIATED_EJECT
, &RpcStatus
))
2974 DPRINT1("Kernel initiated eject: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2976 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_SAFE_REMOVAL
, &RpcStatus
))
2978 DPRINT1("Safe removal: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2980 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_SURPRISE_REMOVAL
, &RpcStatus
))
2982 DPRINT1("Surprise removal: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2984 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_REMOVAL_VETOED
, &RpcStatus
))
2986 DPRINT1("Removal vetoed: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2988 else if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_REMOVE_PENDING
, &RpcStatus
))
2990 DPRINT1("Removal pending: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2994 DPRINT1("Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
2995 PnpEvent
->EventGuid
.Data1
, PnpEvent
->EventGuid
.Data2
, PnpEvent
->EventGuid
.Data3
,
2996 PnpEvent
->EventGuid
.Data4
[0], PnpEvent
->EventGuid
.Data4
[1], PnpEvent
->EventGuid
.Data4
[2],
2997 PnpEvent
->EventGuid
.Data4
[3], PnpEvent
->EventGuid
.Data4
[4], PnpEvent
->EventGuid
.Data4
[5],
2998 PnpEvent
->EventGuid
.Data4
[6], PnpEvent
->EventGuid
.Data4
[7]);
3001 /* Dequeue the current pnp event and signal the next one */
3002 NtPlugPlayControl(PlugPlayControlUserResponse
, NULL
, 0);
3005 HeapFree(GetProcessHeap(), 0, PnpEvent
);
3007 return ERROR_SUCCESS
;
3012 UpdateServiceStatus(DWORD dwState
)
3014 ServiceStatus
.dwServiceType
= SERVICE_WIN32_OWN_PROCESS
;
3015 ServiceStatus
.dwCurrentState
= dwState
;
3016 ServiceStatus
.dwControlsAccepted
= 0;
3017 ServiceStatus
.dwWin32ExitCode
= 0;
3018 ServiceStatus
.dwServiceSpecificExitCode
= 0;
3019 ServiceStatus
.dwCheckPoint
= 0;
3021 if (dwState
== SERVICE_START_PENDING
||
3022 dwState
== SERVICE_STOP_PENDING
||
3023 dwState
== SERVICE_PAUSE_PENDING
||
3024 dwState
== SERVICE_CONTINUE_PENDING
)
3025 ServiceStatus
.dwWaitHint
= 10000;
3027 ServiceStatus
.dwWaitHint
= 0;
3029 SetServiceStatus(ServiceStatusHandle
,
3035 ServiceControlHandler(DWORD dwControl
,
3040 DPRINT1("ServiceControlHandler() called\n");
3044 case SERVICE_CONTROL_STOP
:
3045 DPRINT1(" SERVICE_CONTROL_STOP received\n");
3046 /* Stop listening to RPC Messages */
3047 RpcMgmtStopServerListening(NULL
);
3048 UpdateServiceStatus(SERVICE_STOPPED
);
3049 return ERROR_SUCCESS
;
3051 case SERVICE_CONTROL_PAUSE
:
3052 DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
3053 UpdateServiceStatus(SERVICE_PAUSED
);
3054 return ERROR_SUCCESS
;
3056 case SERVICE_CONTROL_CONTINUE
:
3057 DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
3058 UpdateServiceStatus(SERVICE_RUNNING
);
3059 return ERROR_SUCCESS
;
3061 case SERVICE_CONTROL_INTERROGATE
:
3062 DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
3063 SetServiceStatus(ServiceStatusHandle
,
3065 return ERROR_SUCCESS
;
3067 case SERVICE_CONTROL_SHUTDOWN
:
3068 DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
3069 UpdateServiceStatus(SERVICE_STOPPED
);
3070 return ERROR_SUCCESS
;
3073 DPRINT1(" Control %lu received\n");
3074 return ERROR_CALL_NOT_IMPLEMENTED
;
3079 static VOID CALLBACK
3080 ServiceMain(DWORD argc
, LPTSTR
*argv
)
3085 UNREFERENCED_PARAMETER(argc
);
3086 UNREFERENCED_PARAMETER(argv
);
3088 DPRINT("ServiceMain() called\n");
3090 ServiceStatusHandle
= RegisterServiceCtrlHandlerExW(ServiceName
,
3091 ServiceControlHandler
,
3093 if (!ServiceStatusHandle
)
3095 DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
3099 UpdateServiceStatus(SERVICE_START_PENDING
);
3101 hThread
= CreateThread(NULL
,
3107 if (hThread
!= NULL
)
3108 CloseHandle(hThread
);
3110 hThread
= CreateThread(NULL
,
3116 if (hThread
!= NULL
)
3117 CloseHandle(hThread
);
3119 hThread
= CreateThread(NULL
,
3121 DeviceInstallThread
,
3125 if (hThread
!= NULL
)
3126 CloseHandle(hThread
);
3128 UpdateServiceStatus(SERVICE_RUNNING
);
3130 DPRINT("ServiceMain() done\n");
3135 wmain(int argc
, WCHAR
*argv
[])
3140 UNREFERENCED_PARAMETER(argc
);
3141 UNREFERENCED_PARAMETER(argv
);
3143 DPRINT("Umpnpmgr: main() started\n");
3145 /* We need this privilege for using CreateProcessAsUserW */
3146 RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE
, TRUE
, FALSE
, &OldValue
);
3148 hInstallEvent
= CreateEvent(NULL
, TRUE
, SetupIsActive()/*FALSE*/, NULL
);
3149 if (hInstallEvent
== NULL
)
3151 dwError
= GetLastError();
3152 DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError
);
3156 hDeviceInstallListNotEmpty
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
3157 if (hDeviceInstallListNotEmpty
== NULL
)
3159 dwError
= GetLastError();
3160 DPRINT1("Could not create the Event! (Error %lu)\n", dwError
);
3164 hNoPendingInstalls
= CreateEventW(NULL
,
3167 L
"Global\\PnP_No_Pending_Install_Events");
3168 if (hNoPendingInstalls
== NULL
)
3170 dwError
= GetLastError();
3171 DPRINT1("Could not create the Event! (Error %lu)\n", dwError
);
3175 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
3176 InitializeSListHead(&DeviceInstallListHead
);
3178 InitializeListHead(&DeviceInstallListHead
);
3181 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
3182 L
"System\\CurrentControlSet\\Enum",
3186 if (dwError
!= ERROR_SUCCESS
)
3188 DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError
);
3192 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
3193 L
"System\\CurrentControlSet\\Control\\Class",
3197 if (dwError
!= ERROR_SUCCESS
)
3199 DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError
);
3203 StartServiceCtrlDispatcher(ServiceTable
);
3205 DPRINT("Umpnpmgr: main() done\n");