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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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)
28 /* INCLUDES *****************************************************************/
29 //#define HAVE_SLIST_ENTRY_IMPLEMENTED
30 #define WIN32_NO_STATUS
35 #include <umpnpmgr/sysguid.h>
48 /* GLOBALS ******************************************************************/
51 ServiceMain(DWORD argc
, LPTSTR
*argv
);
53 static SERVICE_TABLE_ENTRY ServiceTable
[2] =
55 {TEXT("PlugPlay"), ServiceMain
},
59 static WCHAR szRootDeviceId
[] = L
"HTREE\\ROOT\\0";
61 static HKEY hEnumKey
= NULL
;
62 static HKEY hClassKey
= NULL
;
64 static HANDLE hUserToken
= NULL
;
65 static HANDLE hInstallEvent
= NULL
;
66 static HANDLE hNoPendingInstalls
= NULL
;
68 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
69 static SLIST_HEADER DeviceInstallListHead
;
71 static LIST_ENTRY DeviceInstallListHead
;
73 static HANDLE hDeviceInstallListNotEmpty
;
77 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
78 SLIST_ENTRY ListEntry
;
83 } DeviceInstallParams
;
85 /* FUNCTIONS *****************************************************************/
88 RpcServerThread(LPVOID lpParameter
)
92 UNREFERENCED_PARAMETER(lpParameter
);
94 DPRINT("RpcServerThread() called\n");
96 Status
= RpcServerUseProtseqEpW(L
"ncacn_np",
99 NULL
); // Security descriptor
100 if (Status
!= RPC_S_OK
)
102 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status
);
106 Status
= RpcServerRegisterIf(pnp_v1_0_s_ifspec
,
109 if (Status
!= RPC_S_OK
)
111 DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status
);
115 Status
= RpcServerListen(1,
118 if (Status
!= RPC_S_OK
)
120 DPRINT1("RpcServerListen() failed (Status %lx)\n", Status
);
124 /* ROS HACK (this should never happen...) */
125 DPRINT1("*** Other devices won't be installed correctly. If something\n");
126 DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
128 DPRINT("RpcServerThread() done\n");
134 void __RPC_FAR
* __RPC_USER
midl_user_allocate(size_t len
)
136 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
140 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
142 HeapFree(GetProcessHeap(), 0, ptr
);
146 static CONFIGRET WINAPI
147 NtStatusToCrError(NTSTATUS Status
)
151 case STATUS_NO_SUCH_DEVICE
:
152 return CR_NO_SUCH_DEVINST
;
155 /* FIXME: add more mappings */
156 DPRINT1("Unable to map status 0x%08lx\n", Status
);
163 DWORD
PNP_Disconnect(
166 UNREFERENCED_PARAMETER(hBinding
);
168 return CR_CALL_NOT_IMPLEMENTED
;
176 UNREFERENCED_PARAMETER(hBinding
);
178 return CR_CALL_NOT_IMPLEMENTED
;
183 DWORD
PNP_GetVersion(
187 UNREFERENCED_PARAMETER(hBinding
);
195 DWORD
PNP_GetGlobalState(
200 UNREFERENCED_PARAMETER(hBinding
);
201 UNREFERENCED_PARAMETER(ulFlags
);
203 *pulState
= CM_GLOBAL_STATE_CAN_DO_UI
| CM_GLOBAL_STATE_SERVICES_AVAILABLE
;
209 DWORD
PNP_InitDetection(
212 UNREFERENCED_PARAMETER(hBinding
);
214 DPRINT("PNP_InitDetection() called\n");
220 DWORD
PNP_ReportLogOn(
227 UNREFERENCED_PARAMETER(hBinding
);
228 UNREFERENCED_PARAMETER(Admin
);
230 DPRINT("PNP_ReportLogOn(%u, %u) called\n", Admin
, ProcessId
);
232 if (hInstallEvent
!= NULL
)
233 SetEvent(hInstallEvent
);
235 /* Get the users token */
236 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
,
239 if (hProcess
!= NULL
)
241 if (hUserToken
!= NULL
)
243 CloseHandle(hUserToken
);
247 OpenProcessToken(hProcess
,
250 CloseHandle(hProcess
);
253 /* Trigger the installer thread */
254 /*if (hInstallEvent != NULL)
255 SetEvent(hInstallEvent);*/
262 DWORD
PNP_ValidateDeviceInstance(
267 CONFIGRET ret
= CR_SUCCESS
;
268 HKEY hDeviceKey
= NULL
;
270 UNREFERENCED_PARAMETER(hBinding
);
271 UNREFERENCED_PARAMETER(ulFlags
);
273 DPRINT("PNP_ValidateDeviceInstance(%S %lx) called\n",
276 if (RegOpenKeyExW(hEnumKey
,
282 DPRINT("Could not open the Device Key!\n");
283 ret
= CR_NO_SUCH_DEVNODE
;
287 /* FIXME: add more tests */
290 if (hDeviceKey
!= NULL
)
291 RegCloseKey(hDeviceKey
);
293 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret
);
300 DWORD
PNP_GetRootDeviceInstance(
303 PNP_RPC_STRING_LEN ulLength
)
305 CONFIGRET ret
= CR_SUCCESS
;
307 UNREFERENCED_PARAMETER(hBinding
);
309 DPRINT("PNP_GetRootDeviceInstance() called\n");
313 ret
= CR_INVALID_POINTER
;
316 if (ulLength
< lstrlenW(szRootDeviceId
) + 1)
318 ret
= CR_BUFFER_SMALL
;
326 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret
);
333 DWORD
PNP_GetRelatedDeviceInstance(
335 DWORD ulRelationship
,
337 LPWSTR pRelatedDeviceId
,
338 PNP_RPC_STRING_LEN
*pulLength
,
341 PLUGPLAY_CONTROL_RELATED_DEVICE_DATA PlugPlayData
;
342 CONFIGRET ret
= CR_SUCCESS
;
345 UNREFERENCED_PARAMETER(hBinding
);
346 UNREFERENCED_PARAMETER(ulFlags
);
348 DPRINT("PNP_GetRelatedDeviceInstance() called\n");
349 DPRINT(" Relationship %ld\n", ulRelationship
);
350 DPRINT(" DeviceId %S\n", pDeviceID
);
352 RtlInitUnicodeString(&PlugPlayData
.TargetDeviceInstance
,
355 PlugPlayData
.Relation
= ulRelationship
;
357 PlugPlayData
.RelatedDeviceInstanceLength
= *pulLength
;
358 PlugPlayData
.RelatedDeviceInstance
= pRelatedDeviceId
;
360 Status
= NtPlugPlayControl(PlugPlayControlGetRelatedDevice
,
361 (PVOID
)&PlugPlayData
,
362 sizeof(PLUGPLAY_CONTROL_RELATED_DEVICE_DATA
));
363 if (!NT_SUCCESS(Status
))
365 ret
= NtStatusToCrError(Status
);
368 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret
);
369 if (ret
== CR_SUCCESS
)
371 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData
.RelatedDeviceInstance
);
379 DWORD
PNP_EnumerateSubKeys(
384 PNP_RPC_STRING_LEN ulLength
,
385 PNP_RPC_STRING_LEN
*pulRequiredLen
,
388 CONFIGRET ret
= CR_SUCCESS
;
392 UNREFERENCED_PARAMETER(hBinding
);
393 UNREFERENCED_PARAMETER(ulFlags
);
395 DPRINT("PNP_EnumerateSubKeys() called\n");
399 case PNP_ENUMERATOR_SUBKEYS
:
403 case PNP_CLASS_SUBKEYS
:
411 *pulRequiredLen
= ulLength
;
412 dwError
= RegEnumKeyExW(hKey
,
420 if (dwError
!= ERROR_SUCCESS
)
422 ret
= (dwError
== ERROR_NO_MORE_ITEMS
) ? CR_NO_SUCH_VALUE
: CR_FAILURE
;
429 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret
);
436 DWORD
PNP_GetDeviceList(
440 PNP_RPC_STRING_LEN
*pulLength
,
444 return CR_CALL_NOT_IMPLEMENTED
;
449 DWORD
PNP_GetDeviceListSize(
452 PNP_RPC_BUFFER_SIZE
*pulLen
,
456 return CR_CALL_NOT_IMPLEMENTED
;
467 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData
;
468 CONFIGRET ret
= CR_SUCCESS
;
471 UNREFERENCED_PARAMETER(hBinding
);
472 UNREFERENCED_PARAMETER(ulFlags
);
474 DPRINT("PNP_GetDepth() called\n");
476 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
479 Status
= NtPlugPlayControl(PlugPlayControlGetDeviceDepth
,
480 (PVOID
)&PlugPlayData
,
481 sizeof(PLUGPLAY_CONTROL_DEPTH_DATA
));
482 if (NT_SUCCESS(Status
))
484 *pulDepth
= PlugPlayData
.Depth
;
488 ret
= NtStatusToCrError(Status
);
491 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret
);
498 DWORD
PNP_GetDeviceRegProp(
502 DWORD
*pulRegDataType
,
504 PNP_PROP_SIZE
*pulTransferLen
,
505 PNP_PROP_SIZE
*pulLength
,
508 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData
;
509 CONFIGRET ret
= CR_SUCCESS
;
510 LPWSTR lpValueName
= NULL
;
514 UNREFERENCED_PARAMETER(hBinding
);
515 UNREFERENCED_PARAMETER(ulFlags
);
517 DPRINT("PNP_GetDeviceRegProp() called\n");
521 case CM_DRP_DEVICEDESC
:
522 lpValueName
= L
"DeviceDesc";
525 case CM_DRP_HARDWAREID
:
526 lpValueName
= L
"HardwareID";
529 case CM_DRP_COMPATIBLEIDS
:
530 lpValueName
= L
"CompatibleIDs";
534 lpValueName
= L
"Service";
538 lpValueName
= L
"Class";
541 case CM_DRP_CLASSGUID
:
542 lpValueName
= L
"ClassGUID";
546 lpValueName
= L
"Driver";
549 case CM_DRP_CONFIGFLAGS
:
550 lpValueName
= L
"ConfigFlags";
554 lpValueName
= L
"Mfg";
557 case CM_DRP_FRIENDLYNAME
:
558 lpValueName
= L
"FriendlyName";
561 case CM_DRP_LOCATION_INFORMATION
:
562 lpValueName
= L
"LocationInformation";
565 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
569 case CM_DRP_CAPABILITIES
:
570 lpValueName
= L
"Capabilities";
573 case CM_DRP_UI_NUMBER
:
577 case CM_DRP_UPPERFILTERS
:
578 lpValueName
= L
"UpperFilters";
581 case CM_DRP_LOWERFILTERS
:
582 lpValueName
= L
"LowerFilters";
585 case CM_DRP_BUSTYPEGUID
:
589 case CM_DRP_LEGACYBUSTYPE
:
593 case CM_DRP_BUSNUMBER
:
597 case CM_DRP_ENUMERATOR_NAME
:
602 return CR_INVALID_PROPERTY
;
605 DPRINT("Value name: %S\n", lpValueName
);
609 /* Retrieve information from the Registry */
610 if (RegOpenKeyExW(hEnumKey
,
615 return CR_INVALID_DEVNODE
;
617 if (RegQueryValueExW(hKey
,
623 ret
= CR_REGISTRY_ERROR
;
625 /* FIXME: Check buffer size */
631 /* Retrieve information from the Device Node */
632 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
634 PlugPlayData
.Buffer
= Buffer
;
635 PlugPlayData
.BufferSize
= *pulTransferLen
;
640 case CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
:
641 PlugPlayData
.Property
= DevicePropertyPhysicalDeviceObjectName
;
644 case CM_DRP_UI_NUMBER
:
645 PlugPlayData
.Property
= DevicePropertyUINumber
;
648 case CM_DRP_BUSTYPEGUID
:
649 PlugPlayData
.Property
= DevicePropertyBusTypeGuid
;
652 case CM_DRP_LEGACYBUSTYPE
:
653 PlugPlayData
.Property
= DevicePropertyLegacyBusType
;
656 case CM_DRP_BUSNUMBER
:
657 PlugPlayData
.Property
= DevicePropertyBusNumber
;
660 case CM_DRP_ENUMERATOR_NAME
:
661 PlugPlayData
.Property
= DevicePropertyEnumeratorName
;
666 return CR_INVALID_PROPERTY
;
669 Status
= NtPlugPlayControl(PlugPlayControlProperty
,
670 (PVOID
)&PlugPlayData
,
671 sizeof(PLUGPLAY_CONTROL_PROPERTY_DATA
));
672 if (NT_SUCCESS(Status
))
674 *pulLength
= PlugPlayData
.BufferSize
;
678 ret
= NtStatusToCrError(Status
);
682 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret
);
689 DWORD
PNP_SetDeviceRegProp(
695 PNP_PROP_SIZE ulLength
,
698 CONFIGRET ret
= CR_SUCCESS
;
699 LPWSTR lpValueName
= NULL
;
702 UNREFERENCED_PARAMETER(hBinding
);
703 UNREFERENCED_PARAMETER(ulFlags
);
705 DPRINT("PNP_SetDeviceRegProp() called\n");
707 DPRINT("DeviceId: %S\n", pDeviceId
);
708 DPRINT("Property: %lu\n", ulProperty
);
709 DPRINT("DataType: %lu\n", ulDataType
);
710 DPRINT("Length: %lu\n", ulLength
);
714 case CM_DRP_DEVICEDESC
:
715 lpValueName
= L
"DeviceDesc";
718 case CM_DRP_HARDWAREID
:
719 lpValueName
= L
"HardwareID";
722 case CM_DRP_COMPATIBLEIDS
:
723 lpValueName
= L
"CompatibleIDs";
727 lpValueName
= L
"Service";
731 lpValueName
= L
"Class";
734 case CM_DRP_CLASSGUID
:
735 lpValueName
= L
"ClassGUID";
739 lpValueName
= L
"Driver";
742 case CM_DRP_CONFIGFLAGS
:
743 lpValueName
= L
"ConfigFlags";
747 lpValueName
= L
"Mfg";
750 case CM_DRP_FRIENDLYNAME
:
751 lpValueName
= L
"FriendlyName";
754 case CM_DRP_LOCATION_INFORMATION
:
755 lpValueName
= L
"LocationInformation";
758 case CM_DRP_UPPERFILTERS
:
759 lpValueName
= L
"UpperFilters";
762 case CM_DRP_LOWERFILTERS
:
763 lpValueName
= L
"LowerFilters";
767 return CR_INVALID_PROPERTY
;
770 DPRINT("Value name: %S\n", lpValueName
);
772 if (RegOpenKeyExW(hEnumKey
,
775 KEY_ALL_ACCESS
, /* FIXME: so much? */
777 return CR_INVALID_DEVNODE
;
781 if (RegDeleteValueW(hKey
,
783 ret
= CR_REGISTRY_ERROR
;
787 if (RegSetValueExW(hKey
,
793 ret
= CR_REGISTRY_ERROR
;
798 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret
);
805 DWORD
PNP_GetClassInstance(
808 LPWSTR pszClassInstance
,
809 PNP_RPC_STRING_LEN ulLength
)
812 return CR_CALL_NOT_IMPLEMENTED
;
824 return CR_CALL_NOT_IMPLEMENTED
;
829 DWORD
PNP_DeleteRegistryKey(
837 return CR_CALL_NOT_IMPLEMENTED
;
842 DWORD
PNP_GetClassCount(
844 DWORD
*pulClassCount
,
850 UNREFERENCED_PARAMETER(hBinding
);
851 UNREFERENCED_PARAMETER(ulFlags
);
853 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
858 if (dwError
!= ERROR_SUCCESS
)
859 return CR_INVALID_DATA
;
861 dwError
= RegQueryInfoKeyW(hKey
,
874 if (dwError
!= ERROR_SUCCESS
)
875 return CR_INVALID_DATA
;
882 DWORD
PNP_GetClassName(
886 PNP_RPC_STRING_LEN
*pulLength
,
889 WCHAR szKeyName
[MAX_PATH
];
890 CONFIGRET ret
= CR_SUCCESS
;
894 UNREFERENCED_PARAMETER(hBinding
);
895 UNREFERENCED_PARAMETER(ulFlags
);
897 DPRINT("PNP_GetClassName() called\n");
899 lstrcpyW(szKeyName
, L
"System\\CurrentControlSet\\Control\\Class\\");
900 if(lstrlenW(pszClassGuid
) + 1 < sizeof(szKeyName
)/sizeof(WCHAR
)-(lstrlenW(szKeyName
) * sizeof(WCHAR
)))
901 lstrcatW(szKeyName
, pszClassGuid
);
902 else return CR_INVALID_DATA
;
904 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
909 return CR_REGISTRY_ERROR
;
911 dwSize
= *pulLength
* sizeof(WCHAR
);
912 if (RegQueryValueExW(hKey
,
920 ret
= CR_REGISTRY_ERROR
;
924 *pulLength
= dwSize
/ sizeof(WCHAR
);
929 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret
);
936 DWORD
PNP_DeleteClassKey(
941 CONFIGRET ret
= CR_SUCCESS
;
943 UNREFERENCED_PARAMETER(hBinding
);
945 DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid
, ulFlags
);
947 if (ulFlags
& CM_DELETE_CLASS_SUBKEYS
)
949 if (RegDeleteTreeW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
950 ret
= CR_REGISTRY_ERROR
;
954 if (RegDeleteKeyW(hClassKey
, pszClassGuid
) != ERROR_SUCCESS
)
955 ret
= CR_REGISTRY_ERROR
;
958 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret
);
965 DWORD
PNP_GetInterfaceDeviceAlias(
967 LPWSTR pszInterfaceDevice
,
968 GUID
*AliasInterfaceGuid
,
969 LPWSTR pszAliasInterfaceDevice
,
970 PNP_RPC_STRING_LEN
*pulLength
,
971 PNP_RPC_STRING_LEN
*pulTransferLen
,
975 return CR_CALL_NOT_IMPLEMENTED
;
980 DWORD
PNP_GetInterfaceDeviceList(
985 PNP_RPC_BUFFER_SIZE
*pulLength
,
989 return CR_CALL_NOT_IMPLEMENTED
;
994 DWORD
PNP_GetInterfaceDeviceListSize(
996 PNP_RPC_BUFFER_SIZE
*pulLen
,
1002 return CR_CALL_NOT_IMPLEMENTED
;
1007 DWORD
PNP_RegisterDeviceClassAssociation(
1010 GUID
*InterfaceGuid
,
1011 LPWSTR pszReference
,
1013 PNP_RPC_STRING_LEN
*pulLength
,
1014 PNP_RPC_STRING_LEN
*pulTransferLen
,
1018 return CR_CALL_NOT_IMPLEMENTED
;
1023 DWORD
PNP_UnregisterDeviceClassAssociation(
1025 LPWSTR pszInterfaceDevice
,
1029 return CR_CALL_NOT_IMPLEMENTED
;
1034 DWORD
PNP_GetClassRegProp(
1036 LPWSTR pszClassGuid
,
1038 DWORD
*pulRegDataType
,
1040 PNP_RPC_STRING_LEN
*pulTransferLen
,
1041 PNP_RPC_STRING_LEN
*pulLength
,
1045 return CR_CALL_NOT_IMPLEMENTED
;
1050 DWORD
PNP_SetClassRegProp(
1052 LPWSTR
*pszClassGuid
,
1056 PNP_PROP_SIZE ulLength
,
1060 return CR_CALL_NOT_IMPLEMENTED
;
1065 DWORD
PNP_CreateDevInst(
1068 LPWSTR pszParentDeviceID
,
1069 PNP_RPC_STRING_LEN ulLength
,
1073 return CR_CALL_NOT_IMPLEMENTED
;
1078 #define PNP_DEVINST_SETUP 0x3
1079 #define PNP_DEVINST_ENABLE 0x4
1080 #define PNP_DEVINST_REENUMERATE 0x7
1081 DWORD
PNP_DeviceInstanceAction(
1083 DWORD ulMajorAction
,
1084 DWORD ulMinorAction
,
1085 LPWSTR pszDeviceInstance1
,
1086 LPWSTR pszDeviceInstance2
)
1088 CONFIGRET ret
= CR_SUCCESS
;
1090 UNREFERENCED_PARAMETER(hBinding
);
1091 UNREFERENCED_PARAMETER(ulMinorAction
);
1092 UNREFERENCED_PARAMETER(pszDeviceInstance1
);
1093 UNREFERENCED_PARAMETER(pszDeviceInstance2
);
1095 DPRINT("PNP_DeviceInstanceAction() called\n");
1097 switch (ulMajorAction
)
1099 case PNP_DEVINST_SETUP
:
1100 DPRINT("Setup device instance\n");
1102 ret
= CR_CALL_NOT_IMPLEMENTED
;
1105 case PNP_DEVINST_ENABLE
:
1106 DPRINT("Enable device instance\n");
1108 ret
= CR_CALL_NOT_IMPLEMENTED
;
1111 case PNP_DEVINST_REENUMERATE
:
1112 DPRINT("Reenumerate device instance\n");
1114 ret
= CR_CALL_NOT_IMPLEMENTED
;
1118 DPRINT1("Unknown function %lu\n", ulMajorAction
);
1119 ret
= CR_CALL_NOT_IMPLEMENTED
;
1122 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret
);
1129 DWORD
PNP_GetDeviceStatus(
1136 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
1137 CONFIGRET ret
= CR_SUCCESS
;
1140 UNREFERENCED_PARAMETER(hBinding
);
1141 UNREFERENCED_PARAMETER(ulFlags
);
1143 DPRINT("PNP_GetDeviceStatus() called\n");
1145 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1147 PlugPlayData
.Operation
= 0; /* Get status */
1149 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
1150 (PVOID
)&PlugPlayData
,
1151 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
1152 if (NT_SUCCESS(Status
))
1154 *pulStatus
= PlugPlayData
.DeviceStatus
;
1155 *pulProblem
= PlugPlayData
.DeviceProblem
;
1159 ret
= NtStatusToCrError(Status
);
1162 DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret
);
1169 DWORD
PNP_SetDeviceProblem(
1176 return CR_CALL_NOT_IMPLEMENTED
;
1181 DWORD
PNP_DisableDevInst(
1184 PPNP_VETO_TYPE pVetoType
,
1190 return CR_CALL_NOT_IMPLEMENTED
;
1194 DWORD
PNP_UninstallDevInst(
1200 return CR_CALL_NOT_IMPLEMENTED
;
1205 CheckForDeviceId(LPWSTR lpDeviceIdList
,
1211 lpPtr
= lpDeviceIdList
;
1214 dwLength
= wcslen(lpPtr
);
1215 if (0 == _wcsicmp(lpPtr
, lpDeviceId
))
1218 lpPtr
+= (dwLength
+ 1);
1226 AppendDeviceId(LPWSTR lpDeviceIdList
,
1227 LPDWORD lpDeviceIdListSize
,
1233 dwLen
= wcslen(lpDeviceId
);
1234 dwPos
= (*lpDeviceIdListSize
/ sizeof(WCHAR
)) - 1;
1236 wcscpy(&lpDeviceIdList
[dwPos
], lpDeviceId
);
1238 dwPos
+= (dwLen
+ 1);
1240 lpDeviceIdList
[dwPos
] = 0;
1242 *lpDeviceIdListSize
= dwPos
* sizeof(WCHAR
);
1253 CONFIGRET ret
= CR_SUCCESS
;
1256 DWORD dwDeviceIdListSize
;
1257 DWORD dwNewDeviceIdSize
;
1258 WCHAR
* pszDeviceIdList
= NULL
;
1260 UNREFERENCED_PARAMETER(hBinding
);
1262 DPRINT("PNP_AddID() called\n");
1263 DPRINT(" DeviceInstance: %S\n", pszDeviceID
);
1264 DPRINT(" DeviceId: %S\n", pszID
);
1265 DPRINT(" Flags: %lx\n", ulFlags
);
1267 if (RegOpenKeyExW(hEnumKey
,
1270 KEY_QUERY_VALUE
| KEY_SET_VALUE
,
1271 &hDeviceKey
) != ERROR_SUCCESS
)
1273 DPRINT("Failed to open the device key!\n");
1274 return CR_INVALID_DEVNODE
;
1277 pszSubKey
= (ulFlags
& CM_ADD_ID_COMPATIBLE
) ? L
"CompatibleIDs" : L
"HardwareID";
1279 if (RegQueryValueExW(hDeviceKey
,
1284 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
1286 DPRINT("Failed to query the desired ID string!\n");
1287 ret
= CR_REGISTRY_ERROR
;
1291 dwNewDeviceIdSize
= lstrlenW(pszDeviceID
);
1292 if (!dwNewDeviceIdSize
)
1294 ret
= CR_INVALID_POINTER
;
1298 dwDeviceIdListSize
+= (dwNewDeviceIdSize
+ 2) * sizeof(WCHAR
);
1300 pszDeviceIdList
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, dwDeviceIdListSize
);
1301 if (!pszDeviceIdList
)
1303 DPRINT("Failed to allocate memory for the desired ID string!\n");
1304 ret
= CR_OUT_OF_MEMORY
;
1308 if (RegQueryValueExW(hDeviceKey
,
1312 (LPBYTE
)pszDeviceIdList
,
1313 &dwDeviceIdListSize
) != ERROR_SUCCESS
)
1315 DPRINT("Failed to query the desired ID string!\n");
1316 ret
= CR_REGISTRY_ERROR
;
1320 /* Check whether the device ID is already in use */
1321 if (CheckForDeviceId(pszDeviceIdList
, pszDeviceID
))
1323 DPRINT("Device ID was found in the ID string!\n");
1328 /* Append the Device ID */
1329 AppendDeviceId(pszDeviceIdList
, &dwDeviceIdListSize
, pszID
);
1331 if (RegSetValueExW(hDeviceKey
,
1335 (LPBYTE
)pszDeviceIdList
,
1336 dwDeviceIdListSize
) != ERROR_SUCCESS
)
1338 DPRINT("Failed to set the desired ID string!\n");
1339 ret
= CR_REGISTRY_ERROR
;
1343 RegCloseKey(hDeviceKey
);
1344 if (pszDeviceIdList
)
1345 HeapFree(GetProcessHeap(), 0, pszDeviceIdList
);
1347 DPRINT("PNP_AddID() done (returns %lx)\n", ret
);
1354 DWORD
PNP_RegisterDriver(
1360 return CR_CALL_NOT_IMPLEMENTED
;
1365 DWORD
PNP_QueryRemove(
1368 PPNP_VETO_TYPE pVetoType
,
1374 return CR_CALL_NOT_IMPLEMENTED
;
1379 DWORD
PNP_RequestDeviceEject(
1382 PPNP_VETO_TYPE pVetoType
,
1388 return CR_CALL_NOT_IMPLEMENTED
;
1393 PNP_IsDockStationPresent(handle_t hBinding
,
1400 CONFIGRET ret
= CR_SUCCESS
;
1402 UNREFERENCED_PARAMETER(hBinding
);
1404 DPRINT1("PNP_IsDockStationPresent() called\n");
1408 if (RegOpenKeyExW(HKEY_CURRENT_CONFIG
,
1412 &hKey
) != ERROR_SUCCESS
)
1413 return CR_REGISTRY_ERROR
;
1415 dwSize
= sizeof(DWORD
);
1416 if (RegQueryValueExW(hKey
,
1421 &dwSize
) != ERROR_SUCCESS
)
1422 ret
= CR_REGISTRY_ERROR
;
1426 if (ret
== CR_SUCCESS
)
1428 if (dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
1430 ret
= CR_REGISTRY_ERROR
;
1432 else if (dwValue
!= 0)
1438 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret
);
1445 DWORD
PNP_RequestEjectPC(
1449 return CR_CALL_NOT_IMPLEMENTED
;
1454 DWORD
PNP_HwProfFlags(
1460 PPNP_VETO_TYPE pVetoType
,
1466 return CR_CALL_NOT_IMPLEMENTED
;
1471 DWORD
PNP_GetHwProfInfo(
1474 HWPROFILEINFO
*pHWProfileInfo
,
1475 DWORD ulProfileInfoSize
,
1479 return CR_CALL_NOT_IMPLEMENTED
;
1484 DWORD
PNP_AddEmptyLogConf(
1488 DWORD
*pulLogConfTag
,
1492 return CR_CALL_NOT_IMPLEMENTED
;
1497 DWORD
PNP_FreeLogConf(
1500 DWORD ulLogConfType
,
1505 return CR_CALL_NOT_IMPLEMENTED
;
1510 DWORD
PNP_GetFirstLogConf(
1513 DWORD ulLogConfType
,
1514 DWORD
*pulLogConfTag
,
1518 return CR_CALL_NOT_IMPLEMENTED
;
1523 DWORD
PNP_GetNextLogConf(
1526 DWORD ulLogConfType
,
1532 return CR_CALL_NOT_IMPLEMENTED
;
1537 DWORD
PNP_GetLogConfPriority(
1546 return CR_CALL_NOT_IMPLEMENTED
;
1551 DWORD
PNP_AddResDes(
1555 DWORD ulLogConfType
,
1556 RESOURCEID ResourceID
,
1557 DWORD
*pulResourceTag
,
1559 PNP_RPC_BUFFER_SIZE ResourceLen
,
1563 return CR_CALL_NOT_IMPLEMENTED
;
1568 DWORD
PNP_FreeResDes(
1572 DWORD ulLogConfType
,
1573 RESOURCEID ResourceID
,
1574 DWORD ulResourceTag
,
1575 DWORD
*pulPreviousResType
,
1576 DWORD
*pulPreviousResTag
,
1580 return CR_CALL_NOT_IMPLEMENTED
;
1585 DWORD
PNP_GetNextResDes(
1589 DWORD ulLogConfType
,
1590 RESOURCEID ResourceID
,
1591 DWORD ulResourceTag
,
1592 DWORD
*pulNextResType
,
1593 DWORD
*pulNextResTag
,
1597 return CR_CALL_NOT_IMPLEMENTED
;
1602 DWORD
PNP_GetResDesData(
1606 DWORD ulLogConfType
,
1607 RESOURCEID ResourceID
,
1608 DWORD ulResourceTag
,
1610 PNP_RPC_BUFFER_SIZE BufferLen
,
1614 return CR_CALL_NOT_IMPLEMENTED
;
1619 DWORD
PNP_GetResDesDataSize(
1623 DWORD ulLogConfType
,
1624 RESOURCEID ResourceID
,
1625 DWORD ulResourceTag
,
1630 return CR_CALL_NOT_IMPLEMENTED
;
1635 DWORD
PNP_ModifyResDes(
1639 DWORD ulLogConfType
,
1640 RESOURCEID CurrentResourceID
,
1641 RESOURCEID NewResourceID
,
1642 DWORD ulResourceTag
,
1644 PNP_RPC_BUFFER_SIZE ResourceLen
,
1648 return CR_CALL_NOT_IMPLEMENTED
;
1653 DWORD
PNP_DetectResourceConflict(
1656 RESOURCEID ResourceID
,
1658 PNP_RPC_BUFFER_SIZE ResourceLen
,
1659 BOOL
*pbConflictDetected
,
1663 return CR_CALL_NOT_IMPLEMENTED
;
1668 DWORD
PNP_QueryResConfList(
1671 RESOURCEID ResourceID
,
1673 PNP_RPC_BUFFER_SIZE ResourceLen
,
1675 PNP_RPC_BUFFER_SIZE BufferLen
,
1679 return CR_CALL_NOT_IMPLEMENTED
;
1684 DWORD
PNP_SetHwProf(
1688 return CR_CALL_NOT_IMPLEMENTED
;
1693 DWORD
PNP_QueryArbitratorFreeData(
1697 return CR_CALL_NOT_IMPLEMENTED
;
1702 DWORD
PNP_QueryArbitratorFreeSize(
1706 return CR_CALL_NOT_IMPLEMENTED
;
1717 return CR_CALL_NOT_IMPLEMENTED
;
1722 DWORD
PNP_RegisterNotification(
1726 return CR_CALL_NOT_IMPLEMENTED
;
1731 DWORD
PNP_UnregisterNotification(
1735 return CR_CALL_NOT_IMPLEMENTED
;
1740 DWORD
PNP_GetCustomDevProp(
1743 LPWSTR CustomPropName
,
1744 DWORD
*pulRegDataType
,
1746 PNP_RPC_STRING_LEN
*pulTransferLen
,
1747 PNP_RPC_STRING_LEN
*pulLength
,
1751 return CR_CALL_NOT_IMPLEMENTED
;
1756 DWORD
PNP_GetVersionInternal(
1761 return CR_CALL_NOT_IMPLEMENTED
;
1766 DWORD
PNP_GetBlockedDriverInfo(
1769 PNP_RPC_BUFFER_SIZE
*pulTransferLen
,
1770 PNP_RPC_BUFFER_SIZE
*pulLength
,
1774 return CR_CALL_NOT_IMPLEMENTED
;
1779 DWORD
PNP_GetServerSideDeviceInstallFlags(
1781 DWORD
*pulSSDIFlags
,
1785 return CR_CALL_NOT_IMPLEMENTED
;
1790 DWORD
PNP_GetObjectPropKeys(
1794 LPWSTR PropertyCultureName
,
1795 PNP_PROP_COUNT
*PropertyCount
,
1796 PNP_PROP_COUNT
*TransferLen
,
1797 DEVPROPKEY
*PropertyKeys
,
1801 return CR_CALL_NOT_IMPLEMENTED
;
1806 DWORD
PNP_GetObjectProp(
1810 LPWSTR PropertyCultureName
,
1811 const DEVPROPKEY
*PropertyKey
,
1812 DEVPROPTYPE
*PropertyType
,
1813 PNP_PROP_SIZE
*PropertySize
,
1814 PNP_PROP_SIZE
*TransferLen
,
1815 BYTE
*PropertyBuffer
,
1819 return CR_CALL_NOT_IMPLEMENTED
;
1824 DWORD
PNP_SetObjectProp(
1828 LPWSTR PropertyCultureName
,
1829 const DEVPROPKEY
*PropertyKey
,
1830 DEVPROPTYPE PropertyType
,
1831 PNP_PROP_SIZE PropertySize
,
1832 BYTE
*PropertyBuffer
,
1836 return CR_CALL_NOT_IMPLEMENTED
;
1841 DWORD
PNP_InstallDevInst(
1845 return CR_CALL_NOT_IMPLEMENTED
;
1850 DWORD
PNP_ApplyPowerSettings(
1854 return CR_CALL_NOT_IMPLEMENTED
;
1859 DWORD
PNP_DriverStoreAddDriverPackage(
1863 return CR_CALL_NOT_IMPLEMENTED
;
1868 DWORD
PNP_DriverStoreDeleteDriverPackage(
1872 return CR_CALL_NOT_IMPLEMENTED
;
1877 DWORD
PNP_RegisterServiceNotification(
1881 return CR_CALL_NOT_IMPLEMENTED
;
1886 DWORD
PNP_SetActiveService(
1890 return CR_CALL_NOT_IMPLEMENTED
;
1895 DWORD
PNP_DeleteServiceDevices(
1899 return CR_CALL_NOT_IMPLEMENTED
;
1903 typedef BOOL (WINAPI
*PDEV_INSTALL_W
)(HWND
, HINSTANCE
, LPCWSTR
, INT
);
1906 InstallDevice(PCWSTR DeviceInstance
, BOOL ShowWizard
)
1908 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData
;
1909 HMODULE hNewDev
= NULL
;
1910 PDEV_INSTALL_W DevInstallW
;
1912 BOOL DeviceInstalled
= FALSE
;
1914 DPRINT("InstallDevice(%S, %d)\n", DeviceInstance
, ShowWizard
);
1916 RtlInitUnicodeString(&PlugPlayData
.DeviceInstance
,
1918 PlugPlayData
.Operation
= 0; /* Get status */
1920 /* Get device status */
1921 Status
= NtPlugPlayControl(PlugPlayControlDeviceStatus
,
1922 (PVOID
)&PlugPlayData
,
1923 sizeof(PLUGPLAY_CONTROL_STATUS_DATA
));
1924 if (!NT_SUCCESS(Status
))
1926 DPRINT1("NtPlugPlayControl('%S') failed with status 0x%08lx\n", DeviceInstance
, Status
);
1930 if ((PlugPlayData
.DeviceStatus
& (DNF_STARTED
| DNF_START_FAILED
)) != 0)
1932 /* Device is already started, or disabled due to some problem. Don't install it */
1933 DPRINT("No need to install '%S'\n", DeviceInstance
);
1937 /* Install device */
1938 SetEnvironmentVariableW(L
"USERPROFILE", L
"."); /* FIXME: why is it needed? */
1940 hNewDev
= LoadLibraryW(L
"newdev.dll");
1943 DPRINT1("Unable to load newdev.dll\n");
1947 DevInstallW
= (PDEV_INSTALL_W
)GetProcAddress(hNewDev
, (LPCSTR
)"DevInstallW");
1950 DPRINT1("'DevInstallW' not found in newdev.dll\n");
1954 if (!DevInstallW(NULL
, NULL
, DeviceInstance
, ShowWizard
? SW_SHOWNOACTIVATE
: SW_HIDE
))
1956 DPRINT1("DevInstallW('%S') failed\n", DeviceInstance
);
1960 DeviceInstalled
= TRUE
;
1963 if (hNewDev
!= NULL
)
1964 FreeLibrary(hNewDev
);
1966 return DeviceInstalled
;
1982 return ERROR_INVALID_PARAMETER
;
1985 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, &dwType
, NULL
, &cbData
);
1986 if (rc
!= ERROR_SUCCESS
)
1988 if (dwType
!= REG_SZ
)
1989 return ERROR_FILE_NOT_FOUND
;
1990 Value
= HeapAlloc(GetProcessHeap(), 0, cbData
+ sizeof(WCHAR
));
1992 return ERROR_NOT_ENOUGH_MEMORY
;
1993 rc
= RegQueryValueExW(hKey
, pszKey
, NULL
, NULL
, (LPBYTE
)Value
, &cbData
);
1994 if (rc
!= ERROR_SUCCESS
)
1996 HeapFree(GetProcessHeap(), 0, Value
);
1999 /* NULL-terminate the string */
2000 Value
[cbData
/ sizeof(WCHAR
)] = '\0';
2003 return ERROR_SUCCESS
;
2011 DWORD regType
, active
, size
;
2015 rc
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
, L
"SYSTEM\\Setup", 0, KEY_QUERY_VALUE
, &hKey
);
2016 if (rc
!= ERROR_SUCCESS
)
2019 size
= sizeof(DWORD
);
2020 rc
= RegQueryValueExW(hKey
, L
"SystemSetupInProgress", NULL
, ®Type
, (LPBYTE
)&active
, &size
);
2021 if (rc
!= ERROR_SUCCESS
)
2023 if (regType
!= REG_DWORD
|| size
!= sizeof(DWORD
))
2026 ret
= (active
!= 0);
2032 DPRINT("System setup in progress? %S\n", ret
? L
"YES" : L
"NO");
2041 HKEY ControlKey
= NULL
;
2042 LPWSTR SystemStartOptions
= NULL
;
2043 LPWSTR CurrentOption
, NextOption
; /* Pointers into SystemStartOptions */
2044 BOOL ConsoleBoot
= FALSE
;
2049 L
"SYSTEM\\CurrentControlSet\\Control",
2054 rc
= ReadRegSzKey(ControlKey
, L
"SystemStartOptions", &SystemStartOptions
);
2055 if (rc
!= ERROR_SUCCESS
)
2058 /* Check for CMDCONS in SystemStartOptions */
2059 CurrentOption
= SystemStartOptions
;
2060 while (CurrentOption
)
2062 NextOption
= wcschr(CurrentOption
, L
' ');
2064 *NextOption
= L
'\0';
2065 if (_wcsicmp(CurrentOption
, L
"CONSOLE") == 0)
2067 DPRINT("Found %S. Switching to console boot\n", CurrentOption
);
2071 CurrentOption
= NextOption
? NextOption
+ 1 : NULL
;
2075 if (ControlKey
!= NULL
)
2076 RegCloseKey(ControlKey
);
2077 HeapFree(GetProcessHeap(), 0, SystemStartOptions
);
2082 /* Loop to install all queued devices installations */
2084 DeviceInstallThread(LPVOID lpParameter
)
2086 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2087 PSLIST_ENTRY ListEntry
;
2089 PLIST_ENTRY ListEntry
;
2091 DeviceInstallParams
* Params
;
2094 UNREFERENCED_PARAMETER(lpParameter
);
2096 WaitForSingleObject(hInstallEvent
, INFINITE
);
2098 showWizard
= !SetupIsActive() && !IsConsoleBoot();
2102 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2103 ListEntry
= InterlockedPopEntrySList(&DeviceInstallListHead
);
2105 if ((BOOL
)IsListEmpty(&DeviceInstallListHead
))
2108 ListEntry
= RemoveHeadList(&DeviceInstallListHead
);
2110 if (ListEntry
== NULL
)
2112 SetEvent(hNoPendingInstalls
);
2113 WaitForSingleObject(hDeviceInstallListNotEmpty
, INFINITE
);
2117 ResetEvent(hNoPendingInstalls
);
2118 Params
= CONTAINING_RECORD(ListEntry
, DeviceInstallParams
, ListEntry
);
2119 InstallDevice(Params
->DeviceIds
, showWizard
);
2128 PnpEventThread(LPVOID lpParameter
)
2130 PPLUGPLAY_EVENT_BLOCK PnpEvent
;
2133 RPC_STATUS RpcStatus
;
2135 UNREFERENCED_PARAMETER(lpParameter
);
2137 PnpEventSize
= 0x1000;
2138 PnpEvent
= HeapAlloc(GetProcessHeap(), 0, PnpEventSize
);
2139 if (PnpEvent
== NULL
)
2140 return ERROR_OUTOFMEMORY
;
2144 DPRINT("Calling NtGetPlugPlayEvent()\n");
2146 /* Wait for the next pnp event */
2147 Status
= NtGetPlugPlayEvent(0, 0, PnpEvent
, PnpEventSize
);
2149 /* Resize the buffer for the PnP event if it's too small. */
2150 if (Status
== STATUS_BUFFER_TOO_SMALL
)
2152 PnpEventSize
+= 0x400;
2153 HeapFree(GetProcessHeap(), 0, PnpEvent
);
2154 PnpEvent
= HeapAlloc(GetProcessHeap(), 0, PnpEventSize
);
2155 if (PnpEvent
== NULL
)
2156 return ERROR_OUTOFMEMORY
;
2160 if (!NT_SUCCESS(Status
))
2162 DPRINT("NtGetPlugPlayEvent() failed (Status %lx)\n", Status
);
2166 /* Process the pnp event */
2167 DPRINT("Received PnP Event\n");
2168 if (UuidEqual(&PnpEvent
->EventGuid
, (UUID
*)&GUID_DEVICE_ENUMERATED
, &RpcStatus
))
2170 DeviceInstallParams
* Params
;
2172 DWORD DeviceIdLength
;
2174 DPRINT("Device arrival event: %S\n", PnpEvent
->TargetDevice
.DeviceIds
);
2176 DeviceIdLength
= lstrlenW(PnpEvent
->TargetDevice
.DeviceIds
);
2179 /* Queue device install (will be dequeued by DeviceInstallThread */
2180 len
= FIELD_OFFSET(DeviceInstallParams
, DeviceIds
) + (DeviceIdLength
+ 1) * sizeof(WCHAR
);
2181 Params
= HeapAlloc(GetProcessHeap(), 0, len
);
2184 wcscpy(Params
->DeviceIds
, PnpEvent
->TargetDevice
.DeviceIds
);
2185 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2186 InterlockedPushEntrySList(&DeviceInstallListHead
, &Params
->ListEntry
);
2188 InsertTailList(&DeviceInstallListHead
, &Params
->ListEntry
);
2190 SetEvent(hDeviceInstallListNotEmpty
);
2196 DPRINT1("Unknown event, GUID {%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}\n",
2197 PnpEvent
->EventGuid
.Data1
, PnpEvent
->EventGuid
.Data2
, PnpEvent
->EventGuid
.Data3
,
2198 PnpEvent
->EventGuid
.Data4
[0], PnpEvent
->EventGuid
.Data4
[1], PnpEvent
->EventGuid
.Data4
[2],
2199 PnpEvent
->EventGuid
.Data4
[3], PnpEvent
->EventGuid
.Data4
[4], PnpEvent
->EventGuid
.Data4
[5],
2200 PnpEvent
->EventGuid
.Data4
[6], PnpEvent
->EventGuid
.Data4
[7]);
2203 /* Dequeue the current pnp event and signal the next one */
2204 NtPlugPlayControl(PlugPlayControlUserResponse
, NULL
, 0);
2207 HeapFree(GetProcessHeap(), 0, PnpEvent
);
2209 return ERROR_SUCCESS
;
2213 static VOID CALLBACK
2214 ServiceMain(DWORD argc
, LPTSTR
*argv
)
2219 UNREFERENCED_PARAMETER(argc
);
2220 UNREFERENCED_PARAMETER(argv
);
2222 DPRINT("ServiceMain() called\n");
2224 hThread
= CreateThread(NULL
,
2230 if (hThread
!= NULL
)
2231 CloseHandle(hThread
);
2233 hThread
= CreateThread(NULL
,
2239 if (hThread
!= NULL
)
2240 CloseHandle(hThread
);
2242 hThread
= CreateThread(NULL
,
2244 DeviceInstallThread
,
2248 if (hThread
!= NULL
)
2249 CloseHandle(hThread
);
2251 DPRINT("ServiceMain() done\n");
2256 wmain(int argc
, WCHAR
*argv
[])
2260 UNREFERENCED_PARAMETER(argc
);
2261 UNREFERENCED_PARAMETER(argv
);
2263 DPRINT("Umpnpmgr: main() started\n");
2265 hInstallEvent
= CreateEvent(NULL
, TRUE
, SetupIsActive()/*FALSE*/, NULL
);
2266 if (hInstallEvent
== NULL
)
2268 dwError
= GetLastError();
2269 DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError
);
2273 hDeviceInstallListNotEmpty
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2274 if (hDeviceInstallListNotEmpty
== NULL
)
2276 dwError
= GetLastError();
2277 DPRINT1("Could not create the Event! (Error %lu)\n", dwError
);
2281 hNoPendingInstalls
= CreateEventW(NULL
,
2284 L
"Global\\PnP_No_Pending_Install_Events");
2285 if (hNoPendingInstalls
== NULL
)
2287 dwError
= GetLastError();
2288 DPRINT1("Could not create the Event! (Error %lu)\n", dwError
);
2292 #ifdef HAVE_SLIST_ENTRY_IMPLEMENTED
2293 InitializeSListHead(&DeviceInstallListHead
);
2295 InitializeListHead(&DeviceInstallListHead
);
2298 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2299 L
"System\\CurrentControlSet\\Enum",
2303 if (dwError
!= ERROR_SUCCESS
)
2305 DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError
);
2309 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
2310 L
"System\\CurrentControlSet\\Control\\Class",
2314 if (dwError
!= ERROR_SUCCESS
)
2316 DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError
);
2320 StartServiceCtrlDispatcher(ServiceTable
);
2322 DPRINT("Umpnpmgr: main() done\n");