ReactOS  0.4.15-dev-3173-g40ee59d
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

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

◆ DeviceInstallThread()

DWORD WINAPI DeviceInstallThread ( LPVOID  lpParameter)

Definition at line 357 of file install.c.

358 {
359  PLIST_ENTRY ListEntry;
361 
363 
364  // Step 1: install all drivers which were configured during the boot
365 
366  DPRINT("Step 1: Installing devices configured during the boot\n");
367 
368  PWSTR deviceList;
369 
370  while (TRUE)
371  {
372  ULONG devListSize;
373  DWORD status = PNP_GetDeviceListSize(NULL, NULL, &devListSize, 0);
374  if (status != CR_SUCCESS)
375  {
376  goto Step2;
377  }
378 
379  deviceList = HeapAlloc(GetProcessHeap(), 0, devListSize * sizeof(WCHAR));
380  if (!deviceList)
381  {
382  goto Step2;
383  }
384 
385  status = PNP_GetDeviceList(NULL, NULL, deviceList, &devListSize, 0);
386  if (status == CR_BUFFER_SMALL)
387  {
388  HeapFree(GetProcessHeap(), 0, deviceList);
389  }
390  else if (status != CR_SUCCESS)
391  {
392  DPRINT1("PNP_GetDeviceList failed with error %u\n", status);
393  goto Cleanup;
394  }
395  else // status == CR_SUCCESS
396  {
397  break;
398  }
399  }
400 
401  for (PWSTR currentDev = deviceList;
402  currentDev[0] != UNICODE_NULL;
403  currentDev += lstrlenW(currentDev) + 1)
404  {
405  InstallDevice(currentDev, FALSE);
406  }
407 
408 Cleanup:
409  HeapFree(GetProcessHeap(), 0, deviceList);
410 
411  // Step 2: start the wait-loop for newly added devices
412 Step2:
413 
414  DPRINT("Step 2: Starting the wait-loop\n");
415 
417 
418  BOOL showWizard = !SetupIsActive() && !IsConsoleBoot();
419 
420  while (TRUE)
421  {
422  /* Dequeue the next oldest device-install event */
424  ListEntry = (IsListEmpty(&DeviceInstallListHead)
427 
428  if (ListEntry == NULL)
429  {
432  }
433  else
434  {
436  Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
437  InstallDevice(Params->DeviceIds, showWizard && !IsUISuppressionAllowed());
439  }
440  }
441 
442  return 0;
443 }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
uint16_t * PWSTR
Definition: typedefs.h:56
HANDLE hInstallEvent
Definition: install.c:40
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
LIST_ENTRY DeviceInstallListHead
Definition: install.c:45
static BOOL InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
Definition: install.c:52
#define lstrlenW
Definition: compat.h:609
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
FORCEINLINE BOOL IsUISuppressionAllowed(VOID)
Definition: install.c:347
static BOOL IsConsoleBoot(VOID)
Definition: install.c:302
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CR_SUCCESS
Definition: cfgmgr32.h:842
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
HANDLE hNoPendingInstalls
Definition: install.c:41
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL SetupIsActive(VOID)
Definition: install.c:271
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseMutex(IN HANDLE hMutex)
Definition: synch.c:618
LPVOID lpParameter
Definition: kernel32.h:241
Definition: typedefs.h:119
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE hDeviceInstallListNotEmpty
Definition: install.c:46
DWORD WINAPI PNP_GetDeviceList(handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1222
DWORD WINAPI PNP_GetDeviceListSize(handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1593
#define NULL
Definition: types.h:112
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define DPRINT
Definition: sndvol32.h:71
HANDLE hDeviceInstallListMutex
Definition: install.c:44
#define INFINITE
Definition: serial.h:102
#define HeapFree(x, y, z)
Definition: compat.h:594
Definition: ps.c:97

Referenced by ServiceMain().

◆ InstallDevice()

static BOOL InstallDevice ( PCWSTR  DeviceInstance,
BOOL  ShowWizard 
)
static

Definition at line 52 of file install.c.

53 {
54  BOOL DeviceInstalled = FALSE;
56  DWORD Value;
60  PROCESS_INFORMATION ProcessInfo;
61  STARTUPINFOW StartupInfo;
62  UUID RandomUuid;
63  HKEY DeviceKey;
64 
65  /* The following lengths are constant (see below), they cannot overflow */
66  WCHAR CommandLine[116];
67  WCHAR InstallEventName[73];
68  WCHAR PipeName[74];
69  WCHAR UuidString[39];
70 
71  DPRINT("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
72 
73  ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
74 
77  0,
79  &DeviceKey) == ERROR_SUCCESS)
80  {
81  if (RegQueryValueExW(DeviceKey,
82  L"Class",
83  NULL,
84  NULL,
85  NULL,
86  NULL) == ERROR_SUCCESS)
87  {
88  DPRINT("No need to install: %S\n", DeviceInstance);
89  RegCloseKey(DeviceKey);
90  return TRUE;
91  }
92 
93  BytesWritten = sizeof(DWORD);
94  if (RegQueryValueExW(DeviceKey,
95  L"ConfigFlags",
96  NULL,
97  NULL,
98  (PBYTE)&Value,
100  {
102  {
103  DPRINT("No need to install: %S\n", DeviceInstance);
104  RegCloseKey(DeviceKey);
105  return TRUE;
106  }
107  }
108 
109  RegCloseKey(DeviceKey);
110  }
111 
112  DPRINT1("Installing: %S\n", DeviceInstance);
113 
114  /* Create a random UUID for the named pipe & event*/
115  UuidCreate(&RandomUuid);
116  swprintf(UuidString, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
117  RandomUuid.Data1, RandomUuid.Data2, RandomUuid.Data3,
118  RandomUuid.Data4[0], RandomUuid.Data4[1], RandomUuid.Data4[2],
119  RandomUuid.Data4[3], RandomUuid.Data4[4], RandomUuid.Data4[5],
120  RandomUuid.Data4[6], RandomUuid.Data4[7]);
121 
122  /* Create the event */
123  wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0.");
124  wcscat(InstallEventName, UuidString);
125  hInstallEvent = CreateEventW(NULL, TRUE, FALSE, InstallEventName);
126  if (!hInstallEvent)
127  {
128  DPRINT1("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError());
129  goto cleanup;
130  }
131 
132  /* Create the named pipe */
133  wcscpy(PipeName, L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
134  wcscat(PipeName, UuidString);
135  hPipe = CreateNamedPipeW(PipeName, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 512, 512, 0, NULL);
136  if (hPipe == INVALID_HANDLE_VALUE)
137  {
138  DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError());
139  goto cleanup;
140  }
141 
142  /* Launch rundll32 to call ClientSideInstallW */
143  wcscpy(CommandLine, L"rundll32.exe newdev.dll,ClientSideInstall ");
144  wcscat(CommandLine, PipeName);
145 
146  ZeroMemory(&StartupInfo, sizeof(StartupInfo));
147  StartupInfo.cb = sizeof(StartupInfo);
148 
149  if (hUserToken)
150  {
151  /* newdev has to run under the environment of the current user */
153  {
154  DPRINT1("CreateEnvironmentBlock failed with error %d\n", GetLastError());
155  goto cleanup;
156  }
157 
158  if (!CreateProcessAsUserW(hUserToken, NULL, CommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, Environment, NULL, &StartupInfo, &ProcessInfo))
159  {
160  DPRINT1("CreateProcessAsUserW failed with error %u\n", GetLastError());
161  goto cleanup;
162  }
163  }
164  else
165  {
166  /* FIXME: This is probably not correct, I guess newdev should never be run with SYSTEM privileges.
167 
168  Still, we currently do that in 2nd stage setup and probably Console mode as well, so allow it here.
169  (ShowWizard is only set to FALSE for these two modes) */
170  ASSERT(!ShowWizard);
171 
172  if (!CreateProcessW(NULL, CommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo))
173  {
174  DPRINT1("CreateProcessW failed with error %u\n", GetLastError());
175  goto cleanup;
176  }
177  }
178 
179  /* Wait for the function to connect to our pipe */
180  if (!ConnectNamedPipe(hPipe, NULL))
181  {
183  {
184  DPRINT1("ConnectNamedPipe failed with error %u\n", GetLastError());
185  goto cleanup;
186  }
187  }
188 
189  /* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */
190  Value = sizeof(InstallEventName);
191  WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
192  WriteFile(hPipe, InstallEventName, Value, &BytesWritten, NULL);
193 
194  /* I couldn't figure out what the following value means under WinXP. It's usually 0 in my tests, but was also 5 once.
195  Therefore the following line is entirely ReactOS-specific. We use the value here to pass the ShowWizard variable. */
196  WriteFile(hPipe, &ShowWizard, sizeof(ShowWizard), &BytesWritten, NULL);
197 
198  Value = (wcslen(DeviceInstance) + 1) * sizeof(WCHAR);
199  WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
201 
202  /* Wait for newdev.dll to finish processing */
203  WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
204 
205  /* If the event got signalled, this is success */
206  DeviceInstalled = WaitForSingleObject(hInstallEvent, 0) == WAIT_OBJECT_0;
207 
208 cleanup:
209  if (hInstallEvent)
211 
212  if (hPipe != INVALID_HANDLE_VALUE)
213  CloseHandle(hPipe);
214 
215  if (Environment)
217 
218  if (ProcessInfo.hProcess)
219  CloseHandle(ProcessInfo.hProcess);
220 
221  if (ProcessInfo.hThread)
222  CloseHandle(ProcessInfo.hThread);
223 
224  if (!DeviceInstalled)
225  {
226  DPRINT1("InstallDevice failed for DeviceInstance '%ws'\n", DeviceInstance);
227  }
228 
229  return DeviceInstalled;
230 }
static HANDLE DWORD
Definition: install.c:28
_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:949
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:186
#define TRUE
Definition: types.h:120
HANDLE hInstallEvent
Definition: install.c:40
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1664
#define swprintf
Definition: precomp.h:40
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
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:4594
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
HANDLE hUserToken
Definition: install.c:39
#define WAIT_OBJECT_0
Definition: winbase.h:403
DWORD cb
Definition: winbase.h:846
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define ASSERT(a)
Definition: mode.c:44
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PIPE_ACCESS_OUTBOUND
Definition: winbase.h:166
HKEY hEnumKey
Definition: umpnpmgr.c:44
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5202
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:281
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:303
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define DPRINT
Definition: sndvol32.h:71
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 INFINITE
Definition: serial.h:102
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
BYTE * PBYTE
Definition: pedump.c:66
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396

Referenced by DeviceInstallThread().

◆ IsConsoleBoot()

static BOOL IsConsoleBoot ( VOID  )
static

Definition at line 302 of file install.c.

303 {
304  HKEY ControlKey = NULL;
305  LPWSTR SystemStartOptions = NULL;
306  LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
307  BOOL ConsoleBoot = FALSE;
308  LONG rc;
309 
310  rc = RegOpenKeyExW(
312  L"SYSTEM\\CurrentControlSet\\Control",
313  0,
315  &ControlKey);
316 
317  rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
318  if (rc != ERROR_SUCCESS)
319  goto cleanup;
320 
321  /* Check for CONSOLE switch in SystemStartOptions */
322  CurrentOption = SystemStartOptions;
323  while (CurrentOption)
324  {
325  NextOption = wcschr(CurrentOption, L' ');
326  if (NextOption)
327  *NextOption = L'\0';
328  if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
329  {
330  DPRINT("Found %S. Switching to console boot\n", CurrentOption);
331  ConsoleBoot = TRUE;
332  goto cleanup;
333  }
334  CurrentOption = NextOption ? NextOption + 1 : NULL;
335  }
336 
337 cleanup:
338  if (ControlKey != NULL)
339  RegCloseKey(ControlKey);
340  HeapFree(GetProcessHeap(), 0, SystemStartOptions);
341  return ConsoleBoot;
342 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
static LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
Definition: install.c:234
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define GetProcessHeap()
Definition: compat.h:595
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DeviceInstallThread().

◆ IsUISuppressionAllowed()

FORCEINLINE BOOL IsUISuppressionAllowed ( VOID  )

Definition at line 347 of file install.c.

348 {
349  /* Display the newdev.dll wizard UI only if it's allowed */
351 }
BOOL g_IsUISuppressed
Definition: umpnpmgr.c:46
BOOL GetSuppressNewUIValue(VOID)
Definition: umpnpmgr.c:330

Referenced by DeviceInstallThread().

◆ ReadRegSzKey()

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

Definition at line 234 of file install.c.

238 {
239  LONG rc;
240  DWORD dwType;
241  DWORD cbData = 0;
242  LPWSTR Value;
243 
244  if (!pValue)
246 
247  *pValue = NULL;
248  rc = RegQueryValueExW(hKey, pszKey, NULL, &dwType, NULL, &cbData);
249  if (rc != ERROR_SUCCESS)
250  return rc;
251  if (dwType != REG_SZ)
252  return ERROR_FILE_NOT_FOUND;
253  Value = HeapAlloc(GetProcessHeap(), 0, cbData + sizeof(WCHAR));
254  if (!Value)
256  rc = RegQueryValueExW(hKey, pszKey, NULL, NULL, (LPBYTE)Value, &cbData);
257  if (rc != ERROR_SUCCESS)
258  {
260  return rc;
261  }
262  /* NULL-terminate the string */
263  Value[cbData / sizeof(WCHAR)] = '\0';
264 
265  *pValue = Value;
266  return ERROR_SUCCESS;
267 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
PWCHAR pValue
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:406
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
#define REG_SZ
Definition: layer.c:22

Referenced by IsConsoleBoot(), and IsLiveCD().

◆ SetupIsActive()

BOOL SetupIsActive ( VOID  )

Definition at line 271 of file install.c.

272 {
273  HKEY hKey = NULL;
274  DWORD regType, active, size;
275  LONG rc;
276  BOOL ret = FALSE;
277 
278  rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SYSTEM\\Setup", 0, KEY_QUERY_VALUE, &hKey);
279  if (rc != ERROR_SUCCESS)
280  goto cleanup;
281 
282  size = sizeof(DWORD);
283  rc = RegQueryValueExW(hKey, L"SystemSetupInProgress", NULL, &regType, (LPBYTE)&active, &size);
284  if (rc != ERROR_SUCCESS)
285  goto cleanup;
286  if (regType != REG_DWORD || size != sizeof(DWORD))
287  goto cleanup;
288 
289  ret = (active != 0);
290 
291 cleanup:
292  if (hKey != NULL)
293  RegCloseKey(hKey);
294 
295  DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
296 
297  return ret;
298 }
static HANDLE DWORD
Definition: install.c:28
DWORD size
Definition: install.c:3631
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
char * cleanup(char *str)
Definition: wpickclick.c:99
#define DPRINT
Definition: sndvol32.h:71
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DeviceInstallThread().

Variable Documentation

◆ DeviceInstallListHead

LIST_ENTRY DeviceInstallListHead

Definition at line 45 of file install.c.

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

◆ hDeviceInstallListMutex

HANDLE hDeviceInstallListMutex

Definition at line 44 of file install.c.

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

◆ hDeviceInstallListNotEmpty

HANDLE hDeviceInstallListNotEmpty

Definition at line 46 of file install.c.

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

◆ hInstallEvent

◆ hNoPendingInstalls

HANDLE hNoPendingInstalls = NULL

Definition at line 41 of file install.c.

Referenced by DeviceInstallThread(), and InitializePnPManager().

◆ hUserToken