ReactOS 0.4.16-dev-905-gc1b8c4f
umpnpmgr.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for umpnpmgr.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID UpdateServiceStatus (_In_ DWORD dwState, _In_ DWORD dwCheckPoint)
 
static DWORD WINAPI ServiceControlHandler (DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
 
static DWORD GetBooleanRegValue (IN HKEY hKey, IN PCWSTR lpSubKey, IN PCWSTR lpValue, OUT PBOOL pValue)
 
BOOL GetSuppressNewUIValue (VOID)
 
VOID WINAPI ServiceMain (DWORD argc, LPTSTR *argv)
 
static DWORD InitializePnPManager (VOID)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

static WCHAR ServiceName [] = L"PlugPlay"
 
static SERVICE_STATUS_HANDLE ServiceStatusHandle
 
static SERVICE_STATUS ServiceStatus
 
HKEY hEnumKey = NULL
 
HKEY hClassKey = NULL
 
BOOL g_IsUISuppressed = FALSE
 
BOOL g_ShuttingDown = FALSE
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 33 of file umpnpmgr.c.

Function Documentation

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 348 of file umpnpmgr.c.

351{
352 switch (fdwReason)
353 {
357 break;
358
360 break;
361 }
362
363 return TRUE;
364}
static DWORD const fdwReason
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static DWORD InitializePnPManager(VOID)
Definition: umpnpmgr.c:262

◆ GetBooleanRegValue()

static DWORD GetBooleanRegValue ( IN HKEY  hKey,
IN PCWSTR  lpSubKey,
IN PCWSTR  lpValue,
OUT PBOOL  pValue 
)
static

Definition at line 132 of file umpnpmgr.c.

137{
138 DWORD dwError, dwType, dwData;
139 DWORD cbData = sizeof(dwData);
140 HKEY hSubKey = NULL;
141
142 /* Default value */
143 *pValue = FALSE;
144
145 dwError = RegOpenKeyExW(hKey,
146 lpSubKey,
147 0,
148 KEY_READ,
149 &hSubKey);
150 if (dwError != ERROR_SUCCESS)
151 {
152 DPRINT("GetBooleanRegValue(): RegOpenKeyExW() has failed to open '%S' key! (Error: %lu)\n",
153 lpSubKey, dwError);
154 return dwError;
155 }
156
157 dwError = RegQueryValueExW(hSubKey,
158 lpValue,
159 0,
160 &dwType,
161 (PBYTE)&dwData,
162 &cbData);
163 if (dwError != ERROR_SUCCESS)
164 {
165 DPRINT("GetBooleanRegValue(): RegQueryValueExW() has failed to query '%S' value! (Error: %lu)\n",
166 lpValue, dwError);
167 goto Cleanup;
168 }
169 if (dwType != REG_DWORD)
170 {
171 DPRINT("GetBooleanRegValue(): The value is not of REG_DWORD type!\n");
172 goto Cleanup;
173 }
174
175 /* Return the value */
176 *pValue = (dwData == 1);
177
178Cleanup:
179 RegCloseKey(hSubKey);
180
181 return dwError;
182}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
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 const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
PWCHAR pValue
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define KEY_READ
Definition: nt_native.h:1023
BYTE * PBYTE
Definition: pedump.c:66
#define REG_DWORD
Definition: sdbapi.c:596
#define DPRINT
Definition: sndvol32.h:73

Referenced by GetSuppressNewUIValue(), and InitializePnPManager().

◆ 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}
unsigned int BOOL
Definition: ntddk_ex.h:94
#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().

◆ InitializePnPManager()

static DWORD InitializePnPManager ( VOID  )
static

Definition at line 262 of file umpnpmgr.c.

263{
264 BOOLEAN OldValue;
265 DWORD dwError;
266
267 DPRINT("UMPNPMGR: InitializePnPManager() started\n");
268
269 /* We need this privilege for using CreateProcessAsUserW */
271
273 if (hInstallEvent == NULL)
274 {
275 dwError = GetLastError();
276 DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
277 return dwError;
278 }
279
281 TRUE,
282 FALSE,
283 L"Global\\PnP_No_Pending_Install_Events");
285 {
286 dwError = GetLastError();
287 DPRINT1("Could not create the Pending-Install Event! (Error %lu)\n", dwError);
288 return dwError;
289 }
290
291 /*
292 * Initialize the device-install event list
293 */
294
297 {
298 dwError = GetLastError();
299 DPRINT1("Could not create the List Event! (Error %lu)\n", dwError);
300 return dwError;
301 }
302
305 {
306 dwError = GetLastError();
307 DPRINT1("Could not create the List Mutex! (Error %lu)\n", dwError);
308 return dwError;
309 }
311
312 /* Query the SuppressUI registry value and cache it for our whole lifetime */
314 L"System\\CurrentControlSet\\Services\\PlugPlay\\Parameters",
315 L"SuppressUI",
318 DPRINT("UMPNPMGR: newdev.dll's wizard UI won't be shown!\n");
319
321 L"System\\CurrentControlSet\\Enum",
322 0,
324 &hEnumKey);
325 if (dwError != ERROR_SUCCESS)
326 {
327 DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError);
328 return dwError;
329 }
330
332 L"System\\CurrentControlSet\\Control\\Class",
333 0,
335 &hClassKey);
336 if (dwError != ERROR_SUCCESS)
337 {
338 DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError);
339 return dwError;
340 }
341
342 DPRINT("UMPNPMGR: InitializePnPManager() done\n");
343
344 return 0;
345}
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
static BOOL SetupIsActive(VOID)
Definition: setup.c:27
HANDLE hDeviceInstallListNotEmpty
Definition: install.c:46
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
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE
Definition: security.c:657
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:576
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
HKEY hEnumKey
Definition: umpnpmgr.c:44
BOOL g_IsUISuppressed
Definition: umpnpmgr.c:46
HKEY hClassKey
Definition: umpnpmgr.c:45
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by DllMain().

