ReactOS  0.4.15-dev-316-g938df97
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 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)
 
DWORD WINAPI PNP_Disconnect (handle_t hBinding)
 
DWORD WINAPI PNP_Connect (handle_t hBinding)
 
DWORD WINAPI PNP_GetVersion (handle_t hBinding, WORD *pVersion)
 
DWORD WINAPI PNP_GetGlobalState (handle_t hBinding, DWORD *pulState, DWORD ulFlags)
 
DWORD WINAPI PNP_InitDetection (handle_t hBinding)
 
DWORD WINAPI PNP_ReportLogOn (handle_t hBinding, BOOL Admin, DWORD ProcessId)
 
DWORD WINAPI PNP_ValidateDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_GetRootDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_GetRelatedDeviceInstance (handle_t hBinding, DWORD ulRelationship, LPWSTR pDeviceID, LPWSTR pRelatedDeviceId, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_EnumerateSubKeys (handle_t hBinding, DWORD ulBranch, DWORD ulIndex, LPWSTR Buffer, PNP_RPC_STRING_LEN ulLength, PNP_RPC_STRING_LEN *pulRequiredLen, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceList (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceList (_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceList (_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
CONFIGRET GetEnumeratorInstanceList (_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetAllInstanceList (_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
DWORD WINAPI PNP_GetDeviceList (handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceListSize (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceListSize (_In_ PWSTR pszService, _Out_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceListSize (_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
 
static CONFIGRET GetEnumeratorInstanceListSize (_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
 
static CONFIGRET GetAllInstanceListSize (_Out_ PULONG pulLength)
 
DWORD WINAPI PNP_GetDeviceListSize (handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDepth (handle_t hBinding, LPWSTR pszDeviceID, DWORD *pulDepth, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceID, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_PROP_SIZE *pulTransferLen, PNP_PROP_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassInstance (handle_t hBinding, LPWSTR pDeviceId, LPWSTR pszClassInstance, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_CreateKey (handle_t hBinding, LPWSTR pszSubKey, DWORD samDesired, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteRegistryKey (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentKey, LPWSTR pszChildKey, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassCount (handle_t hBinding, DWORD *pulClassCount, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassName (handle_t hBinding, LPWSTR pszClassGuid, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteClassKey (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceAlias (handle_t hBinding, LPWSTR pszInterfaceDevice, GUID *AliasInterfaceGuid, LPWSTR pszAliasInterfaceDevice, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceList (handle_t hBinding, GUID *InterfaceGuid, LPWSTR pszDeviceID, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceListSize (handle_t hBinding, PNP_RPC_BUFFER_SIZE *pulLen, GUID *InterfaceGuid, LPWSTR pszDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszDeviceID, GUID *InterfaceGuid, LPWSTR pszReference, LPWSTR pszSymLink, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_UnregisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszInterfaceDevice, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
static CONFIGRET CreateDeviceInstance (LPWSTR pszDeviceID)
 
DWORD WINAPI PNP_CreateDevInst (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentDeviceID, PNP_RPC_STRING_LEN ulLength, DWORD ulFlags)
 
static CONFIGRET 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, DWORD *pulNotify, DWORD ulUnknown8, DWORD *pulUnknown9)
 
DWORD WINAPI PNP_UnregisterNotification (handle_t hBinding, DWORD ulNotify)
 
DWORD WINAPI PNP_GetCustomDevProp (handle_t hBinding, LPWSTR pDeviceID, LPWSTR CustomPropName, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetVersionInternal (handle_t hBinding, WORD *pwVersion)
 
DWORD WINAPI PNP_GetBlockedDriverInfo (handle_t hBinding, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulTransferLen, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetServerSideDeviceInstallFlags (handle_t hBinding, DWORD *pulSSDIFlags, DWORD ulFlags)
 
DWORD WINAPI PNP_GetObjectPropKeys (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, PNP_PROP_COUNT *PropertyCount, PNP_PROP_COUNT *TransferLen, DEVPROPKEY *PropertyKeys, DWORD Flags)
 
DWORD WINAPI PNP_GetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PNP_PROP_SIZE *PropertySize, PNP_PROP_SIZE *TransferLen, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_SetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, PNP_PROP_SIZE PropertySize, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_InstallDevInst (handle_t hBinding)
 
DWORD WINAPI PNP_ApplyPowerSettings (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreAddDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreDeleteDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_RegisterServiceNotification (handle_t hBinding)
 
DWORD WINAPI PNP_SetActiveService (handle_t hBinding, LPWSTR pszFilter, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteServiceDevices (handle_t hBinding)
 

Variables

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

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

3273 {
3274  DWORD dwLen;
3275  DWORD dwPos;
3276 
3277  dwLen = wcslen(lpDeviceId);
3278  dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
3279 
3280  wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
3281 
3282  dwPos += (dwLen + 1);
3283 
3284  lpDeviceIdList[dwPos] = 0;
3285 
3286  *lpDeviceIdListSize = dwPos * sizeof(WCHAR);
3287 }
__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)
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 3249 of file rpcserver.c.

3251 {
3252  LPWSTR lpPtr;
3253  DWORD dwLength;
3254 
3255  lpPtr = lpDeviceIdList;
3256  while (*lpPtr != 0)
3257  {
3258  dwLength = wcslen(lpPtr);
3259  if (0 == _wcsicmp(lpPtr, lpDeviceId))
3260  return TRUE;
3261 
3262  lpPtr += (dwLength + 1);
3263  }
3264 
3265  return FALSE;
3266 }
#define TRUE
Definition: types.h:120
static DWORD DWORD * dwLength
Definition: fusion.c:85
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by PNP_AddID().

◆ ClearDeviceStatus()

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

Definition at line 196 of file rpcserver.c.

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

Referenced by SetupDeviceInstance().

◆ CreateDeviceInstance()

static CONFIGRET CreateDeviceInstance ( LPWSTR  pszDeviceID)
static

Definition at line 2818 of file rpcserver.c.

2819 {
2820  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
2821  WCHAR szDevice[MAX_DEVICE_ID_LEN];
2822  WCHAR szInstance[MAX_DEVICE_ID_LEN];
2823  HKEY hKeyEnumerator;
2824  HKEY hKeyDevice;
2825  HKEY hKeyInstance;
2826  HKEY hKeyControl;
2827  LONG lError;
2828 
2829  /* Split the instance ID */
2830  SplitDeviceInstanceID(pszDeviceID,
2831  szEnumerator,
2832  szDevice,
2833  szInstance);
2834 
2835  /* Open or create the enumerator key */
2836  lError = RegCreateKeyExW(hEnumKey,
2837  szEnumerator,
2838  0,
2839  NULL,
2842  NULL,
2843  &hKeyEnumerator,
2844  NULL);
2845  if (lError != ERROR_SUCCESS)
2846  {
2847  return CR_REGISTRY_ERROR;
2848  }
2849 
2850  /* Open or create the device key */
2851  lError = RegCreateKeyExW(hKeyEnumerator,
2852  szDevice,
2853  0,
2854  NULL,
2857  NULL,
2858  &hKeyDevice,
2859  NULL);
2860 
2861  /* Close the enumerator key */
2862  RegCloseKey(hKeyEnumerator);
2863 
2864  if (lError != ERROR_SUCCESS)
2865  {
2866  return CR_REGISTRY_ERROR;
2867  }
2868 
2869  /* Try to open the instance key and fail if it exists */
2870  lError = RegOpenKeyExW(hKeyDevice,
2871  szInstance,
2872  0,
2873  KEY_SET_VALUE,
2874  &hKeyInstance);
2875  if (lError == ERROR_SUCCESS)
2876  {
2877  DPRINT1("Instance %S already exists!\n", szInstance);
2878  RegCloseKey(hKeyInstance);
2879  RegCloseKey(hKeyDevice);
2880  return CR_ALREADY_SUCH_DEVINST;
2881  }
2882 
2883  /* Create a new instance key */
2884  lError = RegCreateKeyExW(hKeyDevice,
2885  szInstance,
2886  0,
2887  NULL,
2890  NULL,
2891  &hKeyInstance,
2892  NULL);
2893 
2894  /* Close the device key */
2895  RegCloseKey(hKeyDevice);
2896 
2897  if (lError != ERROR_SUCCESS)
2898  {
2899  return CR_REGISTRY_ERROR;
2900  }
2901 
2902  /* Create the 'Control' sub key */
2903  lError = RegCreateKeyExW(hKeyInstance,
2904  L"Control",
2905  0,
2906  NULL,
2909  NULL,
2910  &hKeyControl,
2911  NULL);
2912  if (lError == ERROR_SUCCESS)
2913  {
2914  RegCloseKey(hKeyControl);
2915  }
2916 
2917  RegCloseKey(hKeyInstance);
2918 
2919  return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
2920 }
#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:150
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
HKEY hEnumKey
Definition: umpnpmgr.c:44
static const WCHAR L[]
Definition: oid.c:1250
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define DPRINT1
Definition: precomp.h:8
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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 291 of file rpcserver.c.

296 {
297  PLUGPLAY_CONTROL_QUERY_REMOVE_DATA QueryRemoveData;
300 
301  DPRINT1("DisableDeviceInstance(%S %p %p %lu)\n",
302  pszDeviceInstance, pVetoType, pszVetoName, ulNameLength);
303 
304  RtlInitUnicodeString(&QueryRemoveData.DeviceInstance,
305  pszDeviceInstance);
306 
307  QueryRemoveData.Flags = 0;
308  QueryRemoveData.VetoType = 0;
309  QueryRemoveData.VetoName = pszVetoName;
310  QueryRemoveData.NameLength = ulNameLength;
311 
313  &QueryRemoveData,
316  {
318  }
320  {
321  if (pVetoType != NULL)
322  *pVetoType = QueryRemoveData.VetoType;
323 
325  }
326  else if (!NT_SUCCESS(Status))
327  {
329  }
330 
331  return ret;
332 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#define CR_REMOVE_VETOED
Definition: cfgmgr32.h:869
#define STATUS_PLUGPLAY_QUERY_VETOED
Definition: ntstatus.h:207
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#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
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
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 3068 of file rpcserver.c.

3070 {
3071  PLUGPLAY_CONTROL_RESET_DEVICE_DATA ResetDeviceData;
3073  NTSTATUS Status;
3074 
3075  DPRINT("Enable device instance %S\n", pszDeviceInstance);
3076 
3077  RtlInitUnicodeString(&ResetDeviceData.DeviceInstance,
3078  pszDeviceInstance);
3080  &ResetDeviceData,
3082  if (!NT_SUCCESS(Status))
3084 
3085  return ret;
3086 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by PNP_DeviceInstanceAction().

◆ GetAllInstanceList()

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

Definition at line 1173 of file rpcserver.c.

1176 {
1177  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1178  PWSTR pPtr;
1179  DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
1180  DWORD dwError;
1182 
1183  dwUsedLength = 0;
1184  dwRemainingLength = *pulLength;
1185  pPtr = pszBuffer;
1186 
1187  for (dwIndex = 0; ; dwIndex++)
1188  {
1189  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1190  dwError = RegEnumKeyExW(hEnumKey,
1191  dwIndex,
1192  szEnumeratorBuffer,
1193  &dwEnumeratorLength,
1194  NULL, NULL, NULL, NULL);
1195  if (dwError != ERROR_SUCCESS)
1196  break;
1197 
1198  dwPathLength = dwRemainingLength;
1199  ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
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  if (ret == CR_SUCCESS)
1211  *pulLength = dwUsedLength + 1;
1212  else
1213  *pulLength = 0;
1214 
1215  return ret;
1216 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:55
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1102
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527

Referenced by PNP_GetDeviceList().

◆ GetAllInstanceListSize()

static CONFIGRET GetAllInstanceListSize ( _Out_ PULONG  pulLength)
static

Definition at line 1558 of file rpcserver.c.

1560 {
1561  WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1562  DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
1563  DWORD dwError;
1565 
1566  for (dwIndex = 0; ; dwIndex++)
1567  {
1568  dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1569  dwError = RegEnumKeyExW(hEnumKey,
1570  dwIndex,
1571  szEnumeratorBuffer,
1572  &dwEnumeratorLength,
1573  NULL, NULL, NULL, NULL);
1574  if (dwError != ERROR_SUCCESS)
1575  break;
1576 
1577  /* Get the size of all device instances for the enumerator */
1578  ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
1579  &dwBufferLength);
1580  if (ret != CR_SUCCESS)
1581  break;
1582 
1583  *pulLength += dwBufferLength;
1584  }
1585 
1586  return ret;
1587 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1497
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 459 of file rpcserver.c.

465 {
466  LPCWSTR pszValueName;
467 
468  switch (ulLogConfType)
469  {
470  case BOOT_LOG_CONF:
471  pszValueName = L"BootConfig";
472  *pulRegDataType = REG_RESOURCE_LIST;
473  break;
474 
475  case ALLOC_LOG_CONF:
476  pszValueName = L"AllocConfig";
477  *pulRegDataType = REG_RESOURCE_LIST;
478  break;
479 
480  case FORCED_LOG_CONF:
481  pszValueName = L"ForcedConfig";
482  *pulRegDataType = REG_RESOURCE_LIST;
483  break;
484 
485  case FILTERED_LOG_CONF:
486  pszValueName = L"FilteredConfigVector";
487  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
488  break;
489 
490  case BASIC_LOG_CONF:
491  pszValueName = L"BasicConfigVector";
492  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
493  break;
494 
495  case OVERRIDE_LOG_CONF:
496  pszValueName = L"OverrideConfigVector";
497  *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
498  break;
499 
500  default:
501  DPRINT1("Unsupported configuration type!\n");
502  return CR_FAILURE;
503  }
504 
505  /* Get the configuration data size */
506  if (RegQueryValueExW(hKey,
507  pszValueName,
508  NULL,
509  NULL,
510  NULL,
511  pulDataSize) != ERROR_SUCCESS)
512  {
513  return CR_INVALID_LOG_CONF;
514  }
515 
516  /* Allocate the buffer */
517  *ppBuffer = HeapAlloc(GetProcessHeap(), 0, *pulDataSize);
518  if (*ppBuffer == NULL)
519  {
520  return CR_OUT_OF_MEMORY;
521  }
522 
523  /* Retrieve the configuration data */
524  if (RegQueryValueExW(hKey,
525  pszValueName,
526  NULL,
527  NULL,
528  (LPBYTE)*ppBuffer,
529  pulDataSize) != ERROR_SUCCESS)
530  {
531  return CR_INVALID_LOG_CONF;
532  }
533 
534  return CR_SUCCESS;
535 }
#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
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FILTERED_LOG_CONF
Definition: cfgmgr32.h:597
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#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:404
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:4116
#define CR_INVALID_LOG_CONF
Definition: cfgmgr32.h:850
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define BOOT_LOG_CONF
Definition: cfgmgr32.h:599
static const WCHAR L[]
Definition: oid.c:1250
#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 1031 of file rpcserver.c.

1035 {
1036  WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
1037  WCHAR szPathBuffer[512];
1038  HKEY hDeviceKey;
1039  DWORD dwInstanceLength, dwPathLength, dwUsedLength;
1040  DWORD dwIndex, dwError;
1041  PWSTR pPtr;
1043 
1044  /* Open the device key */
1045  dwError = RegOpenKeyExW(hEnumKey,
1046  pszDevice,
1047  0,
1049  &hDeviceKey);
1050  if (dwError != ERROR_SUCCESS)
1051  {
1052  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1053  return CR_REGISTRY_ERROR;
1054  }
1055 
1056  dwUsedLength = 0;
1057  pPtr = pszBuffer;
1058 
1059  for (dwIndex = 0; ; dwIndex++)
1060  {
1061  dwInstanceLength = MAX_DEVICE_ID_LEN;
1062  dwError = RegEnumKeyExW(hDeviceKey,
1063  dwIndex,
1064  szInstanceBuffer,
1065  &dwInstanceLength,
1066  NULL,
1067  NULL,
1068  NULL,
1069  NULL);
1070  if (dwError != ERROR_SUCCESS)
1071  break;
1072 
1073  wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
1074  DPRINT("Path: %S\n", szPathBuffer);
1075 
1076  dwPathLength = wcslen(szPathBuffer) + 1;
1077  if (dwUsedLength + dwPathLength + 1 > *pulLength)
1078  {
1079  ret = CR_BUFFER_SMALL;
1080  break;
1081  }
1082 
1083  wcscpy(pPtr, szPathBuffer);
1084  dwUsedLength += dwPathLength;
1085  pPtr += dwPathLength;
1086 
1087  *pPtr = UNICODE_NULL;
1088  }
1089 
1090  RegCloseKey(hDeviceKey);
1091 
1092  if (ret == CR_SUCCESS)
1093  *pulLength = dwUsedLength + 1;
1094  else
1095  *pulLength = 0;
1096 
1097  return ret;
1098 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:55
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__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)
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
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 wsprintf
Definition: winuser.h:5840
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019

Referenced by GetEnumeratorInstanceList(), and PNP_GetDeviceList().

◆ GetDeviceInstanceListSize()

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

Definition at line 1445 of file rpcserver.c.

1448 {
1449  HKEY hDeviceKey;
1450  DWORD dwSubKeys, dwMaxSubKeyLength;
1451  DWORD dwError;
1452 
1453  /* Open the device key */
1454  dwError = RegOpenKeyExW(hEnumKey,
1455  pszDevice,
1456  0,
1457  KEY_READ,
1458  &hDeviceKey);
1459  if (dwError != ERROR_SUCCESS)
1460  {
1461  DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1462  return CR_REGISTRY_ERROR;
1463  }
1464 
1465  /* Retrieve the number of device instances and the maximum name length */
1466  dwError = RegQueryInfoKeyW(hDeviceKey,
1467  NULL,
1468  NULL,
1469  NULL,
1470  &dwSubKeys,
1471  &dwMaxSubKeyLength,
1472  NULL,
1473  NULL,
1474  NULL,
1475  NULL,
1476  NULL,
1477  NULL);
1478  if (dwError != ERROR_SUCCESS)
1479  {
1480  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1481  dwSubKeys = 0;
1482  dwMaxSubKeyLength = 0;
1483  }
1484 
1485  /* Close the device key */
1486  RegCloseKey(hDeviceKey);
1487 
1488  /* Return the largest possible buffer size */
1489  *pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
1490 
1491  return CR_SUCCESS;
1492 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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:3686
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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 226 of file rpcserver.c.

230 {
231  PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
234 
235  DPRINT("GetDeviceStatus(%S %p %p)\n",
236  pszDeviceID, pulStatus, pulProblem);
237 
238  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
239  pszDeviceID);
240  PlugPlayData.Operation = PNP_GET_DEVICE_STATUS;
241 
243  (PVOID)&PlugPlayData,
245  if (NT_SUCCESS(Status))
246  {
247  *pulStatus = PlugPlayData.DeviceStatus;
248  *pulProblem = PlugPlayData.DeviceProblem;
249  }
250  else
251  {
253  }
254 
255  return ret;
256 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:513
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

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

◆ GetEnumeratorInstanceList()

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

Definition at line 1102 of file rpcserver.c.

1106 {
1107  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1108  WCHAR szPathBuffer[512];
1109  HKEY hEnumeratorKey;
1110  PWSTR pPtr;
1111  DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
1112  DWORD dwError;
1114 
1115  /* Open the enumerator key */
1116  dwError = RegOpenKeyExW(hEnumKey,
1117  pszEnumerator,
1118  0,
1120  &hEnumeratorKey);
1121  if (dwError != ERROR_SUCCESS)
1122  {
1123  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1124  return CR_REGISTRY_ERROR;
1125  }
1126 
1127  dwUsedLength = 0;
1128  dwRemainingLength = *pulLength;
1129  pPtr = pszBuffer;
1130 
1131  for (dwIndex = 0; ; dwIndex++)
1132  {
1133  dwDeviceLength = MAX_DEVICE_ID_LEN;
1134  dwError = RegEnumKeyExW(hEnumeratorKey,
1135  dwIndex,
1136  szDeviceBuffer,
1137  &dwDeviceLength,
1138  NULL,
1139  NULL,
1140  NULL,
1141  NULL);
1142  if (dwError != ERROR_SUCCESS)
1143  break;
1144 
1145  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1146  DPRINT("Path: %S\n", szPathBuffer);
1147 
1148  dwPathLength = dwRemainingLength;
1149  ret = GetDeviceInstanceList(szPathBuffer,
1150  pPtr,
1151  &dwPathLength);
1152  if (ret != CR_SUCCESS)
1153  break;
1154 
1155  dwUsedLength += dwPathLength - 1;
1156  dwRemainingLength += dwPathLength - 1;
1157  pPtr += dwPathLength - 1;
1158  }
1159 
1160  RegCloseKey(hEnumeratorKey);
1161 
1162  if (ret == CR_SUCCESS)
1163  *pulLength = dwUsedLength + 1;
1164  else
1165  *pulLength = 0;
1166 
1167  return ret;
1168 }
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:55
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1031
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
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 wsprintf
Definition: winuser.h:5840
#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 1497 of file rpcserver.c.

1500 {
1501  WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1502  WCHAR szPathBuffer[512];
1503  HKEY hEnumeratorKey;
1504  DWORD dwIndex, dwDeviceLength, dwBufferLength;
1505  DWORD dwError;
1507 
1508  *pulLength = 0;
1509 
1510  /* Open the enumerator key */
1511  dwError = RegOpenKeyExW(hEnumKey,
1512  pszEnumerator,
1513  0,
1515  &hEnumeratorKey);
1516  if (dwError != ERROR_SUCCESS)
1517  {
1518  DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1519  return CR_REGISTRY_ERROR;
1520  }
1521 
1522  for (dwIndex = 0; ; dwIndex++)
1523  {
1524  dwDeviceLength = MAX_DEVICE_ID_LEN;
1525  dwError = RegEnumKeyExW(hEnumeratorKey,
1526  dwIndex,
1527  szDeviceBuffer,
1528  &dwDeviceLength,
1529  NULL,
1530  NULL,
1531  NULL,
1532  NULL);
1533  if (dwError != ERROR_SUCCESS)
1534  break;
1535 
1536  wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1537  DPRINT("Path: %S\n", szPathBuffer);
1538 
1539  ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
1540  if (ret != CR_SUCCESS)
1541  {
1542  *pulLength = 0;
1543  break;
1544  }
1545 
1546  *pulLength += dwBufferLength;
1547  }
1548 
1549  /* Close the enumerator key */
1550  RegCloseKey(hEnumeratorKey);
1551 
1552  return ret;
1553 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1445
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
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 wsprintf
Definition: winuser.h:5840
#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 861 of file rpcserver.c.

866 {
870 
871  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
872  pszDevice);
873 
874  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
875  {
876  PlugPlayData.Relations = 3;
877  }
878  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
879  {
880  PlugPlayData.Relations = 2;
881  }
882  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
883  {
884  PlugPlayData.Relations = 1;
885  }
886  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
887  {
888  PlugPlayData.Relations = 0;
889  }
890 
891  PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
892  PlugPlayData.Buffer = pszBuffer;
893 
895  (PVOID)&PlugPlayData,
897  if (NT_SUCCESS(Status))
898  {
899  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
900  }
901  else
902  {
904  }
905 
906  return ret;
907 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#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
__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
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
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 1296 of file rpcserver.c.

1300 {
1302  NTSTATUS Status;
1304 
1305  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1306  pszDevice);
1307 
1308  if (ulFlags & CM_GETIDLIST_FILTER_BUSRELATIONS)
1309  {
1310  PlugPlayData.Relations = 3;
1311  }
1312  else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1313  {
1314  PlugPlayData.Relations = 2;
1315  }
1316  else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1317  {
1318  PlugPlayData.Relations = 1;
1319  }
1320  else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1321  {
1322  PlugPlayData.Relations = 0;
1323  }
1324 
1325  PlugPlayData.BufferSize = 0;
1326  PlugPlayData.Buffer = NULL;
1327 
1329  (PVOID)&PlugPlayData,
1331  if (NT_SUCCESS(Status))
1332  {
1333  *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1334  }
1335  else
1336  {
1338  }
1339 
1340  return ret;
1341 }
LONG NTSTATUS
Definition: precomp.h:26
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
__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
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
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 912 of file rpcserver.c.

916 {
917  WCHAR szPathBuffer[512];
918  WCHAR szName[16];
919  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
920  DWORD dwValues, dwSize, dwIndex, dwUsedLength, dwPathLength;
921  DWORD dwError;
922  PWSTR pPtr;
924 
925  /* Open the device key */
927  L"System\\CurrentControlSet\\Services",
928  0,
929  KEY_READ,
930  &hServicesKey);
931  if (dwError != ERROR_SUCCESS)
932  {
933  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
934  return CR_REGISTRY_ERROR;
935  }
936 
937  dwError = RegOpenKeyExW(hServicesKey,
938  pszService,
939  0,
940  KEY_READ,
941  &hServiceKey);
942  if (dwError != ERROR_SUCCESS)
943  {
944  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
946  goto Done;
947  }
948 
949  dwError = RegOpenKeyExW(hServiceKey,
950  L"Enum",
951  0,
952  KEY_READ,
953  &hEnumKey);
954  if (dwError != ERROR_SUCCESS)
955  {
956  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
958  goto Done;
959  }
960 
961  /* Retrieve the number of device instances */
962  dwSize = sizeof(DWORD);
963  dwError = RegQueryValueExW(hEnumKey,
964  L"Count",
965  NULL,
966  NULL,
967  (LPBYTE)&dwValues,
968  &dwSize);
969  if (dwError != ERROR_SUCCESS)
970  {
971  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
972  dwValues = 1;
973  }
974 
975  DPRINT("dwValues %lu\n", dwValues);
976 
977  dwUsedLength = 0;
978  pPtr = pszBuffer;
979 
980  for (dwIndex = 0; dwIndex < dwValues; dwIndex++)
981  {
982  wsprintf(szName, L"%lu", dwIndex);
983 
984  dwSize = sizeof(szPathBuffer);
985  dwError = RegQueryValueExW(hEnumKey,
986  szName,
987  NULL,
988  NULL,
989  (LPBYTE)szPathBuffer,
990  &dwSize);
991  if (dwError != ERROR_SUCCESS)
992  break;
993 
994  DPRINT("Path: %S\n", szPathBuffer);
995 
996  dwPathLength = wcslen(szPathBuffer) + 1;
997  if (dwUsedLength + dwPathLength + 1 > *pulLength)
998  {
1000  break;
1001  }
1002 
1003  wcscpy(pPtr, szPathBuffer);
1004  dwUsedLength += dwPathLength;
1005  pPtr += dwPathLength;
1006 
1007  *pPtr = UNICODE_NULL;
1008  }
1009 
1010 Done:
1011  if (hEnumKey != NULL)
1013 
1014  if (hServiceKey != NULL)
1015  RegCloseKey(hServiceKey);
1016 
1017  if (hServicesKey != NULL)
1019 
1020  if (ret == CR_SUCCESS)
1021  *pulLength = dwUsedLength + 1;
1022  else
1023  *pulLength = 0;
1024 
1025  return ret;
1026 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:55
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HANDLE hServicesKey
Definition: devinst.c:21
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__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)
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
static const WCHAR szName[]
Definition: msipriv.h:1194
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define wsprintf
Definition: winuser.h:5840
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetDeviceList().

◆ GetServiceInstanceListSize()

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

Definition at line 1346 of file rpcserver.c.

1349 {
1350  HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1351  DWORD dwValues, dwMaxValueLength, dwSize;
1352  DWORD dwError;
1354 
1355  /* Open the device key */
1357  L"System\\CurrentControlSet\\Services",
1358  0,
1359  KEY_READ,
1360  &hServicesKey);
1361  if (dwError != ERROR_SUCCESS)
1362  {
1363  DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1364  return CR_REGISTRY_ERROR;
1365  }
1366 
1367  dwError = RegOpenKeyExW(hServicesKey,
1368  pszService,
1369  0,
1370  KEY_READ,
1371  &hServiceKey);
1372  if (dwError != ERROR_SUCCESS)
1373  {
1374  DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1376  goto Done;
1377  }
1378 
1379  dwError = RegOpenKeyExW(hServiceKey,
1380  L"Enum",
1381  0,
1382  KEY_READ,
1383  &hEnumKey);
1384  if (dwError != ERROR_SUCCESS)
1385  {
1386  DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1388  goto Done;
1389  }
1390 
1391  /* Retrieve the number of device instances */
1392  dwSize = sizeof(DWORD);
1393  dwError = RegQueryValueExW(hEnumKey,
1394  L"Count",
1395  NULL,
1396  NULL,
1397  (LPBYTE)&dwValues,
1398  &dwSize);
1399  if (dwError != ERROR_SUCCESS)
1400  {
1401  DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1402  dwValues = 1;
1403  }
1404 
1405  /* Retrieve the maximum instance name length */
1406  dwError = RegQueryInfoKeyW(hEnumKey,
1407  NULL,
1408  NULL,
1409  NULL,
1410  NULL,
1411  NULL,
1412  NULL,
1413  NULL,
1414  NULL,
1415  &dwMaxValueLength,
1416  NULL,
1417  NULL);
1418  if (dwError != ERROR_SUCCESS)
1419  {
1420  DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1421  dwMaxValueLength = MAX_DEVICE_ID_LEN;
1422  }
1423 
1424  DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues, dwMaxValueLength / sizeof(WCHAR));
1425 
1426  /* Return the largest possible buffer size */
1427  *pulLength = dwValues * dwMaxValueLength / sizeof(WCHAR) + 2;
1428 
1429 Done:
1430  if (hEnumKey != NULL)
1432 
1433  if (hServiceKey != NULL)
1434  RegCloseKey(hServiceKey);
1435 
1436  if (hServicesKey != NULL)
1438 
1439  return ret;
1440 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define DWORD
Definition: nt_native.h:44
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static HANDLE hServicesKey
Definition: devinst.c:21
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__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:3686
int ret
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by PNP_GetDeviceListSize().

◆ IsRootDeviceInstanceID()

static BOOL IsRootDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 403 of file rpcserver.c.

405 {
406  if (_wcsicmp(pszDeviceInstanceID, szRootDeviceInstanceID) == 0)
407  return TRUE;
408 
409  return FALSE;
410 }
#define TRUE
Definition: types.h:120
_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_QueryRemove(), and SetupDeviceInstance().

◆ IsValidDeviceInstanceID()

static BOOL IsValidDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 337 of file rpcserver.c.

339 {
340  INT nPartLength[3] = {0, 0, 0};
341  INT nLength = 0, nParts = 0;
342  PWCHAR p;
343 
344  DPRINT("IsValidDeviceInstanceID(%S)\n",
345  pszDeviceInstanceID);
346 
347  if (pszDeviceInstanceID == NULL)
348  {
349  DPRINT("Device instance ID is NULL!\n");
350  return FALSE;
351  }
352 
353  p = pszDeviceInstanceID;
354  while (*p != UNICODE_NULL)
355  {
356  if (*p == L'\\')
357  {
358  nParts++;
359  if (nParts >= 3)
360  {
361  DPRINT("Too many separators: %d\n", nParts);
362  return FALSE;
363  }
364  }
365  else
366  {
367  nPartLength[nParts]++;
368  }
369 
370  nLength++;
371  if (nLength >= MAX_DEVICE_ID_LEN)
372  {
373  DPRINT("Too long: %d\n", nLength);
374  return FALSE;
375  }
376 
377  p++;
378  }
379 
380  if (nParts != 2)
381  {
382  DPRINT("Invalid number of separtors: %d\n", nParts);
383  return FALSE;
384  }
385 
386  if ((nPartLength[0] == 0) ||
387  (nPartLength[1] == 0) ||
388  (nPartLength[2] == 0))
389  {
390  DPRINT("Invalid part lengths: %d %d %d\n",
391  nPartLength[0], nPartLength[1], nPartLength[2]);
392  return FALSE;
393  }
394 
395  DPRINT("Valid device instance ID!\n");
396 
397  return TRUE;
398 }
#define TRUE
Definition: types.h:120
_In_ DWORD nLength
Definition: wincon.h:476
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
uint16_t * PWCHAR
Definition: typedefs.h:55
int32_t INT
Definition: typedefs.h:57
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static const WCHAR L[]
Definition: oid.c:1250
GLfloat GLfloat p
Definition: glext.h:8902

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_SetDeviceRegProp(), and PNP_ValidateDeviceInstance().

◆ midl_user_allocate()

void __RPC_FAR* __RPC_USER midl_user_allocate ( SIZE_T  len)

Definition at line 108 of file rpcserver.c.

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

◆ midl_user_free()

void __RPC_USER midl_user_free ( void __RPC_FAR ptr)

Definition at line 114 of file rpcserver.c.

115 {
116  HeapFree(GetProcessHeap(), 0, ptr);
117 }
static PVOID ptr
Definition: dispmode.c:27
#define GetProcessHeap()
Definition: compat.h:404
#define HeapFree(x, y, z)
Definition: compat.h:403

◆ NtStatusToCrError()

static CONFIGRET WINAPI NtStatusToCrError ( NTSTATUS  Status)
static

Definition at line 121 of file rpcserver.c.

122 {
123  switch (Status)
124  {
127 
129  return CR_INVALID_DATA;
130 
132  return CR_NO_SUCH_DEVINST;
133 
135  return CR_ACCESS_DENIED;
136 
138  return CR_BUFFER_SMALL;
139 
141  return CR_NO_SUCH_VALUE;
142 
143  default:
144  return CR_FAILURE;
145  }
146 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
Status
Definition: gdiplustypes.h:24
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define CR_NO_SUCH_DEVINST
Definition: cfgmgr32.h:858

Referenced by ClearDeviceStatus(), DisableDeviceInstance(), EnableDeviceInstance(), GetDeviceStatus(), GetRelationsInstanceList(), GetRelationsInstanceListSize(), PNP_GetDepth(), PNP_GetDeviceRegProp(), PNP_GetInterfaceDeviceList(), PNP_GetInterfaceDeviceListSize(), PNP_GetRelatedDeviceInstance(), PNP_QueryRemove(), PNP_RequestDeviceEject(), PNP_RequestEjectPC(), ReenumerateDeviceInstance(), and SetDeviceStatus().

◆ OpenConfigurationKey()

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

Definition at line 415 of file rpcserver.c.

418 {
419  WCHAR szKeyName[MAX_PATH];
420  HKEY hInstanceKey;
421  DWORD dwError;
422 
423  /* Build the full device instance key name */
424  wcscpy(szKeyName, L"System\\CurrentControlSet\\Enum\\");
425  wcscat(szKeyName, pszDeviceID);
426 
427  /* Open the device instance key */
429  szKeyName,
430  0,
432  &hInstanceKey);
433  if (dwError != ERROR_SUCCESS)
434  return CR_INVALID_DEVINST;
435 
436  /* Create or open the LogConf key */
437  dwError = RegCreateKeyExW(hInstanceKey,
438  L"LogConf",
439  0,
440  NULL,
443  NULL,
444  phKey,
445  NULL);
446 
447  /* Close the device instance key */
448  RegCloseKey(hInstanceKey);
449 
450  if (dwError != ERROR_SUCCESS)
451  return CR_REGISTRY_ERROR;
452 
453  return CR_SUCCESS;
454 }
#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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
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)
static const WCHAR L[]
Definition: oid.c:1250
#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)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#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 3827 of file rpcserver.c.

3833 {
3834  UNIMPLEMENTED;
3835  return CR_CALL_NOT_IMPLEMENTED;
3836 }
#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 3293 of file rpcserver.c.

3298 {
3300  HKEY hDeviceKey;
3301  LPWSTR pszSubKey;
3302  DWORD dwDeviceIdListSize;
3303  DWORD dwNewDeviceIdSize;
3304  WCHAR * pszDeviceIdList = NULL;
3305 
3307 
3308  DPRINT("PNP_AddID(%p %S %S 0x%08lx)\n",
3309  hBinding, pszDeviceID, pszID, ulFlags);
3310 
3311  if (RegOpenKeyExW(hEnumKey,
3312  pszDeviceID,
3313  0,
3315  &hDeviceKey) != ERROR_SUCCESS)
3316  {
3317  DPRINT("Failed to open the device key!\n");
3318  return CR_INVALID_DEVNODE;
3319  }
3320 
3321  pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
3322 
3323  if (RegQueryValueExW(hDeviceKey,
3324  pszSubKey,
3325  NULL,
3326  NULL,
3327  NULL,
3328  &dwDeviceIdListSize) != ERROR_SUCCESS)
3329  {
3330  DPRINT("Failed to query the desired ID string!\n");
3332  goto Done;
3333  }
3334 
3335  dwNewDeviceIdSize = lstrlenW(pszDeviceID);
3336  if (!dwNewDeviceIdSize)
3337  {
3339  goto Done;
3340  }
3341 
3342  dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
3343 
3344  pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
3345  if (!pszDeviceIdList)
3346  {
3347  DPRINT("Failed to allocate memory for the desired ID string!\n");
3349  goto Done;
3350  }
3351 
3352  if (RegQueryValueExW(hDeviceKey,
3353  pszSubKey,
3354  NULL,
3355  NULL,
3356  (LPBYTE)pszDeviceIdList,
3357  &dwDeviceIdListSize) != ERROR_SUCCESS)
3358  {
3359  DPRINT("Failed to query the desired ID string!\n");
3361  goto Done;
3362  }
3363 
3364  /* Check whether the device ID is already in use */
3365  if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
3366  {
3367  DPRINT("Device ID was found in the ID string!\n");
3368  ret = CR_SUCCESS;
3369  goto Done;
3370  }
3371 
3372  /* Append the Device ID */
3373  AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
3374 
3375  if (RegSetValueExW(hDeviceKey,
3376  pszSubKey,
3377  0,
3378  REG_MULTI_SZ,
3379  (LPBYTE)pszDeviceIdList,
3380  dwDeviceIdListSize) != ERROR_SUCCESS)
3381  {
3382  DPRINT("Failed to set the desired ID string!\n");
3384  }
3385 
3386 Done:
3387  RegCloseKey(hDeviceKey);
3388  if (pszDeviceIdList)
3389  HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
3390 
3391  DPRINT("PNP_AddID() done (returns %lx)\n", ret);
3392 
3393  return ret;
3394 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define lstrlenW
Definition: compat.h:416
#define CM_ADD_ID_COMPATIBLE
Definition: cfgmgr32.h:615
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:3270
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define GetProcessHeap()
Definition: compat.h:404
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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
static BOOL CheckForDeviceId(LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
Definition: rpcserver.c:3249
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:403
#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 4062 of file rpcserver.c.

4072 {
4073  UNIMPLEMENTED;
4074  return CR_CALL_NOT_IMPLEMENTED;
4075 }
#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 4664 of file rpcserver.c.

4666 {
4667  UNIMPLEMENTED;
4668  return CR_CALL_NOT_IMPLEMENTED;
4669 }
#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 554 of file rpcserver.c.

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

◆ PNP_CreateDevInst()

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

Definition at line 2926 of file rpcserver.c.

2932 {
2934 
2935  DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
2936  hBinding, pszParentDeviceID, pszDeviceID, ulLength, ulFlags);
2937 
2938  if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
2939  return CR_INVALID_FLAG;
2940 
2941  if (pszDeviceID == NULL || pszParentDeviceID == NULL)
2942  return CR_INVALID_POINTER;
2943 
2944  /* Fail, if the parent device is not the root device */
2945  if (!IsRootDeviceInstanceID(pszParentDeviceID))
2946  return CR_INVALID_DEVINST;
2947 
2948  if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
2949  {
2950  WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
2951  DWORD dwInstanceNumber;
2952 
2953  /* Generated ID is: Root<Device ID><Instance number> */
2954  dwInstanceNumber = 0;
2955  do
2956  {
2957  swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
2958  pszDeviceID, dwInstanceNumber);
2959 
2960  /* Try to create a device instance with this ID */
2961  ret = CreateDeviceInstance(szGeneratedInstance);
2962 
2963  dwInstanceNumber++;
2964  }
2965  while (ret == CR_ALREADY_SUCH_DEVINST);
2966 
2967  if (ret == CR_SUCCESS)
2968  {
2969  /* pszDeviceID is an out parameter too for generated IDs */
2970  if (wcslen(szGeneratedInstance) > ulLength)
2971  {
2972  ret = CR_BUFFER_SMALL;
2973  }
2974  else
2975  {
2976  wcscpy(pszDeviceID, szGeneratedInstance);
2977  }
2978  }
2979  }
2980  else
2981  {
2982  /* Create the device instance */
2983  ret = CreateDeviceInstance(pszDeviceID);
2984  }
2985 
2986  DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
2987 
2988  return ret;
2989 }
#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 MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CM_CREATE_DEVNODE_BITS
Definition: cfgmgr32.h:624
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:403
int ret
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
static CONFIGRET CreateDeviceInstance(LPWSTR pszDeviceID)
Definition: rpcserver.c:2818
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CM_Create_DevNode_ExW().

◆ PNP_CreateKey()

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

Definition at line 2233 of file rpcserver.c.

2238 {
2239  HKEY hDeviceKey = NULL, hParametersKey = NULL;
2240  DWORD dwError;
2242 
2244  UNREFERENCED_PARAMETER(samDesired);
2245 
2246  DPRINT("PNP_CreateKey(%p %S 0x%lx 0x%08lx)\n",
2247  hBinding, pszSubKey, samDesired, ulFlags);
2248 
2249  if (ulFlags != 0)
2250  return CR_INVALID_FLAG;
2251 
2252  if (!IsValidDeviceInstanceID(pszSubKey))
2253  return CR_INVALID_DEVINST;
2254 
2255  dwError = RegOpenKeyExW(hEnumKey,
2256  pszSubKey,
2257  0,
2258  KEY_WRITE,
2259  &hDeviceKey);
2260  if (dwError != ERROR_SUCCESS)
2261  {
2263  goto done;
2264  }
2265 
2266  dwError = RegCreateKeyExW(hDeviceKey,
2267  L"Device Parameters",
2268  0,
2269  NULL,
2272  NULL,
2273  &hParametersKey,
2274  NULL);
2275  if (dwError != ERROR_SUCCESS)
2276  {
2278  goto done;
2279  }
2280 
2281  /* FIXME: Set key security */
2282 
2283 done:
2284  if (hParametersKey != NULL)
2285  RegCloseKey(hParametersKey);
2286 
2287  if (hDeviceKey != NULL)
2288  RegCloseKey(hDeviceKey);
2289 
2290  return ret;
2291 }
#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:323
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

◆ PNP_DeleteClassKey()

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

Definition at line 2415 of file rpcserver.c.

2419 {
2421 
2423 
2424  DPRINT("PNP_DeleteClassKey(%p %S 0x%08lx)\n",
2425  hBinding, pszClassGuid, ulFlags);
2426 
2427  if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
2428  {
2429  if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2431  }
2432  else
2433  {
2434  if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2436  }
2437 
2438  DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
2439 
2440  return ret;
2441 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_DELETE_CLASS_SUBKEYS
Definition: cfgmgr32.h:635
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
HKEY hClassKey
Definition: umpnpmgr.c:45
int ret
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875

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

2303 {
2304  UNIMPLEMENTED;
2305  return CR_CALL_NOT_IMPLEMENTED;
2306 }
#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 4721 of file rpcserver.c.

4723 {
4724  UNIMPLEMENTED;
4725  return CR_CALL_NOT_IMPLEMENTED;
4726 }
#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 4251 of file rpcserver.c.

4259 {
4260  DPRINT("PNP_DetectResourceConflict()\n");
4261 
4262  if (pbConflictDetected != NULL)
4263  *pbConflictDetected = FALSE;
4264 
4265  return CR_CALL_NOT_IMPLEMENTED;
4266 }
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898

◆ PNP_DeviceInstanceAction()

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

Definition at line 3126 of file rpcserver.c.

3132 {
3134 
3136 
3137  DPRINT("PNP_DeviceInstanceAction(%p %lu 0x%08lx %S %S)\n",
3138  hBinding, ulMajorAction, ulMinorAction,
3139  pszDeviceInstance1, pszDeviceInstance2);
3140 
3141  switch (ulMajorAction)
3142  {
3143  case PNP_DEVINST_SETUP:
3144  ret = SetupDeviceInstance(pszDeviceInstance1,
3145  ulMinorAction);
3146  break;
3147 
3148  case PNP_DEVINST_ENABLE:
3149  ret = EnableDeviceInstance(pszDeviceInstance1);
3150  break;
3151 
3152  case PNP_DEVINST_REENUMERATE:
3153  ret = ReenumerateDeviceInstance(pszDeviceInstance1,
3154  ulMinorAction);
3155  break;
3156 
3157  default:
3158  DPRINT1("Unknown device action %lu: not implemented\n", ulMajorAction);
3160  }
3161 
3162  DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
3163 
3164  return ret;
3165 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static CONFIGRET SetupDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
Definition: rpcserver.c:2993
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
static CONFIGRET EnableDeviceInstance(_In_ LPWSTR pszDeviceInstance)
Definition: rpcserver.c:3068
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:3090

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

3215 {
3217 
3218  DPRINT1("PNP_DisableDevInst(%p %S %p %p %lu 0x%08lx)\n",
3219  hBinding, pDeviceID, pVetoType, pszVetoName, ulNameLength, ulFlags);
3220 
3221  if (ulFlags & ~CM_DISABLE_BITS)
3222  return CR_INVALID_FLAG;
3223 
3224  if (!IsValidDeviceInstanceID(pDeviceID) ||
3225  IsRootDeviceInstanceID(pDeviceID))
3226  return CR_INVALID_DEVINST;
3227 
3228  return DisableDeviceInstance(pDeviceID,
3229  pVetoType,
3230  pszVetoName,
3231  ulNameLength);
3232 }
#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:323
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
#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:291
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:403
#define DPRINT1
Definition: precomp.h:8

Referenced by CM_Disable_DevNode_Ex().

◆ PNP_Disconnect()

DWORD WINAPI PNP_Disconnect ( handle_t  hBinding)

Definition at line 543 of file rpcserver.c.

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

◆ PNP_DriverStoreAddDriverPackage()

DWORD WINAPI PNP_DriverStoreAddDriverPackage ( handle_t  hBinding)

Definition at line 4675 of file rpcserver.c.

4677 {
4678  UNIMPLEMENTED;
4679  return CR_CALL_NOT_IMPLEMENTED;
4680 }
#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 4686 of file rpcserver.c.

4688 {
4689  UNIMPLEMENTED;
4690  return CR_CALL_NOT_IMPLEMENTED;
4691 }
#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 801 of file rpcserver.c.

809 {
811  HKEY hKey;
812  DWORD dwError;
813 
815  UNREFERENCED_PARAMETER(ulFlags);
816 
817  DPRINT("PNP_EnumerateSubKeys(%p %lu %lu %p %lu %p 0x%08lx)\n",
818  hBinding, ulBranch, ulIndex, Buffer, ulLength,
819  pulRequiredLen, ulFlags);
820 
821  switch (ulBranch)
822  {
823  case PNP_ENUMERATOR_SUBKEYS:
824  hKey = hEnumKey;
825  break;
826 
827  case PNP_CLASS_SUBKEYS:
828  hKey = hClassKey;
829  break;
830 
831  default:
832  return CR_FAILURE;
833  }
834 
835  *pulRequiredLen = ulLength;
836  dwError = RegEnumKeyExW(hKey,
837  ulIndex,
838  Buffer,
839  pulRequiredLen,
840  NULL,
841  NULL,
842  NULL,
843  NULL);
844  if (dwError != ERROR_SUCCESS)
845  {
847  }
848  else
849  {
850  (*pulRequiredLen)++;
851  }
852 
853  DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
854 
855  return ret;
856 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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
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 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 3842 of file rpcserver.c.

3848 {
3849  UNIMPLEMENTED;
3850  return CR_CALL_NOT_IMPLEMENTED;
3851 }
#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 4081 of file rpcserver.c.

4091 {
4092  UNIMPLEMENTED;
4093  return CR_CALL_NOT_IMPLEMENTED;
4094 }
#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 4555 of file rpcserver.c.

4561 {
4562  UNIMPLEMENTED;
4563  return CR_CALL_NOT_IMPLEMENTED;
4564 }
#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 2312 of file rpcserver.c.

2316 {
2317  HKEY hKey;
2318  DWORD dwError;
2319 
2321  UNREFERENCED_PARAMETER(ulFlags);
2322 
2323  DPRINT("PNP_GetClassCount(%p %p 0x%08lx)\n",
2324  hBinding, pulClassCount, ulFlags);
2325 
2328  0,
2330  &hKey);
2331  if (dwError != ERROR_SUCCESS)
2332  return CR_INVALID_DATA;
2333 
2334  dwError = RegQueryInfoKeyW(hKey,
2335  NULL,
2336  NULL,
2337  NULL,
2338  pulClassCount,
2339  NULL,
2340  NULL,
2341  NULL,
2342  NULL,
2343  NULL,
2344  NULL,
2345  NULL);
2346  RegCloseKey(hKey);
2347  if (dwError != ERROR_SUCCESS)
2348  return CR_INVALID_DATA;
2349 
2350  return CR_SUCCESS;
2351 }
#define ERROR_SUCCESS
Definition: deptool.c:10
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3686
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REGSTR_PATH_CLASS
Definition: regstr.h:42
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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 2117 of file rpcserver.c.

2122 {
2123  WCHAR szClassGuid[40];
2124  WCHAR szClassInstance[5];
2125  HKEY hDeviceClassKey = NULL;
2126  HKEY hClassInstanceKey;
2127  ULONG ulTransferLength, ulDataLength;
2128  DWORD dwDataType, dwDisposition, i;
2129  DWORD dwError;
2131 
2132  DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
2133  hBinding, pDeviceId, pszClassInstance, ulLength);
2134 
2135  if (!IsValidDeviceInstanceID(pDeviceId))
2136  return CR_INVALID_DEVINST;
2137 
2138  ulTransferLength = ulLength;
2140  pDeviceId,
2141  CM_DRP_DRIVER,
2142  &dwDataType,
2143  (BYTE *)pszClassInstance,
2144  &ulTransferLength,
2145  &ulLength,
2146  0);
2147  if (ret == CR_SUCCESS)
2148  return ret;
2149 
2150  ulTransferLength = sizeof(szClassGuid);
2151  ulDataLength = sizeof(szClassGuid);
2153  pDeviceId,
2155  &dwDataType,
2156  (BYTE *)szClassGuid,
2157  &ulTransferLength,
2158  &ulDataLength,
2159  0);
2160  if (ret != CR_SUCCESS)
2161  {
2162  DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret);
2163  goto done;
2164  }
2165 
2166  dwError = RegOpenKeyExW(hClassKey,
2167  szClassGuid,
2168  0,
2169  KEY_READ,
2170  &hDeviceClassKey);
2171  if (dwError != ERROR_SUCCESS)
2172  {
2173  DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError);
2174  ret = CR_FAILURE;
2175  goto done;
2176  }
2177 
2178  for (i = 0; i < 10000; i++)
2179  {
2180  wsprintf(szClassInstance, L"%04lu", i);
2181 
2182  dwError = RegCreateKeyExW(hDeviceClassKey,
2183  szClassInstance,
2184  0,
2185  NULL,
2188  NULL,
2189  &hClassInstanceKey,
2190  &dwDisposition);
2191  if (dwError == ERROR_SUCCESS)
2192  {
2193  RegCloseKey(hClassInstanceKey);
2194 
2195  if (dwDisposition == REG_CREATED_NEW_KEY)
2196  {
2197  wsprintf(pszClassInstance,
2198  L"%s\\%s",
2199  szClassGuid,
2200  szClassInstance);
2201 
2202  ulDataLength = (wcslen(pszClassInstance) + 1) * sizeof(WCHAR);
2204  pDeviceId,
2205  CM_DRP_DRIVER,
2206  REG_SZ,
2207  (BYTE *)pszClassInstance,
2208  ulDataLength,
2209  0);
2210  if (ret != CR_SUCCESS)
2211  {
2212  DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret);
2213  RegDeleteKeyW(hDeviceClassKey,
2214  szClassInstance);
2215  }
2216 
2217  break;
2218  }
2219  }
2220  }
2221 
2222 done:
2223  if (hDeviceClassKey != NULL)
2224  RegCloseKey(hDeviceClassKey);
2225 
2226  return ret;
2227 }
#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:337
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:1711
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
void DPRINT(...)
Definition: polytest.cpp:61
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
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: xxhash.c:193
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#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:3366
#define wsprintf
Definition: winuser.h:5840
DWORD WINAPI PNP_SetDeviceRegProp(handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
Definition: rpcserver.c:1975
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#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 2357 of file rpcserver.c.

2363 {
2364  WCHAR szKeyName[MAX_PATH];
2366  HKEY hKey;
2367  DWORD dwSize;
2368 
2370  UNREFERENCED_PARAMETER(ulFlags);
2371 
2372  DPRINT("PNP_GetClassName(%p %S %p %p 0x%08lx)\n",
2373  hBinding, pszClassGuid, Buffer, pulLength, ulFlags);
2374 
2375  lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
2376  if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
2377  lstrcatW(szKeyName, pszClassGuid);
2378  else
2379  return CR_INVALID_DATA;
2380 
2382  szKeyName,
2383  0,
2385  &hKey))
2386  return CR_REGISTRY_ERROR;
2387 
2388  dwSize = *pulLength * sizeof(WCHAR);
2389  if (RegQueryValueExW(hKey,
2390  L"Class",
2391  NULL,
2392  NULL,
2393  (LPBYTE)Buffer,
2394  &dwSize))
2395  {
2396  *pulLength = 0;
2398  }
2399  else
2400  {
2401  *pulLength = dwSize / sizeof(WCHAR);
2402  }
2403 
2404  RegCloseKey(hKey);
2405 
2406  DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
2407 
2408  return ret;
2409 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define lstrlenW
Definition: compat.h:416
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define lstrcpyW
Definition: compat.h:415
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CM_Get_Class_Name_ExW().

◆ PNP_GetClassRegProp()

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

Definition at line 2590 of file rpcserver.c.

2599 {
2601  LPWSTR lpValueName = NULL;
2602  HKEY hInstKey = NULL;
2603  HKEY hPropKey = NULL;
2604  LONG lError;
2605 
2607 
2608  DPRINT("PNP_GetClassRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
2609  hBinding, pszClassGuid, ulProperty, pulRegDataType,
2610  Buffer, pulTransferLen, pulLength, ulFlags);
2611 
2612  if (pulTransferLen == NULL || pulLength == NULL)
2613  {
2615  goto done;
2616  }
2617 
2618  if (ulFlags != 0)
2619  {
2620  ret = CR_INVALID_FLAG;
2621  goto done;
2622  }
2623 
2624  if (*pulLength < *pulTransferLen)
2625  *pulLength = *pulTransferLen;
2626 
2627  *pulTransferLen = 0;
2628 
2629  switch (ulProperty)
2630  {
2631  case CM_CRP_SECURITY:
2632  lpValueName = L"Security";
2633  break;
2634 
2635  case CM_CRP_DEVTYPE:
2636  lpValueName = L"DeviceType";
2637  break;
2638 
2639  case CM_CRP_EXCLUSIVE:
2640  lpValueName = L"Exclusive";
2641  break;
2642 
2644  lpValueName = L"DeviceCharacteristics";
2645  break;
2646 
2647  default:
2649  goto done;
2650  }
2651 
2652  DPRINT("Value name: %S\n", lpValueName);
2653 
2654  lError = RegOpenKeyExW(hClassKey,
2655  pszClassGuid,
2656  0,
2657  KEY_READ,
2658  &hInstKey);
2659  if (lError != ERROR_SUCCESS)
2660  {
2661  *pulLength = 0;
2663  goto done;
2664  }
2665 
2666  lError = RegOpenKeyExW(hInstKey,
2667  L"Properties",
2668  0,
2669  KEY_READ,
2670  &hPropKey);
2671  if (lError != ERROR_SUCCESS)
2672  {
2673  *pulLength = 0;
2675  goto done;
2676  }
2677 
2678  lError = RegQueryValueExW(hPropKey,
2679  lpValueName,
2680  NULL,
2681  pulRegDataType,
2682  Buffer,
2683  pulLength);
2684  if (lError != ERROR_SUCCESS)
2685  {
2686  if (lError == ERROR_MORE_DATA)
2687  {
2688  ret = CR_BUFFER_SMALL;
2689  }
2690  else
2691  {
2692  *pulLength = 0;
2694  }
2695  }
2696 
2697 done:
2698  if (ret == CR_SUCCESS)
2699  *pulTransferLen = *pulLength;
2700 
2701  if (hPropKey != NULL)
2702  RegCloseKey(hPropKey);
2703 
2704  if (hInstKey != NULL)
2705  RegCloseKey(hInstKey);
2706 
2707  DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
2708 
2709  return ret;
2710 }
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
#define KEY_READ
Definition: nt_native.h:1023
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_CRP_DEVTYPE
Definition: cfgmgr32.h:710
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CM_CRP_CHARACTERISTICS
Definition: cfgmgr32.h:714
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CM_CRP_EXCLUSIVE
Definition: cfgmgr32.h:712
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
void DPRINT(...)
Definition: polytest.cpp:61
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:4116
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ERROR_MORE_DATA
Definition: dderror.h:13
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
WCHAR * LPWSTR
Definition: xmlstorage.h:184

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

4451 {
4452  HKEY hDeviceKey = NULL;
4453  HKEY hParamKey = NULL;
4454  LONG lError;
4456 
4458 
4459  DPRINT("PNP_GetCustomDevProp() called\n");
4460 
4461  if (pulTransferLen == NULL || pulLength == NULL)
4462  {
4464  goto done;
4465  }
4466 
4467  if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
4468  {
4469  ret = CR_INVALID_FLAG;
4470  goto done;
4471  }
4472 
4473  if (!IsValidDeviceInstanceID(pDeviceID))
4474  return CR_INVALID_DEVINST;
4475 
4476  if (*pulLength < *pulTransferLen)
4477  *pulLength = *pulTransferLen;
4478 
4479  *pulTransferLen = 0;
4480 
4481  lError = RegOpenKeyExW(hEnumKey,
4482  pDeviceID,
4483  0,
4484  KEY_READ,
4485  &hDeviceKey);
4486  if (lError != ERROR_SUCCESS)
4487  {
4489  goto done;
4490  }
4491 
4492  lError = RegOpenKeyExW(hDeviceKey,
4493  L"Device Parameters",
4494  0,
4495  KEY_READ,
4496  &hParamKey);
4497  if (lError != ERROR_SUCCESS)
4498  {
4500  goto done;
4501  }
4502 
4503  lError = RegQueryValueExW(hParamKey,
4504  CustomPropName,
4505  NULL,
4506  pulRegDataType,
4507  Buffer,
4508  pulLength);
4509  if (lError != ERROR_SUCCESS)
4510  {
4511  if (lError == ERROR_MORE_DATA)
4512  {
4513  ret = CR_BUFFER_SMALL;
4514  }
4515  else
4516  {
4517  *pulLength = 0;
4519  }
4520  }
4521 
4522 done:
4523  if (ret == CR_SUCCESS)
4524  *pulTransferLen = *pulLength;
4525 
4526  if (hParamKey != NULL)
4527  RegCloseKey(hParamKey);
4528 
4529  if (hDeviceKey != NULL)
4530  RegCloseKey(hDeviceKey);
4531 
4532  DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
4533 
4534  return ret;
4535 }
#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:323
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
HKEY hEnumKey
Definition: umpnpmgr.c:44
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define CM_CUSTOMDEVPROP_BITS
Definition: cfgmgr32.h:836
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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 1668 of file rpcserver.c.

1673 {
1674  PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
1676  NTSTATUS Status;
1677 
1679  UNREFERENCED_PARAMETER(ulFlags);
1680 
1681  DPRINT("PNP_GetDepth(%p %S %p 0x%08lx)\n",
1682  hBinding, pszDeviceID, pulDepth, ulFlags);
1683 
1684  if (!IsValidDeviceInstanceID(pszDeviceID))
1685  return CR_INVALID_DEVINST;
1686 
1687  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1688  pszDeviceID);
1689 
1691  (PVOID)&PlugPlayData,
1692  sizeof(PLUGPLAY_CONTROL_DEPTH_DATA));
1693  if (NT_SUCCESS(Status))
1694  {
1695  *pulDepth = PlugPlayData.Depth;
1696  }
1697  else
1698  {
1700  }
1701 
1702  DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
1703 
1704  return ret;
1705 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int ret
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:522

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

1228 {
1229  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1230  WCHAR szDevice[MAX_DEVICE_ID_LEN];
1231  WCHAR szInstance[MAX_DEVICE_ID_LEN];
1233 
1234  DPRINT("PNP_GetDeviceList(%p %S %p %p 0x%08lx)\n",
1235  hBinding, pszFilter, Buffer, pulLength, ulFlags);
1236 
1237  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1238  return CR_INVALID_FLAG;
1239 
1240  if (pulLength == NULL)
1241  return CR_INVALID_POINTER;
1242 
1243  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1244  (pszFilter == NULL))
1245  return CR_INVALID_POINTER;
1246 
1247  if (ulFlags &
1252  {
1253  ret = GetRelationsInstanceList(pszFilter,
1254  ulFlags,
1255  Buffer,
1256  pulLength);
1257  }
1258  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1259  {
1260  ret = GetServiceInstanceList(pszFilter,
1261  Buffer,
1262  pulLength);
1263  }
1264  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1265  {
1266  SplitDeviceInstanceID(pszFilter,
1267  szEnumerator,
1268  szDevice,
1269  szInstance);
1270 
1271  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1272  {
1273  ret = GetDeviceInstanceList(pszFilter,
1274  Buffer,
1275  pulLength);
1276  }
1277  else
1278  {
1279  ret = GetEnumeratorInstanceList(pszFilter,
1280  Buffer,
1281  pulLength);
1282  }
1283  }
1284  else /* CM_GETIDLIST_FILTER_NONE */
1285  {
1287  pulLength);
1288  }
1289 
1290  return ret;
1291 }
#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:150
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
static CONFIGRET GetAllInstanceList(_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1173
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1102
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define UNICODE_NULL
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
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:1031
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
#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:912
#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:861

Referenced by CM_Get_Device_ID_List_ExW().

◆ PNP_GetDeviceListSize()

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

Definition at line 1593 of file rpcserver.c.

1598 {
1599  WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1600  WCHAR szDevice[MAX_DEVICE_ID_LEN];
1601  WCHAR szInstance[MAX_DEVICE_ID_LEN];
1603 
1604  DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%08lx)\n",
1605  hBinding, pszFilter, pulLength, ulFlags);
1606 
1607  if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1608  return CR_INVALID_FLAG;
1609 
1610  if (pulLength == NULL)
1611  return CR_INVALID_POINTER;
1612 
1613  if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1614  (pszFilter == NULL))
1615  return CR_INVALID_POINTER;
1616 
1617  *pulLength = 0;
1618 
1619  if (ulFlags &
1624  {
1625  ret = GetRelationsInstanceListSize(pszFilter,
1626  ulFlags,
1627  pulLength);
1628  }
1629  else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1630  {
1631  ret = GetServiceInstanceListSize(pszFilter,
1632  pulLength);
1633  }
1634  else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1635  {
1636  SplitDeviceInstanceID(pszFilter,
1637  szEnumerator,
1638  szDevice,
1639  szInstance);
1640 
1641  if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1642  {
1643  ret = GetDeviceInstanceListSize(pszFilter,
1644  pulLength);
1645  }
1646  else
1647  {
1648  ret = GetEnumeratorInstanceListSize(pszFilter,
1649  pulLength);
1650  }
1651  }
1652  else /* CM_GETIDLIST_FILTER_NONE */
1653  {
1654  ret = GetAllInstanceListSize(pulLength);
1655  }
1656 
1657  /* Add one character for the terminating double UNICODE_NULL */
1658  if (ret == CR_SUCCESS)
1659  (*pulLength) += 1;
1660 
1661  return ret;
1662 }
#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:150
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654
static CONFIGRET GetServiceInstanceListSize(_In_ PWSTR pszService, _Out_ PDWORD pulLength)
Definition: rpcserver.c:1346
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
static CONFIGRET GetAllInstanceListSize(_Out_ PULONG pulLength)
Definition: rpcserver.c:1558
#define MAX_DEVICE_ID_LEN
Definition: pnpmgr.c:28
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1445
#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:1296
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
int ret
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1497
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669

Referenced by CM_Get_Device_ID_List_Size_ExW().

◆ PNP_GetDeviceRegProp()

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

Definition at line 1711 of file rpcserver.c.

1720 {
1721  PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
1723  LPWSTR lpValueName = NULL;
1724  HKEY hKey = NULL;
1725  LONG lError;
1726  NTSTATUS Status;
1727 
1729 
1730  DPRINT("PNP_GetDeviceRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
1731  hBinding, pDeviceID, ulProperty, pulRegDataType, Buffer,
1732  pulTransferLen, pulLength, ulFlags);
1733 
1734  if (pulTransferLen == NULL || pulLength == NULL)
1735  {
1737  goto done;
1738  }
1739 
1740  if (ulFlags != 0)
1741  {
1742  ret = CR_INVALID_FLAG;
1743  goto done;
1744  }
1745 
1746  /* Check pDeviceID */
1747  if (!IsValidDeviceInstanceID(pDeviceID))
1748  {
1750  goto done;
1751  }
1752 
1753  if (*pulLength < *pulTransferLen)
1754  *pulLength = *pulTransferLen;
1755 
1756  *pulTransferLen = 0;
1757 
1758  switch (ulProperty)
1759  {
1760  case CM_DRP_DEVICEDESC:
1761  lpValueName = L"DeviceDesc";
1762  break;
1763 
1764  case CM_DRP_HARDWAREID:
1765  lpValueName = L"HardwareID";
1766  break;
1767 
1768  case CM_DRP_COMPATIBLEIDS:
1769  lpValueName = L"CompatibleIDs";
1770  break;
1771 
1772  case CM_DRP_SERVICE:
1773  lpValueName = L"Service";
1774  break;
1775 
1776  case CM_DRP_CLASS:
1777  lpValueName = L"Class";
1778  break;
1779 
1780  case CM_DRP_CLASSGUID:
1781  lpValueName = L"ClassGUID";
1782  break;
1783 
1784  case CM_DRP_DRIVER:
1785  lpValueName = L"Driver";
1786  break;
1787 
1788  case CM_DRP_CONFIGFLAGS:
1789  lpValueName = L"ConfigFlags";
1790  break;
1791 
1792  case CM_DRP_MFG:
1793  lpValueName = L"Mfg";
1794  break;
1795 
1796  case CM_DRP_FRIENDLYNAME:
1797  lpValueName = L"FriendlyName";
1798  break;
1799 
1801  lpValueName = L"LocationInformation";
1802  break;
1803 
1806  break;
1807 
1808  case CM_DRP_CAPABILITIES:
1809  lpValueName = L"Capabilities";
1810  break;
1811 
1812  case CM_DRP_UI_NUMBER:
1813  PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
1814  break;
1815 
1816  case CM_DRP_UPPERFILTERS:
1817  lpValueName = L"UpperFilters";
1818  break;
1819 
1820  case CM_DRP_LOWERFILTERS:
1821  lpValueName = L"LowerFilters";
1822  break;
1823 
1824  case CM_DRP_BUSTYPEGUID:
1825  PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
1826  break;
1827 
1828  case CM_DRP_LEGACYBUSTYPE:
1829  PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
1830  break;
1831 
1832  case CM_DRP_BUSNUMBER:
1833  PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
1834  break;
1835 
1837  PlugPlayData.Property = PNP_PROPERTY_ENUMERATOR_NAME;
1838  break;
1839 
1840  case CM_DRP_SECURITY:
1841  lpValueName = L"Security";
1842  break;
1843 
1844  case CM_DRP_DEVTYPE:
1845  lpValueName = L"DeviceType";
1846  break;
1847 
1848  case CM_DRP_EXCLUSIVE:
1849  lpValueName = L"Exclusive";
1850  break;
1851 
1853  lpValueName = L"DeviceCharacteristics";
1854  break;
1855 
1856  case CM_DRP_ADDRESS:
1857  PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
1858  break;
1859 
1861  lpValueName = L"UINumberDescFormat";
1862  break;
1863 
1865  PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
1866  break;
1867 
1868  case CM_DRP_REMOVAL_POLICY:
1869  PlugPlayData.Property = PNP_PROPERTY_REMOVAL_POLICY;
1870  break;
1871 
1874  break;
1875 
1877  lpValueName = L"RemovalPolicy";
1878  break;
1879 
1880  case CM_DRP_INSTALL_STATE:
1881  PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
1882  break;
1883 
1884 #if (WINVER >= _WIN32_WINNT_WS03)
1885  case CM_DRP_LOCATION_PATHS:
1886  PlugPlayData.Property = PNP_PROPERTY_LOCATION_PATHS;
1887  break;
1888 #endif
1889 
1890 #if (WINVER >= _WIN32_WINNT_WIN7)
1892  PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
1893  break;
1894 #endif
1895 
1896  default:
1898  goto done;
1899  }
1900 
1901  DPRINT("Value name: %S\n", lpValueName);
1902 
1903  if (lpValueName)
1904  {
1905  /* Retrieve information from the Registry */
1906  lError = RegOpenKeyExW(hEnumKey,
1907  pDeviceID,
1908  0,
1910  &hKey);
1911  if (lError != ERROR_SUCCESS)
1912  {
1913  hKey = NULL;
1914  *pulLength = 0;
1916  goto done;
1917  }
1918 
1919  lError = RegQueryValueExW(hKey,
1920  lpValueName,
1921  NULL,
1922  pulRegDataType,
1923  Buffer,
1924  pulLength);
1925  if (lError != ERROR_SUCCESS)
1926  {
1927  if (lError == ERROR_MORE_DATA)
1928  {
1929  ret = CR_BUFFER_SMALL;
1930  }
1931  else
1932  {
1933  *pulLength = 0;
1935  }
1936  }
1937  }
1938  else
1939  {
1940  /* Retrieve information from the Device Node */
1941  RtlInitUnicodeString(&PlugPlayData.DeviceInstance,
1942  pDeviceID);
1943  PlugPlayData.Buffer = Buffer;
1944  PlugPlayData.BufferSize = *pulLength;
1945 
1947  (PVOID)&PlugPlayData,
1949  if (NT_SUCCESS(Status))
1950  {
1951  *pulLength = PlugPlayData.BufferSize;
1952  }
1953  else
1954  {
1956  }
1957  }
1958 
1959 done:
1960  if (pulTransferLen)
1961  *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
1962 
1963  if (hKey != NULL)
1964  RegCloseKey(hKey);
1965 
1966  DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
1967 
1968  return ret;
1969 }
#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
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CM_DRP_REMOVAL_POLICY_HW_DEFAULT
Definition: cfgmgr32.h:720
#define CM_DRP_FRIENDLYNAME
Definition: cfgmgr32.h:688
#define CM_DRP_EXCLUSIVE
Definition: cfgmgr32.h:711
#define CM_DRP_LEGACYBUSTYPE
Definition: cfgmgr32.h:702
LONG NTSTATUS
Definition: precomp.h:26
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
static CONFIGRET WINAPI NtStatusToCrError(NTSTATUS Status)
Definition: rpcserver.c:121
#define CM_DRP_BUSTYPEGUID
Definition: cfgmgr32.h:701
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define CM_DRP_SERVICE
Definition: cfgmgr32.h:680
#define CM_DRP_COMPATIBLEIDS
Definition: cfgmgr32.h:678
#define CM_DRP_REMOVAL_POLICY
Definition: cfgmgr32.h:719
#define CM_DRP_SECURITY
Definition: cfgmgr32.h:705
#define CM_DRP_UPPERFILTERS
Definition: cfgmgr32.h:693
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define CM_DRP_LOWERFILTERS
Definition: cfgmgr32.h:697
long LONG
Definition: pedump.c:60
#define CR_SUCCESS
Definition: cfgmgr32.h:842
#define CM_DRP_ENUMERATOR_NAME
Definition: cfgmgr32.h:704
smooth NULL
Definition: ftsmooth.c:416
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define CM_DRP_DEVTYPE
Definition: cfgmgr32.h:709
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:495
#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:4116
#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
static const WCHAR L[]
Definition: oid.c:1250
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cfgmgr32.h:690
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CM_DRP_UI_NUMBER
Definition: cfgmgr32.h:692
#define CM_DRP_DEVICE_POWER_DATA
Definition: cfgmgr32.h:718
#define CM_DRP_MFG
Definition: cfgmgr32.h:687
#define ERROR_MORE_DATA
Definition: dderror.h:13
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI NtPlugPlayControl(IN PLUGPLAY_CONTROL_CLASS PlugPlayControlClass, IN OUT PVOID Buffer, IN ULONG BufferLength)
Definition: plugplay.c:1303
#define CM_DRP_CHARACTERISTICS
Definition: cfgmgr32.h:713
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define CM_DRP_CONFIGFLAGS
Definition: cfgmgr32.h:686
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define CM_DRP_CLASS
Definition: cfgmgr32.h:683
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define CM_DRP_ADDRESS
Definition: cfgmgr32.h:715
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define CM_DRP_UI_NUMBER_DESC_FORMAT
Definition: cfgmgr32.h:716
#define CM_DRP_LOCATION_PATHS
Definition: cfgmgr32.h:725
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
#define CM_DRP_INSTALL_STATE
Definition: cfgmgr32.h:722
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
#define CM_DRP_BUSNUMBER
Definition: cfgmgr32.h:703

Referenced by CM_Get_DevNode_Registry_Property_ExW(), GetDeviceInstanceKeyPath(), and PNP_GetClassInstance().

◆ PNP_GetDeviceStatus()

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

Definition at line 3171 of file rpcserver.c.

3177 {
3179  UNREFERENCED_PARAMETER(ulFlags);
3180 
3181  DPRINT("PNP_GetDeviceStatus(%p %S %p %p)\n",
3182  hBinding, pDeviceID, pulStatus, pulProblem, ulFlags);
3183 
3184  if (!IsValidDeviceInstanceID(pDeviceID))
3185  return CR_INVALID_DEVINST;
3186 
3187  return GetDeviceStatus(pDeviceID, pulStatus, pulProblem);
3188 }
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
static CONFIGRET GetDeviceStatus(_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
Definition: rpcserver.c:226
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by CM_Get_DevNode_Status_Ex().

◆ PNP_GetFirstLogConf()

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

Definition at line 3857 of file rpcserver.c.

3863 {
3864  HKEY hConfigKey = NULL;
3865  DWORD RegDataType = 0;
3866  ULONG ulDataSize = 0;
3867  LPBYTE lpData = NULL;
3869 
3870  DPRINT("PNP_GetFirstLogConf(%p %S %lu %p 0x%08lx)\n",
3871  hBinding, pDeviceID, ulLogConfType, pulLogConfTag, ulFlags);
3872 
3873  if (pulLogConfTag == NULL)
3874  return CR_INVALID_POINTER;
3875 
3876  *pulLogConfTag = (DWORD)0;
3877 
3878  if (ulFlags & ~LOG_CONF_BITS)
3879  return CR_INVALID_FLAG;
3880 
3881  if (!IsValidDeviceInstanceID(pDeviceID))
3882  return CR_INVALID_DEVINST;
3883 
3884  ret = OpenConfigurationKey(pDeviceID,
3885  &hConfigKey);
3886  if (ret != CR_SUCCESS)
3887  {
3888  DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
3890  goto done;
3891  }
3892 
3893  ret = GetConfigurationData(hConfigKey,
3894  ulLogConfType,
3895  &RegDataType,
3896  &ulDataSize,
3897  &lpData);
3898  if (ret != CR_SUCCESS)
3899  {
3900  DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
3902  goto done;
3903  }
3904 
3905  DPRINT("Data size %lu\n", ulDataSize);
3906  if (ulDataSize == 0 || lpData == NULL)
3907  {
3908  DPRINT1("No config data available!\n");
3910  goto done;
3911  }
3912 
3913  /* Get the first tag */
3914  if (RegDataType == REG_RESOURCE_LIST)
3915  {
3916  DPRINT("REG_RESOURCE_LIST\n");
3917 
3918  DPRINT("ResourceList->Count %lu\n", ((PCM_RESOURCE_LIST)lpData)->Count);
3919  if (((PCM_RESOURCE_LIST)lpData)->Count == 0)
3920  {
3921  DPRINT1("No resource descriptors!\n");
3923  goto done;
3924  }
3925 
3926  DPRINT("lpData %p\n", lpData);
3927  DPRINT("&List[0] %p\n", &(((PCM_RESOURCE_LIST)lpData)->List[0]));
3928 
3929  *pulLogConfTag = (DWORD)((DWORD_PTR)&(((PCM_RESOURCE_LIST)lpData)->List[0]) - (DWORD_PTR)lpData);
3930  DPRINT("Offset (Tag): 0x%08lx\n", *pulLogConfTag);
3931  }
3932  else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
3933  {
3934  DPRINT1("FIXME: REG_RESOURCE_REQUIREMENTS_LIST\n");
3935  /* FIXME */
3937  goto done;
3938  }
3939 
3940 done:
3941  if (lpData != NULL)
3942  HeapFree(GetProcessHeap(), 0, lpData);
3943 
3944  if (hConfigKey != NULL)
3945  RegCloseKey(hConfigKey);
3946 
3947  DPRINT("PNP_GetFirstLogConf() returns %lu\n", ret);
3948 
3949  return ret;
3950 }
struct _CM_RESOURCE_LIST * PCM_RESOURCE_LIST
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
handle_t hBinding
Definition: ctx_c.c:54
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:337
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define DWORD
Definition: nt_native.h:44
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
static CONFIGRET OpenConfigurationKey(_In_ LPCWSTR pszDeviceID, _Out_ PHKEY phKey)
Definition: rpcserver.c:415
#define CR_NO_MORE_LOG_CONF
Definition: cfgmgr32.h:859
#define CR_SUCCESS
Definition: cfgmgr32.h:842
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
static CONFIGRET GetConfigurationData(_In_ HKEY hKey, _In_ ULONG ulLogConfType, _Out_ PULONG pulRegDataType, _Out_ PULONG pulDataSize, _Out_ LPBYTE *ppBuffer)
Definition: rpcserver.c:459
#define GetProcessHeap()
Definition: compat.h:404
LIST_ENTRY List
Definition: psmgr.c:57
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
uint32_t DWORD_PTR
Definition: typedefs.h:64
#define LOG_CONF_BITS
Definition: cfgmgr32.h:603
RETURN_TYPE CONFIGRET
Definition: cfgmgr32.h:74
#define DPRINT1
Definition: precomp.h:8
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:403

Referenced by CM_Get_First_Log_Conf_Ex().

◆ PNP_GetGlobalState()

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

Definition at line 583 of file rpcserver.c.

587 {
589  UNREFERENCED_PARAMETER(ulFlags);
590 
591  DPRINT("PNP_GetGlobalState(%p %p 0x%08lx)\n",
592  hBinding, pulState, ulFlags);
593 
595 
596  return CR_SUCCESS;
597 }
handle_t hBinding
Definition: ctx_c.c:54
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define CR_SUCCESS
Definition: cfgmgr32.h:842
void DPRINT(...)
Definition: polytest.cpp:61
#define CM_GLOBAL_STATE_SERVICES_AVAILABLE
Definition: cfgmgr32.h:910
#define CM_GLOBAL_STATE_CAN_DO_UI
Definition: cfgmgr32.h:908

Referenced by CM_Get_Global_State_Ex().

◆ PNP_GetHwProfInfo()

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

Definition at line 3692 of file rpcserver.c.

3698 {
3699  WCHAR szProfileName[5];
3700  HKEY hKeyConfig = NULL;
3701  HKEY hKeyProfiles = NULL;
3702  HKEY hKeyProfile = NULL;
3703  DWORD dwDisposition;
3704  DWORD dwSize;
3705  LONG lError;
3707 
3709 
3710  DPRINT("PNP_GetHwProfInfo() called\n");
3711 
3712  if (ulProfileInfoSize == 0)
3713  {
3714  ret = CR_INVALID_DATA;
3715  goto done;
3716  }
3717 
3718  if (ulFlags != 0)
3719  {
3720  ret = CR_INVALID_FLAG;
3721  goto done;
3722  }
3723 
3724  /* Initialize the profile information */
3725  pHWProfileInfo->HWPI_ulHWProfile = 0;
3726  pHWProfileInfo->HWPI_szFriendlyName[0] = 0;
3727  pHWProfileInfo->HWPI_dwFlags = 0;
3728 
3729  /* Open the 'IDConfigDB' key */
3731  L"System\\CurrentControlSet\\Control\\IDConfigDB",
3732  0,
3733  NULL,
3736  NULL,
3737  &hKeyConfig,
3738  &dwDisposition);
3739  if (lError != ERROR_SUCCESS)
3740  {
3742  goto done;
3743  }
3744 
3745  /* Open the 'Hardware Profiles' subkey */
3746  lError = RegCreateKeyExW(hKeyConfig,
3747  L"Hardware Profiles",
3748  0,
3749  NULL,
3752  NULL,
3753  &hKeyProfiles,
3754  &dwDisposition);
3755  if (lError != ERROR_SUCCESS)
3756  {
3758  goto done;
3759  }
3760 
3761  if (ulIndex == (ULONG)-1)
3762  {
3763  dwSize = sizeof(