ReactOS  0.4.12-dev-409-g9f418243
umpnpmgr.c 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 <debug.h>
Include dependency graph for umpnpmgr.c:

Go to the source code of this file.

Classes

struct  DeviceInstallParams
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define NDEBUG
 

Functions

static DWORD WINAPI RpcServerThread (LPVOID lpParameter)
 
void __RPC_FAR *__RPC_USER midl_user_allocate (SIZE_T len)
 
void __RPC_USER midl_user_free (void __RPC_FAR *ptr)
 
static CONFIGRET WINAPI NtStatusToCrError (NTSTATUS Status)
 
static VOID SplitDeviceInstanceID (IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
 
DWORD WINAPI PNP_Disconnect (handle_t hBinding)
 
DWORD WINAPI PNP_Connect (handle_t hBinding)
 
DWORD WINAPI PNP_GetVersion (handle_t hBinding, WORD *pVersion)
 
DWORD WINAPI PNP_GetGlobalState (handle_t hBinding, DWORD *pulState, DWORD ulFlags)
 
DWORD WINAPI PNP_InitDetection (handle_t hBinding)
 
DWORD WINAPI PNP_ReportLogOn (handle_t hBinding, BOOL Admin, DWORD ProcessId)
 
DWORD WINAPI PNP_ValidateDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_GetRootDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_GetRelatedDeviceInstance (handle_t hBinding, DWORD ulRelationship, LPWSTR pDeviceID, LPWSTR pRelatedDeviceId, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_EnumerateSubKeys (handle_t hBinding, DWORD ulBranch, DWORD ulIndex, LPWSTR Buffer, PNP_RPC_STRING_LEN ulLength, PNP_RPC_STRING_LEN *pulRequiredLen, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceList (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceList (_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceList (_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
CONFIGRET GetEnumeratorInstanceList (_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetAllInstanceList (_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
DWORD WINAPI PNP_GetDeviceList (handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceListSize (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceListSize (_In_ PWSTR pszService, _Out_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceListSize (_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
 
static CONFIGRET GetEnumeratorInstanceListSize (_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
 
static CONFIGRET GetAllInstanceListSize (_Out_ PULONG pulLength)
 
DWORD WINAPI PNP_GetDeviceListSize (handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDepth (handle_t hBinding, LPWSTR pszDeviceID, DWORD *pulDepth, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceID, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_PROP_SIZE *pulTransferLen, PNP_PROP_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassInstance (handle_t hBinding, LPWSTR pDeviceId, LPWSTR pszClassInstance, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_CreateKey (handle_t hBinding, LPWSTR pszSubKey, DWORD samDesired, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteRegistryKey (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentKey, LPWSTR pszChildKey, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassCount (handle_t hBinding, DWORD *pulClassCount, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassName (handle_t hBinding, LPWSTR pszClassGuid, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteClassKey (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceAlias (handle_t hBinding, LPWSTR pszInterfaceDevice, GUID *AliasInterfaceGuid, LPWSTR pszAliasInterfaceDevice, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceList (handle_t hBinding, GUID *InterfaceGuid, LPWSTR pszDeviceID, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceListSize (handle_t hBinding, PNP_RPC_BUFFER_SIZE *pulLen, GUID *InterfaceGuid, LPWSTR pszDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszDeviceID, GUID *InterfaceGuid, LPWSTR pszReference, LPWSTR pszSymLink, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_UnregisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszInterfaceDevice, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
static CONFIGRET CreateDeviceInstance (LPWSTR pszDeviceID)
 
DWORD WINAPI PNP_CreateDevInst (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentDeviceID, PNP_RPC_STRING_LEN ulLength, DWORD ulFlags)
 
static CONFIGRET MoveDeviceInstance (LPWSTR pszDeviceInstanceDestination, LPWSTR pszDeviceInstanceSource)
 
static CONFIGRET SetupDeviceInstance (LPWSTR pszDeviceInstance, DWORD ulFlags)
 
static CONFIGRET EnableDeviceInstance (LPWSTR pszDeviceInstance)
 
static CONFIGRET DisableDeviceInstance (LPWSTR pszDeviceInstance)
 
static CONFIGRET ReenumerateDeviceInstance (_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulFlags)
 
DWORD WINAPI PNP_DeviceInstanceAction (handle_t hBinding, DWORD ulAction, DWORD ulFlags, LPWSTR pszDeviceInstance1, LPWSTR pszDeviceInstance2)
 
DWORD WINAPI PNP_GetDeviceStatus (handle_t hBinding, LPWSTR pDeviceID, DWORD *pulStatus, DWORD *pulProblem, DWORD ulFlags)
 
DWORD WINAPI PNP_SetDeviceProblem (handle_t hBinding, LPWSTR pDeviceID, DWORD ulProblem, DWORD ulFlags)
 
DWORD WINAPI PNP_DisableDevInst (handle_t hBinding, LPWSTR pDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_UninstallDevInst (handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
 
static BOOL CheckForDeviceId (LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
 
static VOID AppendDeviceId (LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
 
DWORD WINAPI PNP_AddID (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszID, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterDriver (handle_t hBinding, LPWSTR pszDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryRemove (handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_RequestDeviceEject (handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
CONFIGRET WINAPI PNP_IsDockStationPresent (handle_t hBinding, BOOL *Present)
 
DWORD WINAPI PNP_RequestEjectPC (handle_t hBinding)
 
DWORD WINAPI PNP_HwProfFlags (handle_t hBinding, DWORD ulAction, LPWSTR pDeviceID, DWORD ulConfig, DWORD *pulValue, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetHwProfInfo (handle_t hBinding, DWORD ulIndex, HWPROFILEINFO *pHWProfileInfo, DWORD ulProfileInfoSize, DWORD ulFlags)
 
DWORD WINAPI PNP_AddEmptyLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulPriority, DWORD *pulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_FreeLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetFirstLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD *pulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetNextLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulCurrentTag, DWORD *pulNextTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetLogConfPriority (handle_t hBinding, LPWSTR pDeviceID, DWORD ulType, DWORD ulTag, DWORD *pPriority, DWORD ulFlags)
 
DWORD WINAPI PNP_AddResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD *pulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
 
DWORD WINAPI PNP_FreeResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulPreviousResType, DWORD *pulPreviousResTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetNextResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulNextResType, DWORD *pulNextResTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetResDesData (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_GetResDesDataSize (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulSize, DWORD ulFlags)
 
DWORD WINAPI PNP_ModifyResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID CurrentResourceID, RESOURCEID NewResourceID, DWORD ulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
 
DWORD WINAPI PNP_DetectResourceConflict (handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BOOL *pbConflictDetected, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryResConfList (handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_SetHwProf (handle_t hBinding, DWORD ulHardwareProfile, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryArbitratorFreeData (handle_t hBinding, BYTE *pData, DWORD DataLen, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryArbitratorFreeSize (handle_t hBinding, DWORD *pulSize, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
 
CONFIGRET WINAPI PNP_RunDetection (handle_t hBinding, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterNotification (handle_t hBinding, DWORD ulFlags, DWORD *pulNotify)
 
DWORD WINAPI PNP_UnregisterNotification (handle_t hBinding, DWORD ulNotify)
 
DWORD WINAPI PNP_GetCustomDevProp (handle_t hBinding, LPWSTR pDeviceID, LPWSTR CustomPropName, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetVersionInternal (handle_t hBinding, WORD *pwVersion)
 
DWORD WINAPI PNP_GetBlockedDriverInfo (handle_t hBinding, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulTransferLen, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetServerSideDeviceInstallFlags (handle_t hBinding, DWORD *pulSSDIFlags, DWORD ulFlags)
 
DWORD WINAPI PNP_GetObjectPropKeys (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, PNP_PROP_COUNT *PropertyCount, PNP_PROP_COUNT *TransferLen, DEVPROPKEY *PropertyKeys, DWORD Flags)
 
DWORD WINAPI PNP_GetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PNP_PROP_SIZE *PropertySize, PNP_PROP_SIZE *TransferLen, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_SetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, PNP_PROP_SIZE PropertySize, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_InstallDevInst (handle_t hBinding)
 
DWORD WINAPI PNP_ApplyPowerSettings (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreAddDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreDeleteDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_RegisterServiceNotification (handle_t hBinding)
 
DWORD WINAPI PNP_SetActiveService (handle_t hBinding, LPWSTR pszFilter, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteServiceDevices (handle_t hBinding)
 
static BOOL InstallDevice (PCWSTR DeviceInstance, BOOL ShowWizard)
 
static LONG ReadRegSzKey (IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
 
static BOOL SetupIsActive (VOID)
 
static BOOL IsConsoleBoot (VOID)
 
static DWORD WINAPI DeviceInstallThread (LPVOID lpParameter)
 
static DWORD WINAPI PnpEventThread (LPVOID lpParameter)
 
static VOID UpdateServiceStatus (DWORD dwState)
 
static DWORD WINAPI ServiceControlHandler (DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext)
 
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
 
static WCHAR szRootDeviceId [] = L"HTREE\\ROOT\\0"
 
static HKEY hEnumKey = NULL
 
static HKEY hClassKey = NULL
 
static HANDLE hUserToken = NULL
 
static HANDLE hInstallEvent = NULL
 
static HANDLE hNoPendingInstalls = NULL
 
static SLIST_HEADER DeviceInstallListHead
 
static HANDLE hDeviceInstallListNotEmpty
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 32 of file umpnpmgr.c.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 33 of file umpnpmgr.c.

◆ NDEBUG

#define NDEBUG

Definition at line 52 of file umpnpmgr.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 31 of file umpnpmgr.c.

Function Documentation

◆ AppendDeviceId()

static VOID AppendDeviceId ( LPWSTR  lpDeviceIdList,
LPDWORD  lpDeviceIdListSize,
LPWSTR  lpDeviceId 
)
static

Definition at line 2726 of file umpnpmgr.c.

2729 {
2730  DWORD dwLen;
2731  DWORD dwPos;
2732 
2733  dwLen = wcslen(lpDeviceId);
2734  dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
2735 
2736  wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
2737 
2738  dwPos += (dwLen + 1);
2739 
2740  lpDeviceIdList[dwPos] = 0;
2741 
2742  *lpDeviceIdListSize = dwPos * sizeof(WCHAR);
2743 }
#define WCHAR
Definition: msvc.h:43
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by PNP_AddID().

◆ CheckForDeviceId()

static BOOL CheckForDeviceId ( LPWSTR  lpDeviceIdList,
LPWSTR  lpDeviceId 
)
static

Definition at line 2705 of file umpnpmgr.c.

2707 {
2708  LPWSTR lpPtr;
2709  DWORD dwLength;
2710 
2711  lpPtr = lpDeviceIdList;
2712  while (*lpPtr != 0)
2713  {
2714  dwLength = wcslen(lpPtr);
2715  if (0 == _wcsicmp(lpPtr, lpDeviceId))
2716  return TRUE;
2717 
2718  lpPtr += (dwLength + 1);
2719  }
2720 
2721  return FALSE;
2722 }
#define TRUE
Definition: types.h:120
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by PNP_AddID().

◆ CreateDeviceInstance()

static CONFIGRET CreateDeviceInstance ( LPWSTR  pszDeviceID)
static

Definition at line 2324 of file umpnpmgr.c.

2325 {
2326  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
2327  WCHAR szDevice[MAX_DEVICE_ID_LEN];
2328  WCHAR szInstance[MAX_DEVICE_ID_LEN];
2329  HKEY hKeyEnumerator;
2330  HKEY hKeyDevice;
2331  HKEY hKeyInstance;
2332  HKEY hKeyControl;
2333  LONG lError;
2334 
2335  /* Split the instance ID */
2336  SplitDeviceInstanceID(pszDeviceID,
2337  szEnumerator,
2338  szDevice,
2339  szInstance);
2340 
2341  /* Open or create the enumerator key */
2342  lError = RegCreateKeyExW(hEnumKey,
2343  szEnumerator,
2344  0,
2345  NULL,
2348  NULL,
2349  &hKeyEnumerator,
2350  NULL);
2351  if (lError != ERROR_SUCCESS)
2352  {
2353  return CR_REGISTRY_ERROR;
2354  }
2355 
2356  /* Open or create the device key */
2357  lError = RegCreateKeyExW(hKeyEnumerator,
2358  szDevice,
2359  0,
2360  NULL,
2363  NULL,
2364  &hKeyDevice,
2365  NULL);
2366 
2367  /* Close the enumerator key */
2368  RegCloseKey(hKeyEnumerator);
2369 
2370  if (lError != ERROR_SUCCESS)
2371  {
2372  return CR_REGISTRY_ERROR;
2373  }
2374 
2375  /* Try to open the instance key and fail if it exists */
2376  lError = RegOpenKeyExW(hKeyDevice,
2377  szInstance,
2378  0,
2379  KEY_SET_VALUE,
2380  &hKeyInstance);
2381  if (lError == ERROR_SUCCESS)
2382  {
2383  DPRINT1("Instance %S already exists!\n", szInstance);
2384  RegCloseKey(hKeyInstance);
2385  RegCloseKey(hKeyDevice);
2386  return CR_ALREADY_SUCH_DEVINST;
2387  }
2388 
2389  /* Create a new instance key */
2390  lError = RegCreateKeyExW(hKeyDevice,
2391  szInstance,
2392  0,
2393  NULL,
2396  NULL,
2397  &hKeyInstance,
2398  NULL);
2399 
2400  /* Close the device key */
2401  RegCloseKey(hKeyDevice);
2402 
2403  if (lError != ERROR_SUCCESS)
2404  {
2405  return CR_REGISTRY_ERROR;
2406  }
2407 
2408  /* Create the 'Control' sub key */
2409  lError = RegCreateKeyExW(hKeyInstance,
2410  L"Control",
2411  0,
2412  NULL,
2415  NULL,
2416  &hKeyControl,
2417  NULL);
2418  if (lError == ERROR_SUCCESS)
2419  {
2420  RegCloseKey(hKeyControl);
2421  }
2422 
2423  RegCloseKey(hKeyInstance);
2424 
2425  return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
2426 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: umpnpmgr.c:188
#define KEY_SET_VALUE
Definition: nt_native.h:1017
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
static const WCHAR L[]
Definition: oid.c:1087
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by PNP_CreateDevInst().

◆ DeviceInstallThread()

static DWORD WINAPI DeviceInstallThread ( LPVOID  lpParameter)
static

Definition at line 4098 of file umpnpmgr.c.

4099 {
4100  PSLIST_ENTRY ListEntry;
4101  DeviceInstallParams* Params;
4102  BOOL showWizard;
4103 
4105 
4107 
4108  showWizard = !SetupIsActive() && !IsConsoleBoot();
4109 
4110  while (TRUE)
4111  {
4113 
4114  if (ListEntry == NULL)
4115  {
4118  }
4119  else
4120  {
4122  Params = CONTAINING_RECORD(ListEntry, DeviceInstallParams, ListEntry);
4123  InstallDevice(Params->DeviceIds, showWizard);
4124  HeapFree(GetProcessHeap(), 0, Params);
4125  }
4126  }
4127 
4128  return 0;
4129 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
static BOOL SetupIsActive(VOID)
Definition: umpnpmgr.c:4022
PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER ListHead)
Definition: interlocked.c:55
static HANDLE hInstallEvent
Definition: umpnpmgr.c:68
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
smooth NULL
Definition: ftsmooth.c:416
WCHAR DeviceIds[1]
Definition: umpnpmgr.c:77
static BOOL IsConsoleBoot(VOID)
Definition: umpnpmgr.c:4053
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
static HANDLE hNoPendingInstalls
Definition: umpnpmgr.c:69
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
static SLIST_HEADER DeviceInstallListHead
Definition: umpnpmgr.c:71
#define PSLIST_ENTRY
Definition: rtltypes.h:130
static BOOL InstallDevice(PCWSTR DeviceInstance, BOOL ShowWizard)
Definition: umpnpmgr.c:3803
LPVOID lpParameter
Definition: kernel32.h:234
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:660
#define INFINITE
Definition: serial.h:102
#define HeapFree(x, y, z)
Definition: compat.h:394
static HANDLE hDeviceInstallListNotEmpty
Definition: umpnpmgr.c:72

Referenced by ServiceMain().

◆ DisableDeviceInstance()

static CONFIGRET DisableDeviceInstance ( LPWSTR  pszDeviceInstance)
static

Definition at line 2526 of file umpnpmgr.c.

2527 {
2528  DPRINT("DisableDeviceInstance: not implemented\n");
2529  /* FIXME */
2530  return CR_CALL_NOT_IMPLEMENTED;
2531 }
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898

Referenced by PNP_DeviceInstanceAction().

◆ DllMain()

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

Definition at line 4468 of file umpnpmgr.c.

4471 {
4472  switch (fdwReason)
4473  {
4474  case DLL_PROCESS_ATTACH:
4475  DisableThreadLibraryCalls(hinstDLL);
4477  break;
4478 
4479  case DLL_PROCESS_DETACH:
4480  break;
4481  }
4482 
4483  return TRUE;
4484 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static DWORD InitializePnPManager(VOID)
Definition: umpnpmgr.c:4401
#define DLL_PROCESS_DETACH
Definition: compat.h:119

◆ EnableDeviceInstance()

static CONFIGRET EnableDeviceInstance ( LPWSTR  pszDeviceInstance)
static

Definition at line 2508 of file umpnpmgr.c.

2509 {
2510  PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
2512  NTSTATUS Status;
2513 
2514  DPRINT("Enable device instance %S\n", pszDeviceInstance);
2515 
2516  RtlInitUnicodeString(&ResetDeviceData.DeviceInstance, pszDeviceInstance);
2518  if (!NT_SUCCESS(Status))
2520 
2521  return ret;
2522 }
LONG NTSTATUS
Definition: precomp.h:26
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_DeviceInstanceAction().

◆ GetAllInstanceList()

static CONFIGRET GetAllInstanceList ( _Inout_ PWSTR  pszBuffer,
_Inout_ PDWORD  pulLength 
)
static

Definition at line 846 of file umpnpmgr.c.

849 {
850  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
851  PWSTR pPtr;
852  DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
853  DWORD dwError;
855 
856  dwUsedLength = 0;
857  dwRemainingLength = *pulLength;
858  pPtr = pszBuffer;
859 
860  for (dwIndex = 0; ; dwIndex++)
861  {
862  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
863  dwError = RegEnumKeyExW(hEnumKey,
864  dwIndex,
865  szEnumeratorBuffer,
866  &dwEnumeratorLength,
867  NULL, NULL, NULL, NULL);
868  if (dwError != ERROR_SUCCESS)
869  break;
870 
871  dwPathLength = dwRemainingLength;
872  ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
873  pPtr,
874  &dwPathLength);
875  if (ret != CR_SUCCESS)
876  break;
877 
878  dwUsedLength += dwPathLength - 1;
879  dwRemainingLength += dwPathLength - 1;
880  pPtr += dwPathLength - 1;
881  }
882 
883  if (ret == CR_SUCCESS)
884  *pulLength = dwUsedLength + 1;
885  else
886  *pulLength = 0;
887 
888  return ret;
889 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint16_t * PWSTR
Definition: typedefs.h:54
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:775
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541

Referenced by PNP_GetDeviceList().

◆ GetAllInstanceListSize()

static CONFIGRET GetAllInstanceListSize ( _Out_ PULONG  pulLength)
static

Definition at line 1230 of file umpnpmgr.c.

1232 {
1233  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1234  DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
1235  DWORD dwError;
1237 
1238  for (dwIndex = 0; ; dwIndex++)
1239  {
1240  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1241  dwError = RegEnumKeyExW(hEnumKey,
1242  dwIndex,
1243  szEnumeratorBuffer,
1244  &dwEnumeratorLength,
1245  NULL, NULL, NULL, NULL);
1246  if (dwError != ERROR_SUCCESS)
1247  break;
1248 
1249  /* Get the size of all device instances for the enumerator */
1250  ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
1251  &dwBufferLength);
1252  if (ret != CR_SUCCESS)
1253  break;
1254 
1255  *pulLength += dwBufferLength;
1256  }
1257 
1258  return ret;
1259 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: umpnpmgr.c:1169
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541

Referenced by PNP_GetDeviceListSize().

◆ GetDeviceInstanceList()

static CONFIGRET GetDeviceInstanceList ( _In_ PWSTR  pszDevice,
_Inout_ PWSTR  pszBuffer,
_Inout_ PDWORD  pulLength 
)
static

Definition at line 704 of file umpnpmgr.c.

708 {
709  WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
710  WCHAR szPathBuffer[512];
711  HKEY hDeviceKey;
712  DWORD dwInstanceLength, dwPathLength, dwUsedLength;
713  DWORD dwIndex, dwError;
714  PWSTR pPtr;
716 
717  /* Open the device key */
718  dwError = RegOpenKeyExW(hEnumKey,
719  pszDevice,
720  0,
722  &hDeviceKey);
723  if (dwError != ERROR_SUCCESS)
724  {
725  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
726  return CR_REGISTRY_ERROR;
727  }
728 
729  dwUsedLength = 0;
730  pPtr = pszBuffer;
731 
732  for (dwIndex = 0; ; dwIndex++)
733  {
734  dwInstanceLength = MAX_DEVICE_ID_LEN;
735  dwError = RegEnumKeyExW(hDeviceKey,
736  dwIndex,
737  szInstanceBuffer,
738  &dwInstanceLength,
739  NULL,
740  NULL,
741  NULL,
742  NULL);
743  if (dwError != ERROR_SUCCESS)
744  break;
745 
746  wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
747  DPRINT("Path: %S\n", szPathBuffer);
748 
749  dwPathLength = wcslen(szPathBuffer) + 1;
750  if (dwUsedLength + dwPathLength + 1 > *pulLength)
751  {
753  break;
754  }
755 
756  wcscpy(pPtr, szPathBuffer);
757  dwUsedLength += dwPathLength;
758  pPtr += dwPathLength;
759 
760  *pPtr = UNICODE_NULL;
761  }
762 
763  RegCloseKey(hDeviceKey);
764 
765  if (ret == CR_SUCCESS)
766  *pulLength = dwUsedLength + 1;
767  else
768  *pulLength = 0;
769 
770  return ret;
771 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint16_t * PWSTR
Definition: typedefs.h:54
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
#define wsprintf
Definition: winuser.h:5731
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by GetEnumeratorInstanceList(), and PNP_GetDeviceList().

◆ GetDeviceInstanceListSize()

static CONFIGRET GetDeviceInstanceListSize ( _In_ LPCWSTR  pszDevice,
_Out_ PULONG  pulLength 
)
static

Definition at line 1117 of file umpnpmgr.c.

1120 {
1121  HKEY hDeviceKey;
1122  DWORD dwSubKeys, dwMaxSubKeyLength;
1123  DWORD dwError;
1124 
1125  /* Open the device key */
1126  dwError = RegOpenKeyExW(hEnumKey,
1127  pszDevice,
1128  0,
1129  KEY_READ,
1130  &hDeviceKey);
1131  if (dwError != ERROR_SUCCESS)
1132  {
1133  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1134  return CR_REGISTRY_ERROR;
1135  }
1136 
1137  /* Retrieve the number of device instances and the maximum name length */
1138  dwError = RegQueryInfoKeyW(hDeviceKey,
1139  NULL,
1140  NULL,
1141  NULL,
1142  &dwSubKeys,
1143  &dwMaxSubKeyLength,
1144  NULL,
1145  NULL,
1146  NULL,
1147  NULL,
1148  NULL,
1149  NULL);
1150  if (dwError != ERROR_SUCCESS)
1151  {
1152  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1153  dwSubKeys = 0;
1154  dwMaxSubKeyLength = 0;
1155  }
1156 
1157  /* Close the device key */
1158  RegCloseKey(hDeviceKey);
1159 
1160  /* Return the largest possible buffer size */
1161  *pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
1162 
1163  return CR_SUCCESS;
1164 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by GetEnumeratorInstanceListSize(), and PNP_GetDeviceListSize().

◆ GetEnumeratorInstanceList()

CONFIGRET GetEnumeratorInstanceList ( _In_ PWSTR  pszEnumerator,
_Inout_ PWSTR  pszBuffer,
_Inout_ PDWORD  pulLength 
)

Definition at line 775 of file umpnpmgr.c.

779 {
780  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
781  WCHAR szPathBuffer[512];
782  HKEY hEnumeratorKey;
783  PWSTR pPtr;
784  DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
785  DWORD dwError;
787 
788  /* Open the enumerator key */
789  dwError = RegOpenKeyExW(hEnumKey,
790  pszEnumerator,
791  0,
793  &hEnumeratorKey);
794  if (dwError != ERROR_SUCCESS)
795  {
796  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
797  return CR_REGISTRY_ERROR;
798  }
799 
800  dwUsedLength = 0;
801  dwRemainingLength = *pulLength;
802  pPtr = pszBuffer;
803 
804  for (dwIndex = 0; ; dwIndex++)
805  {
806  dwDeviceLength = MAX_DEVICE_ID_LEN;
807  dwError = RegEnumKeyExW(hEnumeratorKey,
808  dwIndex,
809  szDeviceBuffer,
810  &dwDeviceLength,
811  NULL,
812  NULL,
813  NULL,
814  NULL);
815  if (dwError != ERROR_SUCCESS)
816  break;
817 
818  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
819  DPRINT("Path: %S\n", szPathBuffer);
820 
821  dwPathLength = dwRemainingLength;
822  ret = GetDeviceInstanceList(szPathBuffer,
823  pPtr,
824  &dwPathLength);
825  if (ret != CR_SUCCESS)
826  break;
827 
828  dwUsedLength += dwPathLength - 1;
829  dwRemainingLength += dwPathLength - 1;
830  pPtr += dwPathLength - 1;
831  }
832 
833  RegCloseKey(hEnumeratorKey);
834 
835  if (ret == CR_SUCCESS)
836  *pulLength = dwUsedLength + 1;
837  else
838  *pulLength = 0;
839 
840  return ret;
841 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint16_t * PWSTR
Definition: typedefs.h:54
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:704
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
#define wsprintf
Definition: winuser.h:5731
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by GetAllInstanceList(), and PNP_GetDeviceList().

◆ GetEnumeratorInstanceListSize()

static CONFIGRET GetEnumeratorInstanceListSize ( _In_ LPCWSTR  pszEnumerator,
_Out_ PULONG  pulLength 
)
static

Definition at line 1169 of file umpnpmgr.c.

1172 {
1173  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1174  WCHAR szPathBuffer[512];
1175  HKEY hEnumeratorKey;
1176  DWORD dwIndex, dwDeviceLength, dwBufferLength;
1177  DWORD dwError;
1179 
1180  *pulLength = 0;
1181 
1182  /* Open the enumerator key */
1183  dwError = RegOpenKeyExW(hEnumKey,
1184  pszEnumerator,
1185  0,
1187  &hEnumeratorKey);
1188  if (dwError != ERROR_SUCCESS)
1189  {
1190  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1191  return CR_REGISTRY_ERROR;
1192  }
1193 
1194  for (dwIndex = 0; ; dwIndex++)
1195  {
1196  dwDeviceLength = MAX_DEVICE_ID_LEN;
1197  dwError = RegEnumKeyExW(hEnumeratorKey,
1198  dwIndex,
1199  szDeviceBuffer,
1200  &dwDeviceLength,
1201  NULL,
1202  NULL,
1203  NULL,
1204  NULL);
1205  if (dwError != ERROR_SUCCESS)
1206  break;
1207 
1208  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1209  DPRINT("Path: %S\n", szPathBuffer);
1210 
1211  ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
1212  if (ret != CR_SUCCESS)
1213  {
1214  *pulLength = 0;
1215  break;
1216  }
1217 
1218  *pulLength += dwBufferLength;
1219  }
1220 
1221  /* Close the enumerator key */
1222  RegCloseKey(hEnumeratorKey);
1223 
1224  return ret;
1225 }
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: umpnpmgr.c:1117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
#define wsprintf
Definition: winuser.h:5731
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by GetAllInstanceListSize(), and PNP_GetDeviceListSize().

◆ GetRelationsInstanceList()

static CONFIGRET GetRelationsInstanceList ( _In_ PWSTR  pszDevice,
_In_ DWORD  ulFlags,
_Inout_ PWSTR  pszBuffer,
_Inout_ PDWORD  pulLength 
)
static

Definition at line 534 of file umpnpmgr.c.

539 {
543 
544  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
545  pszDevice);
546 
547  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
548  {
549  PlugPlayData.Relations = 3;
550  }
551  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
552  {
553  PlugPlayData.Relations = 2;
554  }
555  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
556  {
557  PlugPlayData.Relations = 1;
558  }
559  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
560  {
561  PlugPlayData.Relations = 0;
562  }
563 
564  PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
565  PlugPlayData.Buffer = pszBuffer;
566 
568  (PVOID)&PlugPlayData,
570  if (NT_SUCCESS(Status))
571  {
572  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
573  }
574  else
575  {
577  }
578 
579  return ret;
580 }
LONG NTSTATUS
Definition: precomp.h:26
#define WCHAR
Definition: msvc.h:43
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_GetDeviceList().

◆ GetRelationsInstanceListSize()

static CONFIGRET GetRelationsInstanceListSize ( _In_ PWSTR  pszDevice,
_In_ DWORD  ulFlags,
_Inout_ PDWORD  pulLength 
)
static

Definition at line 968 of file umpnpmgr.c.

972 {
976 
977  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
978  pszDevice);
979 
980  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
981  {
982  PlugPlayData.Relations = 3;
983  }
984  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
985  {
986  PlugPlayData.Relations = 2;
987  }
988  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
989  {
990  PlugPlayData.Relations = 1;
991  }
992  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
993  {
994  PlugPlayData.Relations = 0;
995  }
996 
997  PlugPlayData.BufferSize = 0;
998  PlugPlayData.Buffer = NULL;
999 
1001  (PVOID)&PlugPlayData,
1003  if (NT_SUCCESS(Status))
1004  {
1005  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1006  }
1007  else
1008  {
1010  }
1011 
1012  return ret;
1013 }
LONG NTSTATUS
Definition: precomp.h:26
#define WCHAR
Definition: msvc.h:43
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_GetDeviceListSize().

◆ GetServiceInstanceList()

static CONFIGRET GetServiceInstanceList ( _In_ PWSTR  pszService,
_Inout_ PWSTR  pszBuffer,
_Inout_ PDWORD  pulLength 
)
static

Definition at line 585 of file umpnpmgr.c.

589 {
590  WCHAR szPathBuffer[512];
591  WCHAR szName[16];
592  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
593  DWORD dwValues, dwSize, dwIndex, dwUsedLength, dwPathLength;
594  DWORD dwError;
595  PWSTR pPtr;
597 
598  /* Open the device key */
600  L"System\\CurrentControlSet\\Services",
601  0,
602  KEY_READ,
603  &hServicesKey);
604  if (dwError != ERROR_SUCCESS)
605  {
606  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
607  return CR_REGISTRY_ERROR;
608  }
609 
610  dwError = RegOpenKeyExW(hServicesKey,
611  pszService,
612  0,
613  KEY_READ,
614  &hServiceKey);
615  if (dwError != ERROR_SUCCESS)
616  {
617  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
619  goto Done;
620  }
621 
622  dwError = RegOpenKeyExW(hServiceKey,
623  L"Enum",
624  0,
625  KEY_READ,
626  &hEnumKey);
627  if (dwError != ERROR_SUCCESS)
628  {
629  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
631  goto Done;
632  }
633 
634  /* Retrieve the number of device instances */
635  dwSize = sizeof(DWORD);
636  dwError = RegQueryValueExW(hEnumKey,
637  L"Count",
638  NULL,
639  NULL,
640  (LPBYTE)&dwValues,
641  &dwSize);
642  if (dwError != ERROR_SUCCESS)
643  {
644  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
645  dwValues = 1;
646  }
647 
648  DPRINT("dwValues %lu\n", dwValues);
649 
650  dwUsedLength = 0;
651  pPtr = pszBuffer;
652 
653  for (dwIndex = 0; dwIndex < dwValues; dwIndex++)
654  {
655  wsprintf(szName, L"%lu", dwIndex);
656 
657  dwSize = sizeof(szPathBuffer);
658  dwError = RegQueryValueExW(hEnumKey,
659  szName,
660  NULL,
661  NULL,
662  (LPBYTE)szPathBuffer,
663  &dwSize);
664  if (dwError != ERROR_SUCCESS)
665  break;
666 
667  DPRINT("Path: %S\n", szPathBuffer);
668 
669  dwPathLength = wcslen(szPathBuffer) + 1;
670  if (dwUsedLength + dwPathLength + 1 > *pulLength)
671  {
673  break;
674  }
675 
676  wcscpy(pPtr, szPathBuffer);
677  dwUsedLength += dwPathLength;
678  pPtr += dwPathLength;
679 
680  *pPtr = UNICODE_NULL;
681  }
682 
683 Done:
684  if (hEnumKey != NULL)
686 
687  if (hServiceKey != NULL)
688  RegCloseKey(hServiceKey);
689 
690  if (hServicesKey != NULL)
692 
693  if (ret == CR_SUCCESS)
694  *pulLength = dwUsedLength + 1;
695  else
696  *pulLength = 0;
697 
698  return ret;
699 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
uint16_t * PWSTR
Definition: typedefs.h:54
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HANDLE hServicesKey
Definition: devinst.c:21
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
static const WCHAR szName[]
Definition: msipriv.h:1194
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define wsprintf
Definition: winuser.h:5731
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetDeviceList().

◆ GetServiceInstanceListSize()

static CONFIGRET GetServiceInstanceListSize ( _In_ PWSTR  pszService,
_Out_ PDWORD  pulLength 
)
static

Definition at line 1018 of file umpnpmgr.c.

1021 {
1022  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1023  DWORD dwValues, dwMaxValueLength, dwSize;
1024  DWORD dwError;
1026 
1027  /* Open the device key */
1029  L"System\\CurrentControlSet\\Services",
1030  0,
1031  KEY_READ,
1032  &hServicesKey);
1033  if (dwError != ERROR_SUCCESS)
1034  {
1035  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1036  return CR_REGISTRY_ERROR;
1037  }
1038 
1039  dwError = RegOpenKeyExW(hServicesKey,
1040  pszService,
1041  0,
1042  KEY_READ,
1043  &hServiceKey);
1044  if (dwError != ERROR_SUCCESS)
1045  {
1046  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1048  goto Done;
1049  }
1050 
1051  dwError = RegOpenKeyExW(hServiceKey,
1052  L"Enum",
1053  0,
1054  KEY_READ,
1055  &hEnumKey);
1056  if (dwError != ERROR_SUCCESS)
1057  {
1058  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1060  goto Done;
1061  }
1062 
1063  /* Retrieve the number of device instances */
1064  dwSize = sizeof(DWORD);
1065  dwError = RegQueryValueExW(hEnumKey,
1066  L"Count",
1067  NULL,
1068  NULL,
1069  (LPBYTE)&dwValues,
1070  &dwSize);
1071  if (dwError != ERROR_SUCCESS)
1072  {
1073  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1074  dwValues = 1;
1075  }
1076 
1077  /* Retrieve the maximum instance name length */
1078  dwError = RegQueryInfoKeyW(hEnumKey,
1079  NULL,
1080  NULL,
1081  NULL,
1082  NULL,
1083  NULL,
1084  NULL,
1085  NULL,
1086  NULL,
1087  &dwMaxValueLength,
1088  NULL,
1089  NULL);
1090  if (dwError != ERROR_SUCCESS)
1091  {
1092  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1093  dwMaxValueLength = MAX_DEVICE_ID_LEN;
1094  }
1095 
1096  DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues, dwMaxValueLength / sizeof(WCHAR));
1097 
1098  /* Return the largest possible buffer size */
1099  *pulLength = dwValues * dwMaxValueLength / sizeof(WCHAR) + 2;
1100 
1101 Done:
1102  if (hEnumKey != NULL)
1104 
1105  if (hServiceKey != NULL)
1106  RegCloseKey(hServiceKey);
1107 
1108  if (hServicesKey != NULL)
1110 
1111  return ret;
1112 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define WCHAR
Definition: msvc.h:43
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HANDLE hServicesKey
Definition: devinst.c:21
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
int ret
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetDeviceListSize().

◆ InitializePnPManager()

static DWORD InitializePnPManager ( VOID  )
static

Definition at line 4401 of file umpnpmgr.c.

4402 {
4403  BOOLEAN OldValue;
4404  DWORD dwError;
4405 
4406  DPRINT("UMPNPMGR: InitializePnPManager() started\n");
4407 
4408  /* We need this privilege for using CreateProcessAsUserW */
4410 
4412  if (hInstallEvent == NULL)
4413  {
4414  dwError = GetLastError();
4415  DPRINT1("Could not create the Install Event! (Error %lu)\n", dwError);
4416  return dwError;
4417  }
4418 
4421  {
4422  dwError = GetLastError();
4423  DPRINT1("Could not create the Event! (Error %lu)\n", dwError);
4424  return dwError;
4425  }
4426 
4428  TRUE,
4429  FALSE,
4430  L"Global\\PnP_No_Pending_Install_Events");
4431  if (hNoPendingInstalls == NULL)
4432  {
4433  dwError = GetLastError();
4434  DPRINT1("Could not create the Event! (Error %lu)\n", dwError);
4435  return dwError;
4436  }
4437 
4439 
4441  L"System\\CurrentControlSet\\Enum",
4442  0,
4444  &hEnumKey);
4445  if (dwError != ERROR_SUCCESS)
4446  {
4447  DPRINT1("Could not open the Enum Key! (Error %lu)\n", dwError);
4448  return dwError;
4449  }
4450 
4452  L"System\\CurrentControlSet\\Control\\Class",
4453  0,
4455  &hClassKey);
4456  if (dwError != ERROR_SUCCESS)
4457  {
4458  DPRINT1("Could not open the Class Key! (Error %lu)\n", dwError);
4459  return dwError;
4460  }
4461 
4462  DPRINT("UMPNPMGR: InitializePnPManager() done\n");
4463 
4464  return 0;
4465 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
static BOOL SetupIsActive(VOID)
Definition: umpnpmgr.c:4022
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
static HANDLE hInstallEvent
Definition: umpnpmgr.c:68
static HKEY hEnumKey
Definition: umpnpmgr.c:64
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
FORCEINLINE VOID InitializeSListHead(_Out_ PSLIST_HEADER SListHead)
Definition: rtlfuncs.h:3353
static HANDLE hNoPendingInstalls
Definition: umpnpmgr.c:69
static SLIST_HEADER DeviceInstallListHead
Definition: umpnpmgr.c:71
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define DPRINT1
Definition: precomp.h:8
#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE
Definition: security.c:657
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
static HANDLE hDeviceInstallListNotEmpty
Definition: umpnpmgr.c:72
static HKEY hClassKey
Definition: umpnpmgr.c:65
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DllMain().

◆ InstallDevice()

static BOOL InstallDevice ( PCWSTR  DeviceInstance,
BOOL  ShowWizard 
)
static

Definition at line 3803 of file umpnpmgr.c.

3804 {
3805  BOOL DeviceInstalled = FALSE;
3807  DWORD Value;
3809  HANDLE hPipe = INVALID_HANDLE_VALUE;
3811  PROCESS_INFORMATION ProcessInfo;
3812  STARTUPINFOW StartupInfo;
3813  UUID RandomUuid;
3814  HKEY DeviceKey;
3815 
3816  /* The following lengths are constant (see below), they cannot overflow */
3817  WCHAR CommandLine[116];
3818  WCHAR InstallEventName[73];
3819  WCHAR PipeName[74];
3820  WCHAR UuidString[39];
3821 
3822  DPRINT("InstallDevice(%S, %d)\n", DeviceInstance, ShowWizard);
3823 
3824  ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
3825 
3826  if (RegOpenKeyExW(hEnumKey,
3828  0,
3830  &DeviceKey) == ERROR_SUCCESS)
3831  {
3832  if (RegQueryValueExW(DeviceKey,
3833  L"Class",
3834  NULL,
3835  NULL,
3836  NULL,
3837  NULL) == ERROR_SUCCESS)
3838  {
3839  DPRINT("No need to install: %S\n", DeviceInstance);
3840  RegCloseKey(DeviceKey);
3841  return TRUE;
3842  }
3843 
3844  BytesWritten = sizeof(DWORD);
3845  if (RegQueryValueExW(DeviceKey,
3846  L"ConfigFlags",
3847  NULL,
3848  NULL,
3849  (PBYTE)&Value,
3851  {
3853  {
3854  DPRINT("No need to install: %S\n", DeviceInstance);
3855  RegCloseKey(DeviceKey);
3856  return TRUE;
3857  }
3858  }
3859 
3860  RegCloseKey(DeviceKey);
3861  }
3862 
3863  DPRINT1("Installing: %S\n", DeviceInstance);
3864 
3865  /* Create a random UUID for the named pipe & event*/
3866  UuidCreate(&RandomUuid);
3867  swprintf(UuidString, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
3868  RandomUuid.Data1, RandomUuid.Data2, RandomUuid.Data3,
3869  RandomUuid.Data4[0], RandomUuid.Data4[1], RandomUuid.Data4[2],
3870  RandomUuid.Data4[3], RandomUuid.Data4[4], RandomUuid.Data4[5],
3871  RandomUuid.Data4[6], RandomUuid.Data4[7]);
3872 
3873  /* Create the event */
3874  wcscpy(InstallEventName, L"Global\\PNP_Device_Install_Event_0.");
3875  wcscat(InstallEventName, UuidString);
3876  hInstallEvent = CreateEventW(NULL, TRUE, FALSE, InstallEventName);
3877  if (!hInstallEvent)
3878  {
3879  DPRINT1("CreateEventW('%ls') failed with error %lu\n", InstallEventName, GetLastError());
3880  goto cleanup;
3881  }
3882 
3883  /* Create the named pipe */
3884  wcscpy(PipeName, L"\\\\.\\pipe\\PNP_Device_Install_Pipe_0.");
3885  wcscat(PipeName, UuidString);
3886  hPipe = CreateNamedPipeW(PipeName, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 512, 512, 0, NULL);
3887  if (hPipe == INVALID_HANDLE_VALUE)
3888  {
3889  DPRINT1("CreateNamedPipeW failed with error %u\n", GetLastError());
3890  goto cleanup;
3891  }
3892 
3893  /* Launch rundll32 to call ClientSideInstallW */
3894  wcscpy(CommandLine, L"rundll32.exe newdev.dll,ClientSideInstall ");
3895  wcscat(CommandLine, PipeName);
3896 
3897  ZeroMemory(&StartupInfo, sizeof(StartupInfo));
3898  StartupInfo.cb = sizeof(StartupInfo);
3899 
3900  if (hUserToken)
3901  {
3902  /* newdev has to run under the environment of the current user */
3904  {
3905  DPRINT1("CreateEnvironmentBlock failed with error %d\n", GetLastError());
3906  goto cleanup;
3907  }
3908 
3909  if (!CreateProcessAsUserW(hUserToken, NULL, CommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, Environment, NULL, &StartupInfo, &ProcessInfo))
3910  {
3911  DPRINT1("CreateProcessAsUserW failed with error %u\n", GetLastError());
3912  goto cleanup;
3913  }
3914  }
3915  else
3916  {
3917  /* FIXME: This is probably not correct, I guess newdev should never be run with SYSTEM privileges.
3918 
3919  Still, we currently do that in 2nd stage setup and probably Console mode as well, so allow it here.
3920  (ShowWizard is only set to FALSE for these two modes) */
3921  ASSERT(!ShowWizard);
3922 
3923  if (!CreateProcessW(NULL, CommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &StartupInfo, &ProcessInfo))
3924  {
3925  DPRINT1("CreateProcessW failed with error %u\n", GetLastError());
3926  goto cleanup;
3927  }
3928  }
3929 
3930  /* Wait for the function to connect to our pipe */
3931  if (!ConnectNamedPipe(hPipe, NULL))
3932  {
3934  {
3935  DPRINT1("ConnectNamedPipe failed with error %u\n", GetLastError());
3936  goto cleanup;
3937  }
3938  }
3939 
3940  /* Pass the data. The following output is partly compatible to Windows XP SP2 (researched using a modified newdev.dll to log this stuff) */
3941  Value = sizeof(InstallEventName);
3942  WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
3943  WriteFile(hPipe, InstallEventName, Value, &BytesWritten, NULL);
3944 
3945  /* I couldn't figure out what the following value means under WinXP. It's usually 0 in my tests, but was also 5 once.
3946  Therefore the following line is entirely ReactOS-specific. We use the value here to pass the ShowWizard variable. */
3947  WriteFile(hPipe, &ShowWizard, sizeof(ShowWizard), &BytesWritten, NULL);
3948 
3949  Value = (wcslen(DeviceInstance) + 1) * sizeof(WCHAR);
3950  WriteFile(hPipe, &Value, sizeof(Value), &BytesWritten, NULL);
3952 
3953  /* Wait for newdev.dll to finish processing */
3954  WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
3955 
3956  /* If the event got signalled, this is success */
3957  DeviceInstalled = WaitForSingleObject(hInstallEvent, 0) == WAIT_OBJECT_0;
3958 
3959 cleanup:
3960  if (hInstallEvent)
3962 
3963  if (hPipe != INVALID_HANDLE_VALUE)
3964  CloseHandle(hPipe);
3965 
3966  if (Environment)
3968 
3969  if (ProcessInfo.hProcess)
3970  CloseHandle(ProcessInfo.hProcess);
3971 
3972  if (ProcessInfo.hThread)
3973  CloseHandle(ProcessInfo.hThread);
3974 
3975  if (!DeviceInstalled)
3976  {
3977  DPRINT1("InstallDevice failed for DeviceInstance '%ws'\n", DeviceInstance);
3978  }
3979 
3980  return DeviceInstalled;
3981 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2327
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:45
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CREATE_UNICODE_ENVIRONMENT
Definition: winbase.h:186
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define DWORD
Definition: msvc.h:34
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
static HANDLE hInstallEvent
Definition: umpnpmgr.c:68
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static HANDLE hUserToken
Definition: umpnpmgr.c:67
#define PIPE_TYPE_BYTE
Definition: winbase.h:167
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4623
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WAIT_OBJECT_0
Definition: winbase.h:387
DWORD cb
Definition: winbase.h:817
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PIPE_ACCESS_OUTBOUND
Definition: winbase.h:166
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727
#define ERROR_PIPE_CONNECTED
Definition: winerror.h:352
_In_ PNDIS_STRING DeviceInstance
Definition: ndis.h:5184
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
Definition: logon.c:278
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:306
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
HANDLE WINAPI CreateNamedPipeW(LPCWSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:246
#define INFINITE
Definition: serial.h:102
BOOL WINAPI ConnectNamedPipe(IN HANDLE hNamedPipe, IN LPOVERLAPPED lpOverlapped)
Definition: npipe.c:701
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396

Referenced by DeviceInstallThread().

◆ IsConsoleBoot()

static BOOL IsConsoleBoot ( VOID  )
static

Definition at line 4053 of file umpnpmgr.c.

4054 {
4055  HKEY ControlKey = NULL;
4056  LPWSTR SystemStartOptions = NULL;
4057  LPWSTR CurrentOption, NextOption; /* Pointers into SystemStartOptions */
4058  BOOL ConsoleBoot = FALSE;
4059  LONG rc;
4060 
4061  rc = RegOpenKeyExW(
4063  L"SYSTEM\\CurrentControlSet\\Control",
4064  0,
4066  &ControlKey);
4067 
4068  rc = ReadRegSzKey(ControlKey, L"SystemStartOptions", &SystemStartOptions);
4069  if (rc != ERROR_SUCCESS)
4070  goto cleanup;
4071 
4072  /* Check for CONSOLE switch in SystemStartOptions */
4073  CurrentOption = SystemStartOptions;
4074  while (CurrentOption)
4075  {
4076  NextOption = wcschr(CurrentOption, L' ');
4077  if (NextOption)
4078  *NextOption = L'\0';
4079  if (_wcsicmp(CurrentOption, L"CONSOLE") == 0)
4080  {
4081  DPRINT("Found %S. Switching to console boot\n", CurrentOption);
4082  ConsoleBoot = TRUE;
4083  goto cleanup;
4084  }
4085  CurrentOption = NextOption ? NextOption + 1 : NULL;
4086  }
4087 
4088 cleanup:
4089  if (ControlKey != NULL)
4090  RegCloseKey(ControlKey);
4091  HeapFree(GetProcessHeap(), 0, SystemStartOptions);
4092  return ConsoleBoot;
4093 }
static LONG ReadRegSzKey(IN HKEY hKey, IN LPCWSTR pszKey, OUT LPWSTR *pValue)
Definition: umpnpmgr.c:3985
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
static const WCHAR L[]
Definition: oid.c:1087
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by DeviceInstallThread().

◆ midl_user_allocate()

void __RPC_FAR* __RPC_USER midl_user_allocate ( SIZE_T  len)

Definition at line 146 of file umpnpmgr.c.

147 {
149 }
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLsizei len
Definition: glext.h:6722
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

◆ midl_user_free()

void __RPC_USER midl_user_free ( void __RPC_FAR ptr)

Definition at line 152 of file umpnpmgr.c.

153 {
154  HeapFree(GetProcessHeap(), 0, ptr);
155 }
static PVOID ptr
Definition: dispmode.c:27
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ MoveDeviceInstance()

static CONFIGRET MoveDeviceInstance ( LPWSTR  pszDeviceInstanceDestination,
LPWSTR  pszDeviceInstanceSource 
)
static

Definition at line 2488 of file umpnpmgr.c.

2490 {
2491  DPRINT("MoveDeviceInstance: not implemented\n");
2492  /* FIXME */
2493  return CR_CALL_NOT_IMPLEMENTED;
2494 }
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898

Referenced by PNP_DeviceInstanceAction().

◆ NtStatusToCrError()

static CONFIGRET WINAPI NtStatusToCrError ( NTSTATUS  Status)
static

Definition at line 159 of file umpnpmgr.c.

160 {
161  switch (Status)
162  {
165 
167  return CR_INVALID_DATA;
168 
170  return CR_NO_SUCH_DEVINST;
171 
173  return CR_ACCESS_DENIED;
174 
176  return CR_BUFFER_SMALL;
177 
179  return CR_NO_SUCH_VALUE;
180 
181  default:
182  return CR_FAILURE;
183  }
184 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
Status
Definition: gdiplustypes.h:24
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define CR_NO_SUCH_DEVINST
Definition: cfgmgr32.h:858

Referenced by EnableDeviceInstance(), GetRelationsInstanceList(), GetRelationsInstanceListSize(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetDeviceStatus(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetRelatedDeviceInstance(), and ReenumerateDeviceInstance().

◆ PNP_AddEmptyLogConf()

DWORD WINAPI PNP_AddEmptyLogConf ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulPriority,
DWORD pulLogConfTag,
DWORD  ulFlags 
)

Definition at line 3185 of file umpnpmgr.c.

3191 {
3192  UNIMPLEMENTED;
3193  return CR_CALL_NOT_IMPLEMENTED;
3194 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CM_Add_Empty_Log_Conf_Ex().

◆ PNP_AddID()

DWORD WINAPI PNP_AddID ( handle_t  hBinding,
LPWSTR  pszDeviceID,
LPWSTR  pszID,
DWORD  ulFlags 
)

Definition at line 2749 of file umpnpmgr.c.

2754 {
2756  HKEY hDeviceKey;
2757  LPWSTR pszSubKey;
2758  DWORD dwDeviceIdListSize;
2759  DWORD dwNewDeviceIdSize;
2760  WCHAR * pszDeviceIdList = NULL;
2761 
2763 
2764  DPRINT("PNP_AddID() called\n");
2765  DPRINT(" DeviceInstance: %S\n", pszDeviceID);
2766  DPRINT(" DeviceId: %S\n", pszID);
2767  DPRINT(" Flags: %lx\n", ulFlags);
2768 
2769  if (RegOpenKeyExW(hEnumKey,
2770  pszDeviceID,
2771  0,
2773  &hDeviceKey) != ERROR_SUCCESS)
2774  {
2775  DPRINT("Failed to open the device key!\n");
2776  return CR_INVALID_DEVNODE;
2777  }
2778 
2779  pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
2780 
2781  if (RegQueryValueExW(hDeviceKey,
2782  pszSubKey,
2783  NULL,
2784  NULL,
2785  NULL,
2786  &dwDeviceIdListSize) != ERROR_SUCCESS)
2787  {
2788  DPRINT("Failed to query the desired ID string!\n");
2790  goto Done;
2791  }
2792 
2793  dwNewDeviceIdSize = lstrlenW(pszDeviceID);
2794  if (!dwNewDeviceIdSize)
2795  {
2797  goto Done;
2798  }
2799 
2800  dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
2801 
2802  pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
2803  if (!pszDeviceIdList)
2804  {
2805  DPRINT("Failed to allocate memory for the desired ID string!\n");
2807  goto Done;
2808  }
2809 
2810  if (RegQueryValueExW(hDeviceKey,
2811  pszSubKey,
2812  NULL,
2813  NULL,
2814  (LPBYTE)pszDeviceIdList,
2815  &dwDeviceIdListSize) != ERROR_SUCCESS)
2816  {
2817  DPRINT("Failed to query the desired ID string!\n");
2819  goto Done;
2820  }
2821 
2822  /* Check whether the device ID is already in use */
2823  if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
2824  {
2825  DPRINT("Device ID was found in the ID string!\n");
2826  ret = CR_SUCCESS;
2827  goto Done;
2828  }
2829 
2830  /* Append the Device ID */
2831  AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
2832 
2833  if (RegSetValueExW(hDeviceKey,
2834  pszSubKey,
2835  0,
2836  REG_MULTI_SZ,
2837  (LPBYTE)pszDeviceIdList,
2838  dwDeviceIdListSize) != ERROR_SUCCESS)
2839  {
2840  DPRINT("Failed to set the desired ID string!\n");
2842  }
2843 
2844 Done:
2845  RegCloseKey(hDeviceKey);
2846  if (pszDeviceIdList)
2847  HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
2848 
2849  DPRINT("PNP_AddID() done (returns %lx)\n", ret);
2850 
2851  return ret;
2852 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define lstrlenW
Definition: compat.h:407
#define CM_ADD_ID_COMPATIBLE
Definition: cfgmgr32.h:615
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
static VOID AppendDeviceId(LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
Definition: umpnpmgr.c:2726
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
static BOOL CheckForDeviceId(LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
Definition: umpnpmgr.c:2705
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1087
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by CM_Add_ID_ExW().

◆ PNP_AddResDes()

DWORD WINAPI PNP_AddResDes ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfTag,
DWORD  ulLogConfType,
RESOURCEID  ResourceID,
DWORD pulResourceTag,
BYTE ResourceData,
PNP_RPC_BUFFER_SIZE  ResourceLen,
DWORD  ulFlags 
)

Definition at line 3262 of file umpnpmgr.c.

3272 {
3273  UNIMPLEMENTED;
3274  return CR_CALL_NOT_IMPLEMENTED;
3275 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_ApplyPowerSettings()

DWORD WINAPI PNP_ApplyPowerSettings ( handle_t  hBinding)

Definition at line 3737 of file umpnpmgr.c.

3739 {
3740  UNIMPLEMENTED;
3741  return CR_CALL_NOT_IMPLEMENTED;
3742 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_Connect()

DWORD WINAPI PNP_Connect ( handle_t  hBinding)

Definition at line 248 of file umpnpmgr.c.

250 {
252  return CR_SUCCESS;
253 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_SUCCESS
Definition: cfgmgr32.h:842

◆ PNP_CreateDevInst()

DWORD WINAPI PNP_CreateDevInst ( handle_t  hBinding,
LPWSTR  pszDeviceID,
LPWSTR  pszParentDeviceID,
PNP_RPC_STRING_LEN  ulLength,
DWORD  ulFlags 
)

Definition at line 2432 of file umpnpmgr.c.

2438 {
2440 
2441  DPRINT("PNP_CreateDevInst: %S\n", pszDeviceID);
2442 
2443  if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
2444  {
2445  WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
2446  DWORD dwInstanceNumber;
2447 
2448  /* Generated ID is: Root<Device ID><Instance number> */
2449  dwInstanceNumber = 0;
2450  do
2451  {
2452  swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
2453  pszDeviceID, dwInstanceNumber);
2454 
2455  /* Try to create a device instance with this ID */
2456  ret = CreateDeviceInstance(szGeneratedInstance);
2457 
2458  dwInstanceNumber++;
2459  }
2460  while (ret == CR_ALREADY_SUCH_DEVINST);
2461 
2462  if (ret == CR_SUCCESS)
2463  {
2464  /* pszDeviceID is an out parameter too for generated IDs */
2465  if (wcslen(szGeneratedInstance) > ulLength)
2466  {
2467  ret = CR_BUFFER_SMALL;
2468  }
2469  else
2470  {
2471  wcscpy(pszDeviceID, szGeneratedInstance);
2472  }
2473  }
2474  }
2475  else
2476  {
2477  /* Create the device instance */
2478  ret = CreateDeviceInstance(pszDeviceID);
2479  }
2480 
2481  DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
2482 
2483  return ret;
2484 }
#define CM_CREATE_DEVNODE_GENERATE_ID
Definition: cfgmgr32.h:622
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
static CONFIGRET CreateDeviceInstance(LPWSTR pszDeviceID)
Definition: umpnpmgr.c:2324
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1087
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CM_Create_DevNode_ExW().

◆ PNP_CreateKey()

DWORD WINAPI PNP_CreateKey ( handle_t  hBinding,
LPWSTR  pszSubKey,
DWORD  samDesired,
DWORD  ulFlags 
)

Definition at line 1792 of file umpnpmgr.c.

1797 {
1798  HKEY hKey = 0;
1799 
1801  pszSubKey,
1802  0,
1803  NULL,
1804  0,
1806  NULL,
1807  &hKey,
1808  NULL))
1809  return CR_REGISTRY_ERROR;
1810 
1811  /* FIXME: Set security key */
1812 
1813  RegCloseKey(hKey);
1814 
1815  return CR_SUCCESS;
1816 }
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ PNP_DeleteClassKey()

DWORD WINAPI PNP_DeleteClassKey ( handle_t  hBinding,
LPWSTR  pszClassGuid,
DWORD  ulFlags 
)

Definition at line 1936 of file umpnpmgr.c.

1940 {
1942 
1944 
1945  DPRINT("PNP_GetClassName(%S, %lx) called\n", pszClassGuid, ulFlags);
1946 
1947  if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
1948  {
1949  if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
1951  }
1952  else
1953  {
1954  if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
1956  }
1957 
1958  DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
1959 
1960  return ret;
1961 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_DELETE_CLASS_SUBKEYS
Definition: cfgmgr32.h:635
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1240
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
static HKEY hClassKey
Definition: umpnpmgr.c:65

Referenced by CM_Delete_Class_Key_Ex().

◆ PNP_DeleteRegistryKey()

DWORD WINAPI PNP_DeleteRegistryKey ( handle_t  hBinding,
LPWSTR  pszDeviceID,
LPWSTR  pszParentKey,
LPWSTR  pszChildKey,
DWORD  ulFlags 
)

Definition at line 1822 of file umpnpmgr.c.

1828 {
1829  UNIMPLEMENTED;
1830  return CR_CALL_NOT_IMPLEMENTED;
1831 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_DeleteServiceDevices()

DWORD WINAPI PNP_DeleteServiceDevices ( handle_t  hBinding)

Definition at line 3794 of file umpnpmgr.c.

3796 {
3797  UNIMPLEMENTED;
3798  return CR_CALL_NOT_IMPLEMENTED;
3799 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_DetectResourceConflict()

DWORD WINAPI PNP_DetectResourceConflict ( handle_t  hBinding,
LPWSTR  pDeviceID,
RESOURCEID  ResourceID,
BYTE ResourceData,
PNP_RPC_BUFFER_SIZE  ResourceLen,
BOOL pbConflictDetected,
DWORD  ulFlags 
)

Definition at line 3376 of file umpnpmgr.c.

3384 {
3385  DPRINT("PNP_DetectResourceConflict()\n");
3386 
3387  if (pbConflictDetected != NULL)
3388  *pbConflictDetected = FALSE;
3389 
3390  return CR_CALL_NOT_IMPLEMENTED;
3391 }
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898

◆ PNP_DeviceInstanceAction()

DWORD WINAPI PNP_DeviceInstanceAction ( handle_t  hBinding,
DWORD  ulAction,
DWORD  ulFlags,
LPWSTR  pszDeviceInstance1,
LPWSTR  pszDeviceInstance2 
)

Definition at line 2571 of file umpnpmgr.c.

2577 {
2579 
2581 
2582  DPRINT("PNP_DeviceInstanceAction() called\n");
2583 
2584  switch (ulAction)
2585  {
2586  case PNP_DEVINST_MOVE:
2587  ret = MoveDeviceInstance(pszDeviceInstance1,
2588  pszDeviceInstance2);
2589  break;
2590 
2591  case PNP_DEVINST_SETUP:
2592  ret = SetupDeviceInstance(pszDeviceInstance1,
2593  ulFlags);
2594  break;
2595 
2596  case PNP_DEVINST_ENABLE:
2597  ret = EnableDeviceInstance(pszDeviceInstance1);
2598  break;
2599 
2600  case PNP_DEVINST_DISABLE:
2601  ret = DisableDeviceInstance(pszDeviceInstance1);
2602  break;
2603 
2604  case PNP_DEVINST_REENUMERATE:
2605  ret = ReenumerateDeviceInstance(pszDeviceInstance1,
2606  ulFlags);
2607  break;
2608 
2609  default:
2610  DPRINT1("Unknown device action %lu: not implemented\n", ulAction);
2612  }
2613 
2614  DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
2615 
2616  return ret;
2617 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static CONFIGRET DisableDeviceInstance(LPWSTR pszDeviceInstance)
Definition: umpnpmgr.c:2526
static CONFIGRET ReenumerateDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulFlags)
Definition: umpnpmgr.c:2535
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
int ret
static CONFIGRET SetupDeviceInstance(LPWSTR pszDeviceInstance, DWORD ulFlags)
Definition: umpnpmgr.c:2498
static CONFIGRET EnableDeviceInstance(LPWSTR pszDeviceInstance)
Definition: umpnpmgr.c:2508
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
static CONFIGRET MoveDeviceInstance(LPWSTR pszDeviceInstanceDestination, LPWSTR pszDeviceInstanceSource)
Definition: umpnpmgr.c:2488

Referenced by CM_Disable_DevNode_Ex(), CM_Enable_DevNode_Ex(), CM_Move_DevNode_Ex(), CM_Reenumerate_DevNode_Ex(), and CM_Setup_DevNode_Ex().

◆ PNP_DisableDevInst()

DWORD WINAPI PNP_DisableDevInst ( handle_t  hBinding,
LPWSTR  pDeviceID,
PPNP_VETO_TYPE  pVetoType,
LPWSTR  pszVetoName,
DWORD  ulNameLength,
DWORD  ulFlags 
)

Definition at line 2679 of file umpnpmgr.c.

2686 {
2687  UNIMPLEMENTED;
2688  return CR_CALL_NOT_IMPLEMENTED;
2689 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_Disconnect()

DWORD WINAPI PNP_Disconnect ( handle_t  hBinding)

Definition at line 237 of file umpnpmgr.c.

239 {
241  return CR_SUCCESS;
242 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_SUCCESS
Definition: cfgmgr32.h:842

◆ PNP_DriverStoreAddDriverPackage()

DWORD WINAPI PNP_DriverStoreAddDriverPackage ( handle_t  hBinding)

Definition at line 3748 of file umpnpmgr.c.

3750 {
3751  UNIMPLEMENTED;
3752  return CR_CALL_NOT_IMPLEMENTED;
3753 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_DriverStoreDeleteDriverPackage()

DWORD WINAPI PNP_DriverStoreDeleteDriverPackage ( handle_t  hBinding)

Definition at line 3759 of file umpnpmgr.c.

3761 {
3762  UNIMPLEMENTED;
3763  return CR_CALL_NOT_IMPLEMENTED;
3764 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_EnumerateSubKeys()

DWORD WINAPI PNP_EnumerateSubKeys ( handle_t  hBinding,
DWORD  ulBranch,
DWORD  ulIndex,
LPWSTR  Buffer,
PNP_RPC_STRING_LEN  ulLength,
PNP_RPC_STRING_LEN pulRequiredLen,
DWORD  ulFlags 
)

Definition at line 476 of file umpnpmgr.c.

484 {
486  HKEY hKey;
487  DWORD dwError;
488 
490  UNREFERENCED_PARAMETER(ulFlags);
491 
492  DPRINT("PNP_EnumerateSubKeys() called\n");
493 
494  switch (ulBranch)
495  {
496  case PNP_ENUMERATOR_SUBKEYS:
497  hKey = hEnumKey;
498  break;
499 
500  case PNP_CLASS_SUBKEYS:
501  hKey = hClassKey;
502  break;
503 
504  default:
505  return CR_FAILURE;
506  }
507 
508  *pulRequiredLen = ulLength;
509  dwError = RegEnumKeyExW(hKey,
510  ulIndex,
511  Buffer,
512  pulRequiredLen,
513  NULL,
514  NULL,
515  NULL,
516  NULL);
517  if (dwError != ERROR_SUCCESS)
518  {
520  }
521  else
522  {
523  (*pulRequiredLen)++;
524  }
525 
526  DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
527 
528  return ret;
529 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define CR_FAILURE
Definition: cfgmgr32.h:865
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
ULONG ulIndex
Definition: symbols.c:92
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
static HKEY hClassKey
Definition: umpnpmgr.c:65

Referenced by CM_Enumerate_Classes_Ex(), and CM_Enumerate_Enumerators_ExW().

◆ PNP_FreeLogConf()

DWORD WINAPI PNP_FreeLogConf ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfType,
DWORD  ulLogConfTag,
DWORD  ulFlags 
)

Definition at line 3200 of file umpnpmgr.c.

3206 {
3207  UNIMPLEMENTED;
3208  return CR_CALL_NOT_IMPLEMENTED;
3209 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CM_Free_Log_Conf_Ex().

◆ PNP_FreeResDes()

DWORD WINAPI PNP_FreeResDes ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfTag,
DWORD  ulLogConfType,
RESOURCEID  ResourceID,
DWORD  ulResourceTag,
DWORD pulPreviousResType,
DWORD pulPreviousResTag,
DWORD  ulFlags 
)

Definition at line 3281 of file umpnpmgr.c.

3291 {
3292  UNIMPLEMENTED;
3293  return CR_CALL_NOT_IMPLEMENTED;
3294 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_GetBlockedDriverInfo()

DWORD WINAPI PNP_GetBlockedDriverInfo ( handle_t  hBinding,
BYTE Buffer,
PNP_RPC_BUFFER_SIZE pulTransferLen,
PNP_RPC_BUFFER_SIZE pulLength,
DWORD  ulFlags 
)

Definition at line 3628 of file umpnpmgr.c.

3634 {
3635  UNIMPLEMENTED;
3636  return CR_CALL_NOT_IMPLEMENTED;
3637 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CMP_GetBlockedDriverInfo().

◆ PNP_GetClassCount()

DWORD WINAPI PNP_GetClassCount ( handle_t  hBinding,
DWORD pulClassCount,
DWORD  ulFlags 
)

Definition at line 1837 of file umpnpmgr.c.

1841 {
1842  HKEY hKey;
1843  DWORD dwError;
1844 
1846  UNREFERENCED_PARAMETER(ulFlags);
1847 
1850  0,
1852  &hKey);
1853  if (dwError != ERROR_SUCCESS)
1854  return CR_INVALID_DATA;
1855 
1856  dwError = RegQueryInfoKeyW(hKey,
1857  NULL,
1858  NULL,
1859  NULL,
1860  pulClassCount,
1861  NULL,
1862  NULL,
1863  NULL,
1864  NULL,
1865  NULL,
1866  NULL,
1867  NULL);
1868  RegCloseKey(hKey);
1869  if (dwError != ERROR_SUCCESS)
1870  return CR_INVALID_DATA;
1871 
1872  return CR_SUCCESS;
1873 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REGSTR_PATH_CLASS
Definition: regstr.h:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ PNP_GetClassInstance()

DWORD WINAPI PNP_GetClassInstance ( handle_t  hBinding,
LPWSTR  pDeviceId,
LPWSTR  pszClassInstance,
PNP_RPC_STRING_LEN  ulLength 
)

Definition at line 1778 of file umpnpmgr.c.

1783 {
1784  UNIMPLEMENTED;
1785  return CR_CALL_NOT_IMPLEMENTED;
1786 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

◆ PNP_GetClassName()

DWORD WINAPI PNP_GetClassName ( handle_t  hBinding,
LPWSTR  pszClassGuid,
LPWSTR  Buffer,
PNP_RPC_STRING_LEN pulLength,
DWORD  ulFlags 
)

Definition at line 1879 of file umpnpmgr.c.

1885 {
1886  WCHAR szKeyName[MAX_PATH];
1888  HKEY hKey;
1889  DWORD dwSize;
1890 
1892  UNREFERENCED_PARAMETER(ulFlags);
1893 
1894  DPRINT("PNP_GetClassName() called\n");
1895 
1896  lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
1897  if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
1898  lstrcatW(szKeyName, pszClassGuid);
1899  else
1900  return CR_INVALID_DATA;
1901 
1903  szKeyName,
1904  0,
1906  &hKey))
1907  return CR_REGISTRY_ERROR;
1908 
1909  dwSize = *pulLength * sizeof(WCHAR);
1910  if (RegQueryValueExW(hKey,
1911  L"Class",
1912  NULL,
1913  NULL,
1914  (LPBYTE)Buffer,
1915  &dwSize))
1916  {
1917  *pulLength = 0;
1919  }
1920  else
1921  {
1922  *pulLength = dwSize / sizeof(WCHAR);
1923  }
1924 
1925  RegCloseKey(hKey);
1926 
1927  DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
1928 
1929  return ret;
1930 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WCHAR
Definition: msvc.h:43
#define lstrlenW
Definition: compat.h:407
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
int ret
static const WCHAR L[]
Definition: oid.c:1087
#define lstrcpyW
Definition: compat.h:406
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CM_Get_Class_Name_ExW().

◆ PNP_GetClassRegProp()

DWORD WINAPI PNP_GetClassRegProp ( handle_t  hBinding,
LPWSTR  pszClassGuid,
DWORD  ulProperty,
DWORD pulRegDataType,
BYTE Buffer,
PNP_RPC_STRING_LEN pulTransferLen,
PNP_RPC_STRING_LEN pulLength,
DWORD  ulFlags 
)

Definition at line 2100 of file umpnpmgr.c.

2109 {
2111  LPWSTR lpValueName = NULL;
2112  HKEY hInstKey = NULL;
2113  HKEY hPropKey = NULL;
2114  LONG lError;
2115 
2117 
2118  DPRINT("PNP_GetClassRegProp() called\n");
2119 
2120  if (pulTransferLen == NULL || pulLength == NULL)
2121  {
2123  goto done;
2124  }
2125 
2126  if (ulFlags != 0)
2127  {
2128  ret = CR_INVALID_FLAG;
2129  goto done;
2130  }
2131 
2132  if (*pulLength < *pulTransferLen)
2133  *pulLength = *pulTransferLen;
2134 
2135  *pulTransferLen = 0;
2136 
2137  switch (ulProperty)
2138  {
2139  case CM_CRP_SECURITY:
2140  lpValueName = L"Security";
2141  break;
2142 
2143  case CM_CRP_DEVTYPE:
2144  lpValueName = L"DeviceType";
2145  break;
2146 
2147  case CM_CRP_EXCLUSIVE:
2148  lpValueName = L"Exclusive";
2149  break;
2150 
2152  lpValueName = L"DeviceCharacteristics";
2153  break;
2154 
2155  default:
2157  goto done;
2158  }
2159 
2160  DPRINT("Value name: %S\n", lpValueName);
2161 
2162  lError = RegOpenKeyExW(hClassKey,
2163  pszClassGuid,
2164  0,
2165  KEY_READ,
2166  &hInstKey);
2167  if (lError != ERROR_SUCCESS)
2168  {
2169  *pulLength = 0;
2171  goto done;
2172  }
2173 
2174  lError = RegOpenKeyExW(hInstKey,
2175  L"Properties",
2176  0,
2177  KEY_READ,
2178  &hPropKey);
2179  if (lError != ERROR_SUCCESS)
2180  {
2181  *pulLength = 0;
2183  goto done;
2184  }
2185 
2186  lError = RegQueryValueExW(hPropKey,
2187  lpValueName,
2188  NULL,
2189  pulRegDataType,
2190  Buffer,
2191  pulLength);
2192  if (lError != ERROR_SUCCESS)
2193  {
2194  if (lError == ERROR_MORE_DATA)
2195  {
2196  ret = CR_BUFFER_SMALL;
2197  }
2198  else
2199  {
2200  *pulLength = 0;
2202  }
2203  }
2204 
2205 done:
2206  if (ret == CR_SUCCESS)
2207  *pulTransferLen = *pulLength;
2208 
2209  if (hPropKey != NULL)
2210  RegCloseKey(hPropKey);
2211 
2212  if (hInstKey != NULL)
2213  RegCloseKey(hInstKey);
2214 
2215  DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
2216 
2217  return ret;
2218 }
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_CRP_DEVTYPE
Definition: cfgmgr32.h:710
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CM_CRP_CHARACTERISTICS
Definition: cfgmgr32.h:714
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CM_CRP_EXCLUSIVE
Definition: cfgmgr32.h:712
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define CM_CRP_SECURITY
Definition: cfgmgr32.h:706
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
int ret
static const WCHAR L[]
Definition: oid.c:1087
#define ERROR_MORE_DATA
Definition: dderror.h:13
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static HKEY hClassKey
Definition: umpnpmgr.c:65

Referenced by CM_Get_Class_Registry_PropertyW().

◆ PNP_GetCustomDevProp()

DWORD WINAPI PNP_GetCustomDevProp ( handle_t  hBinding,
LPWSTR  pDeviceID,
LPWSTR  CustomPropName,
DWORD pulRegDataType,
BYTE Buffer,
PNP_RPC_STRING_LEN pulTransferLen,
PNP_RPC_STRING_LEN pulLength,
DWORD  ulFlags 
)

Definition at line 3518 of file umpnpmgr.c.

3527 {
3528  HKEY hDeviceKey = NULL;
3529  HKEY hParamKey = NULL;
3530  LONG lError;
3532 
3534 
3535  DPRINT("PNP_GetCustomDevProp() called\n");
3536 
3537  if (pulTransferLen == NULL || pulLength == NULL)
3538  {
3540  goto done;
3541  }
3542 
3543  if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
3544  {
3545  ret = CR_INVALID_FLAG;
3546  goto done;
3547  }
3548 
3549  if (*pulLength < *pulTransferLen)
3550  *pulLength = *pulTransferLen;
3551 
3552  *pulTransferLen = 0;
3553 
3554  lError = RegOpenKeyExW(hEnumKey,
3555  pDeviceID,
3556  0,
3557  KEY_READ,
3558  &hDeviceKey);
3559  if (lError != ERROR_SUCCESS)
3560  {
3562  goto done;
3563  }
3564 
3565  lError = RegOpenKeyExW(hDeviceKey,
3566  L"Device Parameters",
3567  0,
3568  KEY_READ,
3569  &hParamKey);
3570  if (lError != ERROR_SUCCESS)
3571  {
3573  goto done;
3574  }
3575 
3576  lError = RegQueryValueExW(hParamKey,
3577  CustomPropName,
3578  NULL,
3579  pulRegDataType,
3580  Buffer,
3581  pulLength);
3582  if (lError != ERROR_SUCCESS)
3583  {
3584  if (lError == ERROR_MORE_DATA)
3585  {
3586  ret = CR_BUFFER_SMALL;
3587  }
3588  else
3589  {
3590  *pulLength = 0;
3592  }
3593  }
3594 
3595 done:
3596  if (ret == CR_SUCCESS)
3597  *pulTransferLen = *pulLength;
3598 
3599  if (hParamKey != NULL)
3600  RegCloseKey(hParamKey);
3601 
3602  if (hDeviceKey != NULL)
3603  RegCloseKey(hDeviceKey);
3604 
3605  DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
3606 
3607  return ret;
3608 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
int ret
static const WCHAR L[]
Definition: oid.c:1087
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define CM_CUSTOMDEVPROP_BITS
Definition: cfgmgr32.h:836
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by CM_Get_DevNode_Custom_Property_ExW().

◆ PNP_GetDepth()

DWORD WINAPI PNP_GetDepth ( handle_t  hBinding,
LPWSTR  pszDeviceID,
DWORD pulDepth,
DWORD  ulFlags 
)

Definition at line 1340 of file umpnpmgr.c.

1345 {
1346  PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
1348  NTSTATUS Status;
1349 
1351  UNREFERENCED_PARAMETER(ulFlags);
1352 
1353  DPRINT("PNP_GetDepth() called\n");
1354 
1355  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1356  pszDeviceID);
1357 
1359  (PVOID)&PlugPlayData,
1360  sizeof(PLUGPLAY_CONTROL_DEPTH_DATA));
1361  if (NT_SUCCESS(Status))
1362  {
1363  *pulDepth = PlugPlayData.Depth;
1364  }
1365  else
1366  {
1368  }
1369 
1370  DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
1371 
1372  return ret;
1373 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:495

Referenced by CM_Get_Depth_Ex().

◆ PNP_GetDeviceList()

DWORD WINAPI PNP_GetDeviceList ( handle_t  hBinding,
LPWSTR  pszFilter,
LPWSTR  Buffer,
PNP_RPC_STRING_LEN pulLength,
DWORD  ulFlags 
)

Definition at line 895 of file umpnpmgr.c.

901 {
902  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
903  WCHAR szDevice[MAX_DEVICE_ID_LEN];
904  WCHAR szInstance[MAX_DEVICE_ID_LEN];
906 
907  DPRINT("PNP_GetDeviceList() called\n");
908 
909  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
910  return CR_INVALID_FLAG;
911 
912  if (pulLength == NULL)
913  return CR_INVALID_POINTER;
914 
915  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
916  (pszFilter == NULL))
917  return CR_INVALID_POINTER;
918 
919  if (ulFlags &
924  {
925  ret = GetRelationsInstanceList(pszFilter,
926  ulFlags,
927  Buffer,
928  pulLength);
929  }
930  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
931  {
932  ret = GetServiceInstanceList(pszFilter,
933  Buffer,
934  pulLength);
935  }
936  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
937  {
938  SplitDeviceInstanceID(pszFilter,
939  szEnumerator,
940  szDevice,
941  szInstance);
942 
943  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
944  {
945  ret = GetDeviceInstanceList(pszFilter,
946  Buffer,
947  pulLength);
948  }
949  else
950  {
951  ret = GetEnumeratorInstanceList(pszFilter,
952  Buffer,
953  pulLength);
954  }
955  }
956  else /* CM_GETIDLIST_FILTER_NONE */
957  {
959  pulLength);
960  }
961 
962  return ret;
963 }
static CONFIGRET GetAllInstanceList(_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:846
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: umpnpmgr.c:188
static CONFIGRET GetRelationsInstanceList(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:534
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:775
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define UNICODE_NULL
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:704
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
static CONFIGRET GetServiceInstanceList(_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:585
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669

Referenced by CM_Get_Device_ID_List_ExW().

◆ PNP_GetDeviceListSize()

DWORD WINAPI PNP_GetDeviceListSize ( handle_t  hBinding,
LPWSTR  pszFilter,
PNP_RPC_BUFFER_SIZE pulLength,
DWORD  ulFlags 
)

Definition at line 1265 of file umpnpmgr.c.

1270 {
1271  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1272  WCHAR szDevice[MAX_DEVICE_ID_LEN];
1273  WCHAR szInstance[MAX_DEVICE_ID_LEN];
1275 
1276  DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%lx)\n",
1277  hBinding, pszFilter, pulLength, ulFlags);
1278 
1279  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1280  return CR_INVALID_FLAG;
1281 
1282  if (pulLength == NULL)
1283  return CR_INVALID_POINTER;
1284 
1285  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1286  (pszFilter == NULL))
1287  return CR_INVALID_POINTER;
1288 
1289  *pulLength = 0;
1290 
1291  if (ulFlags &
1296  {
1297  ret = GetRelationsInstanceListSize(pszFilter,
1298  ulFlags,
1299  pulLength);
1300  }
1301  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1302  {
1303  ret = GetServiceInstanceListSize(pszFilter,
1304  pulLength);
1305  }
1306  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1307  {
1308  SplitDeviceInstanceID(pszFilter,
1309  szEnumerator,
1310  szDevice,
1311  szInstance);
1312 
1313  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1314  {
1315  ret = GetDeviceInstanceListSize(pszFilter,
1316  pulLength);
1317  }
1318  else
1319  {
1320  ret = GetEnumeratorInstanceListSize(pszFilter,
1321  pulLength);
1322  }
1323  }
1324  else /* CM_GETIDLIST_FILTER_NONE */
1325  {
1326  ret = GetAllInstanceListSize(pulLength);
1327  }
1328 
1329  /* Add one character for the terminating double UNICODE_NULL */
1330  if (ret == CR_SUCCESS)
1331  (*pulLength) += 1;
1332 
1333  return ret;
1334 }
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: umpnpmgr.c:188
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: umpnpmgr.c:1169
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
static CONFIGRET GetRelationsInstanceListSize(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
Definition: umpnpmgr.c:968
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
static CONFIGRET GetServiceInstanceListSize(_In_ PWSTR pszService, _Out_ PDWORD pulLength)
Definition: umpnpmgr.c:1018
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
static CONFIGRET GetAllInstanceListSize(_Out_ PULONG pulLength)
Definition: umpnpmgr.c:1230
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: umpnpmgr.c:1117
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669

Referenced by CM_Get_Device_ID_List_Size_ExW().

◆ PNP_GetDeviceRegProp()

DWORD WINAPI PNP_GetDeviceRegProp ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulProperty,
DWORD pulRegDataType,
BYTE Buffer,
PNP_PROP_SIZE pulTransferLen,
PNP_PROP_SIZE pulLength,
DWORD  ulFlags 
)

Definition at line 1379 of file umpnpmgr.c.

1388 {
1389  PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
1391  LPWSTR lpValueName = NULL;
1392  HKEY hKey = NULL;
1393  LONG lError;
1394  NTSTATUS Status;
1395 
1397 
1398  DPRINT("PNP_GetDeviceRegProp() called\n");
1399 
1400  if (pulTransferLen == NULL || pulLength == NULL)
1401  {
1403  goto done;
1404  }
1405 
1406  if (ulFlags != 0)
1407  {
1408  ret = CR_INVALID_FLAG;
1409  goto done;
1410  }
1411 
1412  /* FIXME: Check pDeviceID */
1413 
1414  if (*pulLength < *pulTransferLen)
1415  *pulLength = *pulTransferLen;
1416 
1417  *pulTransferLen = 0;
1418 
1419  switch (ulProperty)
1420  {
1421  case CM_DRP_DEVICEDESC:
1422  lpValueName = L"DeviceDesc";
1423  break;
1424 
1425  case CM_DRP_HARDWAREID:
1426  lpValueName = L"HardwareID";
1427  break;
1428 
1429  case CM_DRP_COMPATIBLEIDS:
1430  lpValueName = L"CompatibleIDs";
1431  break;
1432 
1433  case CM_DRP_SERVICE:
1434  lpValueName = L"Service";
1435  break;
1436 
1437  case CM_DRP_CLASS:
1438  lpValueName = L"Class";
1439  break;
1440 
1441  case CM_DRP_CLASSGUID:
1442  lpValueName = L"ClassGUID";
1443  break;
1444 
1445  case CM_DRP_DRIVER:
1446  lpValueName = L"Driver";
1447  break;
1448 
1449  case CM_DRP_CONFIGFLAGS:
1450  lpValueName = L"ConfigFlags";
1451  break;
1452 
1453  case CM_DRP_MFG:
1454  lpValueName = L"Mfg";
1455  break;
1456 
1457  case CM_DRP_FRIENDLYNAME:
1458  lpValueName = L"FriendlyName";
1459  break;
1460 
1462  lpValueName = L"LocationInformation";
1463  break;
1464 
1467  break;
1468 
1469  case CM_DRP_CAPABILITIES:
1470  lpValueName = L"Capabilities";
1471  break;
1472 
1473  case CM_DRP_UI_NUMBER:
1474  PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
1475  break;
1476 
1477  case CM_DRP_UPPERFILTERS:
1478  lpValueName = L"UpperFilters";
1479  break;
1480 
1481  case CM_DRP_LOWERFILTERS:
1482  lpValueName = L"LowerFilters";
1483  break;
1484 
1485  case CM_DRP_BUSTYPEGUID:
1486  PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
1487  break;
1488 
1489  case CM_DRP_LEGACYBUSTYPE:
1490  PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
1491  break;
1492 
1493  case CM_DRP_BUSNUMBER:
1494  PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
1495  break;
1496 
1498  PlugPlayData.Property = PNP_PROPERTY_ENUMERATOR_NAME;
1499  break;
1500 
1501  case CM_DRP_SECURITY:
1502  lpValueName = L"Security";
1503  break;
1504 
1505  case CM_DRP_DEVTYPE:
1506  lpValueName = L"DeviceType";
1507  break;
1508 
1509  case CM_DRP_EXCLUSIVE:
1510  lpValueName = L"Exclusive";
1511  break;
1512 
1514  lpValueName = L"DeviceCharacteristics";
1515  break;
1516 
1517  case CM_DRP_ADDRESS:
1518  PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
1519  break;
1520 
1522  lpValueName = L"UINumberDescFormat";
1523  break;
1524 
1526  PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
1527  break;
1528 
1529  case CM_DRP_REMOVAL_POLICY:
1530  PlugPlayData.Property = PNP_PROPERTY_REMOVAL_POLICY;
1531  break;
1532 
1535  break;
1536 
1538  lpValueName = L"RemovalPolicy";
1539  break;
1540 
1541  case CM_DRP_INSTALL_STATE:
1542  PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
1543  break;
1544 
1545 #if (WINVER >= _WIN32_WINNT_WS03)
1546  case CM_DRP_LOCATION_PATHS:
1547  PlugPlayData.Property = PNP_PROPERTY_LOCATION_PATHS;
1548  break;
1549 #endif
1550 
1551 #if (WINVER >= _WIN32_WINNT_WIN7)
1553  PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
1554  break;
1555 #endif
1556 
1557  default:
1559  goto done;
1560  }
1561 
1562  DPRINT("Value name: %S\n", lpValueName);
1563 
1564  if (lpValueName)
1565  {
1566  /* Retrieve information from the Registry */
1567  lError = RegOpenKeyExW(hEnumKey,
1568  pDeviceID,
1569  0,
1571  &hKey);
1572  if (lError != ERROR_SUCCESS)
1573  {
1574  hKey = NULL;
1575  *pulLength = 0;
1577  goto done;
1578  }
1579 
1580  lError = RegQueryValueExW(hKey,
1581  lpValueName,
1582  NULL,
1583  pulRegDataType,
1584  Buffer,
1585  pulLength);
1586  if (lError != ERROR_SUCCESS)
1587  {
1588  if (lError == ERROR_MORE_DATA)
1589  {
1590  ret = CR_BUFFER_SMALL;
1591  }
1592  else
1593  {
1594  *pulLength = 0;
1596  }
1597  }
1598  }
1599  else
1600  {
1601  /* Retrieve information from the Device Node */
1602  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1603  pDeviceID);
1604  PlugPlayData.Buffer = Buffer;
1605  PlugPlayData.BufferSize = *pulLength;
1606 
1608  (PVOID)&PlugPlayData,
1610  if (NT_SUCCESS(Status))
1611  {
1612  *pulLength = PlugPlayData.BufferSize;
1613  }
1614  else
1615  {
1617  }
1618  }
1619 
1620 done:
1621  if (pulTransferLen)
1622  *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
1623 
1624  if (hKey != NULL)
1625  RegCloseKey(hKey);
1626 
1627  DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
1628 
1629  return ret;
1630 }
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_DRP_REMOVAL_POLICY_HW_DEFAULT
Definition: cfgmgr32.h:720
#define CM_DRP_FRIENDLYNAME
Definition: cfgmgr32.h:688
#define CM_DRP_EXCLUSIVE
Definition: cfgmgr32.h:711
#define CM_DRP_LEGACYBUSTYPE
Definition: cfgmgr32.h:702
LONG NTSTATUS
Definition: precomp.h:26
#define CM_DRP_BUSTYPEGUID
Definition: cfgmgr32.h:701
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CM_DRP_SERVICE
Definition: cfgmgr32.h:680
#define CM_DRP_COMPATIBLEIDS
Definition: cfgmgr32.h:678
#define CM_DRP_REMOVAL_POLICY
Definition: cfgmgr32.h:719
#define CM_DRP_SECURITY
Definition: cfgmgr32.h:705
#define CM_DRP_UPPERFILTERS
Definition: cfgmgr32.h:693
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CM_DRP_LOWERFILTERS
Definition: cfgmgr32.h:697
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_ENUMERATOR_NAME
Definition: cfgmgr32.h:704
static HKEY hEnumKey
Definition: umpnpmgr.c:64
smooth NULL
Definition: ftsmooth.c:416
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define CM_DRP_DEVTYPE
Definition: cfgmgr32.h:709
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:468
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CM_DRP_HARDWAREID
Definition: cfgmgr32.h:677
#define CM_DRP_REMOVAL_POLICY_OVERRIDE
Definition: cfgmgr32.h:721
#define CM_DRP_LOCATION_INFORMATION
Definition: cfgmgr32.h:689
#define CM_DRP_BASE_CONTAINERID
Definition: cfgmgr32.h:728
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define CM_DRP_DRIVER
Definition: cfgmgr32.h:685
int ret
static const WCHAR L[]
Definition: oid.c:1087
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cfgmgr32.h:690
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CM_DRP_UI_NUMBER
Definition: cfgmgr32.h:692
#define CM_DRP_DEVICE_POWER_DATA
Definition: cfgmgr32.h:718
#define CM_DRP_MFG
Definition: cfgmgr32.h:687
#define ERROR_MORE_DATA
Definition: dderror.h:13
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
#define CM_DRP_CHARACTERISTICS
Definition: cfgmgr32.h:713
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define CM_DRP_CONFIGFLAGS
Definition: cfgmgr32.h:686
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define CM_DRP_CLASS
Definition: cfgmgr32.h:683
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define CM_DRP_ADDRESS
Definition: cfgmgr32.h:715
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define CM_DRP_UI_NUMBER_DESC_FORMAT
Definition: cfgmgr32.h:716
#define CM_DRP_LOCATION_PATHS
Definition: cfgmgr32.h:725
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
#define CM_DRP_INSTALL_STATE
Definition: cfgmgr32.h:722
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
#define CM_DRP_BUSNUMBER
Definition: cfgmgr32.h:703

Referenced by CM_Get_DevNode_Registry_Property_ExW(), and GetDeviceInstanceKeyPath().

◆ PNP_GetDeviceStatus()

DWORD WINAPI PNP_GetDeviceStatus ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD pulStatus,
DWORD pulProblem,
DWORD  ulFlags 
)

Definition at line 2623 of file umpnpmgr.c.

2629 {
2630  PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
2632  NTSTATUS Status;
2633 
2635  UNREFERENCED_PARAMETER(ulFlags);
2636 
2637  DPRINT("PNP_GetDeviceStatus() called\n");
2638 
2639  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
2640  pDeviceID);
2641  PlugPlayData.Operation = 0; /* Get status */
2642 
2644  (PVOID)&PlugPlayData,
2646  if (NT_SUCCESS(Status))
2647  {
2648  *pulStatus = PlugPlayData.DeviceStatus;
2649  *pulProblem = PlugPlayData.DeviceProblem;
2650  }
2651  else
2652  {
2654  }
2655 
2656  DPRINT("PNP_GetDeviceStatus() done (returns %lx)\n", ret);
2657 
2658  return ret;
2659 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:486
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by CM_Get_DevNode_Status_Ex().

◆ PNP_GetFirstLogConf()

DWORD WINAPI PNP_GetFirstLogConf ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfType,
DWORD pulLogConfTag,
DWORD  ulFlags 
)

Definition at line 3215 of file umpnpmgr.c.

3221 {
3222  UNIMPLEMENTED;
3223  return CR_CALL_NOT_IMPLEMENTED;
3224 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CM_Get_First_Log_Conf_Ex().

◆ PNP_GetGlobalState()

DWORD WINAPI PNP_GetGlobalState ( handle_t  hBinding,
DWORD pulState,
DWORD  ulFlags 
)

Definition at line 273 of file umpnpmgr.c.

277 {
279  UNREFERENCED_PARAMETER(ulFlags);
280 
282  return CR_SUCCESS;
283 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_GLOBAL_STATE_SERVICES_AVAILABLE
Definition: cfgmgr32.h:910
#define CM_GLOBAL_STATE_CAN_DO_UI
Definition: cfgmgr32.h:908

Referenced by CM_Get_Global_State_Ex().

◆ PNP_GetHwProfInfo()

DWORD WINAPI PNP_GetHwProfInfo ( handle_t  hBinding,
DWORD  ulIndex,
HWPROFILEINFO pHWProfileInfo,
DWORD  ulProfileInfoSize,
DWORD  ulFlags 
)

Definition at line 3050 of file umpnpmgr.c.

3056 {
3057  WCHAR szProfileName[5];
3058  HKEY hKeyConfig = NULL;
3059  HKEY hKeyProfiles = NULL;
3060  HKEY hKeyProfile = NULL;
3061  DWORD dwDisposition;
3062  DWORD dwSize;
3063  LONG lError;
3065 
3067 
3068  DPRINT("PNP_GetHwProfInfo() called\n");
3069 
3070  if (ulProfileInfoSize == 0)
3071  {
3072  ret = CR_INVALID_DATA;
3073  goto done;
3074  }
3075 
3076  if (ulFlags != 0)
3077  {
3078  ret = CR_INVALID_FLAG;
3079  goto done;
3080  }
3081 
3082  /* Initialize the profile information */
3083  pHWProfileInfo->HWPI_ulHWProfile = 0;
3084  pHWProfileInfo->HWPI_szFriendlyName[0] = 0;
3085  pHWProfileInfo->HWPI_dwFlags = 0;
3086 
3087  /* Open the 'IDConfigDB' key */
3089  L"System\\CurrentControlSet\\Control\\IDConfigDB",
3090  0,
3091  NULL,
3094  NULL,
3095  &hKeyConfig,
3096  &dwDisposition);
3097  if (lError != ERROR_SUCCESS)
3098  {
3100  goto done;
3101  }
3102 
3103  /* Open the 'Hardware Profiles' subkey */
3104  lError = RegCreateKeyExW(hKeyConfig,
3105  L"Hardware Profiles",
3106  0,
3107  NULL,
3110  NULL,
3111  &hKeyProfiles,
3112  &dwDisposition);
3113  if (lError != ERROR_SUCCESS)
3114  {
3116  goto done;
3117  }
3118 
3119  if (ulIndex == (ULONG)-1)
3120  {
3121  dwSize = sizeof(ULONG);
3122  lError = RegQueryValueExW(hKeyConfig,
3123  L"CurrentConfig",
3124  NULL,
3125  NULL,
3126  (LPBYTE)&pHWProfileInfo->HWPI_ulHWProfile,
3127  &dwSize);
3128  if (lError != ERROR_SUCCESS)
3129  {
3130  pHWProfileInfo->HWPI_ulHWProfile = 0;
3132  goto done;
3133  }
3134  }
3135  else
3136  {
3137  /* FIXME: not implemented yet */
3139  goto done;
3140  }
3141 
3142  swprintf(szProfileName, L"%04lu", pHWProfileInfo->HWPI_ulHWProfile);
3143 
3144  lError = RegOpenKeyExW(hKeyProfiles,
3145  szProfileName,
3146  0,
3148  &hKeyProfile);
3149  if (lError != ERROR_SUCCESS)
3150  {
3152  goto done;
3153  }
3154 
3155  dwSize = sizeof(pHWProfileInfo->HWPI_szFriendlyName);
3156  lError = RegQueryValueExW(hKeyProfile,
3157  L"FriendlyName",
3158  NULL,
3159  NULL,
3160  (LPBYTE)&pHWProfileInfo->HWPI_szFriendlyName,
3161  &dwSize);
3162  if (lError != ERROR_SUCCESS)
3163  {
3165  goto done;
3166  }
3167 
3168 done:
3169  if (hKeyProfile != NULL)
3170  RegCloseKey(hKeyProfile);
3171 
3172  if (hKeyProfiles != NULL)
3173  RegCloseKey(hKeyProfiles);
3174 
3175  if (hKeyConfig != NULL)
3176  RegCloseKey(hKeyConfig);
3177 
3178  return ret;
3179 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
DWORD HWPI_dwFlags
Definition: cfgmgr32.h:556
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1094
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
int ret
static const WCHAR L[]
Definition: oid.c:1087
ULONG HWPI_ulHWProfile
Definition: cfgmgr32.h:554
ULONG ulIndex
Definition: symbols.c:92
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
CHAR HWPI_szFriendlyName[MAX_PROFILE_LEN]
Definition: cfgmgr32.h:555
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by CM_Get_Hardware_Profile_Info_ExW().

◆ PNP_GetInterfaceDeviceAlias()

DWORD WINAPI PNP_GetInterfaceDeviceAlias ( handle_t  hBinding,
LPWSTR  pszInterfaceDevice,
GUID AliasInterfaceGuid,
LPWSTR  pszAliasInterfaceDevice,
PNP_RPC_STRING_LEN pulLength,
PNP_RPC_STRING_LEN pulTransferLen,
DWORD  ulFlags 
)

Definition at line 1967 of file umpnpmgr.c.

1975 {
1976  UNIMPLEMENTED;
1977  return CR_CALL_NOT_IMPLEMENTED;
1978 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:114

Referenced by CM_Get_Device_Interface_Alias_ExW().

◆ PNP_GetInterfaceDeviceList()

DWORD WINAPI PNP_GetInterfaceDeviceList ( handle_t  hBinding,
GUID InterfaceGuid,
LPWSTR  pszDeviceID,
BYTE Buffer,
PNP_RPC_BUFFER_SIZE pulLength,
DWORD  ulFlags 
)

Definition at line 1984 of file umpnpmgr.c.

1991 {
1992  NTSTATUS Status;
1994  DWORD ret = CR_SUCCESS;
1995 
1997 
1998  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1999  pszDeviceID);
2000 
2001  PlugPlayData.Flags = ulFlags;
2002  PlugPlayData.FilterGuid = InterfaceGuid;
2003  PlugPlayData.Buffer = Buffer;
2004  PlugPlayData.BufferSize = *pulLength;
2005 
2007  (PVOID)&PlugPlayData,
2009  if (NT_SUCCESS(Status))
2010  {
2011  *pulLength = PlugPlayData.BufferSize;
2012  }
2013  else
2014  {
2016  }
2017 
2018  DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
2019  return ret;
2020 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const GUID InterfaceGuid
Definition: wlanapi.c:25
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1266
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: umpnpmgr.c:159
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by CM_Get_Device_Interface_List_ExW().

◆ PNP_GetInterfaceDeviceListSize()

DWORD WINAPI PNP_GetInterfaceDeviceListSize ( handle_t  hBinding,
PNP_RPC_BUFFER_SIZE pulLen,
GUID InterfaceGuid,
LPWSTR  pszDeviceID,
DWORD  ulFlags 
)

Definition at line 2026 of file umpnpmgr.c.

2032 {
2033  NTSTATUS Status;
2035  DWORD ret = CR_SUCCESS;
2036 
2038 
2039  DPRINT("PNP_GetInterfaceDeviceListSize() called\n");
2040 
2041  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
2042  pszDeviceID);
2043 
2044  PlugPlayData.FilterGuid = InterfaceGuid;
2045  PlugPlayData.Buffer = NULL;
2046  PlugPlayData.BufferSize = 0;
2047  PlugPlayData.Flags = ulFlags;
2048 
2050  (PVOID)&PlugPlayData,
2052  if (NT_SUCCESS(Status))
2053  {
2054  *pulLen = PlugPlayData.BufferSize;
2055  }
2056  else
2057  {
2059  }
2060 
2061  DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
2062  return ret;
2063 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)