◆ ServiceControlHandler()

static DWORD WINAPI ServiceControlHandler ( DWORD  dwControl,
DWORD  dwEventType,
LPVOID  lpEventData,
LPVOID  lpContext 
)
static

Definition at line 84 of file umpnpmgr.c.

88{
89 DPRINT1("ServiceControlHandler() called\n");
90
91 switch (dwControl)
92 {
94 DPRINT1(" SERVICE_CONTROL_STOP received\n");
96 /* Stop listening to RPC Messages */
99 return ERROR_SUCCESS;
100
102 DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
104 return ERROR_SUCCESS;
105
107 DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
109 return ERROR_SUCCESS;
110
112 DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
115 return ERROR_SUCCESS;
116
118 DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
120 /* Stop listening to RPC Messages */
123 return ERROR_SUCCESS;
124
125 default :
126 DPRINT1(" Control %lu received\n", dwControl);
128 }
129}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
RPC_STATUS WINAPI RpcMgmtStopServerListening(RPC_BINDING_HANDLE Binding)
Definition: rpc_server.c:1596
BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus, LPSERVICE_STATUS lpServiceStatus)
Definition: sctrl.c:997
static VOID UpdateServiceStatus(_In_ DWORD dwState, _In_ DWORD dwCheckPoint)
Definition: umpnpmgr.c:52
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: umpnpmgr.c:41
static SERVICE_STATUS ServiceStatus
Definition: umpnpmgr.c:42
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:40
#define SERVICE_PAUSED
Definition: winsvc.h:27
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:38
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:36
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:37
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:39

Referenced by ServiceMain().

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 204 of file umpnpmgr.c.

205{
208
211
212 DPRINT("ServiceMain() called\n");
213
216 NULL);
218 {
219 DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
220 return;
221 }
222
224
226 0,
228 NULL,
229 0,
230 &dwThreadId);
231 if (hThread != NULL)
233
235
237 0,
239 NULL,
240 0,
241 &dwThreadId);
242 if (hThread != NULL)
244
246
248 0,
250 NULL,
251 0,
252 &dwThreadId);
253 if (hThread != NULL)
255
257
258 DPRINT("ServiceMain() done\n");
259}
static int argc
Definition: ServiceArgs.c:12
DWORD WINAPI PnpEventThread(_In_ LPVOID lpParameter)
Definition: event.c:175
DWORD WINAPI DeviceInstallThread(LPVOID lpParameter)
Definition: install.c:534
DWORD WINAPI RpcServerThread(LPVOID lpParameter)
Definition: rpcserver.c:46
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
DWORD dwThreadId
Definition: fdebug.c:31
#define argv
Definition: mplay32.c:18
HANDLE hThread
Definition: wizard.c:28
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:812
static WCHAR ServiceName[]
Definition: umpnpmgr.c:39
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: umpnpmgr.c:84
#define SERVICE_START_PENDING
Definition: winsvc.h:22

◆ UpdateServiceStatus()

static VOID UpdateServiceStatus ( _In_ DWORD  dwState,
_In_ DWORD  dwCheckPoint 
)
static

Definition at line 52 of file umpnpmgr.c.

55{
56 if ((dwState == SERVICE_STOPPED) || (dwState == SERVICE_STOP_PENDING))
58
63 ServiceStatus.dwCheckPoint = dwCheckPoint;
64
65 if (dwState == SERVICE_RUNNING)
67 else
69
70 if (dwState == SERVICE_START_PENDING ||
71 dwState == SERVICE_STOP_PENDING ||
72 dwState == SERVICE_PAUSE_PENDING ||
73 dwState == SERVICE_CONTINUE_PENDING)
75 else
77
80}
DWORD dwServiceType
Definition: winsvc.h:99
DWORD dwWin32ExitCode
Definition: winsvc.h:102
DWORD dwControlsAccepted
Definition: winsvc.h:101
DWORD dwWaitHint
Definition: winsvc.h:105
DWORD dwCurrentState
Definition: winsvc.h:100
DWORD dwCheckPoint
Definition: winsvc.h:104
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:103
BOOL g_ShuttingDown
Definition: umpnpmgr.c:47
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962

Referenced by ServiceControlHandler(), and ServiceMain().

Variable Documentation

◆ g_IsUISuppressed

BOOL g_IsUISuppressed = FALSE

Definition at line 46 of file umpnpmgr.c.

Referenced by InitializePnPManager(), and IsUISuppressionAllowed().

◆ g_ShuttingDown

BOOL g_ShuttingDown = FALSE

Definition at line 47 of file umpnpmgr.c.

Referenced by PNP_GetGlobalState(), and UpdateServiceStatus().

◆ hClassKey

◆ hEnumKey

◆ ServiceName

WCHAR ServiceName[] = L"PlugPlay"
static

Definition at line 39 of file umpnpmgr.c.

Referenced by ServiceMain().

◆ ServiceStatus

SERVICE_STATUS ServiceStatus
static

Definition at line 42 of file umpnpmgr.c.

Referenced by ServiceControlHandler(), and UpdateServiceStatus().

◆ ServiceStatusHandle

SERVICE_STATUS_HANDLE ServiceStatusHandle
static

Definition at line 41 of file umpnpmgr.c.

Referenced by ServiceControlHandler(), ServiceMain(), and UpdateServiceStatus().