ReactOS  0.4.15-dev-3299-gbe8e5fc
precomp.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <winsvc.h>
#include <winuser.h>
#include <dbt.h>
#include <stdio.h>
#include <cmfuncs.h>
#include <rtlfuncs.h>
#include <setypes.h>
#include <umpnpmgr/sysguid.h>
#include <cfgmgr32.h>
#include <regstr.h>
#include <userenv.h>
#include <shlwapi.h>
#include <pnp_s.h>
Include dependency graph for precomp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DeviceInstallParams
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 

Functions

BOOL SetupIsActive (VOID)
 
DWORD WINAPI DeviceInstallThread (LPVOID lpParameter)
 
DWORD WINAPI RpcServerThread (LPVOID lpParameter)
 
BOOL GetSuppressNewUIValue (VOID)
 

Variables

HANDLE hUserToken
 
HANDLE hInstallEvent
 
HANDLE hNoPendingInstalls
 
HANDLE hDeviceInstallListMutex
 
LIST_ENTRY DeviceInstallListHead
 
HANDLE hDeviceInstallListNotEmpty
 
HKEY hEnumKey
 
HKEY hClassKey
 
BOOL g_IsUISuppressed
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 15 of file precomp.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 16 of file precomp.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 14 of file precomp.h.

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().

◆ GetSuppressNewUIValue()

BOOL GetSuppressNewUIValue ( VOID  )

Definition at line 330 of file umpnpmgr.c.

331 {
332  BOOL bSuppressNewHWUI = FALSE;
333 
334  /*
335  * Query the SuppressNewHWUI policy registry value. Don't cache it
336  * as we want to update our behaviour in consequence.
337  */
339  L"Software\\Policies\\Microsoft\\Windows\\DeviceInstall\\Settings",
340  L"SuppressNewHWUI",
341  &bSuppressNewHWUI);
342  if (bSuppressNewHWUI)
343  DPRINT("GetSuppressNewUIValue(): newdev.dll's wizard UI won't be shown!\n");
344 
345  return bSuppressNewHWUI;
346 }
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR L[]
Definition: oid.c:1250
static DWORD GetBooleanRegValue(IN HKEY hKey, IN PCWSTR lpSubKey, IN PCWSTR lpValue, OUT PBOOL pValue)
Definition: umpnpmgr.c:277
#define DPRINT
Definition: sndvol32.h:71
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by IsUISuppressionAllowed().

◆ RpcServerThread()

DWORD WINAPI RpcServerThread ( LPVOID  lpParameter)

Definition at line 45 of file rpcserver.c.

46 {
48  BOOLEAN RegisteredProtSeq = FALSE;
49 
51 
52  DPRINT("RpcServerThread() called\n");
53 
54 #if 0
55  /* 2k/XP/2k3-compatible protocol sequence/endpoint */
56  Status = RpcServerUseProtseqEpW(L"ncacn_np",
57  20,
58  L"\\pipe\\ntsvcs",
59  NULL); // Security descriptor
60  if (Status == RPC_S_OK)
61  RegisteredProtSeq = TRUE;
62  else
63  DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
64 #endif
65 
66  /* Vista/7-compatible protocol sequence/endpoint */
67  Status = RpcServerUseProtseqEpW(L"ncacn_np",
68  20,
69  L"\\pipe\\plugplay",
70  NULL); // Security descriptor
71  if (Status == RPC_S_OK)
72  RegisteredProtSeq = TRUE;
73  else
74  DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
75 
76  /* Make sure there's a usable endpoint */
77  if (RegisteredProtSeq == FALSE)
78  return 0;
79 
80  Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
81  NULL,
82  NULL);
83  if (Status != RPC_S_OK)
84  {
85  DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
86  return 0;
87  }
88 
90  20,
91  FALSE);
92  if (Status != RPC_S_OK)
93  {
94  DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
95  return 0;
96  }
97 
98  /* ROS HACK (this should never happen...) */
99  DPRINT1("*** Other devices won't be installed correctly. If something\n");
100  DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
101 
102  DPRINT("RpcServerThread() done\n");
103 
104  return 0;
105 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
unsigned char BOOLEAN
Status
Definition: gdiplustypes.h:24
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
static const WCHAR L[]
Definition: oid.c:1250
LPVOID lpParameter
Definition: kernel32.h:241
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define DPRINT
Definition: sndvol32.h:71
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by ServiceMain().

◆ 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().

◆ g_IsUISuppressed

BOOL g_IsUISuppressed

Definition at line 46 of file umpnpmgr.c.

Referenced by InitializePnPManager(), and IsUISuppressionAllowed().

◆ hClassKey

◆ 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().

◆ hEnumKey

◆ hInstallEvent

◆ hNoPendingInstalls

HANDLE hNoPendingInstalls

Definition at line 41 of file install.c.

Referenced by DeviceInstallThread(), and InitializePnPManager().

◆ hUserToken