ReactOS 0.4.17-dev-573-g8315b8c
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)
 
static BOOL IsMiniNT (VOID)
 Check whether we are running in MiniNT mode (e.g. live medium).
 
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
 
BOOL g_IsMiniNT = 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 372 of file umpnpmgr.c.

375{
376 switch (fdwReason)
377 {
381 break;
382
384 break;
385 }
386
387 return TRUE;
388}
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:286

◆ GetBooleanRegValue()

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

Definition at line 133 of file umpnpmgr.c.

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

Referenced by GetSuppressNewUIValue(), and InitializePnPManager().

◆ GetSuppressNewUIValue()

BOOL GetSuppressNewUIValue ( VOID  )

Definition at line 186 of file umpnpmgr.c.

187{
188 BOOL bSuppressNewHWUI = FALSE;
189
190 /*
191 * Query the SuppressNewHWUI policy registry value. Don't cache it
192 * as we want to update our behaviour in consequence.
193 */
195 L"Software\\Policies\\Microsoft\\Windows\\DeviceInstall\\Settings",
196 L"SuppressNewHWUI",
197 &bSuppressNewHWUI);
198 if (bSuppressNewHWUI)
199 DPRINT("GetSuppressNewUIValue(): newdev.dll's wizard UI won't be shown!\n");
200
201 return bSuppressNewHWUI;
202}
#define L(x)
Definition: resources.c:13
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:133
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by IsUISuppressionAllowed().

◆ InitializePnPManager()

static DWORD InitializePnPManager ( VOID  )
static

Definition at line 286 of file umpnpmgr.c.

287{
288 BOOLEAN OldValue;
289 DWORD dwError;
290
291 DPRINT("UMPNPMGR: InitializePnPManager() started\n");
292
293 /* We need this privilege for using CreateProcessAsUserW */
295
297 if (hInstallEvent == NULL)
298 {
299 dwError = GetLastError();
300 DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
301 return dwError;
302 }
303
305 TRUE,
306 FALSE,
307 L"Global\\PnP_No_Pending_Install_Events");
309 {
310 dwError = GetLastError();
311 DPRINT1("Could not create the Pending-Install Event! (Error %lu)\n", dwError);
312 return dwError;
313 }
314
315 /*
316 * Initialize the device-install event list
317 */
318
321 {
322 dwError = GetLastError();
323 DPRINT1("Could not create the List Event! (Error %lu)\n", dwError);
324 return dwError;
325 }
326
329 {
330 dwError = GetLastError();
331 DPRINT1("Could not create the List Mutex! (Error %lu)\n", dwError);
332 return dwError;
333 }
335
336 /* Query the SuppressUI registry value and cache it for our whole lifetime */
338 L"System\\CurrentControlSet\\Services\\PlugPlay\\Parameters",
339 L"SuppressUI",
342 DPRINT("UMPNPMGR: newdev.dll's wizard UI won't be shown!\n");
343
345 L"System\\CurrentControlSet\\Enum",
346 0,
348 &hEnumKey);
349 if (dwError != ERROR_SUCCESS)
350 {
351 DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError);
352 return dwError;
353 }
354
356 L"System\\CurrentControlSet\\Control\\Class",
357 0,
359 &hClassKey);
360 if (dwError != ERROR_SUCCESS)
361 {
362 DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError);
363 return dwError;
364 }
365
366 DPRINT("UMPNPMGR: InitializePnPManager() done\n");
367
368 return 0;
369}
unsigned char BOOLEAN
Definition: actypes.h:127
#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:557
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:525
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
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().

◆ IsMiniNT()

static BOOL IsMiniNT ( VOID  )
static

Check whether we are running in MiniNT mode (e.g. live medium).

Definition at line 208 of file umpnpmgr.c.

209{
210 HKEY hKey;
211 LONG rc;
212
213 /* Check for the presence of the "MiniNT" registry key */
215 L"SYSTEM\\CurrentControlSet\\Control\\MiniNT",
216 0,
218 &hKey);
219 if (rc == ERROR_SUCCESS)
221
222 return (rc == ERROR_SUCCESS);
223}
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
long LONG
Definition: pedump.c:60

Referenced by ServiceMain(), and wWinMain().

◆ ServiceControlHandler()

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

Definition at line 85 of file umpnpmgr.c.

