ReactOS 0.4.16-dev-297-gc569aee
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

DWORD WINAPI PnpEventThread (LPVOID lpParameter)
 
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
 
LIST_ENTRY NotificationListHead
 
HKEY hEnumKey
 
HKEY hClassKey
 
BOOL g_IsUISuppressed
 
BOOL g_ShuttingDown
 

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
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:1720
DWORD WINAPI PNP_GetDeviceList(handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
Definition: rpcserver.c:1349
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define DPRINT
Definition: sndvol32.h:73
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
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ServiceMain().

◆ GetSuppressNewUIValue()

BOOL GetSuppressNewUIValue ( VOID  )

Definition at line 185 of file umpnpmgr.c.

186{
187 BOOL bSuppressNewHWUI = FALSE;
188
189 /*
190 * Query the SuppressNewHWUI policy registry value. Don't cache it
191 * as we want to update our behaviour in consequence.
192 */
194 L"Software\\Policies\\Microsoft\\Windows\\DeviceInstall\\Settings",
195 L"SuppressNewHWUI",
196 &bSuppressNewHWUI);
197 if (bSuppressNewHWUI)
198 DPRINT("GetSuppressNewUIValue(): newdev.dll's wizard UI won't be shown!\n");
199
200 return bSuppressNewHWUI;
201}
#define L(x)
Definition: ntvdm.h:50
static DWORD GetBooleanRegValue(IN HKEY hKey, IN PCWSTR lpSubKey, IN PCWSTR lpValue, OUT PBOOL pValue)
Definition: umpnpmgr.c:132
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by IsUISuppressionAllowed().

◆ PnpEventThread()

DWORD WINAPI PnpEventThread ( LPVOID  lpParameter)

◆ 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 */
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 */
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}
unsigned char BOOLEAN
LIST_ENTRY NotificationListHead
Definition: rpcserver.c:41
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Status
Definition: gdiplustypes.h:25
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
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 RPC_S_OK
Definition: rpcnterr.h:22
long RPC_STATUS
Definition: rpc.h:52

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
310cleanup:
311 if (hKey != NULL)
313
314 DPRINT("System setup in progress? %S\n", ret ? L"YES" : L"NO");
315
316 return ret;
317}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
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
static void cleanup(void)
Definition: main.c:1335
FxAutoRegKey hKey
GLsizeiptr size
Definition: glext.h:5919
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret

Referenced by DeviceInstallThread().

Variable Documentation

◆ DeviceInstallListHead

LIST_ENTRY DeviceInstallListHead
extern

Definition at line 45 of file install.c.

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

◆ g_IsUISuppressed

BOOL g_IsUISuppressed
extern

Definition at line 46 of file umpnpmgr.c.

Referenced by InitializePnPManager(), and IsUISuppressionAllowed().

◆ g_ShuttingDown

BOOL g_ShuttingDown
extern

Definition at line 47 of file umpnpmgr.c.

Referenced by PNP_GetGlobalState(), and UpdateServiceStatus().

◆ hClassKey

◆ hDeviceInstallListMutex

HANDLE hDeviceInstallListMutex
extern

Definition at line 44 of file install.c.

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

◆ hDeviceInstallListNotEmpty

HANDLE hDeviceInstallListNotEmpty
extern

Definition at line 46 of file install.c.

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

◆ hEnumKey

◆ hInstallEvent

HANDLE hInstallEvent
extern

◆ hNoPendingInstalls

HANDLE hNoPendingInstalls
extern

Definition at line 41 of file install.c.

Referenced by DeviceInstallThread(), and InitializePnPManager().

◆ hUserToken

HANDLE hUserToken
extern

◆ NotificationListHead

LIST_ENTRY NotificationListHead
extern

Definition at line 41 of file rpcserver.c.

Referenced by PNP_RegisterNotification(), and RpcServerThread().