ReactOS 0.4.15-dev-7934-g1dc8d80
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
 

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 344 of file umpnpmgr.c.

347{
348 switch (fdwReason)
349 {
353 break;
354
356 break;
357 }
358
359 return TRUE;
360}
#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:258

◆ GetBooleanRegValue()

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

Definition at line 128 of file umpnpmgr.c.

133{
134 DWORD dwError, dwType, dwData;
135 DWORD cbData = sizeof(dwData);
136 HKEY hSubKey = NULL;
137
138 /* Default value */
139 *pValue = FALSE;
140
141 dwError = RegOpenKeyExW(hKey,
142 lpSubKey,
143 0,
144 KEY_READ,
145 &hSubKey);
146 if (dwError != ERROR_SUCCESS)
147 {
148 DPRINT("GetBooleanRegValue(): RegOpenKeyExW() has failed to open '%S' key! (Error: %lu)\n",
149 lpSubKey, dwError);
150 return dwError;
151 }
152
153 dwError = RegQueryValueExW(hSubKey,
154 lpValue,
155 0,
156 &dwType,
157 (PBYTE)&dwData,
158 &cbData);
159 if (dwError != ERROR_SUCCESS)
160 {
161 DPRINT("GetBooleanRegValue(): RegQueryValueExW() has failed to query '%S' value! (Error: %lu)\n",
162 lpValue, dwError);
163 goto Cleanup;
164 }
165 if (dwType != REG_DWORD)
166 {
167 DPRINT("GetBooleanRegValue(): The value is not of REG_DWORD type!\n");
168 goto Cleanup;
169 }
170
171 /* Return the value */
172 *pValue = (dwData == 1);
173
174Cleanup:
175 RegCloseKey(hSubKey);
176
177 return dwError;
178}
#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:71

Referenced by GetSuppressNewUIValue(), and InitializePnPManager().

◆ GetSuppressNewUIValue()

BOOL GetSuppressNewUIValue ( VOID  )

Definition at line 181 of file umpnpmgr.c.

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

Referenced by IsUISuppressionAllowed().

◆ InitializePnPManager()

static DWORD InitializePnPManager ( VOID  )
static

Definition at line 258 of file umpnpmgr.c.

259{
260 BOOLEAN OldValue;
261 DWORD dwError;
262
263 DPRINT("UMPNPMGR: InitializePnPManager() started\n");
264
265 /* We need this privilege for using CreateProcessAsUserW */
267
269 if (hInstallEvent == NULL)
270 {
271 dwError = GetLastError();
272 DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
273 return dwError;
274 }
275
277 TRUE,
278 FALSE,
279 L"Global\\PnP_No_Pending_Install_Events");
281 {
282 dwError = GetLastError();
283 DPRINT1("Could not create the Pending-Install Event! (Error %lu)\n", dwError);
284 return dwError;
285 }
286
287 /*
288 * Initialize the device-install event list
289 */
290
293 {
294 dwError = GetLastError();
295 DPRINT1("Could not create the List Event! (Error %lu)\n", dwError);
296 return dwError;
297 }
298
301 {
302 dwError = GetLastError();
303 DPRINT1("Could not create the List Mutex! (Error %lu)\n", dwError);
304 return dwError;
305 }
307
308 /* Query the SuppressUI registry value and cache it for our whole lifetime */
310 L"System\\CurrentControlSet\\Services\\PlugPlay\\Parameters",
311 L"SuppressUI",
314 DPRINT("UMPNPMGR: newdev.dll's wizard UI won't be shown!\n");
315
317 L"System\\CurrentControlSet\\Enum",
318 0,
320 &hEnumKey);
321 if (dwError != ERROR_SUCCESS)
322 {
323 DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError);
324 return dwError;
325 }
326
328 L"System\\CurrentControlSet\\Control\\Class",
329 0,
331 &hClassKey);
332 if (dwError != ERROR_SUCCESS)
333 {
334 DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError);
335 return dwError;
336 }
337
338 DPRINT("UMPNPMGR: InitializePnPManager() done\n");
339
340 return 0;
341}
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 80 of file umpnpmgr.c.

84{
85 DPRINT1("ServiceControlHandler() called\n");
86
87 switch (dwControl)
88 {
90 DPRINT1(" SERVICE_CONTROL_STOP received\n");
92 /* Stop listening to RPC Messages */
95 return ERROR_SUCCESS;
96
98 DPRINT1(" SERVICE_CONTROL_PAUSE received\n");
100 return ERROR_SUCCESS;
101
103 DPRINT1(" SERVICE_CONTROL_CONTINUE received\n");
105 return ERROR_SUCCESS;
106
108 DPRINT1(" SERVICE_CONTROL_INTERROGATE received\n");
111 return ERROR_SUCCESS;
112
114 DPRINT1(" SERVICE_CONTROL_SHUTDOWN received\n");
116 /* Stop listening to RPC Messages */
119 return ERROR_SUCCESS;
120
121 default :
122 DPRINT1(" Control %lu received\n", dwControl);
124 }
125}
#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:51
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 200 of file umpnpmgr.c.

201{
204
207
208 DPRINT("ServiceMain() called\n");
209
212 NULL);
214 {
215 DPRINT1("RegisterServiceCtrlHandlerExW() failed! (Error %lu)\n", GetLastError());
216 return;
217 }
218
220
222 0,
224 NULL,
225 0,
226 &dwThreadId);
227 if (hThread != NULL)
229
231
233 0,
235 NULL,
236 0,
237 &dwThreadId);
238 if (hThread != NULL)
240
242
244 0,
246 NULL,
247 0,
248 &dwThreadId);
249 if (hThread != NULL)
251
253
254 DPRINT("ServiceMain() done\n");
255}
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:317
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:80
#define SERVICE_START_PENDING
Definition: winsvc.h:22

◆ UpdateServiceStatus()

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

Definition at line 51 of file umpnpmgr.c.

54{
59 ServiceStatus.dwCheckPoint = dwCheckPoint;
60
61 if (dwState == SERVICE_RUNNING)
63 else
65
66 if (dwState == SERVICE_START_PENDING ||
67 dwState == SERVICE_STOP_PENDING ||
68 dwState == SERVICE_PAUSE_PENDING ||
69 dwState == SERVICE_CONTINUE_PENDING)
71 else
73
76}
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
#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().

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