89{
90 DPRINT1("ServiceControlHandler() called\n");
91
92 switch (dwControl)
93 {
95 DPRINT1(" SERVICE_CONTROL_STOP received\n");
97 /* Stop listening to RPC Messages */
100 return ERROR_SUCCESS;
101
103 DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
105 return ERROR_SUCCESS;
106
108 DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
110 return ERROR_SUCCESS;
111
113 DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
116 return ERROR_SUCCESS;
117
119 DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
121 /* Stop listening to RPC Messages */
124 return ERROR_SUCCESS;
125
126 default :
127 DPRINT1(" Control %lu received\n", dwControl);
129 }
130}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SERVICE_STOPPED
Definition: winsvc.h:21
#define SERVICE_STOP_PENDING
Definition: winsvc.h:23
#define SERVICE_CONTROL_SHUTDOWN
Definition: winsvc.h:46
#define SERVICE_PAUSED
Definition: winsvc.h:27
#define SERVICE_RUNNING
Definition: winsvc.h:24
#define SERVICE_CONTROL_CONTINUE
Definition: winsvc.h:44
#define SERVICE_CONTROL_STOP
Definition: winsvc.h:42
#define SERVICE_CONTROL_PAUSE
Definition: winsvc.h:43
#define SERVICE_CONTROL_INTERROGATE
Definition: winsvc.h:45
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:1016
static VOID UpdateServiceStatus(_In_ DWORD dwState, _In_ DWORD dwCheckPoint)
Definition: umpnpmgr.c:53
static SERVICE_STATUS_HANDLE ServiceStatusHandle
Definition: umpnpmgr.c:41
static SERVICE_STATUS ServiceStatus
Definition: umpnpmgr.c:42

Referenced by ServiceMain().

◆ ServiceMain()

VOID WINAPI ServiceMain ( DWORD  argc,
LPTSTR argv 
)

Definition at line 226 of file umpnpmgr.c.

227{
230
233
234 DPRINT("ServiceMain() called\n");
235
237
240 NULL);
242 {
243 DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
244 return;
245 }
246
248
250 0,
252 NULL,
253 0,
254 &dwThreadId);
255 if (hThread != NULL)
257
259
261 0,
263 NULL,
264 0,
265 &dwThreadId);
266 if (hThread != NULL)
268
270
272 0,
274 NULL,
275 0,
276 &dwThreadId);
277 if (hThread != NULL)
279
281
282 DPRINT("ServiceMain() done\n");
283}
DWORD WINAPI PnpEventThread(_In_ LPVOID lpParameter)
Definition: event.c:238
DWORD WINAPI DeviceInstallThread(LPVOID lpParameter)
Definition: install.c:527
DWORD WINAPI RpcServerThread(LPVOID lpParameter)
Definition: rpcserver.c:48
#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
MonoAssembly int argc
Definition: metahost.c:107
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:329
#define SERVICE_START_PENDING
Definition: winsvc.h:22
SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext)
Definition: sctrl.c:831
static WCHAR ServiceName[]
Definition: umpnpmgr.c:39
static BOOL IsMiniNT(VOID)
Check whether we are running in MiniNT mode (e.g. live medium).
Definition: umpnpmgr.c:208
static DWORD WINAPI ServiceControlHandler(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
Definition: umpnpmgr.c:85
BOOL g_IsMiniNT
Definition: umpnpmgr.c:48

◆ UpdateServiceStatus()

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

Definition at line 53 of file umpnpmgr.c.

56{
57 if ((dwState == SERVICE_STOPPED) || (dwState == SERVICE_STOP_PENDING))
59
64 ServiceStatus.dwCheckPoint = dwCheckPoint;
65
66 if (dwState == SERVICE_RUNNING)
68 else
70
71 if (dwState == SERVICE_START_PENDING ||
72 dwState == SERVICE_STOP_PENDING ||
73 dwState == SERVICE_PAUSE_PENDING ||
74 dwState == SERVICE_CONTINUE_PENDING)
76 else
78
81}
#define SERVICE_ACCEPT_SHUTDOWN
Definition: winsvc.h:30
#define SERVICE_PAUSE_PENDING
Definition: winsvc.h:26
#define SERVICE_CONTINUE_PENDING
Definition: winsvc.h:25
DWORD dwServiceType
Definition: winsvc.h:105
DWORD dwWin32ExitCode
Definition: winsvc.h:108
DWORD dwControlsAccepted
Definition: winsvc.h:107
DWORD dwWaitHint
Definition: winsvc.h:111
DWORD dwCurrentState
Definition: winsvc.h:106
DWORD dwCheckPoint
Definition: winsvc.h:110
DWORD dwServiceSpecificExitCode
Definition: winsvc.h:109
BOOL g_ShuttingDown
Definition: umpnpmgr.c:47
#define SERVICE_WIN32_OWN_PROCESS
Definition: cmtypes.h:962

Referenced by ServiceControlHandler(), and ServiceMain().

Variable Documentation

◆ g_IsMiniNT

BOOL g_IsMiniNT = FALSE

Definition at line 48 of file umpnpmgr.c.

Referenced by PNP_ReportLogOn(), and ServiceMain().

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