ReactOS  0.4.15-dev-5452-g3c95c95
rpcserver.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for rpcserver.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

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)
 
static CONFIGRET ClearDeviceStatus (_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
 
static CONFIGRET GetDeviceStatus (_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
 
static CONFIGRET SetDeviceStatus (_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
 
static CONFIGRET DisableDeviceInstance (_In_ LPWSTR pszDeviceInstance, _Inout_opt_ PPNP_VETO_TYPE pVetoType, _Inout_opt_ LPWSTR pszVetoName, _In_ DWORD ulNameLength)
 
static BOOL IsValidDeviceInstanceID (_In_ PWSTR pszDeviceInstanceID)
 
static BOOL IsRootDeviceInstanceID (_In_ PWSTR pszDeviceInstanceID)
 
static BOOL IsPresentDeviceInstanceID (_In_ LPWSTR pszDeviceInstanceID)
 
static CONFIGRET OpenConfigurationKey (_In_ LPCWSTR pszDeviceID, _Out_ PHKEY phKey)
 
static CONFIGRET GetConfigurationData (_In_ HKEY hKey, _In_ ULONG ulLogConfType, _Out_ PULONG pulRegDataType, _Out_ PULONG pulDataSize, _Out_ LPBYTE *ppBuffer)
 
VOID __RPC_USER PNP_NOTIFY_HANDLE_rundown (PNP_NOTIFY_HANDLE pHandle)
 
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 (_In_ LPWSTR pszDeviceID, _In_ BOOL bPhantomDevice)
 
static CONFIGRET GenerateDeviceID (_Inout_ LPWSTR pszDeviceID, _In_ PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_CreateDevInst (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentDeviceID, PNP_RPC_STRING_LEN ulLength, DWORD ulFlags)
 
static CONFIGRET SetupDeviceInstance (_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
 
static CONFIGRET EnableDeviceInstance (_In_ LPWSTR pszDeviceInstance)
 
static CONFIGRET ReenumerateDeviceInstance (_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulMinorAction)
 
DWORD WINAPI PNP_DeviceInstanceAction (handle_t hBinding, DWORD ulMajorAction, DWORD ulMinorAction, 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 ulUnknown2, LPWSTR pszName, BYTE *pNotificationFilter, DWORD ulNotificationFilterSize, DWORD ulFlags, PNP_NOTIFY_HANDLE *pNotifyHandle, DWORD ulUnknown8, DWORD *pulUnknown9)
 
DWORD WINAPI PNP_UnregisterNotification (handle_t hBinding, PNP_NOTIFY_HANDLE *pNotifyHandle)
 
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)
 

Variables

static WCHAR szRootDeviceInstanceID [] = L"HTREE\\ROOT\\0"
 
LIST_ENTRY NotificationListHead
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 33 of file rpcserver.c.

Function Documentation

◆ AppendDeviceId()

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

Definition at line 3530 of file rpcserver.c.

3533 {
3534  DWORD dwLen;
3535  DWORD dwPos;
3536 
3537  dwLen = wcslen(lpDeviceId);
3538  dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
3539 
3540  wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
3541 
3542  dwPos += (dwLen + 1);
3543 
3544  lpDeviceIdList[dwPos] = 0;
3545 
3546  *lpDeviceIdListSize = dwPos * sizeof(WCHAR);
3547 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
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)
_CRTIMP 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 3509 of file rpcserver.c.

3511 {
3512  LPWSTR lpPtr;
3513  DWORD dwLength;
3514 
3515  lpPtr = lpDeviceIdList;
3516  while (*lpPtr != 0)
3517  {
3518  dwLength = wcslen(lpPtr);
3519  if (0 == _wcsicmp(lpPtr, lpDeviceId))
3520  return TRUE;
3521 
3522  lpPtr += (dwLength + 1);
3523  }
3524 
3525  return FALSE;
3526 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by PNP_AddID().

◆ ClearDeviceStatus()

static CONFIGRET ClearDeviceStatus ( _In_ LPWSTR  pszDeviceID,
_In_ DWORD  ulStatus,
_In_ DWORD  ulProblem 
)
static

Definition at line 199 of file rpcserver.c.

203 {
204  PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
207 
208  DPRINT1("ClearDeviceStatus(%S 0x%lx 0x%lx)\n",
209  pszDeviceID, ulStatus, ulProblem);
210 
211  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
212  pszDeviceID);
213  PlugPlayData.Operation = PNP_CLEAR_DEVICE_STATUS;
214  PlugPlayData.DeviceStatus = ulStatus;
215  PlugPlayData.DeviceProblem = ulProblem;
216 
218  (PVOID)&PlugPlayData,
220  if (!NT_SUCCESS(Status))
222 
223  return ret;
224 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:525
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PNP_CLEAR_DEVICE_STATUS
Definition: cmtypes.h:61
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_SetDeviceProblem(), and SetupDeviceInstance().

◆ CreateDeviceInstance()

static CONFIGRET CreateDeviceInstance ( _In_ LPWSTR  pszDeviceID,
_In_ BOOL  bPhantomDevice 
)
static

Definition at line 2882 of file rpcserver.c.

2885 {
2886  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
2887  WCHAR szDevice[MAX_DEVICE_ID_LEN];
2888  WCHAR szInstance[MAX_DEVICE_ID_LEN];
2889  HKEY hKeyEnumerator;
2890  HKEY hKeyDevice;
2891  HKEY hKeyInstance;
2892  HKEY hKeyControl;
2893  LONG lError;
2894 
2895  /* Split the instance ID */
2896  SplitDeviceInstanceID(pszDeviceID,
2897  szEnumerator,
2898  szDevice,
2899  szInstance);
2900 
2901  /* Open or create the enumerator key */
2902  lError = RegCreateKeyExW(hEnumKey,
2903  szEnumerator,
2904  0,
2905  NULL,
2908  NULL,
2909  &hKeyEnumerator,
2910  NULL);
2911  if (lError != ERROR_SUCCESS)
2912  {
2913  return CR_REGISTRY_ERROR;
2914  }
2915 
2916  /* Open or create the device key */
2917  lError = RegCreateKeyExW(hKeyEnumerator,
2918  szDevice,
2919  0,
2920  NULL,
2923  NULL,
2924  &hKeyDevice,
2925  NULL);
2926 
2927  /* Close the enumerator key */
2928  RegCloseKey(hKeyEnumerator);
2929 
2930  if (lError != ERROR_SUCCESS)
2931  {
2932  return CR_REGISTRY_ERROR;
2933  }
2934 
2935  /* Try to open the instance key and fail if it exists */
2936  lError = RegOpenKeyExW(hKeyDevice,
2937  szInstance,
2938  0,
2939  KEY_SET_VALUE,
2940  &hKeyInstance);
2941  if (lError == ERROR_SUCCESS)
2942  {
2943  DPRINT1("Instance %S already exists!\n", szInstance);
2944  RegCloseKey(hKeyInstance);
2945  RegCloseKey(hKeyDevice);
2946  return CR_ALREADY_SUCH_DEVINST;
2947  }
2948 
2949  /* Create a new instance key */
2950  lError = RegCreateKeyExW(hKeyDevice,
2951  szInstance,
2952  0,
2953  NULL,
2956  NULL,
2957  &hKeyInstance,
2958  NULL);
2959 
2960  /* Close the device key */
2961  RegCloseKey(hKeyDevice);
2962 
2963  if (lError != ERROR_SUCCESS)
2964  {
2965  return CR_REGISTRY_ERROR;
2966  }
2967 
2968  if (bPhantomDevice)
2969  {
2970  DWORD dwPhantomValue = 1;
2971  RegSetValueExW(hKeyInstance,
2972  L"Phantom",
2973  0,
2974  REG_DWORD,
2975  (PBYTE)&dwPhantomValue,
2976  sizeof(dwPhantomValue));
2977  }
2978 
2979  /* Create the 'Control' sub key */
2980  lError = RegCreateKeyExW(hKeyInstance,
2981  L"Control",
2982  0,
2983  NULL,
2986  NULL,
2987  &hKeyControl,
2988  NULL);
2989  if (lError == ERROR_SUCCESS)
2990  {
2991  RegCloseKey(hKeyControl);
2992  }
2993 
2994  RegCloseKey(hKeyInstance);
2995 
2996  return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
2997 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: rpcserver.c:153
#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:1091
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
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:4899
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define REG_DWORD
Definition: sdbapi.c:596
BYTE * PBYTE
Definition: pedump.c:66
#define RegCloseKey(hKey)
Definition: registry.h:47
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by PNP_CreateDevInst().

◆ DisableDeviceInstance()

static CONFIGRET DisableDeviceInstance ( _In_ LPWSTR  pszDeviceInstance,
_Inout_opt_ PPNP_VETO_TYPE  pVetoType,
_Inout_opt_ LPWSTR  pszVetoName,
_In_ DWORD  ulNameLength 
)
static

Definition at line 294 of file rpcserver.c.

299 {
300  PLUGPLAY_CONTROL_QUERY_REMOVE_DATA QueryRemoveData;
303 
304  DPRINT1("DisableDeviceInstance(%S %p %p %lu)\n",
305  pszDeviceInstance, pVetoType, pszVetoName, ulNameLength);
306 
307  RtlInitUnicodeString(&QueryRemoveData.DeviceInstance,
308  pszDeviceInstance);
309 
310  QueryRemoveData.Flags = 0;
311  QueryRemoveData.VetoType = 0;
312  QueryRemoveData.VetoName = pszVetoName;
313  QueryRemoveData.NameLength = ulNameLength;
314 
316  &QueryRemoveData,
319  {
321  }
323  {
324  if (pVetoType != NULL)
325  *pVetoType = QueryRemoveData.VetoType;
326 
328  }
329  else if (!NT_SUCCESS(Status))
330  {
332  }
333 
334  return ret;
335 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#define CR_REMOVE_VETOED
Definition: cfgmgr32.h:869
#define STATUS_PLUGPLAY_QUERY_VETOED
Definition: ntstatus.h:219
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
int ret
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_DisableDevInst().

◆ EnableDeviceInstance()

static CONFIGRET EnableDeviceInstance ( _In_ LPWSTR  pszDeviceInstance)
static

Definition at line 3237 of file rpcserver.c.

3239 {
3242  NTSTATUS Status;
3243 
3244  DPRINT("Enable device instance %S\n", pszDeviceInstance);
3245 
3246  RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceInstance);
3247  Status = NtPlugPlayControl(PlugPlayControlStartDevice, &ControlData, sizeof(ControlData));
3248  if (!NT_SUCCESS(Status))
3250 
3251  return ret;
3252 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT
Definition: sndvol32.h:71

Referenced by PNP_DeviceInstanceAction().

◆ GenerateDeviceID()

static CONFIGRET GenerateDeviceID ( _Inout_ LPWSTR  pszDeviceID,
_In_ PNP_RPC_STRING_LEN  ulLength 
)
static

Definition at line 3002 of file rpcserver.c.

3005 {
3006  WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
3007  HKEY hKey;
3008  DWORD dwInstanceNumber;
3009  DWORD dwError = ERROR_SUCCESS;
3011 
3012  /* Fail, if the device name contains backslashes */
3013  if (wcschr(pszDeviceID, L'\\') != NULL)
3014  return CR_INVALID_DEVICE_ID;
3015 
3016  /* Generated ID is: Root<Device ID><Instance number> */
3017  dwInstanceNumber = 0;
3018  while (dwError == ERROR_SUCCESS)
3019  {
3020  if (dwInstanceNumber >= 10000)
3021  return CR_FAILURE;
3022 
3023  swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
3024  pszDeviceID, dwInstanceNumber);
3025 
3026  /* Try to open the enum key of the device instance */
3027  dwError = RegOpenKeyEx(hEnumKey, szGeneratedInstance, 0, KEY_QUERY_VALUE, &hKey);
3028  if (dwError == ERROR_SUCCESS)
3029  {
3030  RegCloseKey(hKey);
3031  dwInstanceNumber++;
3032  }
3033  }
3034 
3035  /* pszDeviceID is an out parameter too for generated IDs */
3036  if (wcslen(szGeneratedInstance) > ulLength)
3037  {
3038  ret = CR_BUFFER_SMALL;
3039  }
3040  else
3041  {
3042  wcscpy(pszDeviceID, szGeneratedInstance);
3043  }
3044 
3045  return ret;
3046 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_DEVICE_ID
Definition: cfgmgr32.h:876
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_FAILURE
Definition: cfgmgr32.h:865
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int _cdecl swprintf(const WCHAR *,...)
#define RegOpenKeyEx
Definition: winreg.h:520
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define RegCloseKey(hKey)
Definition: registry.h:47

Referenced by PNP_CreateDevInst().

◆ GetAllInstanceList()

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

Definition at line 1223 of file rpcserver.c.

1226 {
1227  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1228  PWSTR pPtr;
1229  DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
1230  DWORD dwError;
1232 
1233  dwUsedLength = 0;
1234  dwRemainingLength = *pulLength;
1235  pPtr = pszBuffer;
1236 
1237  for (dwIndex = 0; ; dwIndex++)
1238  {
1239  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1240  dwError = RegEnumKeyExW(hEnumKey,
1241  dwIndex,
1242  szEnumeratorBuffer,
1243  &dwEnumeratorLength,
1244  NULL, NULL, NULL, NULL);
1245  if (dwError != ERROR_SUCCESS)
1246  break;
1247 
1248  dwPathLength = dwRemainingLength;
1249  ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
1250  pPtr,
1251  &dwPathLength);
1252  if (ret != CR_SUCCESS)
1253  break;
1254 
1255  dwUsedLength += dwPathLength - 1;
1256  dwRemainingLength -= dwPathLength - 1;
1257  pPtr += dwPathLength - 1;
1258  }
1259 
1260  if (ret == CR_SUCCESS)
1261  *pulLength = dwUsedLength + 1;
1262  else
1263  *pulLength = 0;
1264 
1265  return ret;
1266 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1152
#define CR_SUCCESS
Definition: cfgmgr32.h:842
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
#define NULL
Definition: types.h:112
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:2527

Referenced by PNP_GetDeviceList().

◆ GetAllInstanceListSize()

static CONFIGRET GetAllInstanceListSize ( _Out_ PULONG  pulLength)
static

Definition at line 1608 of file rpcserver.c.

1610 {
1611  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1612  DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
1613  DWORD dwError;
1615 
1616  for (dwIndex = 0; ; dwIndex++)
1617  {
1618  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1619  dwError = RegEnumKeyExW(hEnumKey,
1620  dwIndex,
1621  szEnumeratorBuffer,
1622  &dwEnumeratorLength,
1623  NULL, NULL, NULL, NULL);
1624  if (dwError != ERROR_SUCCESS)
1625  break;
1626 
1627  /* Get the size of all device instances for the enumerator */
1628  ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
1629  &dwBufferLength);
1630  if (ret != CR_SUCCESS)
1631  break;
1632 
1633  *pulLength += dwBufferLength;
1634  }
1635 
1636  return ret;
1637 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_SUCCESS
Definition: cfgmgr32.h:842
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1547
#define NULL
Definition: types.h:112
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:2527

Referenced by PNP_GetDeviceListSize().

◆ GetConfigurationData()

static CONFIGRET GetConfigurationData ( _In_ HKEY  hKey,
_In_ ULONG  ulLogConfType,
_Out_ PULONG  pulRegDataType,
_Out_ PULONG  pulDataSize,
_Out_ LPBYTE ppBuffer 
)
static

Definition at line 473 of file rpcserver.c.

479 {
480  LPCWSTR pszValueName;
481 
482  switch (ulLogConfType)
483  {
484  case BOOT_LOG_CONF:
485  pszValueName = L"BootConfig";
486  *pulRegDataType = REG_RESOURCE_LIST;
487  break;
488 
489  case ALLOC_LOG_CONF:
490  pszValueName = L"AllocConfig";
491  *pulRegDataType = REG_RESOURCE_LIST;
492  break;
493 
494  case FORCED_LOG_CONF:
495  pszValueName = L"ForcedConfig";
496  *pulRegDataType = REG_RESOURCE_LIST;
497  break;
498 
499  case FILTERED_LOG_CONF:
500  pszValueName = L"FilteredConfigVector";
501  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
502  break;
503 
504  case BASIC_LOG_CONF:
505  pszValueName = L"BasicConfigVector";
506  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
507  break;
508 
509  case OVERRIDE_LOG_CONF:
510  pszValueName = L"OverrideConfigVector";
511  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
512  break;
513 
514  default:
515  DPRINT1("Unsupported configuration type!\n");
516  return CR_FAILURE;
517  }
518 
519  /* Get the configuration data size */
521  pszValueName,
522  NULL,
523  NULL,
524  NULL,
525  pulDataSize) != ERROR_SUCCESS)
526  {
527  return CR_INVALID_LOG_CONF;
528  }
529 
530  /* Allocate the buffer */
531  *ppBuffer = HeapAlloc(GetProcessHeap(), 0, *pulDataSize);
532  if (*ppBuffer == NULL)
533  {
534  return CR_OUT_OF_MEMORY;
535  }
536 
537  /* Retrieve the configuration data */
539  pszValueName,
540  NULL,
541  NULL,
542  (LPBYTE)*ppBuffer,
543  pulDataSize) != ERROR_SUCCESS)
544  {
545  return CR_INVALID_LOG_CONF;
546  }
547 
548  return CR_SUCCESS;
549 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define FORCED_LOG_CONF
Definition: cfgmgr32.h:600
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FILTERED_LOG_CONF
Definition: cfgmgr32.h:597
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define BASIC_LOG_CONF
Definition: cfgmgr32.h:596
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define ALLOC_LOG_CONF
Definition: cfgmgr32.h:598
#define GetProcessHeap()
Definition: compat.h:736
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:4120
#define CR_INVALID_LOG_CONF
Definition: cfgmgr32.h:850
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define BOOT_LOG_CONF
Definition: cfgmgr32.h:599
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
#define OVERRIDE_LOG_CONF
Definition: cfgmgr32.h:601

Referenced by PNP_GetFirstLogConf(), PNP_GetNextLogConf(), and PNP_GetNextResDes().

◆ GetDeviceInstanceList()

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

Definition at line 1081 of file rpcserver.c.

1085 {
1086  WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
1087  WCHAR szPathBuffer[512];
1088  HKEY hDeviceKey;
1089  DWORD dwInstanceLength, dwPathLength, dwUsedLength;
1090  DWORD dwIndex, dwError;
1091  PWSTR pPtr;
1093 
1094  /* Open the device key */
1095  dwError = RegOpenKeyExW(hEnumKey,
1096  pszDevice,
1097  0,
1099  &hDeviceKey);
1100  if (dwError != ERROR_SUCCESS)
1101  {
1102  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1103  return CR_REGISTRY_ERROR;
1104  }
1105 
1106  dwUsedLength = 0;
1107  pPtr = pszBuffer;
1108 
1109  for (dwIndex = 0; ; dwIndex++)
1110  {
1111  dwInstanceLength = MAX_DEVICE_ID_LEN;
1112  dwError = RegEnumKeyExW(hDeviceKey,
1113  dwIndex,
1114  szInstanceBuffer,
1115  &dwInstanceLength,
1116  NULL,
1117  NULL,
1118  NULL,
1119  NULL);
1120  if (dwError != ERROR_SUCCESS)
1121  break;
1122 
1123  wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
1124  DPRINT("Path: %S\n", szPathBuffer);
1125 
1126  dwPathLength = wcslen(szPathBuffer) + 1;
1127  if (dwUsedLength + dwPathLength + 1 > *pulLength)
1128  {
1129  ret = CR_BUFFER_SMALL;
1130  break;
1131  }
1132 
1133  wcscpy(pPtr, szPathBuffer);
1134  dwUsedLength += dwPathLength;
1135  pPtr += dwPathLength;
1136 
1137  *pPtr = UNICODE_NULL;
1138  }
1139 
1140  RegCloseKey(hDeviceKey);
1141 
1142  if (ret == CR_SUCCESS)
1143  *pulLength = dwUsedLength + 1;
1144  else
1145  *pulLength = 0;
1146 
1147  return ret;
1148 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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:2527
#define DPRINT
Definition: sndvol32.h:71
#define wsprintf
Definition: winuser.h:5855
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 1495 of file rpcserver.c.

1498 {
1499  HKEY hDeviceKey;
1500  DWORD dwSubKeys, dwMaxSubKeyLength;
1501  DWORD dwError;
1502 
1503  /* Open the device key */
1504  dwError = RegOpenKeyExW(hEnumKey,
1505  pszDevice,
1506  0,
1507  KEY_READ,
1508  &hDeviceKey);
1509  if (dwError != ERROR_SUCCESS)
1510  {
1511  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1512  return CR_REGISTRY_ERROR;
1513  }
1514 
1515  /* Retrieve the number of device instances and the maximum name length */
1516  dwError = RegQueryInfoKeyW(hDeviceKey,
1517  NULL,
1518  NULL,
1519  NULL,
1520  &dwSubKeys,
1521  &dwMaxSubKeyLength,
1522  NULL,
1523  NULL,
1524  NULL,
1525  NULL,
1526  NULL,
1527  NULL);
1528  if (dwError != ERROR_SUCCESS)
1529  {
1530  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1531  dwSubKeys = 0;
1532  dwMaxSubKeyLength = 0;
1533  }
1534 
1535  /* Close the device key */
1536  RegCloseKey(hDeviceKey);
1537 
1538  /* Return the largest possible buffer size */
1539  *pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
1540 
1541  return CR_SUCCESS;
1542 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define CR_SUCCESS
Definition: cfgmgr32.h:842
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
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:3690
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

Referenced by GetEnumeratorInstanceListSize(), and PNP_GetDeviceListSize().

◆ GetDeviceStatus()

static CONFIGRET GetDeviceStatus ( _In_ LPWSTR  pszDeviceID,
_Out_ DWORD pulStatus,
_Out_ DWORD pulProblem 
)
static

Definition at line 229 of file rpcserver.c.

233 {
234  PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
237 
238  DPRINT("GetDeviceStatus(%S %p %p)\n",
239  pszDeviceID, pulStatus, pulProblem);
240 
241  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
242  pszDeviceID);
243  PlugPlayData.Operation = PNP_GET_DEVICE_STATUS;
244 
246  (PVOID)&PlugPlayData,
248  if (NT_SUCCESS(Status))
249  {
250  *pulStatus = PlugPlayData.DeviceStatus;
251  *pulProblem = PlugPlayData.DeviceProblem;
252  }
253  else
254  {
256  }
257 
258  return ret;
259 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:525
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT
Definition: sndvol32.h:71

Referenced by DECLARE_INTERFACE_(), IsPresentDeviceInstanceID(), PNP_GetDeviceStatus(), PNP_SetDeviceProblem(), and SetupDeviceInstance().

◆ GetEnumeratorInstanceList()

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

Definition at line 1152 of file rpcserver.c.

1156 {
1157  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1158  WCHAR szPathBuffer[512];
1159  HKEY hEnumeratorKey;
1160  PWSTR pPtr;
1161  DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
1162  DWORD dwError;
1164 
1165  /* Open the enumerator key */
1166  dwError = RegOpenKeyExW(hEnumKey,
1167  pszEnumerator,
1168  0,
1170  &hEnumeratorKey);
1171  if (dwError != ERROR_SUCCESS)
1172  {
1173  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1174  return CR_REGISTRY_ERROR;
1175  }
1176 
1177  dwUsedLength = 0;
1178  dwRemainingLength = *pulLength;
1179  pPtr = pszBuffer;
1180 
1181  for (dwIndex = 0; ; dwIndex++)
1182  {
1183  dwDeviceLength = MAX_DEVICE_ID_LEN;
1184  dwError = RegEnumKeyExW(hEnumeratorKey,
1185  dwIndex,
1186  szDeviceBuffer,
1187  &dwDeviceLength,
1188  NULL,
1189  NULL,
1190  NULL,
1191  NULL);
1192  if (dwError != ERROR_SUCCESS)
1193  break;
1194 
1195  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1196  DPRINT("Path: %S\n", szPathBuffer);
1197 
1198  dwPathLength = dwRemainingLength;
1199  ret = GetDeviceInstanceList(szPathBuffer,
1200  pPtr,
1201  &dwPathLength);
1202  if (ret != CR_SUCCESS)
1203  break;
1204 
1205  dwUsedLength += dwPathLength - 1;
1206  dwRemainingLength -= dwPathLength - 1;
1207  pPtr += dwPathLength - 1;
1208  }
1209 
1210  RegCloseKey(hEnumeratorKey);
1211 
1212  if (ret == CR_SUCCESS)
1213  *pulLength = dwUsedLength + 1;
1214  else
1215  *pulLength = 0;
1216 
1217  return ret;
1218 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:56
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
__wchar_t WCHAR
Definition: xmlstorage.h:180
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1081
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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:2527
#define DPRINT
Definition: sndvol32.h:71
#define wsprintf
Definition: winuser.h:5855
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 1547 of file rpcserver.c.

1550 {
1551  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1552  WCHAR szPathBuffer[512];
1553  HKEY hEnumeratorKey;
1554  DWORD dwIndex, dwDeviceLength, dwBufferLength;
1555  DWORD dwError;
1557 
1558  *pulLength = 0;
1559 
1560  /* Open the enumerator key */
1561  dwError = RegOpenKeyExW(hEnumKey,
1562  pszEnumerator,
1563  0,
1565  &hEnumeratorKey);
1566  if (dwError != ERROR_SUCCESS)
1567  {
1568  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1569  return CR_REGISTRY_ERROR;
1570  }
1571 
1572  for (dwIndex = 0; ; dwIndex++)
1573  {
1574  dwDeviceLength = MAX_DEVICE_ID_LEN;
1575  dwError = RegEnumKeyExW(hEnumeratorKey,
1576  dwIndex,
1577  szDeviceBuffer,
1578  &dwDeviceLength,
1579  NULL,
1580  NULL,
1581  NULL,
1582  NULL);
1583  if (dwError != ERROR_SUCCESS)
1584  break;
1585 
1586  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1587  DPRINT("Path: %S\n", szPathBuffer);
1588 
1589  ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
1590  if (ret != CR_SUCCESS)
1591  {
1592  *pulLength = 0;
1593  break;
1594  }
1595 
1596  *pulLength += dwBufferLength;
1597  }
1598 
1599  /* Close the enumerator key */
1600  RegCloseKey(hEnumeratorKey);
1601 
1602  return ret;
1603 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1495
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
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:2527
#define DPRINT
Definition: sndvol32.h:71
#define wsprintf
Definition: winuser.h:5855
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 911 of file rpcserver.c.

916 {
920 
921  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
922  pszDevice);
923 
924  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
925  {
926  PlugPlayData.Relations = 3;
927  }
928  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
929  {
930  PlugPlayData.Relations = 2;
931  }
932  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
933  {
934  PlugPlayData.Relations = 1;
935  }
936  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
937  {
938  PlugPlayData.Relations = 0;
939  }
940 
941  PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
942  PlugPlayData.Buffer = pszBuffer;
943 
945  (PVOID)&PlugPlayData,
947  if (NT_SUCCESS(Status))
948  {
949  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
950  }
951  else
952  {
954  }
955 
956  return ret;
957 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#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
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
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 1346 of file rpcserver.c.

1350 {
1352  NTSTATUS Status;
1354 
1355  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1356  pszDevice);
1357 
1358  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
1359  {
1360  PlugPlayData.Relations = 3;
1361  }
1362  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1363  {
1364  PlugPlayData.Relations = 2;
1365  }
1366  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1367  {
1368  PlugPlayData.Relations = 1;
1369  }
1370  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1371  {
1372  PlugPlayData.Relations = 0;
1373  }
1374 
1375  PlugPlayData.BufferSize = 0;
1376  PlugPlayData.Buffer = NULL;
1377 
1379  (PVOID)&PlugPlayData,
1381  if (NT_SUCCESS(Status))
1382  {
1383  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1384  }
1385  else
1386  {
1388  }
1389 
1390  return ret;
1391 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#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
Status
Definition: gdiplustypes.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
#define NULL
Definition: types.h:112
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 962 of file rpcserver.c.

966 {
967  WCHAR szPathBuffer[512];
968  WCHAR szName[16];
969  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
970  DWORD dwValues, dwSize, dwIndex, dwUsedLength, dwPathLength;
971  DWORD dwError;
972  PWSTR pPtr;
974 
975  /* Open the device key */
977  L"System\\CurrentControlSet\\Services",
978  0,
979  KEY_READ,
980  &hServicesKey);
981  if (dwError != ERROR_SUCCESS)
982  {
983  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
984  return CR_REGISTRY_ERROR;
985  }
986 
987  dwError = RegOpenKeyExW(hServicesKey,
988  pszService,
989  0,
990  KEY_READ,
991  &hServiceKey);
992  if (dwError != ERROR_SUCCESS)
993  {
994  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
996  goto Done;
997  }
998 
999  dwError = RegOpenKeyExW(hServiceKey,
1000  L"Enum",
1001  0,
1002  KEY_READ,
1003  &hEnumKey);
1004  if (dwError != ERROR_SUCCESS)
1005  {
1006  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1008  goto Done;
1009  }
1010 
1011  /* Retrieve the number of device instances */
1012  dwSize = sizeof(DWORD);
1013  dwError = RegQueryValueExW(hEnumKey,
1014  L"Count",
1015  NULL,
1016  NULL,
1017  (LPBYTE)&dwValues,
1018  &dwSize);
1019  if (dwError != ERROR_SUCCESS)
1020  {
1021  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1022  dwValues = 1;
1023  }
1024 
1025  DPRINT("dwValues %lu\n", dwValues);
1026 
1027  dwUsedLength = 0;
1028  pPtr = pszBuffer;
1029 
1030  for (dwIndex = 0; dwIndex < dwValues; dwIndex++)
1031  {
1032  wsprintf(szName, L"%lu", dwIndex);
1033 
1034  dwSize = sizeof(szPathBuffer);
1035  dwError = RegQueryValueExW(hEnumKey,
1036  szName,
1037  NULL,
1038  NULL,
1039  (LPBYTE)szPathBuffer,
1040  &dwSize);
1041  if (dwError != ERROR_SUCCESS)
1042  break;
1043 
1044  DPRINT("Path: %S\n", szPathBuffer);
1045 
1046  dwPathLength = wcslen(szPathBuffer) + 1;
1047  if (dwUsedLength + dwPathLength + 1 > *pulLength)
1048  {
1049  ret = CR_BUFFER_SMALL;
1050  break;
1051  }
1052 
1053  wcscpy(pPtr, szPathBuffer);
1054  dwUsedLength += dwPathLength;
1055  pPtr += dwPathLength;
1056 
1057  *pPtr = UNICODE_NULL;
1058  }
1059 
1060 Done:
1061  if (hEnumKey != NULL)
1063 
1064  if (hServiceKey != NULL)
1065  RegCloseKey(hServiceKey);
1066 
1067  if (hServicesKey != NULL)
1069 
1070  if (ret == CR_SUCCESS)
1071  *pulLength = dwUsedLength + 1;
1072  else
1073  *pulLength = 0;
1074 
1075  return ret;
1076 }
static const WCHAR szName[]
Definition: powrprof.c:45
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:56
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
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:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define wsprintf
Definition: winuser.h:5855
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#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 1396 of file rpcserver.c.

1399 {
1400  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1401  DWORD dwValues, dwMaxValueLength, dwSize;
1402  DWORD dwError;
1404 
1405  /* Open the device key */
1407  L"System\\CurrentControlSet\\Services",
1408  0,
1409  KEY_READ,
1410  &hServicesKey);
1411  if (dwError != ERROR_SUCCESS)
1412  {
1413  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1414  return CR_REGISTRY_ERROR;
1415  }
1416 
1417  dwError = RegOpenKeyExW(hServicesKey,
1418  pszService,
1419  0,
1420  KEY_READ,
1421  &hServiceKey);
1422  if (dwError != ERROR_SUCCESS)
1423  {
1424  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1426  goto Done;
1427  }
1428 
1429  dwError = RegOpenKeyExW(hServiceKey,
1430  L"Enum",
1431  0,
1432  KEY_READ,
1433  &hEnumKey);
1434  if (dwError != ERROR_SUCCESS)
1435  {
1436  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1438  goto Done;
1439  }
1440 
1441  /* Retrieve the number of device instances */
1442  dwSize = sizeof(DWORD);
1443  dwError = RegQueryValueExW(hEnumKey,
1444  L"Count",
1445  NULL,
1446  NULL,
1447  (LPBYTE)&dwValues,
1448  &dwSize);
1449  if (dwError != ERROR_SUCCESS)
1450  {
1451  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1452  dwValues = 1;
1453  }
1454 
1455  /* Retrieve the maximum instance name length */
1456  dwError = RegQueryInfoKeyW(hEnumKey,
1457  NULL,
1458  NULL,
1459  NULL,
1460  NULL,
1461  NULL,
1462  NULL,
1463  NULL,
1464  NULL,
1465  &dwMaxValueLength,
1466  NULL,
1467  NULL);
1468  if (dwError != ERROR_SUCCESS)
1469  {
1470  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1471  dwMaxValueLength = MAX_DEVICE_ID_LEN;
1472  }
1473 
1474  DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues, dwMaxValueLength / sizeof(WCHAR));
1475 
1476  /* Return the largest possible buffer size */
1477  *pulLength = dwValues * dwMaxValueLength / sizeof(WCHAR) + 2;
1478 
1479 Done:
1480  if (hEnumKey != NULL)
1482 
1483  if (hServiceKey != NULL)
1484  RegCloseKey(hServiceKey);
1485 
1486  if (hServicesKey != NULL)
1488 
1489  return ret;
1490 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CR_SUCCESS
Definition: cfgmgr32.h:842
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:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
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:3690
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
int ret
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetDeviceListSize().

◆ IsPresentDeviceInstanceID()

static BOOL IsPresentDeviceInstanceID ( _In_ LPWSTR  pszDeviceInstanceID)
static

Definition at line 418 of file rpcserver.c.

420 {
421  DWORD ulStatus, ulProblem;
422 
423  return (GetDeviceStatus(pszDeviceInstanceID, &ulStatus, &ulProblem) == CR_SUCCESS);
424 }
static CONFIGRET GetDeviceStatus(_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
Definition: rpcserver.c:229
#define CR_SUCCESS
Definition: cfgmgr32.h:842
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by PNP_CreateDevInst(), and PNP_GetRelatedDeviceInstance().

◆ IsRootDeviceInstanceID()

static BOOL IsRootDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 406 of file rpcserver.c.

408 {
409  if (_wcsicmp(pszDeviceInstanceID, szRootDeviceInstanceID) == 0)
410  return TRUE;
411 
412  return FALSE;
413 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
static WCHAR szRootDeviceInstanceID[]
Definition: rpcserver.c:39

Referenced by PNP_CreateDevInst(), PNP_DisableDevInst(), PNP_GetRelatedDeviceInstance(), PNP_QueryRemove(), and SetupDeviceInstance().

◆ IsValidDeviceInstanceID()

static BOOL IsValidDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 340 of file rpcserver.c.

342 {
343  INT nPartLength[3] = {0, 0, 0};
344  INT nLength = 0, nParts = 0;
345  PWCHAR p;
346 
347  DPRINT("IsValidDeviceInstanceID(%S)\n",
348  pszDeviceInstanceID);
349 
350  if (pszDeviceInstanceID == NULL)
351  {
352  DPRINT("Device instance ID is NULL!\n");
353  return FALSE;
354  }
355 
356  p = pszDeviceInstanceID;
357  while (*p != UNICODE_NULL)
358  {
359  if (*p == L'\\')
360  {
361  nParts++;
362  if (nParts >= 3)
363  {
364  DPRINT("Too many separators: %d\n", nParts);
365  return FALSE;
366  }
367  }
368  else
369  {
370  nPartLength[nParts]++;
371  }
372 
373  nLength++;
374  if (nLength >= MAX_DEVICE_ID_LEN)
375  {
376  DPRINT("Too long: %d\n", nLength);
377  return FALSE;
378  }
379 
380  p++;
381  }
382 
383  if (nParts != 2)
384  {
385  DPRINT("Invalid number of separtors: %d\n", nParts);
386  return FALSE;
387  }
388 
389  if ((nPartLength[0] == 0) ||
390  (nPartLength[1] == 0) ||
391  (nPartLength[2] == 0))
392  {
393  DPRINT("Invalid part lengths: %d %d %d\n",
394  nPartLength[0], nPartLength[1], nPartLength[2]);
395  return FALSE;
396  }
397 
398  DPRINT("Valid device instance ID!\n");
399 
400  return TRUE;
401 }
#define TRUE
Definition: types.h:120
_In_ DWORD nLength
Definition: wincon.h:473
uint16_t * PWCHAR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define NULL
Definition: types.h:112
GLfloat GLfloat p
Definition: glext.h:8902
#define DPRINT
Definition: sndvol32.h:71

Referenced by PNP_CreateKey(), PNP_DisableDevInst(), PNP_GetClassInstance(), PNP_GetCustomDevProp(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetDeviceStatus(), PNP_GetFirstLogConf(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetNextLogConf(), PNP_GetNextResDes(), PNP_GetRelatedDeviceInstance(), PNP_HwProfFlags(), PNP_QueryRemove(), PNP_RegisterDriver(), PNP_RequestDeviceEject(), PNP_SetDeviceProblem(), PNP_SetDeviceRegProp(), and PNP_ValidateDeviceInstance().

◆ midl_user_allocate()

void __RPC_FAR* __RPC_USER midl_user_allocate ( SIZE_T  len)

Definition at line 111 of file rpcserver.c.

112 {
114 }
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLsizei len
Definition: glext.h:6722
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

◆ midl_user_free()

void __RPC_USER midl_user_free ( void __RPC_FAR ptr)

Definition at line 117 of file rpcserver.c.

118 {
119  HeapFree(GetProcessHeap(), 0, ptr);
120 }
static PVOID ptr
Definition: dispmode.c:27
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735

◆ NtStatusToCrError()

static CONFIGRET WINAPI NtStatusToCrError ( NTSTATUS  Status)
static

Definition at line 124 of file rpcserver.c.

125 {
126  switch (Status)
127  {
130 
132  return CR_INVALID_DATA;
133 
135  return CR_NO_SUCH_DEVINST;
136 
138  return CR_ACCESS_DENIED;
139 
141  return CR_BUFFER_SMALL;
142 
144  return CR_NO_SUCH_VALUE;
145 
146  default:
147  return CR_FAILURE;
148  }
149 }
#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:69
return STATUS_NOT_IMPLEMENTED
Status
Definition: gdiplustypes.h:24
#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
#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 ClearDeviceStatus(), DisableDeviceInstance(), EnableDeviceInstance(), GetDeviceStatus(), GetRelationsInstanceList(), GetRelationsInstanceListSize(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetRelatedDeviceInstance(), PNP_QueryRemove(), PNP_RequestDeviceEject(), PNP_RequestEjectPC(), ReenumerateDeviceInstance(), SetDeviceStatus(), and SetupDeviceInstance().

◆ OpenConfigurationKey()

static CONFIGRET OpenConfigurationKey ( _In_ LPCWSTR  pszDeviceID,
_Out_ PHKEY  phKey 
)
static

Definition at line 429 of file rpcserver.c.

432 {
433  WCHAR szKeyName[MAX_PATH];
434  HKEY hInstanceKey;
435  DWORD dwError;
436 
437  /* Build the full device instance key name */
438  wcscpy(szKeyName, L"System\\CurrentControlSet\\Enum\\");
439  wcscat(szKeyName, pszDeviceID);
440 
441  /* Open the device instance key */
443  szKeyName,
444  0,
446  &hInstanceKey);
447  if (dwError != ERROR_SUCCESS)
448  return CR_INVALID_DEVINST;
449 
450  /* Create or open the LogConf key */
451  dwError = RegCreateKeyExW(hInstanceKey,
452  L"LogConf",
453  0,
454  NULL,
457  NULL,
458  phKey,
459  NULL);
460 
461  /* Close the device instance key */
462  RegCloseKey(hInstanceKey);
463 
464  if (dwError != ERROR_SUCCESS)
465  return CR_REGISTRY_ERROR;
466 
467  return CR_SUCCESS;
468 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
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:1091
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
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)
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#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 NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define RegCloseKey(hKey)
Definition: registry.h:47
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetFirstLogConf(), PNP_GetNextLogConf(), and PNP_GetNextResDes().

◆ PNP_AddEmptyLogConf()

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

Definition at line 4087 of file rpcserver.c.

4093 {
4094  UNIMPLEMENTED;
4095  return CR_CALL_NOT_IMPLEMENTED;
4096 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

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 3553 of file rpcserver.c.

3558 {
3560  HKEY hDeviceKey;
3561  LPWSTR pszSubKey;
3562  DWORD dwDeviceIdListSize;
3563  DWORD dwNewDeviceIdSize;
3564  WCHAR * pszDeviceIdList = NULL;
3565 
3567 
3568  DPRINT("PNP_AddID(%p %S %S 0x%08lx)\n",
3569  hBinding, pszDeviceID, pszID, ulFlags);
3570 
3571  if (RegOpenKeyExW(hEnumKey,
3572  pszDeviceID,
3573  0,
3575  &hDeviceKey) != ERROR_SUCCESS)
3576  {
3577  DPRINT("Failed to open the device key!\n");
3578  return CR_INVALID_DEVNODE;
3579  }
3580 
3581  pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
3582 
3583  if (RegQueryValueExW(hDeviceKey,
3584  pszSubKey,
3585  NULL,
3586  NULL,
3587  NULL,
3588  &dwDeviceIdListSize) != ERROR_SUCCESS)
3589  {
3590  DPRINT("Failed to query the desired ID string!\n");
3592  goto Done;
3593  }
3594 
3595  dwNewDeviceIdSize = lstrlenW(pszDeviceID);
3596  if (!dwNewDeviceIdSize)
3597  {
3599  goto Done;
3600  }
3601 
3602  dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
3603 
3604  pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
3605  if (!pszDeviceIdList)
3606  {
3607  DPRINT("Failed to allocate memory for the desired ID string!\n");
3609  goto Done;
3610  }
3611 
3612  if (RegQueryValueExW(hDeviceKey,
3613  pszSubKey,
3614  NULL,
3615  NULL,
3616  (LPBYTE)pszDeviceIdList,
3617  &dwDeviceIdListSize) != ERROR_SUCCESS)
3618  {
3619  DPRINT("Failed to query the desired ID string!\n");
3621  goto Done;
3622  }
3623 
3624  /* Check whether the device ID is already in use */
3625  if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
3626  {
3627  DPRINT("Device ID was found in the ID string!\n");
3628  ret = CR_SUCCESS;
3629  goto Done;
3630  }
3631 
3632  /* Append the Device ID */
3633  AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
3634 
3635  if (RegSetValueExW(hDeviceKey,
3636  pszSubKey,
3637  0,
3638  REG_MULTI_SZ,
3639  (LPBYTE)pszDeviceIdList,
3640  dwDeviceIdListSize) != ERROR_SUCCESS)
3641  {
3642  DPRINT("Failed to set the desired ID string!\n");
3644  }
3645 
3646 Done:
3647  RegCloseKey(hDeviceKey);
3648  if (pszDeviceIdList)
3649  HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
3650 
3651  DPRINT("PNP_AddID() done (returns %lx)\n", ret);
3652 
3653  return ret;
3654 }
#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:317
#define lstrlenW
Definition: compat.h:750
#define CM_ADD_ID_COMPATIBLE
Definition: cfgmgr32.h:615
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define REG_MULTI_SZ
Definition: nt_native.h:1501
static VOID AppendDeviceId(LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
Definition: rpcserver.c:3530
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#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:4899
#define GetProcessHeap()
Definition: compat.h:736
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:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
static BOOL CheckForDeviceId(LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
Definition: rpcserver.c:3509
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
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:3356
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:735
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 4322 of file rpcserver.c.

4332 {
4333  UNIMPLEMENTED;
4334  return CR_CALL_NOT_IMPLEMENTED;
4335 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ PNP_ApplyPowerSettings()

DWORD WINAPI PNP_ApplyPowerSettings ( handle_t  hBinding)

Definition at line 4944 of file rpcserver.c.

4946 {
4947  UNIMPLEMENTED;
4948  return CR_CALL_NOT_IMPLEMENTED;
4949 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ PNP_Connect()

DWORD WINAPI PNP_Connect ( handle_t  hBinding)

Definition at line 577 of file rpcserver.c.

579 {
581  return CR_SUCCESS;
582 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#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 3052 of file rpcserver.c.

3058 {
3060  HKEY hKey = NULL;
3061  DWORD dwSize, dwPhantom;
3062  NTSTATUS Status;
3064 
3065  DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
3066  hBinding, pszParentDeviceID, pszDeviceID, ulLength, ulFlags);
3067 
3068  if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
3069  return CR_INVALID_FLAG;
3070 
3071  if (pszDeviceID == NULL || pszParentDeviceID == NULL)
3072  return CR_INVALID_POINTER;
3073 
3074  /* Fail, if the parent device is not the root device */
3075  if (!IsRootDeviceInstanceID(pszParentDeviceID))
3076  return CR_INVALID_DEVINST;
3077 
3078  if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
3079  {
3080  ret = GenerateDeviceID(pszDeviceID,
3081  ulLength);
3082  if (ret != CR_SUCCESS)
3083  return ret;
3084  }
3085 
3086  /* Try to open the device instance key */
3087  RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3088 
3089  if (ulFlags & CM_CREATE_DEVNODE_PHANTOM)
3090  {
3091  /* Fail, if the device already exists */
3092  if (hKey != NULL)
3093  {
3095  goto done;
3096  }
3097 
3098  /* Create the phantom device instance */
3099  ret = CreateDeviceInstance(pszDeviceID, TRUE);
3100  }
3101  else
3102  {
3103  /* Fail, if the device exists and is present */
3104  if ((hKey != NULL) && (IsPresentDeviceInstanceID(pszDeviceID)))
3105  {
3107  goto done;
3108  }
3109 
3110  /* If it does not already exist ... */
3111  if (hKey == NULL)
3112  {
3113  /* Create the device instance */
3114  ret = CreateDeviceInstance(pszDeviceID, FALSE);
3115 
3116  /* Open the device instance key */
3117  RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3118  }
3119 
3120  /* Create a device node for the device */
3121  RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceID);
3123  &ControlData,
3124  sizeof(ControlData));
3125  if (!NT_SUCCESS(Status))
3126  {
3127  ret = CR_FAILURE;
3128  goto done;
3129  }
3130 
3131  /* If the device is a phantom device, turn it into a normal device */
3132  if (hKey != NULL)
3133  {
3134  dwPhantom = 0;
3135  dwSize = sizeof(DWORD);
3136  RegQueryValueEx(hKey, L"Phantom", NULL, NULL, (PBYTE)&dwPhantom, &dwSize);
3137 
3138  if (dwPhantom != 0)
3139  RegDeleteValue(hKey, L"Phantom");
3140  }
3141  }
3142 
3143 done:
3144  if (hKey)
3145  RegCloseKey(hKey);
3146 
3147  DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
3148 
3149  return ret;
3150 }
#define RegQueryValueEx
Definition: winreg.h:524
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define CM_CREATE_DEVNODE_GENERATE_ID
Definition: cfgmgr32.h:622
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static BOOL IsPresentDeviceInstanceID(_In_ LPWSTR pszDeviceInstanceID)
Definition: rpcserver.c:418
#define CM_CREATE_DEVNODE_BITS
Definition: cfgmgr32.h:624
Status
Definition: gdiplustypes.h:24
#define KEY_WRITE
Definition: nt_native.h:1031
#define RegDeleteValue
Definition: winreg.h:508
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CR_FAILURE
Definition: cfgmgr32.h:865
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:406
int ret
#define CM_CREATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:621
static CONFIGRET CreateDeviceInstance(_In_ LPWSTR pszDeviceID, _In_ BOOL bPhantomDevice)
Definition: rpcserver.c:2882
#define RegOpenKeyEx
Definition: winreg.h:520
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
static CONFIGRET GenerateDeviceID(_Inout_ LPWSTR pszDeviceID, _In_ PNP_RPC_STRING_LEN ulLength)
Definition: rpcserver.c:3002
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT
Definition: sndvol32.h:71
BYTE * PBYTE
Definition: pedump.c:66
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by CM_Create_DevNode_ExW().

◆ PNP_CreateKey()

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

Definition at line 2296 of file rpcserver.c.

2301 {
2302  HKEY hDeviceKey = NULL, hParametersKey = NULL;
2303  DWORD dwError;
2305 
2307  UNREFERENCED_PARAMETER(samDesired);
2308 
2309  DPRINT("PNP_CreateKey(%p %S 0x%lx 0x%08lx)\n",
2310  hBinding, pszSubKey, samDesired, ulFlags);
2311 
2312  if (ulFlags != 0)
2313  return CR_INVALID_FLAG;
2314 
2315  if (!IsValidDeviceInstanceID(pszSubKey))
2316  return CR_INVALID_DEVINST;
2317 
2318  dwError = RegOpenKeyExW(hEnumKey,
2319  pszSubKey,
2320  0,
2321  KEY_WRITE,
2322  &hDeviceKey);
2323  if (dwError != ERROR_SUCCESS)
2324  {
2326  goto done;
2327  }
2328 
2329  dwError = RegCreateKeyExW(hDeviceKey,
2330  L"Device Parameters",
2331  0,
2332  NULL,
2335  NULL,
2336  &hParametersKey,
2337  NULL);
2338  if (dwError != ERROR_SUCCESS)
2339  {
2341  goto done;
2342  }
2343 
2344  /* FIXME: Set key security */
2345 
2346 done:
2347  if (hParametersKey != NULL)
2348  RegCloseKey(hParametersKey);
2349 
2350  if (hDeviceKey != NULL)
2351  RegCloseKey(hDeviceKey);
2352 
2353  return ret;
2354 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#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:317
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
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:1091
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

◆ PNP_DeleteClassKey()

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

Definition at line 2478 of file rpcserver.c.

2482 {
2484 
2486 
2487  DPRINT("PNP_DeleteClassKey(%p %S 0x%08lx)\n",
2488  hBinding, pszClassGuid, ulFlags);
2489 
2490  if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
2491  {
2492  if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2494  }
2495  else
2496  {
2497  if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2499  }
2500 
2501  DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
2502 
2503  return ret;
2504 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CM_DELETE_CLASS_SUBKEYS
Definition: cfgmgr32.h:635
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
#define CR_SUCCESS
Definition: cfgmgr32.h:842
HKEY hClassKey
Definition: umpnpmgr.c:45
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT
Definition: sndvol32.h:71
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

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 2360 of file rpcserver.c.

2366 {
2367  UNIMPLEMENTED;
2368  return CR_CALL_NOT_IMPLEMENTED;
2369 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by CM_Delete_DevNode_Key_Ex().

◆ PNP_DeleteServiceDevices()

DWORD WINAPI PNP_DeleteServiceDevices ( handle_t  hBinding)

Definition at line 5001 of file rpcserver.c.

5003 {
5004  UNIMPLEMENTED;
5005  return CR_CALL_NOT_IMPLEMENTED;
5006 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ 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 4511 of file rpcserver.c.

4519 {
4520  DPRINT("PNP_DetectResourceConflict()\n");
4521 
4522  if (pbConflictDetected != NULL)
4523  *pbConflictDetected = FALSE;
4524 
4525  return CR_CALL_NOT_IMPLEMENTED;
4526 }
#define FALSE
Definition: types.h:117
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define NULL
Definition: types.h:112
#define DPRINT
Definition: sndvol32.h:71

◆ PNP_DeviceInstanceAction()

DWORD WINAPI PNP_DeviceInstanceAction ( handle_t  hBinding,
DWORD  ulMajorAction,
DWORD  ulMinorAction,
LPWSTR  pszDeviceInstance1,
LPWSTR  pszDeviceInstance2 
)

Definition at line 3292 of file rpcserver.c.

3298 {
3300 
3302 
3303  DPRINT("PNP_DeviceInstanceAction(%p %lu 0x%08lx %S %S)\n",
3304  hBinding, ulMajorAction, ulMinorAction,
3305  pszDeviceInstance1, pszDeviceInstance2);
3306 
3307  switch (ulMajorAction)
3308  {
3309  case PNP_DEVINST_SETUP:
3310  ret = SetupDeviceInstance(pszDeviceInstance1,
3311  ulMinorAction);
3312  break;
3313 
3314  case PNP_DEVINST_ENABLE:
3315  ret = EnableDeviceInstance(pszDeviceInstance1);
3316  break;
3317 
3318  case PNP_DEVINST_REENUMERATE:
3319  ret = ReenumerateDeviceInstance(pszDeviceInstance1,
3320  ulMinorAction);
3321  break;
3322 
3323  default:
3324  DPRINT1("Unknown device action %lu: not implemented\n", ulMajorAction);
3326  }
3327 
3328  DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
3329 
3330  return ret;
3331 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
static CONFIGRET SetupDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
Definition: rpcserver.c:3154
#define CR_SUCCESS
Definition: cfgmgr32.h:842
static CONFIGRET EnableDeviceInstance(_In_ LPWSTR pszDeviceInstance)
Definition: rpcserver.c:3237
int ret
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
static CONFIGRET ReenumerateDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulMinorAction)
Definition: rpcserver.c:3256
#define DPRINT
Definition: sndvol32.h:71

Referenced by 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 3468 of file rpcserver.c.

3475 {
3477 
3478  DPRINT1("PNP_DisableDevInst(%p %S %p %p %lu 0x%08lx)\n",
3479  hBinding, pDeviceID, pVetoType, pszVetoName, ulNameLength, ulFlags);
3480 
3481  if (ulFlags & ~CM_DISABLE_BITS)
3482  return CR_INVALID_FLAG;
3483 
3484  if (!IsValidDeviceInstanceID(pDeviceID) ||
3485  IsRootDeviceInstanceID(pDeviceID))
3486  return CR_INVALID_DEVINST;
3487 
3488  return DisableDeviceInstance(pDeviceID,
3489  pVetoType,
3490  pszVetoName,
3491  ulNameLength);
3492 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
#define CM_DISABLE_BITS
Definition: cfgmgr32.h:652
static CONFIGRET DisableDeviceInstance(_In_ LPWSTR pszDeviceInstance, _Inout_opt_ PPNP_VETO_TYPE pVetoType, _Inout_opt_ LPWSTR pszVetoName, _In_ DWORD ulNameLength)
Definition: rpcserver.c:294
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:406
#define DPRINT1
Definition: precomp.h:8

Referenced by CM_Disable_DevNode_Ex().

◆ PNP_Disconnect()

DWORD WINAPI PNP_Disconnect ( handle_t  hBinding)

Definition at line 566 of file rpcserver.c.

568 {
570  return CR_SUCCESS;
571 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CR_SUCCESS
Definition: cfgmgr32.h:842

◆ PNP_DriverStoreAddDriverPackage()

DWORD WINAPI PNP_DriverStoreAddDriverPackage ( handle_t  hBinding)

Definition at line 4955 of file rpcserver.c.

4957 {
4958  UNIMPLEMENTED;
4959  return CR_CALL_NOT_IMPLEMENTED;
4960 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ PNP_DriverStoreDeleteDriverPackage()

DWORD WINAPI PNP_DriverStoreDeleteDriverPackage ( handle_t  hBinding)

Definition at line 4966 of file rpcserver.c.

4968 {
4969  UNIMPLEMENTED;
4970  return CR_CALL_NOT_IMPLEMENTED;
4971 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ 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 851 of file rpcserver.c.

859 {
861  HKEY hKey;
862  DWORD dwError;
863 
865  UNREFERENCED_PARAMETER(ulFlags);
866 
867  DPRINT("PNP_EnumerateSubKeys(%p %lu %lu %p %lu %p 0x%08lx)\n",
868  hBinding, ulBranch, ulIndex, Buffer, ulLength,
869  pulRequiredLen, ulFlags);
870 
871  switch (ulBranch)
872  {
873  case PNP_ENUMERATOR_SUBKEYS:
874  hKey = hEnumKey;
875  break;
876 
877  case PNP_CLASS_SUBKEYS:
878  hKey = hClassKey;
879  break;
880 
881  default:
882  return CR_FAILURE;
883  }
884 
885  *pulRequiredLen = ulLength;
886  dwError = RegEnumKeyExW(hKey,
887  ulIndex,
888  Buffer,
889  pulRequiredLen,
890  NULL,
891  NULL,
892  NULL,
893  NULL);
894  if (dwError != ERROR_SUCCESS)
895  {
897  }
898  else
899  {
900  (*pulRequiredLen)++;
901  }
902 
903  DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
904 
905  return ret;
906 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_SUCCESS
Definition: cfgmgr32.h:842
HKEY hClassKey
Definition: umpnpmgr.c:45
Definition: bufpool.h:45
#define CR_FAILURE
Definition: cfgmgr32.h:865
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
ULONG ulIndex
Definition: symbols.c:92
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
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:2527
#define DPRINT
Definition: sndvol32.h:71

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 4102 of file rpcserver.c.

4108 {
4109  UNIMPLEMENTED;
4110  return CR_CALL_NOT_IMPLEMENTED;
4111 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

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 4341 of file rpcserver.c.

4351 {
4352  UNIMPLEMENTED;
4353  return CR_CALL_NOT_IMPLEMENTED;
4354 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

◆ 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 4835 of file rpcserver.c.

4841 {
4842  UNIMPLEMENTED;
4843  return CR_CALL_NOT_IMPLEMENTED;
4844 }
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define UNIMPLEMENTED
Definition: debug.h:115

Referenced by CMP_GetBlockedDriverInfo().

◆ PNP_GetClassCount()

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

Definition at line 2375 of file rpcserver.c.

2379 {
2380  HKEY hKey;
2381  DWORD dwError;
2382 
2384  UNREFERENCED_PARAMETER(ulFlags);
2385 
2386  DPRINT("PNP_GetClassCount(%p %p 0x%08lx)\n",
2387  hBinding, pulClassCount, ulFlags);
2388 
2391  0,
2393  &hKey);
2394  if (dwError != ERROR_SUCCESS)
2395  return CR_INVALID_DATA;
2396 
2397  dwError = RegQueryInfoKeyW(hKey,
2398  NULL,
2399  NULL,
2400  NULL,
2401  pulClassCount,
2402  NULL,
2403  NULL,
2404  NULL,
2405  NULL,
2406  NULL,
2407  NULL,
2408  NULL);
2409  RegCloseKey(hKey);
2410  if (dwError != ERROR_SUCCESS)
2411  return CR_INVALID_DATA;
2412 
2413  return CR_SUCCESS;
2414 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define CR_SUCCESS
Definition: cfgmgr32.h:842
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:3690
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
#define REGSTR_PATH_CLASS
Definition: regstr.h:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 2180 of file rpcserver.c.

2185 {
2186  WCHAR szClassGuid[40];
2187  WCHAR szClassInstance[5];
2188  HKEY hDeviceClassKey = NULL;
2189  HKEY hClassInstanceKey;
2190  ULONG ulTransferLength, ulDataLength;
2191  DWORD dwDataType, dwDisposition, i;
2192  DWORD dwError;
2194 
2195  DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
2196  hBinding, pDeviceId, pszClassInstance, ulLength);
2197 
2198  if (!IsValidDeviceInstanceID(pDeviceId))
2199  return CR_INVALID_DEVINST;
2200 
2201  ulTransferLength = ulLength;
2203  pDeviceId,
2204  CM_DRP_DRIVER,
2205  &dwDataType,
2206  (BYTE *)pszClassInstance,
2207  &ulTransferLength,
2208  &ulLength,
2209  0);
2210  if (ret == CR_SUCCESS)
2211  return ret;
2212 
2213  ulTransferLength = sizeof(szClassGuid);
2214  ulDataLength = sizeof(szClassGuid);
2216  pDeviceId,
2218  &dwDataType,
2219  (BYTE *)szClassGuid,
2220  &ulTransferLength,
2221  &ulDataLength,
2222  0);
2223  if (ret != CR_SUCCESS)
2224  {
2225  DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret);
2226  goto done;
2227  }
2228 
2229  dwError = RegOpenKeyExW(hClassKey,
2230  szClassGuid,
2231  0,
2232  KEY_READ,
2233  &hDeviceClassKey);
2234  if (dwError != ERROR_SUCCESS)
2235  {
2236  DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError);
2237  ret = CR_FAILURE;
2238  goto done;
2239  }
2240 
2241  for (i = 0; i < 10000; i++)
2242  {
2243  wsprintf(szClassInstance, L"%04lu", i);
2244 
2245  dwError = RegCreateKeyExW(hDeviceClassKey,
2246  szClassInstance,
2247  0,
2248  NULL,
2251  NULL,
2252  &hClassInstanceKey,
2253  &dwDisposition);
2254  if (dwError == ERROR_SUCCESS)
2255  {
2256  RegCloseKey(hClassInstanceKey);
2257 
2258  if (dwDisposition == REG_CREATED_NEW_KEY)
2259  {
2260  wsprintf(pszClassInstance,
2261  L"%s\\%s",
2262  szClassGuid,
2263  szClassInstance);
2264 
2265  ulDataLength = (wcslen(pszClassInstance) + 1) * sizeof(WCHAR);
2267  pDeviceId,
2268  CM_DRP_DRIVER,
2269  REG_SZ,
2270  (BYTE *)pszClassInstance,
2271  ulDataLength,
2272  0);
2273  if (ret != CR_SUCCESS)
2274  {
2275  DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret);
2276  RegDeleteKeyW(hDeviceClassKey,
2277  szClassInstance);
2278  }
2279 
2280  break;
2281  }
2282  }
2283  }
2284 
2285 done:
2286  if (hDeviceClassKey != NULL)
2287  RegCloseKey(hDeviceClassKey);
2288 
2289  return ret;
2290 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
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:1091
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: rpcserver.c:1761
#define L(x)
Definition: ntvdm.h:50
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
HKEY hClassKey
Definition: umpnpmgr.c:45
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_FAILURE
Definition: cfgmgr32.h:865
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CM_DRP_DRIVER
Definition: cfgmgr32.h:685
int ret
unsigned char BYTE
Definition: xxhash.c:193
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define DPRINT
Definition: sndvol32.h:71
#define wsprintf
Definition: winuser.h:5855
DWORD WINAPI PNP_SetDeviceRegProp(handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
Definition: rpcserver.c:2038
#define RegCloseKey(hKey)
Definition: registry.h:47
#define REG_SZ
Definition: layer.c:22

Referenced by GetDeviceInstanceKeyPath().

◆ PNP_GetClassName()

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

Definition at line 2420 of file rpcserver.c.

2426 {
2427  WCHAR szKeyName[MAX_PATH];
2429  HKEY hKey;
2430  DWORD dwSize;
2431 
2433  UNREFERENCED_PARAMETER(ulFlags);
2434 
2435  DPRINT("PNP_GetClassName(%p %S %p %p 0x%08lx)\n",
2436  hBinding, pszClassGuid, Buffer, pulLength, ulFlags);
2437 
2438  lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
2439  if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
2440  lstrcatW(szKeyName, pszClassGuid);
2441  else
2442  return CR_INVALID_DATA;
2443 
2445  szKeyName,
2446  0,
2448  &hKey))
2449  return CR_REGISTRY_ERROR;
2450 
2451  dwSize = *pulLength * sizeof(WCHAR);
2452  if (RegQueryValueExW(hKey,
2453  L"Class",
2454  NULL,
2455  NULL,
2456  (LPBYTE)Buffer,
2457  &dwSize))
2458  {
2459  *pulLength = 0;
2461  }
2462  else
2463  {
2464  *pulLength = dwSize / sizeof(WCHAR);
2465  }
2466 
2467  RegCloseKey(hKey);
2468 
2469  DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
2470 
2471  return ret;
2472 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define lstrlenW
Definition: compat.h:750
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CR_SUCCESS
Definition: cfgmgr32.h:842
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:4120
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
int ret
#define lstrcpyW
Definition: compat.h:749
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define NULL
Definition: types.h:112
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#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 2653 of file rpcserver.c.

2662 {
2664  LPWSTR lpValueName = NULL;
2665  HKEY hInstKey = NULL;
2666  HKEY hPropKey = NULL;
2667  LONG lError;
2668 
2670 
2671  DPRINT("PNP_GetClassRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
2672  hBinding, pszClassGuid, ulProperty, pulRegDataType,
2673  Buffer, pulTransferLen, pulLength, ulFlags);
2674 
2675  if (pulTransferLen == NULL || pulLength == NULL)
2676  {
2678  goto done;
2679  }
2680 
2681  if (ulFlags != 0)
2682  {
2683  ret = CR_INVALID_FLAG;
2684  goto done;
2685  }
2686 
2687  if (*pulLength < *pulTransferLen)
2688  *pulLength = *pulTransferLen;
2689 
2690  *pulTransferLen = 0;
2691 
2692  switch (ulProperty)
2693  {
2694  case CM_CRP_SECURITY:
2695  lpValueName = L"Security";
2696  break;
2697 
2698  case CM_CRP_DEVTYPE:
2699  lpValueName = L"DeviceType";
2700  break;
2701 
2702  case CM_CRP_EXCLUSIVE:
2703  lpValueName = L"Exclusive";
2704  break;
2705 
2707  lpValueName = L"DeviceCharacteristics";
2708  break;
2709 
2710  default:
2712  goto done;
2713  }
2714 
2715  DPRINT("Value name: %S\n", lpValueName);
2716 
2717  lError = RegOpenKeyExW(hClassKey,
2718  pszClassGuid,
2719  0,
2720  KEY_READ,
2721  &hInstKey);
2722  if (lError != ERROR_SUCCESS)
2723  {
2724  *pulLength = 0;
2726  goto done;
2727  }
2728 
2729  lError = RegOpenKeyExW(hInstKey,
2730  L"Properties",
2731  0,
2732  KEY_READ,
2733  &hPropKey);
2734  if (lError != ERROR_SUCCESS)
2735  {
2736  *pulLength = 0;
2738  goto done;
2739  }
2740 
2741  lError = RegQueryValueExW(hPropKey,
2742  lpValueName,
2743  NULL,
2744  pulRegDataType,
2745  Buffer,
2746  pulLength);
2747  if (lError != ERROR_SUCCESS)
2748  {
2749  if (lError == ERROR_MORE_DATA)
2750  {
2751  ret = CR_BUFFER_SMALL;
2752  }
2753  else
2754  {
2755  *pulLength = 0;
2757  }
2758  }
2759 
2760 done:
2761  if (ret == CR_SUCCESS)
2762  *pulTransferLen = *pulLength;
2763 
2764  if (hPropKey != NULL)
2765  RegCloseKey(hPropKey);
2766 
2767  if (hInstKey != NULL)
2768  RegCloseKey(hInstKey);
2769 
2770  DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
2771 
2772  return ret;
2773 }
#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:317
#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
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define CM_CRP_EXCLUSIVE
Definition: cfgmgr32.h:712
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
HKEY hClassKey
Definition: umpnpmgr.c:45
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:4120
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
int ret
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define NULL
Definition: types.h:112
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:3356
#define DPRINT
Definition: sndvol32.h:71
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define RegCloseKey(hKey)
Definition: registry.h:47

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 4722 of file rpcserver.c.

4731 {
4732  HKEY hDeviceKey = NULL;
4733  HKEY hParamKey = NULL;
4734  LONG lError;
4736 
4738 
4739  DPRINT("PNP_GetCustomDevProp() called\n");
4740 
4741  if (pulTransferLen == NULL || pulLength == NULL)
4742  {
4744  goto done;
4745  }
4746 
4747  if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
4748  {
4749  ret = CR_INVALID_FLAG;
4750  goto done;
4751  }
4752 
4753  if (!IsValidDeviceInstanceID(pDeviceID))
4754  return CR_INVALID_DEVINST;
4755 
4756  if (*pulLength < *pulTransferLen)
4757  *pulLength = *pulTransferLen;
4758 
4759  *pulTransferLen = 0;
4760 
4761  lError = RegOpenKeyExW(hEnumKey,
4762  pDeviceID,
4763  0,
4764  KEY_READ,
4765  &hDeviceKey);
4766  if (lError != ERROR_SUCCESS)
4767  {
4769  goto done;
4770  }
4771 
4772  lError = RegOpenKeyExW(hDeviceKey,
4773  L"Device Parameters",
4774  0,
4775  KEY_READ,
4776  &hParamKey);
4777  if (lError != ERROR_SUCCESS)
4778  {
4780  goto done;
4781  }
4782 
4783  lError = RegQueryValueExW(hParamKey,
4784  CustomPropName,
4785  NULL,
4786  pulRegDataType,
4787  Buffer,
4788  pulLength);
4789  if (lError != ERROR_SUCCESS)
4790  {
4791  if (lError == ERROR_MORE_DATA)
4792  {
4793  ret = CR_BUFFER_SMALL;
4794  }
4795  else
4796  {
4797  *pulLength = 0;
4799  }
4800  }
4801 
4802 done:
4803  if (ret == CR_SUCCESS)
4804  *pulTransferLen = *pulLength;
4805 
4806  if (hParamKey != NULL)
4807  RegCloseKey(hParamKey);
4808 
4809  if (hDeviceKey != NULL)
4810  RegCloseKey(hDeviceKey);
4811 
4812  DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
4813 
4814  return ret;
4815 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#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:317
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
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:4120
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define CM_CUSTOMDEVPROP_BITS
Definition: cfgmgr32.h:836
#define NULL
Definition: types.h:112
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:3356
#define DPRINT
Definition: sndvol32.h:71
#define RegCloseKey(hKey)
Definition: registry.h:47
#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 1718 of file rpcserver.c.

1723 {
1724  PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
1726  NTSTATUS Status;
1727 
1729  UNREFERENCED_PARAMETER(ulFlags);
1730 
1731  DPRINT("PNP_GetDepth(%p %S %p 0x%08lx)\n",
1732  hBinding, pszDeviceID, pulDepth, ulFlags);
1733 
1734  if (!IsValidDeviceInstanceID(pszDeviceID))
1735  return CR_INVALID_DEVINST;
1736 
1737  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1738  pszDeviceID);
1739 
1741  (PVOID)&PlugPlayData,
1742  sizeof(PLUGPLAY_CONTROL_DEPTH_DATA));
1743  if (NT_SUCCESS(Status))
1744  {
1745  *pulDepth = PlugPlayData.Depth;
1746  }
1747  else
1748  {
1750  }
1751 
1752  DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
1753 
1754  return ret;
1755 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#define CR_SUCCESS
Definition: cfgmgr32.h:842
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int ret
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:534

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 1272 of file rpcserver.c.

1278 {
1279  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1280  WCHAR szDevice[MAX_DEVICE_ID_LEN];
1281  WCHAR szInstance[MAX_DEVICE_ID_LEN];
1283 
1284  DPRINT("PNP_GetDeviceList(%p %S %p %p 0x%08lx)\n",
1285  hBinding, pszFilter, Buffer, pulLength, ulFlags);
1286 
1287  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1288  return CR_INVALID_FLAG;
1289 
1290  if (pulLength == NULL)
1291  return CR_INVALID_POINTER;
1292 
1293  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1294  (pszFilter == NULL))
1295  return CR_INVALID_POINTER;
1296 
1297  if (ulFlags &
1302  {
1303  ret = GetRelationsInstanceList(pszFilter,
1304  ulFlags,
1305  Buffer,
1306  pulLength);
1307  }
1308  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1309  {
1310  ret = GetServiceInstanceList(pszFilter,
1311  Buffer,
1312  pulLength);
1313  }
1314  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1315  {
1316  SplitDeviceInstanceID(pszFilter,
1317  szEnumerator,
1318  szDevice,
1319  szInstance);
1320 
1321  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1322  {
1323  ret = GetDeviceInstanceList(pszFilter,
1324  Buffer,
1325  pulLength);
1326  }
1327  else
1328  {
1329  ret = GetEnumeratorInstanceList(pszFilter,
1330  Buffer,
1331  pulLength);
1332  }
1333  }
1334  else /* CM_GETIDLIST_FILTER_NONE */
1335  {
1337  pulLength);
1338  }
1339 
1340  return ret;
1341 }
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: rpcserver.c:153
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
static CONFIGRET GetAllInstanceList(_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1223
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1152
#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
Definition: bufpool.h:45
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
__wchar_t WCHAR
Definition: xmlstorage.h:180
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1081
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
#define NULL
Definition: types.h:112
#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 GetServiceInstanceList(_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:962
#define DPRINT
Definition: sndvol32.h:71
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669
static CONFIGRET GetRelationsInstanceList(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:911

Referenced by CM_Get_Device_ID_List_ExW(), and DeviceInstallThread().

◆ PNP_GetDeviceListSize()

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

Definition at line 1643 of file rpcserver.c.

1648 {
1649  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1650  WCHAR szDevice[MAX_DEVICE_ID_LEN];
1651  WCHAR szInstance[MAX_DEVICE_ID_LEN];
1653 
1654  DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%08lx)\n",
1655  hBinding, pszFilter, pulLength, ulFlags);
1656 
1657  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1658  return CR_INVALID_FLAG;
1659 
1660  if (pulLength == NULL)
1661  return CR_INVALID_POINTER;
1662 
1663  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1664  (pszFilter == NULL))
1665  return CR_INVALID_POINTER;
1666 
1667  *pulLength = 0;
1668 
1669  if (ulFlags &
1674  {
1675  ret = GetRelationsInstanceListSize(pszFilter,
1676  ulFlags,
1677  pulLength);
1678  }
1679  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1680  {
1681  ret = GetServiceInstanceListSize(pszFilter,
1682  pulLength);
1683  }
1684  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1685  {
1686  SplitDeviceInstanceID(pszFilter,
1687  szEnumerator,
1688  szDevice,
1689  szInstance);
1690 
1691  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1692  {
1693  ret = GetDeviceInstanceListSize(pszFilter,
1694  pulLength);
1695  }
1696  else
1697  {
1698  ret = GetEnumeratorInstanceListSize(pszFilter,
1699  pulLength);
1700  }
1701  }
1702  else /* CM_GETIDLIST_FILTER_NONE */
1703  {
1704  ret = GetAllInstanceListSize(pulLength);
1705  }
1706 
1707  /* Add one character for the terminating double UNICODE_NULL */
1708  if (ret == CR_SUCCESS)
1709  (*pulLength) += 1;
1710 
1711  return ret;
1712 }
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: rpcserver.c:153
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
static CONFIGRET GetServiceInstanceListSize(_In_ PWSTR pszService, _Out_ PDWORD pulLength)
Definition: rpcserver.c:1396
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
static CONFIGRET GetAllInstanceListSize(_Out_ PULONG pulLength)
Definition: rpcserver.c:1608
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1495
#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
static CONFIGRET GetRelationsInstanceListSize(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1346
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1547
#define NULL
Definition: types.h:112
#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 DPRINT
Definition: sndvol32.h:71
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669

Referenced by CM_Get_Device_ID_List_Size_ExW(), and DeviceInstallThread().

◆ 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 1761 of file rpcserver.c.

1770 {
1771  PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
1773  LPWSTR lpValueName = NULL;
1774  HKEY hKey = NULL;
1775  LONG lError;
1776  NTSTATUS Status;
1777 
1779 
1780  DPRINT("PNP_GetDeviceRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
1781  hBinding, pDeviceID, ulProperty, pulRegDataType, Buffer,
1782  pulTransferLen, pulLength, ulFlags);
1783 
1784  if (pulTransferLen == NULL || pulLength == NULL)
1785  {
1787  goto done;
1788  }
1789 
1790  if (ulFlags != 0)
1791  {
1792  ret = CR_INVALID_FLAG;
1793  goto done;
1794  }
1795 
1796  /* Check pDeviceID */
1797  if (!IsValidDeviceInstanceID(pDeviceID))
1798  {
1800  goto done;
1801  }
1802 
1803  if (*pulLength < *pulTransferLen)
1804  *pulLength = *pulTransferLen;
1805 
1806  *pulTransferLen = 0;
1807 
1808  switch (ulProperty)
1809  {
1810  case CM_DRP_DEVICEDESC:
1811  lpValueName = L"DeviceDesc";
1812  break;
1813 
1814  case CM_DRP_HARDWAREID:
1815  lpValueName = L"HardwareID";
1816  break;
1817 
1818  case CM_DRP_COMPATIBLEIDS:
1819  lpValueName = L"CompatibleIDs";
1820  break;
1821 
1822  case CM_DRP_SERVICE:
1823  lpValueName = L"Service";
1824  break;
1825 
1826  case CM_DRP_CLASS:
1827  lpValueName = L"Class";
1828  break;
1829 
1830  case CM_DRP_CLASSGUID:
1831  lpValueName = L"ClassGUID";
1832  break;
1833 
1834  case CM_DRP_DRIVER:
1835  lpValueName = L"Driver";
1836  break;
1837 
1838  case CM_DRP_CONFIGFLAGS:
1839  lpValueName = L"ConfigFlags";
1840  break;
1841 
1842  case CM_DRP_MFG:
1843  lpValueName = L"Mfg";
1844  break;
1845 
1846  case CM_DRP_FRIENDLYNAME:
1847  lpValueName = L"FriendlyName";
1848  break;
1849 
1851  lpValueName = L"LocationInformation";
1852  break;
1853 
1856  *pulRegDataType = REG_SZ;
1857  break;
1858 
1859  case CM_DRP_CAPABILITIES:
1860  lpValueName = L"Capabilities";
1861  break;
1862 
1863  case CM_DRP_UI_NUMBER:
1864  PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
1865  break;
1866 
1867  case CM_DRP_UPPERFILTERS:
1868  lpValueName = L"UpperFilters";
1869  break;
1870 
1871  case CM_DRP_LOWERFILTERS:
1872  lpValueName = L"LowerFilters";
1873  break;
1874 
1875  case CM_DRP_BUSTYPEGUID:
1876  PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
1877  *pulRegDataType = REG_BINARY;
1878  break;
1879 
1880  case CM_DRP_LEGACYBUSTYPE:
1881  PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
1882  *pulRegDataType = REG_DWORD;
1883  break;
1884 
1885  case CM_DRP_BUSNUMBER:
1886  PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
1887  *pulRegDataType = REG_DWORD;
1888  break;
1889 
1891  PlugPlayData.Property = PNP_PROPERTY_ENUMERATOR_NAME;
1892  *pulRegDataType = REG_SZ;
1893  break;
1894 
1895  case CM_DRP_SECURITY:
1896  lpValueName = L"Security";
1897  break;
1898 
1899  case CM_DRP_DEVTYPE:
1900  lpValueName = L"DeviceType";
1901  break;
1902 
1903  case CM_DRP_EXCLUSIVE:
1904  lpValueName = L"Exclusive";
1905  break;
1906 
1908  lpValueName = L"DeviceCharacteristics";
1909  break;
1910 
1911  case CM_DRP_ADDRESS:
1912  PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
1913  *pulRegDataType = REG_DWORD;
1914  break;
1915 
1917  lpValueName = L"UINumberDescFormat";
1918  break;
1919 
1921  PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
1922  *pulRegDataType = REG_BINARY;
1923  break;
1924 
1925  case CM_DRP_REMOVAL_POLICY:
1926  PlugPlayData.Property = PNP_PROPERTY_REMOVAL_POLICY;
1927  *pulRegDataType = REG_DWORD;
1928  break;
1929 
1932  *pulRegDataType = REG_DWORD;
1933  break;
1934 
1936  lpValueName = L"RemovalPolicy";
1937  *pulRegDataType = REG_DWORD;
1938  break;
1939 
1940  case CM_DRP_INSTALL_STATE:
1941  PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
1942  *pulRegDataType = REG_DWORD;
1943  break;
1944 
1945 #if (WINVER >= _WIN32_WINNT_WS03)
1946  case CM_DRP_LOCATION_PATHS:
1947  PlugPlayData.Property = PNP_PROPERTY_LOCATION_PATHS;
1948  *pulRegDataType = REG_MULTI_SZ;
1949  break;
1950 #endif
1951 
1952 #if (WINVER >= _WIN32_WINNT_WIN7)
1954  PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
1955  *pulRegDataType = REG_SZ;
1956  break;
1957 #endif
1958 
1959  default:
1961  goto done;
1962  }
1963 
1964  DPRINT("Value name: %S\n", lpValueName);
1965 
1966  if (lpValueName)
1967  {
1968  /* Retrieve information from the Registry */
1969  lError = RegOpenKeyExW(hEnumKey,
1970  pDeviceID,
1971  0,
1973  &hKey);
1974  if (lError != ERROR_SUCCESS)
1975  {
1976  hKey = NULL;
1977  *pulLength = 0;
1979  goto done;
1980  }
1981 
1982  lError = RegQueryValueExW(hKey,
1983  lpValueName,
1984  NULL,
1985  pulRegDataType,
1986  Buffer,
1987  pulLength);
1988  if (lError != ERROR_SUCCESS)
1989  {
1990  if (lError == ERROR_MORE_DATA)
1991  {
1992  ret = CR_BUFFER_SMALL;
1993  }
1994  else
1995  {
1996  *pulLength = 0;
1998  }
1999  }
2000  }
2001  else
2002  {
2003  /* Retrieve information from the Device Node */
2004  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
2005  pDeviceID);
2006  PlugPlayData.Buffer = Buffer;
2007  PlugPlayData.BufferSize = *pulLength;
2008 
2010  (PVOID)&PlugPlayData,
2012  if (NT_SUCCESS(Status))
2013  {
2014  *pulLength = PlugPlayData.BufferSize;
2015  }
2016  else
2017  {
2019  }
2020  }
2021 
2022 done:
2023  if (pulTransferLen)
2024  *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
2025 
2026  if (hKey != NULL)
2027  RegCloseKey(hKey);
2028 
2029  DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
2030 
2031  return ret;
2032 }
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define REG_BINARY
Definition: nt_native.h:1496
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#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
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:124
#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
#define L(x)
Definition: ntvdm.h:50
#define CM_DRP_LOWERFILTERS
Definition: cfgmgr32.h:697
long LONG
Definition: pedump.c:60
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_ENUMERATOR_NAME
Definition: cfgmgr32.h:704
#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
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:507
Status
Definition: gdiplustypes.h:24
#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:4120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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
HKEY hEnumKey
Definition: umpnpmgr.c:44
#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
#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
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1376
#define CM_DRP_CHARACTERISTICS
Definition: cfgmgr32.h:713
FxAutoRegKey hKey
#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 NULL
Definition: types.h:112
#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:3356
#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_