ReactOS  0.4.15-dev-5097-g328cc41
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
 
struct  NOTIFY_ENTRY
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 

Typedefs

typedef struct NOTIFY_ENTRYPNOTIFY_ENTRY
 

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.

Typedef Documentation

◆ PNOTIFY_ENTRY

Function Documentation

◆ 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 
585 Cleanup:
586  HeapFree(GetProcessHeap(), 0, deviceList);
587 
588  // Step 2: start the wait-loop for newly added devices
589 Step2:
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 */
601  ListEntry = (IsListEmpty(&DeviceInstallListHead)
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 }
_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:55
#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:524
static BOOL IsConsoleBoot(VOID)
Definition: install.c:479
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:290
__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
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:1272
DWORD WINAPI PNP_GetDeviceListSize(handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1643
#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 338 of file umpnpmgr.c.

339 {
340  BOOL bSuppressNewHWUI = FALSE;
341 
342  /*
343  * Query the SuppressNewHWUI policy registry value. Don't cache it
344  * as we want to update our behaviour in consequence.
345  */
347  L"Software\\Policies\\Microsoft\\Windows\\DeviceInstall\\Settings",
348  L"SuppressNewHWUI",
349  &bSuppressNewHWUI);
350  if (bSuppressNewHWUI)
351  DPRINT("GetSuppressNewUIValue(): newdev.dll's wizard UI won't be shown!\n");
352 
353  return bSuppressNewHWUI;
354 }
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static DWORD GetBooleanRegValue(IN HKEY hKey, IN PCWSTR lpSubKey, IN PCWSTR lpValue, OUT PBOOL pValue)
Definition: umpnpmgr.c:285
#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 46 of file rpcserver.c.

47 {
49  BOOLEAN RegisteredProtSeq = FALSE;
50 
51  UNREFERENCED_PARAMETER(lpParameter);
52 
53  DPRINT("RpcServerThread() called\n");
54 
56 
57 #if 0
58  /* 2k/XP/2k3-compatible protocol sequence/endpoint */
59  Status = RpcServerUseProtseqEpW(L"ncacn_np",
60  20,
61  L"\\pipe\\ntsvcs",
62  NULL); // Security descriptor
63  if (Status == RPC_S_OK)
64  RegisteredProtSeq = TRUE;
65  else
66  DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
67 #endif
68 
69  /* Vista/7-compatible protocol sequence/endpoint */
70  Status = RpcServerUseProtseqEpW(L"ncacn_np",
71  20,
72  L"\\pipe\\plugplay",
73  NULL); // Security descriptor
74  if (Status == RPC_S_OK)
75  RegisteredProtSeq = TRUE;
76  else
77  DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
78 
79  /* Make sure there's a usable endpoint */
80  if (RegisteredProtSeq == FALSE)
81  return 0;
82 
83  Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
84  NULL,
85  NULL);
86  if (Status != RPC_S_OK)
87  {
88  DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
89  return 0;
90  }
91 
93  20,
94  FALSE);
95  if (Status != RPC_S_OK)
96  {
97  DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
98  return 0;
99  }
100 
101  /* ROS HACK (this should never happen...) */
102  DPRINT1("*** Other devices won't be installed correctly. If something\n");
103  DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
104 
105  DPRINT("RpcServerThread() done\n");
106 
107  return 0;
108 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long RPC_STATUS
Definition: rpc.h:52
#define L(x)
Definition: ntvdm.h:50
#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
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define DPRINT
Definition: sndvol32.h:71
LIST_ENTRY NotificationListHead
Definition: rpcserver.c:41
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by ServiceMain().

◆ 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 
310 cleanup:
311  if (hKey != NULL)
312  RegCloseKey(hKey);
313 
314  DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
315 
316  return ret;
317 }
static HANDLE DWORD
Definition: install.c:28
DWORD size
Definition: install.c:3757
#define ERROR_SUCCESS
Definition: deptool.c:10
#define L(x)
Definition: ntvdm.h:50
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:4120
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
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:3356
char * cleanup(char *str)
Definition: wpickclick.c:99
#define DPRINT
Definition: sndvol32.h:71
#define REG_DWORD
Definition: sdbapi.c:596
#define RegCloseKey(hKey)
Definition: registry.h:47
#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