ReactOS 0.4.15-dev-7998-gdb93cb1
install.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for install.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD CreatePnpInstallEventSecurity (_Out_ PSECURITY_DESCRIPTOR *EventSd)
 Creates a security descriptor for the PnP event installation.
 
static BOOL InstallDevice (PCWSTR DeviceInstance, BOOL ShowWizard)
 
static LONG ReadRegSzKey (IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
 
BOOL SetupIsActive (VOID)
 
static BOOL IsConsoleBoot (VOID)
 
FORCEINLINE BOOL IsUISuppressionAllowed (VOID)
 
DWORD WINAPI DeviceInstallThread (LPVOID lpParameter)
 

Variables

HANDLE hUserToken = NULL
 
HANDLE hInstallEvent = NULL
 
HANDLE hNoPendingInstalls = NULL
 
HANDLE hDeviceInstallListMutex
 
LIST_ENTRY DeviceInstallListHead
 
HANDLE hDeviceInstallListNotEmpty
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 33 of file install.c.

Function Documentation

◆ CreatePnpInstallEventSecurity()

DWORD CreatePnpInstallEventSecurity ( _Out_ PSECURITY_DESCRIPTOR EventSd)

Creates a security descriptor for the PnP event installation.

Parameters
[out]EventSdA pointer to an allocated security descriptor for the event.
Returns
ERROR_SUCCESS is returned if the function has successfully created the descriptor, otherwise a Win32 error code is returned.
Remarks
Only admins and local system have full power over this event as privileged users can install devices on a system.

Definition at line 340 of file install.c.

342{
343 DWORD ErrCode;
344 PACL Dacl;
346 SECURITY_DESCRIPTOR AbsoluteSd;
347 ULONG Size = 0;
348 PSECURITY_DESCRIPTOR RelativeSd = NULL;
349 PSID SystemSid = NULL, AdminsSid = NULL;
351
353 1,
355 0, 0, 0, 0, 0, 0, 0,
356 &SystemSid))
357 {
358 return GetLastError();
359 }
360
362 2,
365 0, 0, 0, 0, 0, 0,
366 &AdminsSid))
367 {
368 ErrCode = GetLastError();
369 goto Quit;
370 }
371
372 DaclSize = sizeof(ACL) +
373 sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(SystemSid) +
374 sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(AdminsSid);
375
377 if (!Dacl)
378 {
379 ErrCode = ERROR_OUTOFMEMORY;
380 goto Quit;
381 }
382
384 {
385 ErrCode = GetLastError();
386 goto Quit;
387 }
388
392 SystemSid))
393 {
394 ErrCode = GetLastError();
395 goto Quit;
396 }
397
401 AdminsSid))
402 {
403 ErrCode = GetLastError();
404 goto Quit;
405 }
406
408 {
409 ErrCode = GetLastError();
410 goto Quit;
411 }
412
413 if (!SetSecurityDescriptorDacl(&AbsoluteSd, TRUE, Dacl, FALSE))
414 {
415 ErrCode = GetLastError();
416 goto Quit;
417 }
418
419 if (!SetSecurityDescriptorOwner(&AbsoluteSd, SystemSid, FALSE))
420 {
421 ErrCode = GetLastError();
422 goto Quit;
423 }
424
425 if (!SetSecurityDescriptorGroup(&AbsoluteSd, AdminsSid, FALSE))
426 {
427 ErrCode = GetLastError();
428 goto Quit;
429 }
430
432 {
434 if (RelativeSd == NULL)
435 {
436 ErrCode = ERROR_OUTOFMEMORY;
437 goto Quit;
438 }
439
440 if (!MakeSelfRelativeSD(&AbsoluteSd, RelativeSd, &Size))
441 {
442 ErrCode = GetLastError();
443 goto Quit;
444 }
445 }
446
447 *EventSd = RelativeSd;
448 ErrCode = ERROR_SUCCESS;
449
450Quit:
451 if (SystemSid)
452 {
453 FreeSid(SystemSid);
454 }
455
456 if (AdminsSid)
457 {
458 FreeSid(AdminsSid);
459 }
460
461 if (Dacl)
462 {
464 }
465
466 if (ErrCode != ERROR_SUCCESS)
467 {
468 if (RelativeSd)
469 {
470 HeapFree(GetProcessHeap(), 0, RelativeSd);
471 }
472 }
473
474 return ErrCode;
475}
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:1039
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
struct _ACL ACL
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
Definition: rtlfuncs.h:1593
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1594
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
Definition: sec.c:214
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652

