72 WCHAR CommandLine[116];
73 WCHAR InstallEventName[73];
122 swprintf(UuidString,
L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
123 RandomUuid.Data1, RandomUuid.Data2, RandomUuid.Data3,
124 RandomUuid.Data4[0], RandomUuid.Data4[1], RandomUuid.Data4[2],
125 RandomUuid.Data4[3], RandomUuid.Data4[4], RandomUuid.Data4[5],
126 RandomUuid.Data4[6], RandomUuid.Data4[7]);
141 wcscpy(InstallEventName,
L"Global\\PNP_Device_Install_Event_0.");
142 wcscat(InstallEventName, UuidString);
152 wcscpy(PipeName,
L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
153 wcscat(PipeName, UuidString);
162 wcscpy(CommandLine,
L"rundll32.exe newdev.dll,ClientSideInstall ");
163 wcscat(CommandLine, PipeName);
165 ZeroMemory(&StartupInfo,
sizeof(StartupInfo));
166 StartupInfo.
cb =
sizeof(StartupInfo);
177 if (!
CreateProcessAsUserW(
hUserToken,
NULL, CommandLine,
NULL,
NULL,
FALSE,
CREATE_UNICODE_ENVIRONMENT,
Environment,
NULL, &StartupInfo, &ProcessInfo))
209 Value =
sizeof(InstallEventName);
243 if (!DeviceInstalled)
248 return DeviceInstalled;
314 DPRINT(
"System setup in progress? %S\n",
ret ?
L"YES" :
L"NO");
434 if (RelativeSd ==
NULL)
447 *EventSd = RelativeSd;
489 L"SYSTEM\\CurrentControlSet\\Control",
494 rc =
ReadRegSzKey(ControlKey,
L"SystemStartOptions", &SystemStartOptions);
499 CurrentOption = SystemStartOptions;
500 while (CurrentOption)
505 if (
_wcsicmp(CurrentOption,
L"CONSOLE") == 0)
507 DPRINT(
"Found %S. Switching to console boot\n", CurrentOption);
515 if (ControlKey !=
NULL)
543 DPRINT(
"Step 1: Installing devices configured during the boot\n");
578 for (
PWSTR currentDev = deviceList;
580 currentDev +=
lstrlenW(currentDev) + 1)
591 DPRINT(
"Step 2: Starting the wait-loop\n");
605 if (ListEntry ==
NULL)
static BOOL InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
static LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
HANDLE hDeviceInstallListNotEmpty
static BOOL IsConsoleBoot(VOID)
DWORD WINAPI DeviceInstallThread(LPVOID lpParameter)
FORCEINLINE BOOL IsUISuppressionAllowed(VOID)
DWORD CreatePnpInstallEventSecurity(_Out_ PSECURITY_DESCRIPTOR *EventSd)
Creates a security descriptor for the PnP event installation.
HANDLE hDeviceInstallListMutex
HANDLE hNoPendingInstalls
LIST_ENTRY DeviceInstallListHead
BOOL GetSuppressNewUIValue(VOID)
DWORD WINAPI PNP_GetDeviceListSize(handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
DWORD WINAPI PNP_GetDeviceList(handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
static SID_IDENTIFIER_AUTHORITY NtAuthority
#define RegCloseKey(hKey)
#define ERROR_NOT_ENOUGH_MEMORY
#define ERROR_INSUFFICIENT_BUFFER
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
DWORD WINAPI GetLengthSid(PSID pSid)
PVOID WINAPI FreeSid(PSID pSid)
#define ERROR_INVALID_PARAMETER
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define INVALID_HANDLE_VALUE
#define HeapFree(x, y, z)
static void cleanup(void)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
static const WCHAR DeviceInstance[]
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
static const WCHAR Cleanup[]
#define IsListEmpty(ListHead)
#define RemoveHeadList(ListHead)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static char * NextOption(const char *const ostr)
#define ERROR_FILE_NOT_FOUND
PVOID PVOID PWCHAR PVOID Environment
struct _ACCESS_ALLOWED_ACE ACCESS_ALLOWED_ACE
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
#define UNREFERENCED_PARAMETER(P)
#define CONFIGFLAG_FAILEDINSTALL
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
LPVOID lpSecurityDescriptor
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
DWORD WINAPI GetLastError(void)
#define CREATE_UNICODE_ENVIRONMENT
#define PIPE_ACCESS_OUTBOUND
#define ERROR_PIPE_CONNECTED
#define HKEY_LOCAL_MACHINE
#define SECURITY_BUILTIN_DOMAIN_RID
#define SECURITY_LOCAL_SYSTEM_RID
#define SECURITY_NT_AUTHORITY
#define SECURITY_DESCRIPTOR_REVISION
#define DOMAIN_ALIAS_RID_ADMINS