Referenced by InstallDevice().

◆ DeviceInstallThread()

DWORD WINAPI DeviceInstallThread ( LPVOID  lpParameter)

Definition at line 534 of file install.c.

535{
536 PLIST_ENTRY ListEntry;
538
539 UNREFERENCED_PARAMETER(lpParameter);
540
541 // Step 1: install all drivers which were configured during the boot
542
543 DPRINT("Step 1: Installing devices configured during the boot\n");
544
545 PWSTR deviceList;
546
547 while (TRUE)
548 {
549 ULONG devListSize;
550 DWORD status = PNP_GetDeviceListSize(NULL, NULL, &devListSize, 0);
551 if (status != CR_SUCCESS)
552 {
553 goto Step2;
554 }
555
556 deviceList = HeapAlloc(GetProcessHeap(), 0, devListSize * sizeof(WCHAR));
557 if (!deviceList)
558 {
559 goto Step2;
560 }
561
562 status = PNP_GetDeviceList(NULL, NULL, deviceList, &devListSize, 0);
563 if (status == CR_BUFFER_SMALL)
564 {
565 HeapFree(GetProcessHeap(), 0, deviceList);
566 }
567 else if (status != CR_SUCCESS)
568 {
569 DPRINT1("PNP_GetDeviceList failed with error %u\n", status);
570 goto Cleanup;
571 }
572 else // status == CR_SUCCESS
573 {
574 break;
575 }
576 }
577
578 for (PWSTR currentDev = deviceList;
579 currentDev[0] != UNICODE_NULL;
580 currentDev += lstrlenW(currentDev) + 1)
581 {
582 InstallDevice(currentDev, FALSE);
583 }
584
585Cleanup:
586 HeapFree(GetProcessHeap(), 0, deviceList);
587
588 // Step 2: start the wait-loop for newly added devices
589Step2:
590
591 DPRINT("Step 2: Starting the wait-loop\n");
592
594
595 BOOL showWizard = !SetupIsActive() && !IsConsoleBoot();
596
597 while (TRUE)
598 {
599 /* Dequeue the next oldest device-install event */
604
605 if (ListEntry == NULL)
606 {
609 }
610 else
611 {
613 Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
614 InstallDevice(Params->DeviceIds, showWizard && !IsUISuppressionAllowed());
616 }
617 }
618
619 return 0;
620}
#define DPRINT1
Definition: precomp.h:8
static BOOL InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
Definition: install.c:55
HANDLE hDeviceInstallListNotEmpty
Definition: install.c:46
BOOL SetupIsActive(VOID)
Definition: install.c:290
static BOOL IsConsoleBoot(VOID)
Definition: install.c:479
FORCEINLINE BOOL IsUISuppressionAllowed(VOID)
Definition: install.c:524
HANDLE hInstallEvent
Definition: install.c:40
HANDLE hDeviceInstallListMutex
Definition: install.c:44
HANDLE hNoPendingInstalls
Definition: install.c:41
LIST_ENTRY DeviceInstallListHead
Definition: install.c:45
DWORD WINAPI PNP_GetDeviceListSize(handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1717
DWORD WINAPI PNP_GetDeviceList(handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1346
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define lstrlenW
Definition: compat.h:750
static const WCHAR Cleanup[]
Definition: register.c:80
#define INFINITE
Definition: serial.h:102
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define DPRINT
Definition: sndvol32.h:71
Definition: typedefs.h:120
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
uint16_t * PWSTR
Definition: typedefs.h:56
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ServiceMain().

◆ InstallDevice()

static BOOL InstallDevice ( PCWSTR  DeviceInstance,
BOOL  ShowWizard 
)
static

Definition at line 55 of file install.c.

56{
57 BOOL DeviceInstalled = FALSE;
60 DWORD ErrCode;
64 PROCESS_INFORMATION ProcessInfo;
65 STARTUPINFOW StartupInfo;
66 UUID RandomUuid;
67 HKEY DeviceKey;
68 SECURITY_ATTRIBUTES EventAttrs;
70
71 /* The following lengths are constant (see below), they cannot overflow */
72 WCHAR CommandLine[116];
73 WCHAR InstallEventName[73];
74 WCHAR PipeName[74];
75 WCHAR UuidString[39];
76
77 DPRINT("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
78
79 ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
80
83 0,
85 &DeviceKey) == ERROR_SUCCESS)
86 {
87 if (RegQueryValueExW(DeviceKey,
88 L"Class",
89 NULL,
90 NULL,
91 NULL,
93 {
94 DPRINT("No need to install: %S\n", DeviceInstance);
95 RegCloseKey(DeviceKey);
96 return TRUE;
97 }
98
99 BytesWritten = sizeof(DWORD);
100 if (RegQueryValueExW(DeviceKey,
101 L"ConfigFlags",
102 NULL,
103 NULL,
104 (PBYTE)&Value,
106 {
108 {
109 DPRINT("No need to install: %S\n", DeviceInstance);
110 RegCloseKey(DeviceKey);
111 return TRUE;
112 }
113 }
114
115 RegCloseKey(DeviceKey);
116 }
117
118 DPRINT1("Installing: %S\n", DeviceInstance);
119
120 /* Create a random UUID for the named pipe & event*/
121 UuidCreate(&RandomUuid);
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]);
127
128 ErrCode = CreatePnpInstallEventSecurity(&EventSd);
129 if (ErrCode != ERROR_SUCCESS)
130 {
131 DPRINT1("CreatePnpInstallEventSecurity failed with error %u\n", GetLastError());
132 return FALSE;
133 }
134
135 /* Set up the security attributes for the event */
136 EventAttrs.nLength = sizeof(SECURITY_ATTRIBUTES);
137 EventAttrs.lpSecurityDescriptor = EventSd;
138 EventAttrs.bInheritHandle = FALSE;
139
140 /* Create the event */
141 wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0.");
142 wcscat(InstallEventName, UuidString);
143 hInstallEvent = CreateEventW(&EventAttrs, TRUE, FALSE, InstallEventName);
144 HeapFree(GetProcessHeap(), 0, EventSd);
145 if (!hInstallEvent)
146 {
147 DPRINT1("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError());
148 goto cleanup;
149 }
150
151 /* Create the named pipe */
152 wcscpy(PipeName, L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
153 wcscat(PipeName, UuidString);
154 hPipe = CreateNamedPipeW(PipeName, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 512, 512, 0, NULL);
155 if (hPipe == INVALID_HANDLE_VALUE)
156 {
157 DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError());
158 goto cleanup;
159 }
160
161 /* Launch rundll32 to call ClientSideInstallW */
162 wcscpy(CommandLine, L"rundll32.exe newdev.dll,ClientSideInstall ");
163 wcscat(CommandLine, PipeName);
164
165 ZeroMemory(&StartupInfo, sizeof(StartupInfo));
166 StartupInfo.cb = sizeof(StartupInfo);
167
168 if (hUserToken)
169 {
170 /* newdev has to run under the environment of the current user */
172 {
173 DPRINT1("CreateEnvironmentBlock failed with error %d\n", GetLastError());
174 goto cleanup;
175 }
176
177 if (!CreateProcessAsUserW(hUserToken, NULL, CommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, Environment, NULL, &StartupInfo, &ProcessInfo))
178 {
179 DPRINT1("CreateProcessAsUserW failed with error %u\n", GetLastError());
180 goto cleanup;
181 }
182 }
183 else
184 {
185 /* FIXME: This is probably not correct, I guess newdev should never be run with SYSTEM privileges.
186
187 Still, we currently do that in 2nd stage setup and probably Console mode as well, so allow it here.
188 (ShowWizard is only set to FALSE for these two modes) */
189 ASSERT(!ShowWizard);
190
191 if (!CreateProcessW(NULL, CommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo))
192 {
193 DPRINT1("CreateProcessW failed with error %u\n", GetLastError());
194 goto cleanup;
195 }
196 }
197
198 /* Wait for the function to connect to our pipe */
199 if (!ConnectNamedPipe(hPipe, NULL))
200 {
202 {
203 DPRINT1("ConnectNamedPipe failed with error %u\n", GetLastError());
204 goto cleanup;
205 }
206 }
207
208 /* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */
209 Value = sizeof(InstallEventName);
210 WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
211 WriteFile(hPipe, InstallEventName, Value, &BytesWritten, NULL);
212
213 /* I couldn't figure out what the following value means under WinXP. It's usually 0 in my tests, but was also 5 once.
214 Therefore the following line is entirely ReactOS-specific. We use the value here to pass the ShowWizard variable. */
215 WriteFile(hPipe, &ShowWizard, sizeof(ShowWizard), &BytesWritten, NULL);
216
217 Value = (wcslen(DeviceInstance) + 1) * sizeof(WCHAR);
218 WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
220
221 /* Wait for newdev.dll to finish processing */
223
224 /* If the event got signalled, this is success */
225 DeviceInstalled = WaitForSingleObject(hInstallEvent, 0) == WAIT_OBJECT_0;
226
227cleanup:
228 if (hInstallEvent)
230
231 if (hPipe != INVALID_HANDLE_VALUE)
232 CloseHandle(hPipe);
233
234 if (Environment)
236
237 if (ProcessInfo.hProcess)
238 CloseHandle(ProcessInfo.hProcess);
239
240 if (ProcessInfo.hThread)
241 CloseHandle(ProcessInfo.hThread);
242
243 if (!DeviceInstalled)
244 {
245 DPRINT1("InstallDevice failed for DeviceInstance '%ws'\n", DeviceInstance);
246 }
247
248 return DeviceInstalled;
249}
DWORD CreatePnpInstallEventSecurity(_Out_ PSECURITY_DESCRIPTOR *EventSd)
Creates a security descriptor for the PnP event installation.
Definition: install.c:340
HANDLE hUserToken
Definition: install.c:39
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define RegCloseKey(hKey)
Definition: registry.h:49
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)
Definition: logon.c:993
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define CloseHandle
Definition: compat.h:739
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static void cleanup(void)
Definition: main.c:1335
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
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)
Definition: proc.c:4592
static const WCHAR DeviceInstance[]
Definition: interface.c:28
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:725
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:503
#define swprintf
Definition: precomp.h:40
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ASSERT(a)
Definition: mode.c:44
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:246
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:305
_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)
LPVOID lpSecurityDescriptor
Definition: compat.h:193
DWORD cb
Definition: winbase.h:852
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
_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
Definition: wdfiotarget.h:960
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define ZeroMemory
Definition: winbase.h:1712
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:186
#define PIPE_ACCESS_OUTBOUND
Definition: winbase.h:166
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352

Referenced by DeviceInstallThread(), and IopQueueDeviceInstallEvent().

◆ IsConsoleBoot()

static BOOL IsConsoleBoot ( VOID  )
static

Definition at line 479 of file install.c.

480{
481 HKEY ControlKey = NULL;
482 LPWSTR SystemStartOptions = NULL;
483 LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
484 BOOL ConsoleBoot = FALSE;
485 LONG rc;
486
487 rc = RegOpenKeyExW(
489 L"SYSTEM\\CurrentControlSet\\Control",
490 0,
492 &ControlKey);
493
494 rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
495 if (rc != ERROR_SUCCESS)
496 goto cleanup;
497
498 /* Check for CONSOLE switch in SystemStartOptions */
499 CurrentOption = SystemStartOptions;
500 while (CurrentOption)
501 {
502 NextOption = wcschr(CurrentOption, L' ');
503 if (NextOption)
504 *NextOption = L'\0';
505 if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
506 {
507 DPRINT("Found %S. Switching to console boot\n", CurrentOption);
508 ConsoleBoot = TRUE;
509 goto cleanup;
510 }
511 CurrentOption = NextOption ? NextOption + 1 : NULL;
512 }
513
514cleanup:
515 if (ControlKey != NULL)
516 RegCloseKey(ControlKey);
517 HeapFree(GetProcessHeap(), 0, SystemStartOptions);
518 return ConsoleBoot;
519}
static LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
Definition: install.c:253
#define wcschr
Definition: compat.h:17
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CommonInstall(), and DeviceInstallThread().

◆ IsUISuppressionAllowed()

FORCEINLINE BOOL IsUISuppressionAllowed ( VOID  )

Definition at line 524 of file install.c.

525{
526 /* Display the newdev.dll wizard UI only if it's allowed */
528}
BOOL GetSuppressNewUIValue(VOID)
Definition: umpnpmgr.c:181
BOOL g_IsUISuppressed
Definition: umpnpmgr.c:46

Referenced by DeviceInstallThread().

◆ ReadRegSzKey()

static LONG ReadRegSzKey ( IN HKEY  hKey,
IN LPCWSTR  pszKey,
OUT LPWSTR pValue 
)
static

Definition at line 253 of file install.c.

257{
258 LONG rc;
259 DWORD dwType;
260 DWORD cbData = 0;
262
263 if (!pValue)
265
266 *pValue = NULL;
267 rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
268 if (rc != ERROR_SUCCESS)
269 return rc;
270 if (dwType != REG_SZ)
272 Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
273 if (!Value)
275 rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
276 if (rc != ERROR_SUCCESS)
277 {
279 return rc;
280 }
281 /* NULL-terminate the string */
282 Value[cbData / sizeof(WCHAR)] = '\0';
283
284 *pValue = Value;
285 return ERROR_SUCCESS;
286}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
FxAutoRegKey hKey
PWCHAR pValue
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by IsConsoleBoot(), and IsLiveCD().

◆ SetupIsActive()

BOOL SetupIsActive ( VOID  )

Definition at line 290 of file install.c.

291{
292 HKEY hKey = NULL;
293 DWORD regType, active, size;
294 LONG rc;
295 BOOL ret = FALSE;
296
297 rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\Setup", 0, KEY_QUERY_VALUE, &hKey);
298 if (rc != ERROR_SUCCESS)
299 goto cleanup;
300
301 size = sizeof(DWORD);
302 rc = RegQueryValueExW(hKey, L"SystemSetupInProgress", NULL, &regType, (LPBYTE)&active, &size);
303 if (rc != ERROR_SUCCESS)
304 goto cleanup;
305 if (regType != REG_DWORD || size != sizeof(DWORD))
306 goto cleanup;
307
308 ret = (active != 0);
309
310cleanup:
311 if (hKey != NULL)
313
314 DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
315
316 return ret;
317}
GLsizeiptr size
Definition: glext.h:5919
#define REG_DWORD
Definition: sdbapi.c:596
int ret

Referenced by DeviceInstallThread().

Variable Documentation

◆ DeviceInstallListHead

LIST_ENTRY DeviceInstallListHead

Definition at line 45 of file install.c.

Referenced by DeviceInstallThread(), InitializePnPManager(), and ProcessDeviceInstallEvent().

◆ hDeviceInstallListMutex

HANDLE hDeviceInstallListMutex

Definition at line 44 of file install.c.

Referenced by DeviceInstallThread(), InitializePnPManager(), and ProcessDeviceInstallEvent().

◆ hDeviceInstallListNotEmpty

HANDLE hDeviceInstallListNotEmpty

Definition at line 46 of file install.c.

Referenced by DeviceInstallThread(), InitializePnPManager(), and ProcessDeviceInstallEvent().

◆ hInstallEvent

◆ hNoPendingInstalls

HANDLE hNoPendingInstalls = NULL

Definition at line 41 of file install.c.

Referenced by DeviceInstallThread(), and InitializePnPManager().

◆ hUserToken