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

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

DWORD WINAPI RpcServerThread (LPVOID lpParameter)
 
void __RPC_FAR *__RPC_USER midl_user_allocate (SIZE_T len)
 
void __RPC_USER midl_user_free (void __RPC_FAR *ptr)
 
static CONFIGRET WINAPI NtStatusToCrError (NTSTATUS Status)
 
static VOID SplitDeviceInstanceID (IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
 
static CONFIGRET ClearDeviceStatus (_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
 
static CONFIGRET GetDeviceStatus (_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
 
static CONFIGRET SetDeviceStatus (_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
 
static CONFIGRET DisableDeviceInstance (_In_ LPWSTR pszDeviceInstance, _Inout_opt_ PPNP_VETO_TYPE pVetoType, _Inout_opt_ LPWSTR pszVetoName, _In_ DWORD ulNameLength)
 
static BOOL IsValidDeviceInstanceID (_In_ PWSTR pszDeviceInstanceID)
 
static BOOL IsRootDeviceInstanceID (_In_ PWSTR pszDeviceInstanceID)
 
static BOOL IsPresentDeviceInstanceID (_In_ LPWSTR pszDeviceInstanceID)
 
static CONFIGRET OpenConfigurationKey (_In_ LPCWSTR pszDeviceID, _In_ DWORD ulLogConfType, _Out_ PHKEY phKey)
 
static CONFIGRET GetConfigurationData (_In_ HKEY hKey, _In_ ULONG ulLogConfType, _Out_ PULONG pulRegDataType, _Out_ PULONG pulDataSize, _Out_ LPBYTE *ppBuffer)
 
static BOOL IsCallerInteractive (_In_ handle_t hBinding)
 
VOID __RPC_USER PNP_NOTIFY_HANDLE_rundown (PNP_NOTIFY_HANDLE pHandle)
 
DWORD WINAPI PNP_Disconnect (handle_t hBinding)
 
DWORD WINAPI PNP_Connect (handle_t hBinding)
 
DWORD WINAPI PNP_GetVersion (handle_t hBinding, WORD *pVersion)
 
DWORD WINAPI PNP_GetGlobalState (handle_t hBinding, DWORD *pulState, DWORD ulFlags)
 
DWORD WINAPI PNP_InitDetection (handle_t hBinding)
 
DWORD WINAPI PNP_ReportLogOn (handle_t hBinding, BOOL Admin, DWORD ProcessId)
 
DWORD WINAPI PNP_ValidateDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_GetRootDeviceInstance (handle_t hBinding, LPWSTR pDeviceID, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_GetRelatedDeviceInstance (handle_t hBinding, DWORD ulRelationship, LPWSTR pDeviceID, LPWSTR pRelatedDeviceId, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_EnumerateSubKeys (handle_t hBinding, DWORD ulBranch, DWORD ulIndex, LPWSTR Buffer, PNP_RPC_STRING_LEN ulLength, PNP_RPC_STRING_LEN *pulRequiredLen, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceList (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceList (_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceList (_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
CONFIGRET GetEnumeratorInstanceList (_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetAllInstanceList (_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
 
DWORD WINAPI PNP_GetDeviceList (handle_t hBinding, LPWSTR pszFilter, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
static CONFIGRET GetRelationsInstanceListSize (_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
 
static CONFIGRET GetServiceInstanceListSize (_In_ PWSTR pszService, _Out_ PDWORD pulLength)
 
static CONFIGRET GetDeviceInstanceListSize (_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
 
static CONFIGRET GetEnumeratorInstanceListSize (_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
 
static CONFIGRET GetAllInstanceListSize (_Out_ PULONG pulLength)
 
DWORD WINAPI PNP_GetDeviceListSize (handle_t hBinding, LPWSTR pszFilter, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDepth (handle_t hBinding, LPWSTR pszDeviceID, DWORD *pulDepth, DWORD ulFlags)
 
DWORD WINAPI PNP_GetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceID, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_PROP_SIZE *pulTransferLen, PNP_PROP_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetDeviceRegProp (handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassInstance (handle_t hBinding, LPWSTR pDeviceId, LPWSTR pszClassInstance, PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_CreateKey (handle_t hBinding, LPWSTR pszSubKey, DWORD samDesired, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteRegistryKey (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentKey, LPWSTR pszChildKey, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassCount (handle_t hBinding, DWORD *pulClassCount, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassName (handle_t hBinding, LPWSTR pszClassGuid, LPWSTR Buffer, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteClassKey (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceAlias (handle_t hBinding, LPWSTR pszInterfaceDevice, GUID *AliasInterfaceGuid, LPWSTR pszAliasInterfaceDevice, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceList (handle_t hBinding, GUID *InterfaceGuid, LPWSTR pszDeviceID, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetInterfaceDeviceListSize (handle_t hBinding, PNP_RPC_BUFFER_SIZE *pulLen, GUID *InterfaceGuid, LPWSTR pszDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszDeviceID, GUID *InterfaceGuid, LPWSTR pszReference, LPWSTR pszSymLink, PNP_RPC_STRING_LEN *pulLength, PNP_RPC_STRING_LEN *pulTransferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_UnregisterDeviceClassAssociation (handle_t hBinding, LPWSTR pszInterfaceDevice, DWORD ulFlags)
 
DWORD WINAPI PNP_GetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_SetClassRegProp (handle_t hBinding, LPWSTR pszClassGuid, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
 
static CONFIGRET CreateDeviceInstance (_In_ LPWSTR pszDeviceID, _In_ BOOL bPhantomDevice)
 
static CONFIGRET GenerateDeviceID (_Inout_ LPWSTR pszDeviceID, _In_ PNP_RPC_STRING_LEN ulLength)
 
DWORD WINAPI PNP_CreateDevInst (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszParentDeviceID, PNP_RPC_STRING_LEN ulLength, DWORD ulFlags)
 
static CONFIGRET SetupDeviceInstance (_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
 
static CONFIGRET EnableDeviceInstance (_In_ LPWSTR pszDeviceInstance)
 
static CONFIGRET ReenumerateDeviceInstance (_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulMinorAction)
 
DWORD WINAPI PNP_DeviceInstanceAction (handle_t hBinding, DWORD ulMajorAction, DWORD ulMinorAction, LPWSTR pszDeviceInstance1, LPWSTR pszDeviceInstance2)
 
DWORD WINAPI PNP_GetDeviceStatus (handle_t hBinding, LPWSTR pDeviceID, DWORD *pulStatus, DWORD *pulProblem, DWORD ulFlags)
 
DWORD WINAPI PNP_SetDeviceProblem (handle_t hBinding, LPWSTR pDeviceID, DWORD ulProblem, DWORD ulFlags)
 
DWORD WINAPI PNP_DisableDevInst (handle_t hBinding, LPWSTR pDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_UninstallDevInst (handle_t hBinding, LPWSTR pDeviceID, DWORD ulFlags)
 
static BOOL CheckForDeviceId (LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
 
static VOID AppendDeviceId (LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
 
DWORD WINAPI PNP_AddID (handle_t hBinding, LPWSTR pszDeviceID, LPWSTR pszID, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterDriver (handle_t hBinding, LPWSTR pszDeviceID, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryRemove (handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_RequestDeviceEject (handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
CONFIGRET WINAPI PNP_IsDockStationPresent (handle_t hBinding, BOOL *Present)
 
DWORD WINAPI PNP_RequestEjectPC (handle_t hBinding)
 
DWORD WINAPI PNP_HwProfFlags (handle_t hBinding, DWORD ulAction, LPWSTR pDeviceID, DWORD ulConfig, DWORD *pulValue, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetHwProfInfo (handle_t hBinding, DWORD ulIndex, HWPROFILEINFO *pHWProfileInfo, DWORD ulProfileInfoSize, DWORD ulFlags)
 
DWORD WINAPI PNP_AddEmptyLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulPriority, DWORD *pulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_FreeLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetFirstLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD *pulLogConfTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetNextLogConf (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfType, DWORD ulCurrentTag, DWORD *pulNextTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetLogConfPriority (handle_t hBinding, LPWSTR pDeviceID, DWORD ulType, DWORD ulTag, DWORD *pPriority, DWORD ulFlags)
 
DWORD WINAPI PNP_AddResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD *pulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
 
DWORD WINAPI PNP_FreeResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulPreviousResType, DWORD *pulPreviousResTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetNextResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulNextResType, DWORD *pulNextResTag, DWORD ulFlags)
 
DWORD WINAPI PNP_GetResDesData (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_GetResDesDataSize (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID ResourceID, DWORD ulResourceTag, DWORD *pulSize, DWORD ulFlags)
 
DWORD WINAPI PNP_ModifyResDes (handle_t hBinding, LPWSTR pDeviceID, DWORD ulLogConfTag, DWORD ulLogConfType, RESOURCEID CurrentResourceID, RESOURCEID NewResourceID, DWORD ulResourceTag, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, DWORD ulFlags)
 
DWORD WINAPI PNP_DetectResourceConflict (handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BOOL *pbConflictDetected, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryResConfList (handle_t hBinding, LPWSTR pDeviceID, RESOURCEID ResourceID, BYTE *ResourceData, PNP_RPC_BUFFER_SIZE ResourceLen, BYTE *Buffer, PNP_RPC_BUFFER_SIZE BufferLen, DWORD ulFlags)
 
DWORD WINAPI PNP_SetHwProf (handle_t hBinding, DWORD ulHardwareProfile, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryArbitratorFreeData (handle_t hBinding, BYTE *pData, DWORD DataLen, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
 
DWORD WINAPI PNP_QueryArbitratorFreeSize (handle_t hBinding, DWORD *pulSize, LPWSTR pDeviceID, RESOURCEID ResourceID, DWORD ulFlags)
 
CONFIGRET WINAPI PNP_RunDetection (handle_t hBinding, DWORD ulFlags)
 
DWORD WINAPI PNP_RegisterNotification (handle_t hBinding, DWORD_PTR hRecipient, LPWSTR pszName, BYTE *pNotificationFilter, DWORD ulNotificationFilterSize, DWORD ulFlags, PNP_NOTIFY_HANDLE *pNotifyHandle, DWORD ulProcessId, DWORD *pulUnknown9)
 
DWORD WINAPI PNP_UnregisterNotification (handle_t hBinding, PNP_NOTIFY_HANDLE *pNotifyHandle)
 
DWORD WINAPI PNP_GetCustomDevProp (handle_t hBinding, LPWSTR pDeviceID, LPWSTR CustomPropName, DWORD *pulRegDataType, BYTE *Buffer, PNP_RPC_STRING_LEN *pulTransferLen, PNP_RPC_STRING_LEN *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetVersionInternal (handle_t hBinding, WORD *pwVersion)
 
DWORD WINAPI PNP_GetBlockedDriverInfo (handle_t hBinding, BYTE *Buffer, PNP_RPC_BUFFER_SIZE *pulTransferLen, PNP_RPC_BUFFER_SIZE *pulLength, DWORD ulFlags)
 
DWORD WINAPI PNP_GetServerSideDeviceInstallFlags (handle_t hBinding, DWORD *pulSSDIFlags, DWORD ulFlags)
 
DWORD WINAPI PNP_GetObjectPropKeys (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, PNP_PROP_COUNT *PropertyCount, PNP_PROP_COUNT *TransferLen, DEVPROPKEY *PropertyKeys, DWORD Flags)
 
DWORD WINAPI PNP_GetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE *PropertyType, PNP_PROP_SIZE *PropertySize, PNP_PROP_SIZE *TransferLen, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_SetObjectProp (handle_t hBinding, LPWSTR ObjectName, DWORD ObjectType, LPWSTR PropertyCultureName, const DEVPROPKEY *PropertyKey, DEVPROPTYPE PropertyType, PNP_PROP_SIZE PropertySize, BYTE *PropertyBuffer, DWORD Flags)
 
DWORD WINAPI PNP_InstallDevInst (handle_t hBinding)
 
DWORD WINAPI PNP_ApplyPowerSettings (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreAddDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_DriverStoreDeleteDriverPackage (handle_t hBinding)
 
DWORD WINAPI PNP_RegisterServiceNotification (handle_t hBinding)
 
DWORD WINAPI PNP_SetActiveService (handle_t hBinding, LPWSTR pszFilter, DWORD ulFlags)
 
DWORD WINAPI PNP_DeleteServiceDevices (handle_t hBinding)
 

Variables

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

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 33 of file rpcserver.c.

Function Documentation

◆ AppendDeviceId()

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

Definition at line 3604 of file rpcserver.c.

3607{
3608 DWORD dwLen;
3609 DWORD dwPos;
3610
3611 dwLen = wcslen(lpDeviceId);
3612 dwPos = (*lpDeviceIdListSize / sizeof(WCHAR)) - 1;
3613
3614 wcscpy(&lpDeviceIdList[dwPos], lpDeviceId);
3615
3616 dwPos += (dwLen + 1);
3617
3618 lpDeviceIdList[dwPos] = 0;
3619
3620 *lpDeviceIdListSize = dwPos * sizeof(WCHAR);
3621}
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by PNP_AddID().

◆ CheckForDeviceId()

static BOOL CheckForDeviceId ( LPWSTR  lpDeviceIdList,
LPWSTR  lpDeviceId 
)
static

Definition at line 3583 of file rpcserver.c.

3585{
3586 LPWSTR lpPtr;
3588
3589 lpPtr = lpDeviceIdList;
3590 while (*lpPtr != 0)
3591 {
3592 dwLength = wcslen(lpPtr);
3593 if (0 == _wcsicmp(lpPtr, lpDeviceId))
3594 return TRUE;
3595
3596 lpPtr += (dwLength + 1);
3597 }
3598
3599 return FALSE;
3600}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static DWORD DWORD * dwLength
Definition: fusion.c:86
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by PNP_AddID().

◆ ClearDeviceStatus()

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

Definition at line 199 of file rpcserver.c.

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

Referenced by PNP_SetDeviceProblem(), and SetupDeviceInstance().

◆ CreateDeviceInstance()

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

Definition at line 2956 of file rpcserver.c.

2959{
2960 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
2961 WCHAR szDevice[MAX_DEVICE_ID_LEN];
2962 WCHAR szInstance[MAX_DEVICE_ID_LEN];
2963 HKEY hKeyEnumerator;
2964 HKEY hKeyDevice;
2965 HKEY hKeyInstance;
2966 HKEY hKeyControl;
2967 LONG lError;
2968
2969 /* Split the instance ID */
2970 SplitDeviceInstanceID(pszDeviceID,
2971 szEnumerator,
2972 szDevice,
2973 szInstance);
2974
2975 /* Open or create the enumerator key */
2976 lError = RegCreateKeyExW(hEnumKey,
2977 szEnumerator,
2978 0,
2979 NULL,
2982 NULL,
2983 &hKeyEnumerator,
2984 NULL);
2985 if (lError != ERROR_SUCCESS)
2986 {
2987 return CR_REGISTRY_ERROR;
2988 }
2989
2990 /* Open or create the device key */
2991 lError = RegCreateKeyExW(hKeyEnumerator,
2992 szDevice,
2993 0,
2994 NULL,
2997 NULL,
2998 &hKeyDevice,
2999 NULL);
3000
3001 /* Close the enumerator key */
3002 RegCloseKey(hKeyEnumerator);
3003
3004 if (lError != ERROR_SUCCESS)
3005 {
3006 return CR_REGISTRY_ERROR;
3007 }
3008
3009 /* Try to open the instance key and fail if it exists */
3010 lError = RegOpenKeyExW(hKeyDevice,
3011 szInstance,
3012 0,
3014 &hKeyInstance);
3015 if (lError == ERROR_SUCCESS)
3016 {
3017 DPRINT1("Instance %S already exists!\n", szInstance);
3018 RegCloseKey(hKeyInstance);
3019 RegCloseKey(hKeyDevice);
3021 }
3022
3023 /* Create a new instance key */
3024 lError = RegCreateKeyExW(hKeyDevice,
3025 szInstance,
3026 0,
3027 NULL,
3030 NULL,
3031 &hKeyInstance,
3032 NULL);
3033
3034 /* Close the device key */
3035 RegCloseKey(hKeyDevice);
3036
3037 if (lError != ERROR_SUCCESS)
3038 {
3039 return CR_REGISTRY_ERROR;
3040 }
3041
3042 if (bPhantomDevice)
3043 {
3044 DWORD dwPhantomValue = 1;
3045 RegSetValueExW(hKeyInstance,
3046 L"Phantom",
3047 0,
3048 REG_DWORD,
3049 (PBYTE)&dwPhantomValue,
3050 sizeof(dwPhantomValue));
3051 }
3052
3053 /* Create the 'Control' sub key */
3054 lError = RegCreateKeyExW(hKeyInstance,
3055 L"Control",
3056 0,
3057 NULL,
3060 NULL,
3061 &hKeyControl,
3062 NULL);
3063 if (lError == ERROR_SUCCESS)
3064 {
3065 RegCloseKey(hKeyControl);
3066 }
3067
3068 RegCloseKey(hKeyInstance);
3069
3070 return (lError == ERROR_SUCCESS) ? CR_SUCCESS : CR_REGISTRY_ERROR;
3071}
HKEY hEnumKey
Definition: umpnpmgr.c:44
static VOID SplitDeviceInstanceID(IN LPWSTR pszDeviceInstanceID, OUT LPWSTR pszEnumerator, OUT LPWSTR pszDevice, OUT LPWSTR pszInstance)
Definition: rpcserver.c:153
#define RegCloseKey(hKey)
Definition: registry.h:49
#define CR_ALREADY_SUCH_DEVINST
Definition: cfgmgr32.h:862
#define CR_REGISTRY_ERROR
Definition: cfgmgr32.h:875
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_DEVICE_ID_LEN
Definition: devaction.c:40
#define NULL
Definition: types.h:112
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:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
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:4882
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by PNP_CreateDevInst().

◆ DisableDeviceInstance()

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

Definition at line 294 of file rpcserver.c.

299{
303
304 DPRINT1("DisableDeviceInstance(%S %p %p %lu)\n",
305 pszDeviceInstance, pVetoType, pszVetoName, ulNameLength);
306
307 RtlInitUnicodeString(&QueryRemoveData.DeviceInstance,
308 pszDeviceInstance);
309
310 QueryRemoveData.Flags = 0;
311 QueryRemoveData.VetoType = 0;
312 QueryRemoveData.VetoName = pszVetoName;
313 QueryRemoveData.NameLength = ulNameLength;
314
316 &QueryRemoveData,
319 {
321 }
323 {
324 if (pVetoType != NULL)
325 *pVetoType = QueryRemoveData.VetoType;
326
328 }
329 else if (!NT_SUCCESS(Status))
330 {
332 }
333
334 return ret;
335}
#define CR_INVALID_DEVNODE
Definition: cfgmgr32.h:847
#define CR_REMOVE_VETOED
Definition: cfgmgr32.h:869
@ PlugPlayControlQueryAndRemoveDevice
Definition: cmtypes.h:215
#define STATUS_PLUGPLAY_QUERY_VETOED
Definition: ntstatus.h:219
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

Referenced by PNP_DisableDevInst().

◆ EnableDeviceInstance()

static CONFIGRET EnableDeviceInstance ( _In_ LPWSTR  pszDeviceInstance)
static

Definition at line 3311 of file rpcserver.c.

3313{
3317
3318 DPRINT("Enable device instance %S\n", pszDeviceInstance);
3319
3320 RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceInstance);
3321 Status = NtPlugPlayControl(PlugPlayControlStartDevice, &ControlData, sizeof(ControlData));
3322 if (!NT_SUCCESS(Status))
3324
3325 return ret;
3326}
@ PlugPlayControlStartDevice
Definition: cmtypes.h:213
#define DPRINT
Definition: sndvol32.h:71

Referenced by PNP_DeviceInstanceAction().

◆ GenerateDeviceID()

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

Definition at line 3076 of file rpcserver.c.

3079{
3080 WCHAR szGeneratedInstance[MAX_DEVICE_ID_LEN];
3081 HKEY hKey;
3082 DWORD dwInstanceNumber;
3083 DWORD dwError = ERROR_SUCCESS;
3085
3086 /* Fail, if the device name contains backslashes */
3087 if (wcschr(pszDeviceID, L'\\') != NULL)
3088 return CR_INVALID_DEVICE_ID;
3089
3090 /* Generated ID is: Root<Device ID><Instance number> */
3091 dwInstanceNumber = 0;
3092 while (dwError == ERROR_SUCCESS)
3093 {
3094 if (dwInstanceNumber >= 10000)
3095 return CR_FAILURE;
3096
3097 swprintf(szGeneratedInstance, L"Root\\%ls\\%04lu",
3098 pszDeviceID, dwInstanceNumber);
3099
3100 /* Try to open the enum key of the device instance */
3101 dwError = RegOpenKeyEx(hEnumKey, szGeneratedInstance, 0, KEY_QUERY_VALUE, &hKey);
3102 if (dwError == ERROR_SUCCESS)
3103 {
3105 dwInstanceNumber++;
3106 }
3107 }
3108
3109 /* pszDeviceID is an out parameter too for generated IDs */
3110 if (wcslen(szGeneratedInstance) > ulLength)
3111 {
3113 }
3114 else
3115 {
3116 wcscpy(pszDeviceID, szGeneratedInstance);
3117 }
3118
3119 return ret;
3120}
#define CR_INVALID_DEVICE_ID
Definition: cfgmgr32.h:876
#define CR_FAILURE
Definition: cfgmgr32.h:865
#define CR_BUFFER_SMALL
Definition: cfgmgr32.h:872
#define wcschr
Definition: compat.h:17
#define swprintf
Definition: precomp.h:40
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define RegOpenKeyEx
Definition: winreg.h:520

Referenced by PNP_CreateDevInst().

◆ GetAllInstanceList()

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

Definition at line 1297 of file rpcserver.c.

1300{
1301 WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1302 PWSTR pPtr;
1303 DWORD dwIndex, dwEnumeratorLength, dwUsedLength, dwRemainingLength, dwPathLength;
1304 DWORD dwError;
1306
1307 dwUsedLength = 0;
1308 dwRemainingLength = *pulLength;
1309 pPtr = pszBuffer;
1310
1311 for (dwIndex = 0; ; dwIndex++)
1312 {
1313 dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1314 dwError = RegEnumKeyExW(hEnumKey,
1315 dwIndex,
1316 szEnumeratorBuffer,
1317 &dwEnumeratorLength,
1318 NULL, NULL, NULL, NULL);
1319 if (dwError != ERROR_SUCCESS)
1320 break;
1321
1322 dwPathLength = dwRemainingLength;
1323 ret = GetEnumeratorInstanceList(szEnumeratorBuffer,
1324 pPtr,
1325 &dwPathLength);
1326 if (ret != CR_SUCCESS)
1327 break;
1328
1329 dwUsedLength += dwPathLength - 1;
1330 dwRemainingLength -= dwPathLength - 1;
1331 pPtr += dwPathLength - 1;
1332 }
1333
1334 if (ret == CR_SUCCESS)
1335 *pulLength = dwUsedLength + 1;
1336 else
1337 *pulLength = 0;
1338
1339 return ret;
1340}
CONFIGRET GetEnumeratorInstanceList(_In_ PWSTR pszEnumerator, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1226
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:2504
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by PNP_GetDeviceList().

◆ GetAllInstanceListSize()

static CONFIGRET GetAllInstanceListSize ( _Out_ PULONG  pulLength)
static

Definition at line 1682 of file rpcserver.c.

1684{
1685 WCHAR szEnumeratorBuffer[MAX_DEVICE_ID_LEN];
1686 DWORD dwIndex, dwEnumeratorLength, dwBufferLength;
1687 DWORD dwError;
1689
1690 for (dwIndex = 0; ; dwIndex++)
1691 {
1692 dwEnumeratorLength = MAX_DEVICE_ID_LEN;
1693 dwError = RegEnumKeyExW(hEnumKey,
1694 dwIndex,
1695 szEnumeratorBuffer,
1696 &dwEnumeratorLength,
1697 NULL, NULL, NULL, NULL);
1698 if (dwError != ERROR_SUCCESS)
1699 break;
1700
1701 /* Get the size of all device instances for the enumerator */
1702 ret = GetEnumeratorInstanceListSize(szEnumeratorBuffer,
1703 &dwBufferLength);
1704 if (ret != CR_SUCCESS)
1705 break;
1706
1707 *pulLength += dwBufferLength;
1708 }
1709
1710 return ret;
1711}
static CONFIGRET GetEnumeratorInstanceListSize(_In_ LPCWSTR pszEnumerator, _Out_ PULONG pulLength)
Definition: rpcserver.c:1621

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

498{
499 LPCWSTR pszValueName;
500
501 switch (ulLogConfType)
502 {
503 case BOOT_LOG_CONF:
504 pszValueName = L"BootConfig";
505 *pulRegDataType = REG_RESOURCE_LIST;
506 break;
507
508 case ALLOC_LOG_CONF:
509 pszValueName = L"AllocConfig";
510 *pulRegDataType = REG_RESOURCE_LIST;
511 break;
512
513 case FORCED_LOG_CONF:
514 pszValueName = L"ForcedConfig";
515 *pulRegDataType = REG_RESOURCE_LIST;
516 break;
517
519 pszValueName = L"FilteredConfigVector";
520 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
521 break;
522
523 case BASIC_LOG_CONF:
524 pszValueName = L"BasicConfigVector";
525 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
526 break;
527
529 pszValueName = L"OverrideConfigVector";
530 *pulRegDataType = REG_RESOURCE_REQUIREMENTS_LIST;
531 break;
532
533 default:
534 DPRINT1("Unsupported configuration type!\n");
535 return CR_FAILURE;
536 }
537
538 /* Get the configuration data size */
540 pszValueName,
541 NULL,
542 NULL,
543 NULL,
544 pulDataSize) != ERROR_SUCCESS)
545 {
546 return CR_INVALID_LOG_CONF;
547 }
548
549 /* Allocate the buffer */
550 *ppBuffer = HeapAlloc(GetProcessHeap(), 0, *pulDataSize);
551 if (*ppBuffer == NULL)
552 {
553 return CR_OUT_OF_MEMORY;
554 }
555
556 /* Retrieve the configuration data */
558 pszValueName,
559 NULL,
560 NULL,
561 (LPBYTE)*ppBuffer,
562 pulDataSize) != ERROR_SUCCESS)
563 {
564 return CR_INVALID_LOG_CONF;
565 }
566
567 return CR_SUCCESS;
568}
#define FILTERED_LOG_CONF
Definition: cfgmgr32.h:597
#define BASIC_LOG_CONF
Definition: cfgmgr32.h:596
#define CR_OUT_OF_MEMORY
Definition: cfgmgr32.h:844
#define CR_INVALID_LOG_CONF
Definition: cfgmgr32.h:850
#define BOOT_LOG_CONF
Definition: cfgmgr32.h:599
#define OVERRIDE_LOG_CONF
Definition: cfgmgr32.h:601
#define ALLOC_LOG_CONF
Definition: cfgmgr32.h:598
#define FORCED_LOG_CONF
Definition: cfgmgr32.h:600
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
unsigned char * LPBYTE
Definition: typedefs.h:53
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

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

1159{
1160 WCHAR szInstanceBuffer[MAX_DEVICE_ID_LEN];
1161 WCHAR szPathBuffer[512];
1162 HKEY hDeviceKey;
1163 DWORD dwInstanceLength, dwPathLength, dwUsedLength;
1164 DWORD dwIndex, dwError;
1165 PWSTR pPtr;
1167
1168 /* Open the device key */
1169 dwError = RegOpenKeyExW(hEnumKey,
1170 pszDevice,
1171 0,
1173 &hDeviceKey);
1174 if (dwError != ERROR_SUCCESS)
1175 {
1176 DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1177 return CR_REGISTRY_ERROR;
1178 }
1179
1180 dwUsedLength = 0;
1181 pPtr = pszBuffer;
1182
1183 for (dwIndex = 0; ; dwIndex++)
1184 {
1185 dwInstanceLength = MAX_DEVICE_ID_LEN;
1186 dwError = RegEnumKeyExW(hDeviceKey,
1187 dwIndex,
1188 szInstanceBuffer,
1189 &dwInstanceLength,
1190 NULL,
1191 NULL,
1192 NULL,
1193 NULL);
1194 if (dwError != ERROR_SUCCESS)
1195 break;
1196
1197 wsprintf(szPathBuffer, L"%s\\%s", pszDevice, szInstanceBuffer);
1198 DPRINT("Path: %S\n", szPathBuffer);
1199
1200 dwPathLength = wcslen(szPathBuffer) + 1;
1201 if (dwUsedLength + dwPathLength + 1 > *pulLength)
1202 {
1204 break;
1205 }
1206
1207 wcscpy(pPtr, szPathBuffer);
1208 dwUsedLength += dwPathLength;
1209 pPtr += dwPathLength;
1210
1211 *pPtr = UNICODE_NULL;
1212 }
1213
1214 RegCloseKey(hDeviceKey);
1215
1216 if (ret == CR_SUCCESS)
1217 *pulLength = dwUsedLength + 1;
1218 else
1219 *pulLength = 0;
1220
1221 return ret;
1222}
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define UNICODE_NULL
#define wsprintf
Definition: winuser.h:5865

Referenced by GetEnumeratorInstanceList(), and PNP_GetDeviceList().

◆ GetDeviceInstanceListSize()

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

Definition at line 1569 of file rpcserver.c.

1572{
1573 HKEY hDeviceKey;
1574 DWORD dwSubKeys, dwMaxSubKeyLength;
1575 DWORD dwError;
1576
1577 /* Open the device key */
1578 dwError = RegOpenKeyExW(hEnumKey,
1579 pszDevice,
1580 0,
1581 KEY_READ,
1582 &hDeviceKey);
1583 if (dwError != ERROR_SUCCESS)
1584 {
1585 DPRINT("Failed to open the device key (Error %lu)\n", dwError);
1586 return CR_REGISTRY_ERROR;
1587 }
1588
1589 /* Retrieve the number of device instances and the maximum name length */
1590 dwError = RegQueryInfoKeyW(hDeviceKey,
1591 NULL,
1592 NULL,
1593 NULL,
1594 &dwSubKeys,
1595 &dwMaxSubKeyLength,
1596 NULL,
1597 NULL,
1598 NULL,
1599 NULL,
1600 NULL,
1601 NULL);
1602 if (dwError != ERROR_SUCCESS)
1603 {
1604 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1605 dwSubKeys = 0;
1606 dwMaxSubKeyLength = 0;
1607 }
1608
1609 /* Close the device key */
1610 RegCloseKey(hDeviceKey);
1611
1612 /* Return the largest possible buffer size */
1613 *pulLength = dwSubKeys * (wcslen(pszDevice) + 1 + dwMaxSubKeyLength + 1);
1614
1615 return CR_SUCCESS;
1616}
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:3662
#define KEY_READ
Definition: nt_native.h:1023

Referenced by GetEnumeratorInstanceListSize(), and PNP_GetDeviceListSize().

◆ GetDeviceStatus()

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

Definition at line 229 of file rpcserver.c.

233{
234 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
237
238 DPRINT("GetDeviceStatus(%S %p %p)\n",
239 pszDeviceID, pulStatus, pulProblem);
240
242 pszDeviceID);
243 PlugPlayData.Operation = PNP_GET_DEVICE_STATUS;
244
246 (PVOID)&PlugPlayData,
248 if (NT_SUCCESS(Status))
249 {
250 *pulStatus = PlugPlayData.DeviceStatus;
251 *pulProblem = PlugPlayData.DeviceProblem;
252 }
253 else
254 {
256 }
257
258 return ret;
259}
#define PNP_GET_DEVICE_STATUS
Definition: cmtypes.h:59

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

◆ GetEnumeratorInstanceList()

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

Definition at line 1226 of file rpcserver.c.

1230{
1231 WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1232 WCHAR szPathBuffer[512];
1233 HKEY hEnumeratorKey;
1234 PWSTR pPtr;
1235 DWORD dwIndex, dwDeviceLength, dwUsedLength, dwRemainingLength, dwPathLength;
1236 DWORD dwError;
1238
1239 /* Open the enumerator key */
1240 dwError = RegOpenKeyExW(hEnumKey,
1241 pszEnumerator,
1242 0,
1244 &hEnumeratorKey);
1245 if (dwError != ERROR_SUCCESS)
1246 {
1247 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1248 return CR_REGISTRY_ERROR;
1249 }
1250
1251 dwUsedLength = 0;
1252 dwRemainingLength = *pulLength;
1253 pPtr = pszBuffer;
1254
1255 for (dwIndex = 0; ; dwIndex++)
1256 {
1257 dwDeviceLength = MAX_DEVICE_ID_LEN;
1258 dwError = RegEnumKeyExW(hEnumeratorKey,
1259 dwIndex,
1260 szDeviceBuffer,
1261 &dwDeviceLength,
1262 NULL,
1263 NULL,
1264 NULL,
1265 NULL);
1266 if (dwError != ERROR_SUCCESS)
1267 break;
1268
1269 wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1270 DPRINT("Path: %S\n", szPathBuffer);
1271
1272 dwPathLength = dwRemainingLength;
1273 ret = GetDeviceInstanceList(szPathBuffer,
1274 pPtr,
1275 &dwPathLength);
1276 if (ret != CR_SUCCESS)
1277 break;
1278
1279 dwUsedLength += dwPathLength - 1;
1280 dwRemainingLength -= dwPathLength - 1;
1281 pPtr += dwPathLength - 1;
1282 }
1283
1284 RegCloseKey(hEnumeratorKey);
1285
1286 if (ret == CR_SUCCESS)
1287 *pulLength = dwUsedLength + 1;
1288 else
1289 *pulLength = 0;
1290
1291 return ret;
1292}
static CONFIGRET GetDeviceInstanceList(_In_ PWSTR pszDevice, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1155

Referenced by GetAllInstanceList(), and PNP_GetDeviceList().

◆ GetEnumeratorInstanceListSize()

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

Definition at line 1621 of file rpcserver.c.

1624{
1625 WCHAR szDeviceBuffer[MAX_DEVICE_ID_LEN];
1626 WCHAR szPathBuffer[512];
1627 HKEY hEnumeratorKey;
1628 DWORD dwIndex, dwDeviceLength, dwBufferLength;
1629 DWORD dwError;
1631
1632 *pulLength = 0;
1633
1634 /* Open the enumerator key */
1635 dwError = RegOpenKeyExW(hEnumKey,
1636 pszEnumerator,
1637 0,
1639 &hEnumeratorKey);
1640 if (dwError != ERROR_SUCCESS)
1641 {
1642 DPRINT("Failed to open the enumerator key (Error %lu)\n", dwError);
1643 return CR_REGISTRY_ERROR;
1644 }
1645
1646 for (dwIndex = 0; ; dwIndex++)
1647 {
1648 dwDeviceLength = MAX_DEVICE_ID_LEN;
1649 dwError = RegEnumKeyExW(hEnumeratorKey,
1650 dwIndex,
1651 szDeviceBuffer,
1652 &dwDeviceLength,
1653 NULL,
1654 NULL,
1655 NULL,
1656 NULL);
1657 if (dwError != ERROR_SUCCESS)
1658 break;
1659
1660 wsprintf(szPathBuffer, L"%s\\%s", pszEnumerator, szDeviceBuffer);
1661 DPRINT("Path: %S\n", szPathBuffer);
1662
1663 ret = GetDeviceInstanceListSize(szPathBuffer, &dwBufferLength);
1664 if (ret != CR_SUCCESS)
1665 {
1666 *pulLength = 0;
1667 break;
1668 }
1669
1670 *pulLength += dwBufferLength;
1671 }
1672
1673 /* Close the enumerator key */
1674 RegCloseKey(hEnumeratorKey);
1675
1676 return ret;
1677}
static CONFIGRET GetDeviceInstanceListSize(_In_ LPCWSTR pszDevice, _Out_ PULONG pulLength)
Definition: rpcserver.c:1569

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

990{
994
996 pszDevice);
997
999 {
1000 PlugPlayData.Relations = 3;
1001 }
1002 else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1003 {
1004 PlugPlayData.Relations = 2;
1005 }
1006 else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1007 {
1008 PlugPlayData.Relations = 1;
1009 }
1010 else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1011 {
1012 PlugPlayData.Relations = 0;
1013 }
1014
1015 PlugPlayData.BufferSize = *pulLength * sizeof(WCHAR);
1016 PlugPlayData.Buffer = pszBuffer;
1017
1019 (PVOID)&PlugPlayData,
1021 if (NT_SUCCESS(Status))
1022 {
1023 *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1024 }
1025 else
1026 {
1028 }
1029
1030 return ret;
1031}
#define CM_GETIDLIST_FILTER_REMOVALRELATIONS
Definition: cfgmgr32.h:658
#define CM_GETIDLIST_FILTER_EJECTRELATIONS
Definition: cfgmgr32.h:657
#define CM_GETIDLIST_FILTER_BUSRELATIONS
Definition: cfgmgr32.h:660
#define CM_GETIDLIST_FILTER_POWERRELATIONS
Definition: cfgmgr32.h:659
@ PlugPlayControlQueryDeviceRelations
Definition: cmtypes.h:225

Referenced by PNP_GetDeviceList().

◆ GetRelationsInstanceListSize()

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

Definition at line 1420 of file rpcserver.c.

1424{
1428
1430 pszDevice);
1431
1433 {
1434 PlugPlayData.Relations = 3;
1435 }
1436 else if (ulFlags & CM_GETIDLIST_FILTER_POWERRELATIONS)
1437 {
1438 PlugPlayData.Relations = 2;
1439 }
1440 else if (ulFlags & CM_GETIDLIST_FILTER_REMOVALRELATIONS)
1441 {
1442 PlugPlayData.Relations = 1;
1443 }
1444 else if (ulFlags & CM_GETIDLIST_FILTER_EJECTRELATIONS)
1445 {
1446 PlugPlayData.Relations = 0;
1447 }
1448
1449 PlugPlayData.BufferSize = 0;
1450 PlugPlayData.Buffer = NULL;
1451
1453 (PVOID)&PlugPlayData,
1455 if (NT_SUCCESS(Status))
1456 {
1457 *pulLength = PlugPlayData.BufferSize / sizeof(WCHAR);
1458 }
1459 else
1460 {
1462 }
1463
1464 return ret;
1465}

Referenced by PNP_GetDeviceListSize().

◆ GetServiceInstanceList()

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

Definition at line 1036 of file rpcserver.c.

1040{
1041 WCHAR szPathBuffer[512];
1042 WCHAR szName[16];
1043 HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1044 DWORD dwValues, dwSize, dwIndex, dwUsedLength, dwPathLength;
1045 DWORD dwError;
1046 PWSTR pPtr;
1048
1049 /* Open the device key */
1051 L"System\\CurrentControlSet\\Services",
1052 0,
1053 KEY_READ,
1054 &hServicesKey);
1055 if (dwError != ERROR_SUCCESS)
1056 {
1057 DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1058 return CR_REGISTRY_ERROR;
1059 }
1060
1061 dwError = RegOpenKeyExW(hServicesKey,
1062 pszService,
1063 0,
1064 KEY_READ,
1065 &hServiceKey);
1066 if (dwError != ERROR_SUCCESS)
1067 {
1068 DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1070 goto Done;
1071 }
1072
1073 dwError = RegOpenKeyExW(hServiceKey,
1074 L"Enum",
1075 0,
1076 KEY_READ,
1077 &hEnumKey);
1078 if (dwError != ERROR_SUCCESS)
1079 {
1080 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1082 goto Done;
1083 }
1084
1085 /* Retrieve the number of device instances */
1086 dwSize = sizeof(DWORD);
1087 dwError = RegQueryValueExW(hEnumKey,
1088 L"Count",
1089 NULL,
1090 NULL,
1091 (LPBYTE)&dwValues,
1092 &dwSize);
1093 if (dwError != ERROR_SUCCESS)
1094 {
1095 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1096 dwValues = 1;
1097 }
1098
1099 DPRINT("dwValues %lu\n", dwValues);
1100
1101 dwUsedLength = 0;
1102 pPtr = pszBuffer;
1103
1104 for (dwIndex = 0; dwIndex < dwValues; dwIndex++)
1105 {
1106 wsprintf(szName, L"%lu", dwIndex);
1107
1108 dwSize = sizeof(szPathBuffer);
1109 dwError = RegQueryValueExW(hEnumKey,
1110 szName,
1111 NULL,
1112 NULL,
1113 (LPBYTE)szPathBuffer,
1114 &dwSize);
1115 if (dwError != ERROR_SUCCESS)
1116 break;
1117
1118 DPRINT("Path: %S\n", szPathBuffer);
1119
1120 dwPathLength = wcslen(szPathBuffer) + 1;
1121 if (dwUsedLength + dwPathLength + 1 > *pulLength)
1122 {
1124 break;
1125 }
1126
1127 wcscpy(pPtr, szPathBuffer);
1128 dwUsedLength += dwPathLength;
1129 pPtr += dwPathLength;
1130
1131 *pPtr = UNICODE_NULL;
1132 }
1133
1134Done:
1135 if (hEnumKey != NULL)
1137
1138 if (hServiceKey != NULL)
1139 RegCloseKey(hServiceKey);
1140
1141 if (hServicesKey != NULL)
1143
1144 if (ret == CR_SUCCESS)
1145 *pulLength = dwUsedLength + 1;
1146 else
1147 *pulLength = 0;
1148
1149 return ret;
1150}
static HANDLE hServicesKey
Definition: devinst.c:21
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define DWORD
Definition: nt_native.h:44
static const WCHAR szName[]
Definition: powrprof.c:45
#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 1470 of file rpcserver.c.

1473{
1474 HKEY hServicesKey = NULL, hServiceKey = NULL, hEnumKey = NULL;
1475 DWORD dwValues, dwMaxValueLength, dwSize;
1476 DWORD dwError;
1478
1479 /* Open the device key */
1481 L"System\\CurrentControlSet\\Services",
1482 0,
1483 KEY_READ,
1484 &hServicesKey);
1485 if (dwError != ERROR_SUCCESS)
1486 {
1487 DPRINT("Failed to open the services key (Error %lu)\n", dwError);
1488 return CR_REGISTRY_ERROR;
1489 }
1490
1491 dwError = RegOpenKeyExW(hServicesKey,
1492 pszService,
1493 0,
1494 KEY_READ,
1495 &hServiceKey);
1496 if (dwError != ERROR_SUCCESS)
1497 {
1498 DPRINT("Failed to open the service key (Error %lu)\n", dwError);
1500 goto Done;
1501 }
1502
1503 dwError = RegOpenKeyExW(hServiceKey,
1504 L"Enum",
1505 0,
1506 KEY_READ,
1507 &hEnumKey);
1508 if (dwError != ERROR_SUCCESS)
1509 {
1510 DPRINT("Failed to open the service enum key (Error %lu)\n", dwError);
1512 goto Done;
1513 }
1514
1515 /* Retrieve the number of device instances */
1516 dwSize = sizeof(DWORD);
1517 dwError = RegQueryValueExW(hEnumKey,
1518 L"Count",
1519 NULL,
1520 NULL,
1521 (LPBYTE)&dwValues,
1522 &dwSize);
1523 if (dwError != ERROR_SUCCESS)
1524 {
1525 DPRINT("RegQueryValueExW failed (Error %lu)\n", dwError);
1526 dwValues = 1;
1527 }
1528
1529 /* Retrieve the maximum instance name length */
1530 dwError = RegQueryInfoKeyW(hEnumKey,
1531 NULL,
1532 NULL,
1533 NULL,
1534 NULL,
1535 NULL,
1536 NULL,
1537 NULL,
1538 NULL,
1539 &dwMaxValueLength,
1540 NULL,
1541 NULL);
1542 if (dwError != ERROR_SUCCESS)
1543 {
1544 DPRINT("RegQueryInfoKeyW failed (Error %lu)\n", dwError);
1545 dwMaxValueLength = MAX_DEVICE_ID_LEN;
1546 }
1547
1548 DPRINT("dwValues %lu dwMaxValueLength %lu\n", dwValues, dwMaxValueLength / sizeof(WCHAR));
1549
1550 /* Return the largest possible buffer size */
1551 *pulLength = dwValues * dwMaxValueLength / sizeof(WCHAR) + 2;
1552
1553Done:
1554 if (hEnumKey != NULL)
1556
1557 if (hServiceKey != NULL)
1558 RegCloseKey(hServiceKey);
1559
1560 if (hServicesKey != NULL)
1562
1563 return ret;
1564}

Referenced by PNP_GetDeviceListSize().

◆ IsCallerInteractive()

static BOOL IsCallerInteractive ( _In_ handle_t  hBinding)
static

Definition at line 573 of file rpcserver.c.

575{
577 HANDLE hToken;
578 PSID pInteractiveSid = NULL;
579 BOOL bInteractive = FALSE;
580 RPC_STATUS RpcStatus;
581
582 DPRINT("IsCallerInteractive(%p)\n", hBinding);
583
584 /* Allocate an interactive user sid */
586 1,
588 0, 0, 0, 0, 0, 0, 0,
589 &pInteractiveSid))
590 {
591 DPRINT1("AllocateAndInitializeSid failed\n");
592 return FALSE;
593 }
594
595 /* Impersonate the client */
596 RpcStatus = RpcImpersonateClient(hBinding);
597 if (RpcStatus != RPC_S_OK)
598 {
599 DPRINT1("RpcImpersonateClient failed (Status 0x%08lx)\n", RpcStatus);
600 goto done;
601 }
602
603 /* Open the thread token and check for interactive user membership */
605 {
606 CheckTokenMembership(hToken, pInteractiveSid, &bInteractive);
607 CloseHandle(hToken);
608 }
609
610 /* Revert the impersonation */
612
613done:
614 if (pInteractiveSid)
615 FreeSid(pInteractiveSid);
616
617 return bInteractive;
618}
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
handle_t hBinding
Definition: ctx_c.c:54
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define CloseHandle
Definition: compat.h:739
unsigned int BOOL
Definition: ntddk_ex.h:94
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
#define RPC_S_OK
Definition: rpcnterr.h:22
long RPC_STATUS
Definition: rpc.h:52
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define SECURITY_INTERACTIVE_RID
Definition: setypes.h:559
#define TOKEN_QUERY
Definition: setypes.h:928
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554

Referenced by PNP_ReportLogOn().

◆ IsPresentDeviceInstanceID()

static BOOL IsPresentDeviceInstanceID ( _In_ LPWSTR  pszDeviceInstanceID)
static

Definition at line 418 of file rpcserver.c.

420{
421 DWORD ulStatus, ulProblem;
422
423 return (GetDeviceStatus(pszDeviceInstanceID, &ulStatus, &ulProblem) == CR_SUCCESS);
424}
static CONFIGRET GetDeviceStatus(_In_ LPWSTR pszDeviceID, _Out_ DWORD *pulStatus, _Out_ DWORD *pulProblem)
Definition: rpcserver.c:229

Referenced by PNP_CreateDevInst(), and PNP_GetRelatedDeviceInstance().

◆ IsRootDeviceInstanceID()

static BOOL IsRootDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 406 of file rpcserver.c.

408{
409 if (_wcsicmp(pszDeviceInstanceID, szRootDeviceInstanceID) == 0)
410 return TRUE;
411
412 return FALSE;
413}
static WCHAR szRootDeviceInstanceID[]
Definition: rpcserver.c:39

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

◆ IsValidDeviceInstanceID()

static BOOL IsValidDeviceInstanceID ( _In_ PWSTR  pszDeviceInstanceID)
static

Definition at line 340 of file rpcserver.c.

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

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

◆ midl_user_allocate()

void __RPC_FAR *__RPC_USER midl_user_allocate ( SIZE_T  len)

Definition at line 111 of file rpcserver.c.

112{
114}
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLenum GLsizei len
Definition: glext.h:6722

◆ midl_user_free()

void __RPC_USER midl_user_free ( void __RPC_FAR ptr)

Definition at line 117 of file rpcserver.c.

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

◆ NtStatusToCrError()

static CONFIGRET WINAPI NtStatusToCrError ( NTSTATUS  Status)
static

Definition at line 124 of file rpcserver.c.

125{
126 switch (Status)
127 {
130
132 return CR_INVALID_DATA;
133
135 return CR_NO_SUCH_DEVINST;
136
138 return CR_ACCESS_DENIED;
139
141 return CR_BUFFER_SMALL;
142
144 return CR_NO_SUCH_VALUE;
145
146 default:
147 return CR_FAILURE;
148 }
149}
#define CR_INVALID_DATA
Definition: cfgmgr32.h:877
#define CR_NO_SUCH_DEVINST
Definition: cfgmgr32.h:858
#define CR_ACCESS_DENIED
Definition: cfgmgr32.h:897
#define CR_CALL_NOT_IMPLEMENTED
Definition: cfgmgr32.h:898
#define CR_NO_SUCH_VALUE
Definition: cfgmgr32.h:883
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

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

◆ OpenConfigurationKey()

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

Definition at line 429 of file rpcserver.c.

433{
434 WCHAR szKeyName[MAX_PATH];
435 PCWSTR pszSubKeyName;
436 HKEY hInstanceKey;
437 DWORD dwError;
438
439 /* Build the full device instance key name */
440 wcscpy(szKeyName, L"System\\CurrentControlSet\\Enum\\");
441 wcscat(szKeyName, pszDeviceID);
442
443 /* Open the device instance key */
445 szKeyName,
446 0,
448 &hInstanceKey);
449 if (dwError != ERROR_SUCCESS)
450 return CR_INVALID_DEVINST;
451
452 switch (ulLogConfType)
453 {
454 case BOOT_LOG_CONF:
455 case BASIC_LOG_CONF:
456 pszSubKeyName = L"LogConf";
457 break;
458
459 case ALLOC_LOG_CONF:
461 pszSubKeyName = L"Control";
462 break;
463
464 default:
465 DPRINT1("Unsupported configuration type!\n");
466 return CR_FAILURE;
467 }
468
469 /* Create or open the LogConf key */
470 dwError = RegCreateKeyExW(hInstanceKey,
471 pszSubKeyName,
472 0,
473 NULL,
476 NULL,
477 phKey,
478 NULL);
479
480 /* Close the device instance key */
481 RegCloseKey(hInstanceKey);
482
483 if (dwError != ERROR_SUCCESS)
484 return CR_REGISTRY_ERROR;
485
486 return CR_SUCCESS;
487}
#define CR_INVALID_DEVINST
Definition: cfgmgr32.h:848
#define MAX_PATH
Definition: compat.h:34
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
const uint16_t * PCWSTR
Definition: typedefs.h:57

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

4167{
4170}
#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 3627 of file rpcserver.c.

3632{
3634 HKEY hDeviceKey;
3635 LPWSTR pszSubKey;
3636 DWORD dwDeviceIdListSize;
3637 DWORD dwNewDeviceIdSize;
3638 WCHAR * pszDeviceIdList = NULL;
3639
3641
3642 DPRINT("PNP_AddID(%p %S %S 0x%08lx)\n",
3643 hBinding, pszDeviceID, pszID, ulFlags);
3644
3646 pszDeviceID,
3647 0,
3649 &hDeviceKey) != ERROR_SUCCESS)
3650 {
3651 DPRINT("Failed to open the device key!\n");
3652 return CR_INVALID_DEVNODE;
3653 }
3654
3655 pszSubKey = (ulFlags & CM_ADD_ID_COMPATIBLE) ? L"CompatibleIDs" : L"HardwareID";
3656
3657 if (RegQueryValueExW(hDeviceKey,
3658 pszSubKey,
3659 NULL,
3660 NULL,
3661 NULL,
3662 &dwDeviceIdListSize) != ERROR_SUCCESS)
3663 {
3664 DPRINT("Failed to query the desired ID string!\n");
3666 goto Done;
3667 }
3668
3669 dwNewDeviceIdSize = lstrlenW(pszDeviceID);
3670 if (!dwNewDeviceIdSize)
3671 {
3673 goto Done;
3674 }
3675
3676 dwDeviceIdListSize += (dwNewDeviceIdSize + 2) * sizeof(WCHAR);
3677
3678 pszDeviceIdList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwDeviceIdListSize);
3679 if (!pszDeviceIdList)
3680 {
3681 DPRINT("Failed to allocate memory for the desired ID string!\n");
3683 goto Done;
3684 }
3685
3686 if (RegQueryValueExW(hDeviceKey,
3687 pszSubKey,
3688 NULL,
3689 NULL,
3690 (LPBYTE)pszDeviceIdList,
3691 &dwDeviceIdListSize) != ERROR_SUCCESS)
3692 {
3693 DPRINT("Failed to query the desired ID string!\n");
3695 goto Done;
3696 }
3697
3698 /* Check whether the device ID is already in use */
3699 if (CheckForDeviceId(pszDeviceIdList, pszDeviceID))
3700 {
3701 DPRINT("Device ID was found in the ID string!\n");
3702 ret = CR_SUCCESS;
3703 goto Done;
3704 }
3705
3706 /* Append the Device ID */
3707 AppendDeviceId(pszDeviceIdList, &dwDeviceIdListSize, pszID);
3708
3709 if (RegSetValueExW(hDeviceKey,
3710 pszSubKey,
3711 0,
3713 (LPBYTE)pszDeviceIdList,
3714 dwDeviceIdListSize) != ERROR_SUCCESS)
3715 {
3716 DPRINT("Failed to set the desired ID string!\n");
3718 }
3719
3720Done:
3721 RegCloseKey(hDeviceKey);
3722 if (pszDeviceIdList)
3723 HeapFree(GetProcessHeap(), 0, pszDeviceIdList);
3724
3725 DPRINT("PNP_AddID() done (returns %lx)\n", ret);
3726
3727 return ret;
3728}
static VOID AppendDeviceId(LPWSTR lpDeviceIdList, LPDWORD lpDeviceIdListSize, LPWSTR lpDeviceId)
Definition: rpcserver.c:3604
static BOOL CheckForDeviceId(LPWSTR lpDeviceIdList, LPWSTR lpDeviceId)
Definition: rpcserver.c:3583
#define CM_ADD_ID_COMPATIBLE
Definition: cfgmgr32.h:615
#define CR_INVALID_POINTER
Definition: cfgmgr32.h:845
#define lstrlenW
Definition: compat.h:750
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

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

4416{
4419}

◆ PNP_ApplyPowerSettings()

DWORD WINAPI PNP_ApplyPowerSettings ( handle_t  hBinding)

Definition at line 5029 of file rpcserver.c.

5031{
5034}

◆ PNP_Connect()

DWORD WINAPI PNP_Connect ( handle_t  hBinding)

Definition at line 646 of file rpcserver.c.

648{
650 return CR_SUCCESS;
651}

◆ PNP_CreateDevInst()

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

Definition at line 3126 of file rpcserver.c.

3132{
3134 HKEY hKey = NULL;
3135 DWORD dwSize, dwPhantom;
3138
3139 DPRINT("PNP_CreateDevInst(%p %S %S %lu 0x%08lx)\n",
3140 hBinding, pszParentDeviceID, pszDeviceID, ulLength, ulFlags);
3141
3142 if (ulFlags & ~CM_CREATE_DEVNODE_BITS)
3143 return CR_INVALID_FLAG;
3144
3145 if (pszDeviceID == NULL || pszParentDeviceID == NULL)
3146 return CR_INVALID_POINTER;
3147
3148 /* Fail, if the parent device is not the root device */
3149 if (!IsRootDeviceInstanceID(pszParentDeviceID))
3150 return CR_INVALID_DEVINST;
3151
3152 if (ulFlags & CM_CREATE_DEVNODE_GENERATE_ID)
3153 {
3154 ret = GenerateDeviceID(pszDeviceID,
3155 ulLength);
3156 if (ret != CR_SUCCESS)
3157 return ret;
3158 }
3159
3160 /* Try to open the device instance key */
3161 RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3162
3163 if (ulFlags & CM_CREATE_DEVNODE_PHANTOM)
3164 {
3165 /* Fail, if the device already exists */
3166 if (hKey != NULL)
3167 {
3169 goto done;
3170 }
3171
3172 /* Create the phantom device instance */
3173 ret = CreateDeviceInstance(pszDeviceID, TRUE);
3174 }
3175 else
3176 {
3177 /* Fail, if the device exists and is present */
3178 if ((hKey != NULL) && (IsPresentDeviceInstanceID(pszDeviceID)))
3179 {
3181 goto done;
3182 }
3183
3184 /* If it does not already exist ... */
3185 if (hKey == NULL)
3186 {
3187 /* Create the device instance */
3188 ret = CreateDeviceInstance(pszDeviceID, FALSE);
3189
3190 /* Open the device instance key */
3191 RegOpenKeyEx(hEnumKey, pszDeviceID, 0, KEY_READ | KEY_WRITE, &hKey);
3192 }
3193
3194 /* Create a device node for the device */
3195 RtlInitUnicodeString(&ControlData.DeviceInstance, pszDeviceID);
3197 &ControlData,
3198 sizeof(ControlData));
3199 if (!NT_SUCCESS(Status))
3200 {
3201 ret = CR_FAILURE;
3202 goto done;
3203 }
3204
3205 /* If the device is a phantom device, turn it into a normal device */
3206 if (hKey != NULL)
3207 {
3208 dwPhantom = 0;
3209 dwSize = sizeof(DWORD);
3210 RegQueryValueEx(hKey, L"Phantom", NULL, NULL, (PBYTE)&dwPhantom, &dwSize);
3211
3212 if (dwPhantom != 0)
3213 RegDeleteValue(hKey, L"Phantom");
3214 }
3215 }
3216
3217done:
3218 if (hKey)
3220
3221 DPRINT("PNP_CreateDevInst() done (returns %lx)\n", ret);
3222
3223 return ret;
3224}
static CONFIGRET GenerateDeviceID(_Inout_ LPWSTR pszDeviceID, _In_ PNP_RPC_STRING_LEN ulLength)
Definition: rpcserver.c:3076
static BOOL IsPresentDeviceInstanceID(_In_ LPWSTR pszDeviceInstanceID)
Definition: rpcserver.c:418
static BOOL IsRootDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:406
static CONFIGRET CreateDeviceInstance(_In_ LPWSTR pszDeviceID, _In_ BOOL bPhantomDevice)
Definition: rpcserver.c:2956
#define CR_INVALID_FLAG
Definition: cfgmgr32.h:846
#define CM_CREATE_DEVNODE_BITS
Definition: cfgmgr32.h:624
#define CM_CREATE_DEVNODE_GENERATE_ID
Definition: cfgmgr32.h:622
#define CM_CREATE_DEVNODE_PHANTOM
Definition: cfgmgr32.h:621
@ PlugPlayControlInitializeDevice
Definition: cmtypes.h:212
#define KEY_WRITE
Definition: nt_native.h:1031
#define RegQueryValueEx
Definition: winreg.h:524
#define RegDeleteValue
Definition: winreg.h:508

Referenced by CM_Create_DevNode_ExW().

◆ PNP_CreateKey()

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

Definition at line 2370 of file rpcserver.c.

2375{
2376 HKEY hDeviceKey = NULL, hParametersKey = NULL;
2377 DWORD dwError;
2379
2381 UNREFERENCED_PARAMETER(samDesired);
2382
2383 DPRINT("PNP_CreateKey(%p %S 0x%lx 0x%08lx)\n",
2384 hBinding, pszSubKey, samDesired, ulFlags);
2385
2386 if (ulFlags != 0)
2387 return CR_INVALID_FLAG;
2388
2389 if (!IsValidDeviceInstanceID(pszSubKey))
2390 return CR_INVALID_DEVINST;
2391
2392 dwError = RegOpenKeyExW(hEnumKey,
2393 pszSubKey,
2394 0,
2395 KEY_WRITE,
2396 &hDeviceKey);
2397 if (dwError != ERROR_SUCCESS)
2398 {
2400 goto done;
2401 }
2402
2403 dwError = RegCreateKeyExW(hDeviceKey,
2404 L"Device Parameters",
2405 0,
2406 NULL,
2409 NULL,
2410 &hParametersKey,
2411 NULL);
2412 if (dwError != ERROR_SUCCESS)
2413 {
2415 goto done;
2416 }
2417
2418 /* FIXME: Set key security */
2419
2420done:
2421 if (hParametersKey != NULL)
2422 RegCloseKey(hParametersKey);
2423
2424 if (hDeviceKey != NULL)
2425 RegCloseKey(hDeviceKey);
2426
2427 return ret;
2428}
static BOOL IsValidDeviceInstanceID(_In_ PWSTR pszDeviceInstanceID)
Definition: rpcserver.c:340

◆ PNP_DeleteClassKey()

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

Definition at line 2552 of file rpcserver.c.

2556{
2558
2560
2561 DPRINT("PNP_DeleteClassKey(%p %S 0x%08lx)\n",
2562 hBinding, pszClassGuid, ulFlags);
2563
2564 if (ulFlags & CM_DELETE_CLASS_SUBKEYS)
2565 {
2566 if (SHDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2568 }
2569 else
2570 {
2571 if (RegDeleteKeyW(hClassKey, pszClassGuid) != ERROR_SUCCESS)
2573 }
2574
2575 DPRINT("PNP_DeleteClassKey() done (returns %lx)\n", ret);
2576
2577 return ret;
2578}
HKEY hClassKey
Definition: umpnpmgr.c:45
#define CM_DELETE_CLASS_SUBKEYS
Definition: cfgmgr32.h:635
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
DWORD WINAPI SHDeleteKeyW(HKEY hKey, LPCWSTR lpszSubKey)
Definition: reg.c:1546

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

2440{
2443}

Referenced by CM_Delete_DevNode_Key_Ex().

◆ PNP_DeleteServiceDevices()

DWORD WINAPI PNP_DeleteServiceDevices ( handle_t  hBinding)

Definition at line 5086 of file rpcserver.c.

5088{
5091}

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

4604{
4605 DPRINT("PNP_DetectResourceConflict()\n");
4606
4607 if (pbConflictDetected != NULL)
4608 *pbConflictDetected = FALSE;
4609
4611}

◆ PNP_DeviceInstanceAction()

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

Definition at line 3366 of file rpcserver.c.

3372{
3374
3376
3377 DPRINT("PNP_DeviceInstanceAction(%p %lu 0x%08lx %S %S)\n",
3378 hBinding, ulMajorAction, ulMinorAction,
3379 pszDeviceInstance1, pszDeviceInstance2);
3380
3381 switch (ulMajorAction)
3382 {
3383 case PNP_DEVINST_SETUP:
3384 ret = SetupDeviceInstance(pszDeviceInstance1,
3385 ulMinorAction);
3386 break;
3387
3388 case PNP_DEVINST_ENABLE:
3389 ret = EnableDeviceInstance(pszDeviceInstance1);
3390 break;
3391
3392 case PNP_DEVINST_REENUMERATE:
3393 ret = ReenumerateDeviceInstance(pszDeviceInstance1,
3394 ulMinorAction);
3395 break;
3396
3397 default:
3398 DPRINT1("Unknown device action %lu: not implemented\n", ulMajorAction);
3400 }
3401
3402 DPRINT("PNP_DeviceInstanceAction() done (returns %lx)\n", ret);
3403
3404 return ret;
3405}
static CONFIGRET SetupDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ DWORD ulMinorAction)
Definition: rpcserver.c:3228
static CONFIGRET ReenumerateDeviceInstance(_In_ LPWSTR pszDeviceInstance, _In_ ULONG ulMinorAction)
Definition: rpcserver.c:3330
static CONFIGRET EnableDeviceInstance(_In_ LPWSTR pszDeviceInstance)
Definition: rpcserver.c:3311

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

3549{
3551
3552 DPRINT1("PNP_DisableDevInst(%p %S %p %p %lu 0x%08lx)\n",
3553 hBinding, pDeviceID, pVetoType, pszVetoName, ulNameLength, ulFlags);
3554
3555 if (ulFlags & ~CM_DISABLE_BITS)
3556 return CR_INVALID_FLAG;
3557
3558 if (!IsValidDeviceInstanceID(pDeviceID) ||
3559 IsRootDeviceInstanceID(pDeviceID))
3560 return CR_INVALID_DEVINST;
3561
3562 return DisableDeviceInstance(pDeviceID,
3563 pVetoType,
3564 pszVetoName,
3565 ulNameLength);
3566}
static CONFIGRET DisableDeviceInstance(_In_ LPWSTR pszDeviceInstance, _Inout_opt_ PPNP_VETO_TYPE pVetoType, _Inout_opt_ LPWSTR pszVetoName, _In_ DWORD ulNameLength)
Definition: rpcserver.c:294
#define CM_DISABLE_BITS
Definition: cfgmgr32.h:652

Referenced by CM_Disable_DevNode_Ex().

◆ PNP_Disconnect()

DWORD WINAPI PNP_Disconnect ( handle_t  hBinding)

Definition at line 635 of file rpcserver.c.

637{
639 return CR_SUCCESS;
640}

◆ PNP_DriverStoreAddDriverPackage()

DWORD WINAPI PNP_DriverStoreAddDriverPackage ( handle_t  hBinding)

Definition at line 5040 of file rpcserver.c.

5042{
5045}

◆ PNP_DriverStoreDeleteDriverPackage()

DWORD WINAPI PNP_DriverStoreDeleteDriverPackage ( handle_t  hBinding)

Definition at line 5051 of file rpcserver.c.

5053{
5056}

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

933{
935 HKEY hKey;
936 DWORD dwError;
937
939 UNREFERENCED_PARAMETER(ulFlags);
940
941 DPRINT("PNP_EnumerateSubKeys(%p %lu %lu %p %lu %p 0x%08lx)\n",
942 hBinding, ulBranch, ulIndex, Buffer, ulLength,
943 pulRequiredLen, ulFlags);
944
945 switch (ulBranch)
946 {
947 case PNP_ENUMERATOR_SUBKEYS:
948 hKey = hEnumKey;
949 break;
950
951 case PNP_CLASS_SUBKEYS:
952 hKey = hClassKey;
953 break;
954
955 default:
956 return CR_FAILURE;
957 }
958
959 *pulRequiredLen = ulLength;
960 dwError = RegEnumKeyExW(hKey,
961 ulIndex,
962 Buffer,
963 pulRequiredLen,
964 NULL,
965 NULL,
966 NULL,
967 NULL);
968 if (dwError != ERROR_SUCCESS)
969 {
971 }
972 else
973 {
974 (*pulRequiredLen)++;
975 }
976
977 DPRINT("PNP_EnumerateSubKeys() done (returns %lx)\n", ret);
978
979 return ret;
980}
Definition: bufpool.h:45
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105

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

4182{
4185}

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

4435{
4438}

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

4926{
4929}

Referenced by CMP_GetBlockedDriverInfo().

◆ PNP_GetClassCount()

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

Definition at line 2449 of file rpcserver.c.

2453{
2454 HKEY hKey;
2455 DWORD dwError;
2456
2458 UNREFERENCED_PARAMETER(ulFlags);
2459
2460 DPRINT("PNP_GetClassCount(%p %p 0x%08lx)\n",
2461 hBinding, pulClassCount, ulFlags);
2462
2465 0,
2467 &hKey);
2468 if (dwError != ERROR_SUCCESS)
2469 return CR_INVALID_DATA;
2470
2471 dwError = RegQueryInfoKeyW(hKey,
2472 NULL,
2473 NULL,
2474 NULL,
2475 pulClassCount,
2476 NULL,
2477 NULL,
2478 NULL,
2479 NULL,
2480 NULL,
2481 NULL,
2482 NULL);
2484 if (dwError != ERROR_SUCCESS)
2485 return CR_INVALID_DATA;
2486
2487 return CR_SUCCESS;
2488}
#define REGSTR_PATH_CLASS
Definition: regstr.h:42

◆ PNP_GetClassInstance()

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

Definition at line 2254 of file rpcserver.c.

2259{
2260 WCHAR szClassGuid[40];
2261 WCHAR szClassInstance[5];
2262 HKEY hDeviceClassKey = NULL;
2263 HKEY hClassInstanceKey;
2264 ULONG ulTransferLength, ulDataLength;
2265 DWORD dwDataType, dwDisposition, i;
2266 DWORD dwError;
2268
2269 DPRINT("PNP_GetClassInstance(%p %S %p %lu)\n",
2270 hBinding, pDeviceId, pszClassInstance, ulLength);
2271
2272 if (!IsValidDeviceInstanceID(pDeviceId))
2273 return CR_INVALID_DEVINST;
2274
2275 ulTransferLength = ulLength;
2277 pDeviceId,
2279 &dwDataType,
2280 (BYTE *)pszClassInstance,
2281 &ulTransferLength,
2282 &ulLength,
2283 0);
2284 if (ret == CR_SUCCESS)
2285 return ret;
2286
2287 ulTransferLength = sizeof(szClassGuid);
2288 ulDataLength = sizeof(szClassGuid);
2290 pDeviceId,
2292 &dwDataType,
2293 (BYTE *)szClassGuid,
2294 &ulTransferLength,
2295 &ulDataLength,
2296 0);
2297 if (ret != CR_SUCCESS)
2298 {
2299 DPRINT1("PNP_GetDeviceRegProp() failed (Error %lu)\n", ret);
2300 goto done;
2301 }
2302
2303 dwError = RegOpenKeyExW(hClassKey,
2304 szClassGuid,
2305 0,
2306 KEY_READ,
2307 &hDeviceClassKey);
2308 if (dwError != ERROR_SUCCESS)
2309 {
2310 DPRINT1("RegOpenKeyExW() failed (Error %lu)\n", dwError);
2311 ret = CR_FAILURE;
2312 goto done;
2313 }
2314
2315 for (i = 0; i < 10000; i++)
2316 {
2317 wsprintf(szClassInstance, L"%04lu", i);
2318
2319 dwError = RegCreateKeyExW(hDeviceClassKey,
2320 szClassInstance,
2321 0,
2322 NULL,
2325 NULL,
2326 &hClassInstanceKey,
2327 &dwDisposition);
2328 if (dwError == ERROR_SUCCESS)
2329 {
2330 RegCloseKey(hClassInstanceKey);
2331
2332 if (dwDisposition == REG_CREATED_NEW_KEY)
2333 {
2334 wsprintf(pszClassInstance,
2335 L"%s\\%s",
2336 szClassGuid,
2337 szClassInstance);
2338
2339 ulDataLength = (wcslen(pszClassInstance) + 1) * sizeof(WCHAR);
2341 pDeviceId,
2343 REG_SZ,
2344 (BYTE *)pszClassInstance,
2345 ulDataLength,
2346 0);
2347 if (ret != CR_SUCCESS)
2348 {
2349 DPRINT1("PNP_SetDeviceRegProp() failed (Error %lu)\n", ret);
2350 RegDeleteKeyW(hDeviceClassKey,
2351 szClassInstance);
2352 }
2353
2354 break;
2355 }
2356 }
2357 }
2358
2359done:
2360 if (hDeviceClassKey != NULL)
2361 RegCloseKey(hDeviceClassKey);
2362
2363 return ret;
2364}
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:1835
DWORD WINAPI PNP_SetDeviceRegProp(handle_t hBinding, LPWSTR pDeviceId, DWORD ulProperty, DWORD ulDataType, BYTE *Buffer, PNP_PROP_SIZE ulLength, DWORD ulFlags)
Definition: rpcserver.c:2112
#define CM_DRP_DRIVER
Definition: cfgmgr32.h:685
#define CM_DRP_CLASSGUID
Definition: cfgmgr32.h:684
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
#define REG_CREATED_NEW_KEY
Definition: nt_native.h:1084
uint32_t ULONG
Definition: typedefs.h:59
unsigned char BYTE
Definition: xxhash.c:193

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

2500{
2501 WCHAR szKeyName[MAX_PATH];
2503 HKEY hKey;
2504 DWORD dwSize;
2505
2507 UNREFERENCED_PARAMETER(ulFlags);
2508
2509 DPRINT("PNP_GetClassName(%p %S %p %p 0x%08lx)\n",
2510 hBinding, pszClassGuid, Buffer, pulLength, ulFlags);
2511
2512 lstrcpyW(szKeyName, L"System\\CurrentControlSet\\Control\\Class\\");
2513 if (lstrlenW(pszClassGuid) + 1 < sizeof(szKeyName)/sizeof(WCHAR)-(lstrlenW(szKeyName) * sizeof(WCHAR)))
2514 lstrcatW(szKeyName, pszClassGuid);
2515 else
2516 return CR_INVALID_DATA;
2517
2519 szKeyName,
2520 0,
2522 &hKey))
2523 return CR_REGISTRY_ERROR;
2524
2525 dwSize = *pulLength * sizeof(WCHAR);
2527 L"Class",
2528 NULL,
2529 NULL,
2530 (LPBYTE)Buffer,
2531 &dwSize))
2532 {
2533 *pulLength = 0;
2535 }
2536 else
2537 {
2538 *pulLength = dwSize / sizeof(WCHAR);
2539 }
2540
2542
2543 DPRINT("PNP_GetClassName() done (returns %lx)\n", ret);
2544
2545 return ret;
2546}
#define lstrcpyW
Definition: compat.h:749
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

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

2736{
2738 LPWSTR lpValueName = NULL;
2739 HKEY hInstKey = NULL;
2740 HKEY hPropKey = NULL;
2741 LONG lError;
2742
2744
2745 DPRINT("PNP_GetClassRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
2746 hBinding, pszClassGuid, ulProperty, pulRegDataType,
2747 Buffer, pulTransferLen, pulLength, ulFlags);
2748
2749 if (pulTransferLen == NULL || pulLength == NULL)
2750 {
2752 goto done;
2753 }
2754
2755 if (ulFlags != 0)
2756 {
2758 goto done;
2759 }
2760
2761 if (*pulLength < *pulTransferLen)
2762 *pulLength = *pulTransferLen;
2763
2764 *pulTransferLen = 0;
2765
2766 switch (ulProperty)
2767 {
2768 case CM_CRP_SECURITY:
2769 lpValueName = L"Security";
2770 break;
2771
2772 case CM_CRP_DEVTYPE:
2773 lpValueName = L"DeviceType";
2774 break;
2775
2776 case CM_CRP_EXCLUSIVE:
2777 lpValueName = L"Exclusive";
2778 break;
2779
2781 lpValueName = L"DeviceCharacteristics";
2782 break;
2783
2784 default:
2786 goto done;
2787 }
2788
2789 DPRINT("Value name: %S\n", lpValueName);
2790
2791 lError = RegOpenKeyExW(hClassKey,
2792 pszClassGuid,
2793 0,
2794 KEY_READ,
2795 &hInstKey);
2796 if (lError != ERROR_SUCCESS)
2797 {
2798 *pulLength = 0;
2800 goto done;
2801 }
2802
2803 lError = RegOpenKeyExW(hInstKey,
2804 L"Properties",
2805 0,
2806 KEY_READ,
2807 &hPropKey);
2808 if (lError != ERROR_SUCCESS)
2809 {
2810 *pulLength = 0;
2812 goto done;
2813 }
2814
2815 lError = RegQueryValueExW(hPropKey,
2816 lpValueName,
2817 NULL,
2818 pulRegDataType,
2819 Buffer,
2820 pulLength);
2821 if (lError != ERROR_SUCCESS)
2822 {
2823 if (lError == ERROR_MORE_DATA)
2824 {
2826 }
2827 else
2828 {
2829 *pulLength = 0;
2831 }
2832 }
2833
2834done:
2835 if (ret == CR_SUCCESS)
2836 *pulTransferLen = *pulLength;
2837
2838 if (hPropKey != NULL)
2839 RegCloseKey(hPropKey);
2840
2841 if (hInstKey != NULL)
2842 RegCloseKey(hInstKey);
2843
2844 DPRINT("PNP_GetClassRegProp() done (returns %lx)\n", ret);
2845
2846 return ret;
2847}
#define CR_INVALID_PROPERTY
Definition: cfgmgr32.h:899
#define CM_CRP_DEVTYPE
Definition: cfgmgr32.h:710
#define CM_CRP_SECURITY
Definition: cfgmgr32.h:706
#define CM_CRP_EXCLUSIVE
Definition: cfgmgr32.h:712
#define CM_CRP_CHARACTERISTICS
Definition: cfgmgr32.h:714
#define CR_NO_SUCH_REGISTRY_KEY
Definition: cfgmgr32.h:892
#define ERROR_MORE_DATA
Definition: dderror.h:13

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

4816{
4817 HKEY hDeviceKey = NULL;
4818 HKEY hParamKey = NULL;
4819 LONG lError;
4821
4823
4824 DPRINT("PNP_GetCustomDevProp() called\n");
4825
4826 if (pulTransferLen == NULL || pulLength == NULL)
4827 {
4829 goto done;
4830 }
4831
4832 if (ulFlags & ~CM_CUSTOMDEVPROP_BITS)
4833 {
4835 goto done;
4836 }
4837
4838 if (!IsValidDeviceInstanceID(pDeviceID))
4839 return CR_INVALID_DEVINST;
4840
4841 if (*pulLength < *pulTransferLen)
4842 *pulLength = *pulTransferLen;
4843
4844 *pulTransferLen = 0;
4845
4846 lError = RegOpenKeyExW(hEnumKey,
4847 pDeviceID,
4848 0,
4849 KEY_READ,
4850 &hDeviceKey);
4851 if (lError != ERROR_SUCCESS)
4852 {
4854 goto done;
4855 }
4856
4857 lError = RegOpenKeyExW(hDeviceKey,
4858 L"Device Parameters",
4859 0,
4860 KEY_READ,
4861 &hParamKey);
4862 if (lError != ERROR_SUCCESS)
4863 {
4865 goto done;
4866 }
4867
4868 lError = RegQueryValueExW(hParamKey,
4869 CustomPropName,
4870 NULL,
4871 pulRegDataType,
4872 Buffer,
4873 pulLength);
4874 if (lError != ERROR_SUCCESS)
4875 {
4876 if (lError == ERROR_MORE_DATA)
4877 {
4879 }
4880 else
4881 {
4882 *pulLength = 0;
4884 }
4885 }
4886
4887done:
4888 if (ret == CR_SUCCESS)
4889 *pulTransferLen = *pulLength;
4890
4891 if (hParamKey != NULL)
4892 RegCloseKey(hParamKey);
4893
4894 if (hDeviceKey != NULL)
4895 RegCloseKey(hDeviceKey);
4896
4897 DPRINT("PNP_GetCustomDevProp() done (returns %lx)\n", ret);
4898
4899 return ret;
4900}
#define CM_CUSTOMDEVPROP_BITS
Definition: cfgmgr32.h:836

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

1797{
1798 PLUGPLAY_CONTROL_DEPTH_DATA PlugPlayData;
1801
1803 UNREFERENCED_PARAMETER(ulFlags);
1804
1805 DPRINT("PNP_GetDepth(%p %S %p 0x%08lx)\n",
1806 hBinding, pszDeviceID, pulDepth, ulFlags);
1807
1808 if (!IsValidDeviceInstanceID(pszDeviceID))
1809 return CR_INVALID_DEVINST;
1810
1812 pszDeviceID);
1813
1815 (PVOID)&PlugPlayData,
1817 if (NT_SUCCESS(Status))
1818 {
1819 *pulDepth = PlugPlayData.Depth;
1820 }
1821 else
1822 {
1824 }
1825
1826 DPRINT("PNP_GetDepth() done (returns %lx)\n", ret);
1827
1828 return ret;
1829}
@ PlugPlayControlGetDeviceDepth
Definition: cmtypes.h:224
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:534

Referenced by CM_Get_Depth_Ex().

◆ PNP_GetDeviceList()

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

Definition at line 1346 of file rpcserver.c.

1352{
1353 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1354 WCHAR szDevice[MAX_DEVICE_ID_LEN];
1355 WCHAR szInstance[MAX_DEVICE_ID_LEN];
1357
1358 DPRINT("PNP_GetDeviceList(%p %S %p %p 0x%08lx)\n",
1359 hBinding, pszFilter, Buffer, pulLength, ulFlags);
1360
1361 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1362 return CR_INVALID_FLAG;
1363
1364 if (pulLength == NULL)
1365 return CR_INVALID_POINTER;
1366
1367 if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1368 (pszFilter == NULL))
1369 return CR_INVALID_POINTER;
1370
1371 if (ulFlags &
1376 {
1377 ret = GetRelationsInstanceList(pszFilter,
1378 ulFlags,
1379 Buffer,
1380 pulLength);
1381 }
1382 else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1383 {
1384 ret = GetServiceInstanceList(pszFilter,
1385 Buffer,
1386 pulLength);
1387 }
1388 else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1389 {
1390 SplitDeviceInstanceID(pszFilter,
1391 szEnumerator,
1392 szDevice,
1393 szInstance);
1394
1395 if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1396 {
1397 ret = GetDeviceInstanceList(pszFilter,
1398 Buffer,
1399 pulLength);
1400 }
1401 else
1402 {
1403 ret = GetEnumeratorInstanceList(pszFilter,
1404 Buffer,
1405 pulLength);
1406 }
1407 }
1408 else /* CM_GETIDLIST_FILTER_NONE */
1409 {
1411 pulLength);
1412 }
1413
1414 return ret;
1415}
static CONFIGRET GetRelationsInstanceList(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:985
static CONFIGRET GetAllInstanceList(_Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1297
static CONFIGRET GetServiceInstanceList(_In_ PWSTR pszService, _Inout_ PWSTR pszBuffer, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1036
#define CM_GETIDLIST_FILTER_BITS
Definition: cfgmgr32.h:669
#define CM_GETIDLIST_FILTER_ENUMERATOR
Definition: cfgmgr32.h:655
#define CM_GETIDLIST_FILTER_SERVICE
Definition: cfgmgr32.h:656
#define CM_GETIDLIST_FILTER_NONE
Definition: cfgmgr32.h:654

Referenced by CM_Get_Device_ID_List_ExW(), and DeviceInstallThread().

◆ PNP_GetDeviceListSize()

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

Definition at line 1717 of file rpcserver.c.

1722{
1723 WCHAR szEnumerator[MAX_DEVICE_ID_LEN];
1724 WCHAR szDevice[MAX_DEVICE_ID_LEN];
1725 WCHAR szInstance[MAX_DEVICE_ID_LEN];
1727
1728 DPRINT("PNP_GetDeviceListSize(%p %S %p 0x%08lx)\n",
1729 hBinding, pszFilter, pulLength, ulFlags);
1730
1731 if (ulFlags & ~CM_GETIDLIST_FILTER_BITS)
1732 return CR_INVALID_FLAG;
1733
1734 if (pulLength == NULL)
1735 return CR_INVALID_POINTER;
1736
1737 if ((ulFlags != CM_GETIDLIST_FILTER_NONE) &&
1738 (pszFilter == NULL))
1739 return CR_INVALID_POINTER;
1740
1741 *pulLength = 0;
1742
1743 if (ulFlags &
1748 {
1750 ulFlags,
1751 pulLength);
1752 }
1753 else if (ulFlags & CM_GETIDLIST_FILTER_SERVICE)
1754 {
1755 ret = GetServiceInstanceListSize(pszFilter,
1756 pulLength);
1757 }
1758 else if (ulFlags & CM_GETIDLIST_FILTER_ENUMERATOR)
1759 {
1760 SplitDeviceInstanceID(pszFilter,
1761 szEnumerator,
1762 szDevice,
1763 szInstance);
1764
1765 if (*szEnumerator != UNICODE_NULL && *szDevice != UNICODE_NULL)
1766 {
1767 ret = GetDeviceInstanceListSize(pszFilter,
1768 pulLength);
1769 }
1770 else
1771 {
1773 pulLength);
1774 }
1775 }
1776 else /* CM_GETIDLIST_FILTER_NONE */
1777 {
1778 ret = GetAllInstanceListSize(pulLength);
1779 }
1780
1781 /* Add one character for the terminating double UNICODE_NULL */
1782 if (ret == CR_SUCCESS)
1783 (*pulLength) += 1;
1784
1785 return ret;
1786}
static CONFIGRET GetServiceInstanceListSize(_In_ PWSTR pszService, _Out_ PDWORD pulLength)
Definition: rpcserver.c:1470
static CONFIGRET GetAllInstanceListSize(_Out_ PULONG pulLength)
Definition: rpcserver.c:1682
static CONFIGRET GetRelationsInstanceListSize(_In_ PWSTR pszDevice, _In_ DWORD ulFlags, _Inout_ PDWORD pulLength)
Definition: rpcserver.c:1420

Referenced by CM_Get_Device_ID_List_Size_ExW(), and DeviceInstallThread().

◆ PNP_GetDeviceRegProp()

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

Definition at line 1835 of file rpcserver.c.

1844{
1845 PLUGPLAY_CONTROL_PROPERTY_DATA PlugPlayData;
1847 LPWSTR lpValueName = NULL;
1848 HKEY hKey = NULL;
1849 LONG lError;
1851
1853
1854 DPRINT("PNP_GetDeviceRegProp(%p %S %lu %p %p %p %p 0x%08lx)\n",
1855 hBinding, pDeviceID, ulProperty, pulRegDataType, Buffer,
1856 pulTransferLen, pulLength, ulFlags);
1857
1858 if (pulTransferLen == NULL || pulLength == NULL)
1859 {
1861 goto done;
1862 }
1863
1864 if (ulFlags != 0)
1865 {
1867 goto done;
1868 }
1869
1870 /* Check pDeviceID */
1871 if (!IsValidDeviceInstanceID(pDeviceID))
1872 {
1874 goto done;
1875 }
1876
1877 if (*pulLength < *pulTransferLen)
1878 *pulLength = *pulTransferLen;
1879
1880 *pulTransferLen = 0;
1881
1882 switch (ulProperty)
1883 {
1884 case CM_DRP_DEVICEDESC:
1885 lpValueName = L"DeviceDesc";
1886 break;
1887
1888 case CM_DRP_HARDWAREID:
1889 lpValueName = L"HardwareID";
1890 break;
1891
1893 lpValueName = L"CompatibleIDs";
1894 break;
1895
1896 case CM_DRP_SERVICE:
1897 lpValueName = L"Service";
1898 break;
1899
1900 case CM_DRP_CLASS:
1901 lpValueName = L"Class";
1902 break;
1903
1904 case CM_DRP_CLASSGUID:
1905 lpValueName = L"ClassGUID";
1906 break;
1907
1908 case CM_DRP_DRIVER:
1909 lpValueName = L"Driver";
1910 break;
1911
1912 case CM_DRP_CONFIGFLAGS:
1913 lpValueName = L"ConfigFlags";
1914 break;
1915
1916 case CM_DRP_MFG:
1917 lpValueName = L"Mfg";
1918 break;
1919
1921 lpValueName = L"FriendlyName";
1922 break;
1923
1925 lpValueName = L"LocationInformation";
1926 break;
1927
1930 *pulRegDataType = REG_SZ;
1931 break;
1932
1934 lpValueName = L"Capabilities";
1935 break;
1936
1937 case CM_DRP_UI_NUMBER:
1938 PlugPlayData.Property = PNP_PROPERTY_UI_NUMBER;
1939 break;
1940
1942 lpValueName = L"UpperFilters";
1943 break;
1944
1946 lpValueName = L"LowerFilters";
1947 break;
1948
1949 case CM_DRP_BUSTYPEGUID:
1950 PlugPlayData.Property = PNP_PROPERTY_BUSTYPEGUID;
1951 *pulRegDataType = REG_BINARY;
1952 break;
1953
1955 PlugPlayData.Property = PNP_PROPERTY_LEGACYBUSTYPE;
1956 *pulRegDataType = REG_DWORD;
1957 break;
1958
1959 case CM_DRP_BUSNUMBER:
1960 PlugPlayData.Property = PNP_PROPERTY_BUSNUMBER;
1961 *pulRegDataType = REG_DWORD;
1962 break;
1963
1966 *pulRegDataType = REG_SZ;
1967 break;
1968
1969 case CM_DRP_SECURITY:
1970 lpValueName = L"Security";
1971 break;
1972
1973 case CM_DRP_DEVTYPE:
1974 lpValueName = L"DeviceType";
1975 break;
1976
1977 case CM_DRP_EXCLUSIVE:
1978 lpValueName = L"Exclusive";
1979 break;
1980
1982 lpValueName = L"DeviceCharacteristics";
1983 break;
1984
1985 case CM_DRP_ADDRESS:
1986 PlugPlayData.Property = PNP_PROPERTY_ADDRESS;
1987 *pulRegDataType = REG_DWORD;
1988 break;
1989
1991 lpValueName = L"UINumberDescFormat";
1992 break;
1993
1995 PlugPlayData.Property = PNP_PROPERTY_POWER_DATA;
1996 *pulRegDataType = REG_BINARY;
1997 break;
1998
2001 *pulRegDataType = REG_DWORD;
2002 break;
2003
2006 *pulRegDataType = REG_DWORD;
2007 break;
2008
2010 lpValueName = L"RemovalPolicy";
2011 *pulRegDataType = REG_DWORD;
2012 break;
2013
2015 PlugPlayData.Property = PNP_PROPERTY_INSTALL_STATE;
2016 *pulRegDataType = REG_DWORD;
2017 break;
2018
2019#if (WINVER >= _WIN32_WINNT_WS03)
2022 *pulRegDataType = REG_MULTI_SZ;
2023 break;
2024#endif
2025
2026#if (WINVER >= _WIN32_WINNT_WIN7)
2028 PlugPlayData.Property = PNP_PROPERTY_CONTAINERID;
2029 *pulRegDataType = REG_SZ;
2030 break;
2031#endif
2032
2033 default:
2035 goto done;
2036 }
2037
2038 DPRINT("Value name: %S\n", lpValueName);
2039
2040 if (lpValueName)
2041 {
2042 /* Retrieve information from the Registry */
2043 lError = RegOpenKeyExW(hEnumKey,
2044 pDeviceID,
2045 0,
2047 &hKey);
2048 if (lError != ERROR_SUCCESS)
2049 {
2050 hKey = NULL;
2051 *pulLength = 0;
2053 goto done;
2054 }
2055
2056 lError = RegQueryValueExW(hKey,
2057 lpValueName,
2058 NULL,
2059 pulRegDataType,
2060 Buffer,
2061 pulLength);
2062 if (lError != ERROR_SUCCESS)
2063 {
2064 if (lError == ERROR_MORE_DATA)
2065 {
2067 }
2068 else
2069 {
2070 *pulLength = 0;
2072 }
2073 }
2074 }
2075 else
2076 {
2077 /* Retrieve information from the Device Node */
2079 pDeviceID);
2080 PlugPlayData.Buffer = Buffer;
2081 PlugPlayData.BufferSize = *pulLength;
2082
2084 (PVOID)&PlugPlayData,
2086 if (NT_SUCCESS(Status))
2087 {
2088 *pulLength = PlugPlayData.BufferSize;
2089 }
2090 else
2091 {
2093 }
2094 }
2095
2096done:
2097 if (pulTransferLen)
2098 *pulTransferLen = (ret == CR_SUCCESS) ? *pulLength : 0;
2099
2100 if (hKey != NULL)
2102
2103 DPRINT("PNP_GetDeviceRegProp() done (returns %lx)\n", ret);
2104
2105 return ret;
2106}
#define CM_DRP_BUSNUMBER
Definition: cfgmgr32.h:703
#define CM_DRP_LOCATION_INFORMATION
Definition: cfgmgr32.h:689
#define CM_DRP_CONFIGFLAGS
Definition: cfgmgr32.h:686
#define CM_DRP_REMOVAL_POLICY
Definition: cfgmgr32.h:719
#define CM_DRP_ENUMERATOR_NAME
Definition: cfgmgr32.h:704
#define CM_DRP_REMOVAL_POLICY_HW_DEFAULT
Definition: cfgmgr32.h:720
#define CM_DRP_BUSTYPEGUID
Definition: cfgmgr32.h:701
#define CM_DRP_LOWERFILTERS
Definition: cfgmgr32.h:697
#define CM_DRP_SECURITY
Definition: cfgmgr32.h:705
#define CM_DRP_MFG
Definition: cfgmgr32.h:687
#define CM_DRP_EXCLUSIVE
Definition: cfgmgr32.h:711
#define CM_DRP_LOCATION_PATHS
Definition: cfgmgr32.h:725
#define CM_DRP_REMOVAL_POLICY_OVERRIDE
Definition: cfgmgr32.h:721
#define CM_DRP_CAPABILITIES
Definition: cfgmgr32.h:691
#define CM_DRP_UPPERFILTERS
Definition: cfgmgr32.h:693
#define CM_DRP_COMPATIBLEIDS
Definition: cfgmgr32.h:678
#define CM_DRP_DEVICEDESC
Definition: cfgmgr32.h:676
#define CM_DRP_CLASS
Definition: cfgmgr32.h:683
#define CM_DRP_LEGACYBUSTYPE
Definition: cfgmgr32.h:702
#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cfgmgr32.h:690
#define CM_DRP_DEVTYPE
Definition: cfgmgr32.h:709
#define CM_DRP_FRIENDLYNAME
Definition: cfgmgr32.h:688
#define CM_DRP_INSTALL_STATE
Definition: cfgmgr32.h:722
#define CM_DRP_UI_NUMBER
Definition: cfgmgr32.h:692
#define CM_DRP_CHARACTERISTICS
Definition: cfgmgr32.h:713
#define CM_DRP_BASE_CONTAINERID
Definition: cfgmgr32.h:728
#define CM_DRP_UI_NUMBER_DESC_FORMAT
Definition: cfgmgr32.h:716
#define CM_DRP_ADDRESS
Definition: cfgmgr32.h:715
#define CM_DRP_DEVICE_POWER_DATA
Definition: cfgmgr32.h:718
#define CM_DRP_HARDWAREID
Definition: cfgmgr32.h:677
#define CM_DRP_SERVICE
Definition: cfgmgr32.h:680
#define PNP_PROPERTY_UI_NUMBER
Definition: cmtypes.h:34
#define PNP_PROPERTY_REMOVAL_POLICY
Definition: cmtypes.h:40
#define PNP_PROPERTY_POWER_DATA
Definition: cmtypes.h:39
#define PNP_PROPERTY_ENUMERATOR_NAME
Definition: cmtypes.h:43
#define PNP_PROPERTY_PHYSICAL_DEVICE_OBJECT_NAME
Definition: cmtypes.h:35
@ PlugPlayControlProperty
Definition: cmtypes.h:219
#define PNP_PROPERTY_INSTALL_STATE
Definition: cmtypes.h:45
#define PNP_PROPERTY_LOCATION_PATHS
Definition: cmtypes.h:46
#define PNP_PROPERTY_REMOVAL_POLICY_HARDWARE_DEFAULT
Definition: cmtypes.h:44
#define PNP_PROPERTY_LEGACYBUSTYPE
Definition: cmtypes.h:37
#define PNP_PROPERTY_BUSTYPEGUID
Definition: cmtypes.h:36
#define PNP_PROPERTY_ADDRESS
Definition: cmtypes.h:42
#define PNP_PROPERTY_BUSNUMBER
Definition: cmtypes.h:38
#define PNP_PROPERTY_CONTAINERID
Definition: cmtypes.h:47
#define REG_BINARY
Definition: nt_native.h:1496
UNICODE_STRING DeviceInstance
Definition: cmtypes.h:507

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

◆ PNP_GetDeviceStatus()

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

Definition at line 3411 of file rpcserver.c.

3417{
3418 DWORD ulDataType, ulTransferLength, ulLength;
3419 DWORD ulCapabilities, ulConfigFlags;
3420 CONFIGRET ret;
3421
3423 UNREFERENCED_PARAMETER(ulFlags);
3424
3425 DPRINT("PNP_GetDeviceStatus(%p %S %p %p 0x%08lx)\n",
3426 hBinding, pDeviceID, pulStatus, pulProblem, ulFlags);
3427
3428 if (ulFlags != 0)
3429 return CR_INVALID_FLAG;
3430
3431 if ((pulStatus == NULL) || (pulProblem == NULL))
3432 return CR_INVALID_POINTER;
3433
3434 if (!IsValidDeviceInstanceID(pDeviceID))
3435 return CR_INVALID_DEVINST;
3436
3437 ret = GetDeviceStatus(pDeviceID, pulStatus, pulProblem);
3438 if (ret != CR_SUCCESS)
3439 return ret;
3440
3441 /* Check for DN_REMOVABLE */
3442 ulTransferLength = sizeof(ulCapabilities);
3443 ulLength = sizeof(ulCapabilities);
3445 pDeviceID,
3447 &ulDataType,
3448 (PBYTE)&ulCapabilities,
3449 &ulTransferLength,
3450 &ulLength,
3451 0);
3452 if (ret != CR_SUCCESS)
3453 ulCapabilities = 0;
3454
3455 if (ulCapabilities & CM_DEVCAP_REMOVABLE)
3456 *pulStatus |= DN_REMOVABLE;
3457
3458 /* Check for DN_MANUAL */
3459 ulTransferLength = sizeof(ulConfigFlags);
3460 ulLength = sizeof(ulConfigFlags);
3462 pDeviceID,
3464 &ulDataType,
3465 (PBYTE)&ulConfigFlags,
3466 &ulTransferLength,
3467 &ulLength,
3468 0);
3469 if (ret != CR_SUCCESS)
3470 ulConfigFlags = 0;
3471
3472 if (ulConfigFlags & CONFIGFLAG_MANUAL_INSTALL)
3473 *pulStatus |= DN_MANUAL;
3474
3475 /* Check for failed install */
3476 if (((*pulStatus & DN_HAS_PROBLEM) == 0) && (ulConfigFlags & CONFIGFLAG_FAILEDINSTALL))
3477 {
3478 *pulStatus |= DN_HAS_PROBLEM;
3479 *pulProblem = CM_PROB_FAILED_INSTALL;
3480 }
3481
3482 return CR_SUCCESS;
3483}
#define DN_REMOVABLE
Definition: cfg.h:132
#define DN_HAS_PROBLEM
Definition: cfg.h:128
#define DN_MANUAL
Definition: cfg.h:122
#define CM_PROB_FAILED_INSTALL
Definition: cfg.h:58
#define CM_DEVCAP_REMOVABLE
Definition: cfgmgr32.h:737
#define CONFIGFLAG_MANUAL_INSTALL
Definition: regstr.h:392
#define CONFIGFLAG_FAILEDINSTALL
Definition: regstr.h:396

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

4197{
4198 HKEY hConfigKey = NULL;
4199 DWORD RegDataType = 0;
4200 ULONG ulDataSize = 0;
4201 LPBYTE lpData = NULL;
4203
4204 DPRINT("PNP_GetFirstLogConf(%p %S %lu %p 0x%08lx)\n",
4205 hBinding, pDeviceID, ulLogConfType, pulLogConfTag, ulFlags);
4206
4207 if (pulLogConfTag == NULL)
4208 return CR_INVALID_POINTER;
4209
4210 *pulLogConfTag = (DWORD)0;
4211
4212 if (ulFlags & ~LOG_CONF_BITS)
4213 return CR_INVALID_FLAG;
4214
4215 if (!IsValidDeviceInstanceID(pDeviceID))
4216 return CR_INVALID_DEVINST;
4217
4218 ret = OpenConfigurationKey(pDeviceID,
4219 ulLogConfType,
4220 &hConfigKey);
4221 if (ret != CR_SUCCESS)
4222 {
4223 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4225 goto done;
4226 }
4227
4228 ret = GetConfigurationData(hConfigKey,
4229 ulLogConfType,
4230 &RegDataType,
4231 &ulDataSize,
4232 &lpData);
4233 if (ret != CR_SUCCESS)
4234 {
4235 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
4237 goto done;
4238 }
4239
4240 DPRINT1("Data size %lu\n", ulDataSize);
4241 if (ulDataSize == 0 || lpData == NULL)
4242 {
4243 DPRINT1("No config data available!\n");
4245 goto done;
4246 }
4247
4248 /* Get the first tag */
4249 if (RegDataType == REG_RESOURCE_LIST)
4250 {
4251 DPRINT("REG_RESOURCE_LIST->Count %lu\n", ((PCM_RESOURCE_LIST)lpData)->Count);
4252
4253 /* Indicate that we reached the end of the list */
4254 if (((PCM_RESOURCE_LIST)lpData)->Count == 0)
4255 {
4256 DPRINT1("No resource descriptors!\n");
4258 goto done;
4259 }
4260 }
4261 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4262 {
4263 DPRINT1("FIXME: REG_RESOURCE_REQUIREMENTS_LIST\n");
4264 /* FIXME */
4266 goto done;
4267 }
4268
4269done:
4270 if (lpData != NULL)
4271 HeapFree(GetProcessHeap(), 0, lpData);
4272
4273 if (hConfigKey != NULL)
4274 RegCloseKey(hConfigKey);
4275
4276 DPRINT("PNP_GetFirstLogConf() returns %lu\n", ret);
4277
4278 return ret;
4279}
static CONFIGRET GetConfigurationData(_In_ HKEY hKey, _In_ ULONG ulLogConfType, _Out_ PULONG pulRegDataType, _Out_ PULONG pulDataSize, _Out_ LPBYTE *ppBuffer)
Definition: rpcserver.c:492
static CONFIGRET OpenConfigurationKey(_In_ LPCWSTR pszDeviceID, _In_ DWORD ulLogConfType, _Out_ PHKEY phKey)
Definition: rpcserver.c:429
#define CR_NO_MORE_LOG_CONF
Definition: cfgmgr32.h:859
#define LOG_CONF_BITS
Definition: cfgmgr32.h:603
int Count
Definition: noreturn.cpp:7

Referenced by CM_Get_First_Log_Conf_Ex().

◆ PNP_GetGlobalState()

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

Definition at line 675 of file rpcserver.c.

679{
681
682 DPRINT("PNP_GetGlobalState(%p %p 0x%08lx)\n",
683 hBinding, pulState, ulFlags);
684
685 if (ulFlags != 0)
686 return CR_INVALID_FLAG;
687
689
690 return CR_SUCCESS;
691}
#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 4026 of file rpcserver.c.

4032{
4033 WCHAR szProfileName[5];
4034 HKEY hKeyConfig = NULL;
4035 HKEY hKeyProfiles = NULL;
4036 HKEY hKeyProfile = NULL;
4037 DWORD dwDisposition;
4038 DWORD dwSize;
4039 LONG lError;
4041
4043
4044 DPRINT("PNP_GetHwProfInfo() called\n");
4045
4046 if (ulProfileInfoSize == 0)
4047 {
4049 goto done;
4050 }
4051
4052 if (ulFlags != 0)
4053 {
4055 goto done;
4056 }
4057
4058 /* Initialize the profile information */
4059 pHWProfileInfo->HWPI_ulHWProfile = 0;
4060 pHWProfileInfo->HWPI_szFriendlyName[0] = 0;
4061 pHWProfileInfo->HWPI_dwFlags = 0;
4062
4063 /* Open the 'IDConfigDB' key */
4065 L"System\\CurrentControlSet\\Control\\IDConfigDB",
4066 0,
4067 NULL,
4070 NULL,
4071 &hKeyConfig,
4072 &dwDisposition);
4073 if (lError != ERROR_SUCCESS)
4074 {
4076 goto done;
4077 }
4078
4079 /* Open the 'Hardware Profiles' subkey */
4080 lError = RegCreateKeyExW(hKeyConfig,
4081 L"Hardware Profiles",
4082 0,
4083 NULL,
4086 NULL,
4087 &hKeyProfiles,
4088 &dwDisposition);
4089 if (lError != ERROR_SUCCESS)
4090 {
4092 goto done;
4093 }
4094
4095 if (ulIndex == (ULONG)-1)
4096 {
4097 dwSize = sizeof(ULONG);
4098 lError = RegQueryValueExW(hKeyConfig,
4099 L"CurrentConfig",
4100 NULL,
4101 NULL,
4102 (LPBYTE)&pHWProfileInfo->HWPI_ulHWProfile,
4103 &dwSize);
4104 if (lError != ERROR_SUCCESS)
4105 {
4106 pHWProfileInfo->HWPI_ulHWProfile = 0;
4108 goto done;
4109 }
4110 }
4111 else
4112 {
4113 /* FIXME: not implemented yet */
4115 goto done;
4116 }
4117
4118 swprintf(szProfileName, L"%04lu", pHWProfileInfo->HWPI_ulHWProfile);
4119
4120 lError = RegOpenKeyExW(hKeyProfiles,
4121 szProfileName,
4122 0,
4124 &hKeyProfile);
4125 if (lError != ERROR_SUCCESS)
4126 {
4128 goto done;
4129 }
4130
4131 dwSize = sizeof(pHWProfileInfo->HWPI_szFriendlyName);
4132 lError = RegQueryValueExW(hKeyProfile,
4133 L"FriendlyName",
4134 NULL,
4135 NULL,
4136 (LPBYTE)&pHWProfileInfo->HWPI_szFriendlyName,
4137 &dwSize);
4138 if (lError != ERROR_SUCCESS)
4139 {
4141 goto done;
4142 }
4143
4144done:
4145 if (hKeyProfile != NULL)
4146 RegCloseKey(hKeyProfile);
4147
4148 if (hKeyProfiles != NULL)
4149 RegCloseKey(hKeyProfiles);
4150
4151 if (hKeyConfig != NULL)
4152 RegCloseKey(hKeyConfig);
4153
4154 return ret;
4155}
ULONG HWPI_ulHWProfile
Definition: cfgmgr32.h:554
CHAR HWPI_szFriendlyName[MAX_PROFILE_LEN]
Definition: cfgmgr32.h:555
DWORD HWPI_dwFlags
Definition: cfgmgr32.h:556

Referenced by CM_Get_Hardware_Profile_Info_ExW().

◆ PNP_GetInterfaceDeviceAlias()

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

Definition at line 2584 of file rpcserver.c.

2592{
2595}

Referenced by CM_Get_Device_Interface_Alias_ExW().

◆ PNP_GetInterfaceDeviceList()

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

Definition at line 2601 of file rpcserver.c.

2608{
2612
2614
2615 DPRINT("PNP_GetInterfaceDeviceList(%p %p %S %p %p 0x%08lx)\n",
2616 hBinding, InterfaceGuid, pszDeviceID, Buffer, pulLength, ulFlags);
2617
2618 if (!IsValidDeviceInstanceID(pszDeviceID))
2619 return CR_INVALID_DEVINST;
2620
2622 pszDeviceID);
2623
2624 PlugPlayData.Flags = ulFlags;
2625 PlugPlayData.FilterGuid = InterfaceGuid;
2626 PlugPlayData.Buffer = Buffer;
2627 PlugPlayData.BufferSize = *pulLength;
2628
2630 (PVOID)&PlugPlayData,
2632 if (NT_SUCCESS(Status))
2633 {
2634 *pulLength = PlugPlayData.BufferSize;
2635 }
2636 else
2637 {
2639 }
2640
2641 DPRINT("PNP_GetInterfaceDeviceList() done (returns %lx)\n", ret);
2642 return ret;
2643}
@ PlugPlayControlGetInterfaceDeviceList
Definition: cmtypes.h:218
static const GUID InterfaceGuid
Definition: wlanapi.c:25

Referenced by CM_Get_Device_Interface_List_ExW().

◆ PNP_GetInterfaceDeviceListSize()

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

Definition at line 2649 of file rpcserver.c.

2655{
2659
2661
2662 DPRINT("PNP_GetInterfaceDeviceListSize(%p %p %p %S 0x%08lx)\n",
2663 hBinding, pulLen, InterfaceGuid, pszDeviceID, ulFlags);
2664
2665 if (!IsValidDeviceInstanceID(pszDeviceID))
2666 return CR_INVALID_DEVINST;
2667
2669 pszDeviceID);
2670
2671 PlugPlayData.FilterGuid = InterfaceGuid;
2672 PlugPlayData.Buffer = NULL;
2673 PlugPlayData.BufferSize = 0;
2674 PlugPlayData.Flags = ulFlags;
2675
2677 (PVOID)&PlugPlayData,
2679 if (NT_SUCCESS(Status))
2680 {
2681 *pulLen = PlugPlayData.BufferSize;
2682 }
2683 else
2684 {
2686 }
2687
2688 DPRINT("PNP_GetInterfaceDeviceListSize() done (returns %lx)\n", ret);
2689 return ret;
2690}

Referenced by CM_Get_Device_Interface_List_Size_ExW().

◆ PNP_GetLogConfPriority()

DWORD WINAPI PNP_GetLogConfPriority ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulType,
DWORD  ulTag,
DWORD pPriority,
DWORD  ulFlags 
)

Definition at line 4390 of file rpcserver.c.

4397{
4400}

Referenced by CM_Get_Log_Conf_Priority_Ex().

◆ PNP_GetNextLogConf()

DWORD WINAPI PNP_GetNextLogConf ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfType,
DWORD  ulCurrentTag,
DWORD pulNextTag,
DWORD  ulFlags 
)

Definition at line 4285 of file rpcserver.c.

4292{
4293 HKEY hConfigKey = NULL;
4294 DWORD RegDataType = 0;
4295 ULONG ulDataSize = 0;
4296 LPBYTE lpData = NULL;
4298
4299 DPRINT("PNP_GetNextLogConf(%p %S %lu %ul %p 0x%08lx)\n",
4300 hBinding, pDeviceID, ulLogConfType, ulCurrentTag, pulNextTag, ulFlags);
4301
4302 if (pulNextTag == NULL)
4303 return CR_INVALID_POINTER;
4304
4305 *pulNextTag = (DWORD)0;
4306
4307 if (ulFlags != 0)
4308 return CR_INVALID_FLAG;
4309
4310 if (!IsValidDeviceInstanceID(pDeviceID))
4311 return CR_INVALID_DEVINST;
4312
4313 ret = OpenConfigurationKey(pDeviceID,
4314 ulLogConfType,
4315 &hConfigKey);
4316 if (ret != CR_SUCCESS)
4317 {
4318 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4320 goto done;
4321 }
4322
4323 ret = GetConfigurationData(hConfigKey,
4324 ulLogConfType,
4325 &RegDataType,
4326 &ulDataSize,
4327 &lpData);
4328 if (ret != CR_SUCCESS)
4329 {
4330 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
4332 goto done;
4333 }
4334
4335 DPRINT("Data size %lu\n", ulDataSize);
4336
4337 if (ulDataSize == 0 || lpData == NULL)
4338 {
4339 DPRINT1("No config data available!\n");
4341 goto done;
4342 }
4343
4344 /* Check if the next entry is available */
4345 if (RegDataType == REG_RESOURCE_LIST)
4346 {
4347 DPRINT("REG_RESOURCE_LIST->Count %lu\n", ((PCM_RESOURCE_LIST)lpData)->Count);
4348
4349 /* Fail, if we are beyond the end of the list */
4350 if (ulCurrentTag >= ((PCM_RESOURCE_LIST)lpData)->Count)
4351 {
4353 goto done;
4354 }
4355
4356 /* Indicate that we reached the end of the list */
4357 if (ulCurrentTag == ((PCM_RESOURCE_LIST)lpData)->Count - 1)
4358 {
4360 goto done;
4361 }
4362 }
4363 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4364 {
4365 DPRINT1("FIXME: REG_RESOURCE_REQUIREMENTS_LIST\n");
4366 /* FIXME */
4368 goto done;
4369 }
4370
4371 /* Return the next tag value */
4372 *pulNextTag = ulCurrentTag + 1;
4373
4374done:
4375 if (lpData != NULL)
4376 HeapFree(GetProcessHeap(), 0, lpData);
4377
4378 if (hConfigKey != NULL)
4379 RegCloseKey(hConfigKey);
4380
4381 DPRINT("PNP_GetNextLogConf() returns %lu\n", ret);
4382
4383 return ret;
4384}

Referenced by CM_Get_Next_Log_Conf_Ex().

◆ PNP_GetNextResDes()

DWORD WINAPI PNP_GetNextResDes ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfTag,
DWORD  ulLogConfType,
RESOURCEID  ResourceID,
DWORD  ulResourceTag,
DWORD pulNextResType,
DWORD pulNextResTag,
DWORD  ulFlags 
)

Definition at line 4444 of file rpcserver.c.

4454{
4455 HKEY hConfigKey = NULL;
4456 DWORD RegDataType = 0;
4457 ULONG ulDataSize = 0;
4458 LPBYTE lpData = NULL;
4460
4461 DPRINT1("PNP_GetNextResDes(%p %S 0x%lx %lu %lu %ul %p %p 0x%08lx)\n",
4462 hBinding, pDeviceID, ulLogConfTag, ulLogConfType, ResourceID,
4463 ulResourceTag, pulNextResType, pulNextResTag, ulFlags);
4464
4465 if (pulNextResType == NULL)
4466 return CR_INVALID_POINTER;
4467
4468 *pulNextResType = 0;
4469
4470 if (ulFlags != 0)
4471 return CR_INVALID_FLAG;
4472
4473 if (!IsValidDeviceInstanceID(pDeviceID))
4474 return CR_INVALID_DEVINST;
4475
4476 ret = OpenConfigurationKey(pDeviceID,
4477 ulLogConfType,
4478 &hConfigKey);
4479 if (ret != CR_SUCCESS)
4480 {
4481 DPRINT1("OpenConfigurationKey() failed (Error %lu)\n", ret);
4483 goto done;
4484 }
4485
4486 ret = GetConfigurationData(hConfigKey,
4487 ulLogConfType,
4488 &RegDataType,
4489 &ulDataSize,
4490 &lpData);
4491 if (ret != CR_SUCCESS)
4492 {
4493 DPRINT1("GetConfigurationData() failed (Error %lu)\n", ret);
4495 goto done;
4496 }
4497
4498 DPRINT1("Data size %lu\n", ulDataSize);
4499
4500 if (ulDataSize == 0 || lpData == NULL)
4501 {
4502 DPRINT1("No config data available!\n");
4504 goto done;
4505 }
4506
4507 /* Get the next resource descriptor */
4508 if (RegDataType == REG_RESOURCE_LIST)
4509 {
4510 DPRINT1("FIXME: REG_RESOURCE_LIST\n");
4511 /* FIXME */
4513 goto done;
4514 }
4515 else if (RegDataType == REG_RESOURCE_REQUIREMENTS_LIST)
4516 {
4517 DPRINT1("FIXME: REG_RESOURCE_REQUIREMENTS_LIST\n");
4518 /* FIXME */
4520 goto done;
4521 }
4522
4523done:
4524 if (lpData != NULL)
4525 HeapFree(GetProcessHeap(), 0, lpData);
4526
4527 if (hConfigKey != NULL)
4528 RegCloseKey(hConfigKey);
4529
4530 DPRINT1("PNP_GetNextResDes() returns %lu\n", ret);
4531
4532 return ret;
4533}

Referenced by CM_Get_Next_Res_Des_Ex().

◆ PNP_GetObjectProp()

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 
)

Definition at line 4979 of file rpcserver.c.

4990{
4993}

◆ PNP_GetObjectPropKeys()

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 
)

Definition at line 4961 of file rpcserver.c.

4970{
4973}

◆ PNP_GetRelatedDeviceInstance()

DWORD WINAPI PNP_GetRelatedDeviceInstance ( handle_t  hBinding,
DWORD  ulRelationship,
LPWSTR  pDeviceID,
LPWSTR  pRelatedDeviceId,
PNP_RPC_STRING_LEN pulLength,
DWORD  ulFlags 
)

Definition at line 847 of file rpcserver.c.

854{
858
860 UNREFERENCED_PARAMETER(ulFlags);
861
862 DPRINT("PNP_GetRelatedDeviceInstance(%p %lu %S %p %p 0x%lx)\n",
863 hBinding, ulRelationship, pDeviceID, pRelatedDeviceId,
864 pulLength, ulFlags);
865
866 if (!IsValidDeviceInstanceID(pDeviceID))
867 return CR_INVALID_DEVINST;
868
869 if (ulRelationship == PNP_GET_PARENT_DEVICE_INSTANCE)
870 {
871 /* The root device does not have a parent */
872 if (IsRootDeviceInstanceID(pDeviceID))
873 return CR_NO_SUCH_DEVINST;
874
875 /* Return the root device for non existing devices */
876 if (!IsPresentDeviceInstanceID(pDeviceID))
877 {
878 if ((wcslen(szRootDeviceInstanceID) + 1) > *pulLength)
879 {
880 *pulLength = wcslen(szRootDeviceInstanceID) + 1;
881 return CR_BUFFER_SMALL;
882 }
883
884 wcscpy(pRelatedDeviceId, szRootDeviceInstanceID);
885 *pulLength = wcslen(szRootDeviceInstanceID) + 1;
886 return CR_SUCCESS;
887 }
888 }
889 else if (ulRelationship == PNP_GET_SIBLING_DEVICE_INSTANCE)
890 {
891 /* The root device does not have siblings */
892 if (IsRootDeviceInstanceID(pDeviceID))
893 return CR_NO_SUCH_DEVINST;
894 }
895
897 pDeviceID);
898
899 PlugPlayData.Relation = ulRelationship;
900
901 PlugPlayData.RelatedDeviceInstanceLength = *pulLength;
902 PlugPlayData.RelatedDeviceInstance = pRelatedDeviceId;
903
905 (PVOID)&PlugPlayData,
907 if (!NT_SUCCESS(Status))
908 {
910 }
911
912 DPRINT("PNP_GetRelatedDeviceInstance() done (returns %lx)\n", ret);
913 if (ret == CR_SUCCESS)
914 {
915 DPRINT("RelatedDevice: %wZ\n", &PlugPlayData.RelatedDeviceInstance);
916 }
917
918 return ret;
919}
@ PlugPlayControlGetRelatedDevice
Definition: cmtypes.h:221

Referenced by CM_Get_Child_Ex(), CM_Get_Parent_Ex(), and CM_Get_Sibling_Ex().

◆ PNP_GetResDesData()

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 
)

Definition at line 4539 of file rpcserver.c.

4549{
4552}

◆ PNP_GetResDesDataSize()

DWORD WINAPI PNP_GetResDesDataSize ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulLogConfTag,
DWORD  ulLogConfType,
RESOURCEID  ResourceID,
DWORD  ulResourceTag,
DWORD pulSize,
DWORD  ulFlags 
)

Definition at line 4558 of file rpcserver.c.

4567{
4570}

◆ PNP_GetRootDeviceInstance()

DWORD WINAPI PNP_GetRootDeviceInstance ( handle_t  hBinding,
LPWSTR  pDeviceID,
PNP_RPC_STRING_LEN  ulLength 
)

Definition at line 810 of file rpcserver.c.

814{
816
818
819 DPRINT("PNP_GetRootDeviceInstance(%p %S %lu)\n",
820 hBinding, pDeviceID, ulLength);
821
822 if (!pDeviceID)
823 {
825 goto Done;
826 }
827
828 if (ulLength < lstrlenW(szRootDeviceInstanceID) + 1)
829 {
831 goto Done;
832 }
833
834 lstrcpyW(pDeviceID,
836
837Done:
838 DPRINT("PNP_GetRootDeviceInstance() done (returns %lx)\n", ret);
839
840 return ret;
841}

Referenced by CM_Locate_DevNode_ExW().

◆ PNP_GetServerSideDeviceInstallFlags()

DWORD WINAPI PNP_GetServerSideDeviceInstallFlags ( handle_t  hBinding,
DWORD pulSSDIFlags,
DWORD  ulFlags 
)

Definition at line 4935 of file rpcserver.c.

4939{
4941
4942 DPRINT1("PNP_GetServerSideDeviceInstallFlags(%p %p %lu)\n",
4943 hBinding, pulSSDIFlags, ulFlags);
4944
4945 if (pulSSDIFlags == NULL)
4946 return CR_INVALID_POINTER;
4947
4948 if (ulFlags != 0)
4949 return CR_INVALID_FLAG;
4950
4951 /* FIXME */
4952 *pulSSDIFlags = 0;
4953
4954 return CR_SUCCESS;
4955}

Referenced by CMP_GetServerSideDeviceInstallFlags().

◆ PNP_GetVersion()

DWORD WINAPI PNP_GetVersion ( handle_t  hBinding,
WORD pVersion 
)

Definition at line 657 of file rpcserver.c.

660{
662
663 DPRINT("PNP_GetVersion(%p %p)\n",
664 hBinding, pVersion);
665
666 *pVersion = CONFIGMG_VERSION;
667
668 return CR_SUCCESS;
669}
#define CONFIGMG_VERSION
Definition: cfgmgr32.h:64

Referenced by CM_Get_Version_Ex(), CM_Is_Version_Available_Ex(), and CMP_WaitServicesAvailable().

◆ PNP_GetVersionInternal()

DWORD WINAPI PNP_GetVersionInternal ( handle_t  hBinding,
WORD pwVersion 
)

Definition at line 4906 of file rpcserver.c.

4909{
4911
4912 *pwVersion = WINVER;
4913 return CR_SUCCESS;
4914}
#define WINVER
Definition: targetver.h:11

◆ PNP_HwProfFlags()

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 
)

Definition at line 3942 of file rpcserver.c.

3952{
3954 WCHAR szKeyName[MAX_PATH];
3955 HKEY hKey;
3956 HKEY hDeviceKey;
3957 DWORD dwSize;
3958
3960
3961 DPRINT("PNP_HwProfFlags() called\n");
3962
3963 if (!IsValidDeviceInstanceID(pDeviceID))
3964 return CR_INVALID_DEVINST;
3965
3966 if (ulConfig == 0)
3967 {
3968 wcscpy(szKeyName,
3969 L"System\\CurrentControlSet\\HardwareProfiles\\Current\\System\\CurrentControlSet\\Enum");
3970 }
3971 else
3972 {
3973 swprintf(szKeyName,
3974 L"System\\CurrentControlSet\\HardwareProfiles\\%04lu\\System\\CurrentControlSet\\Enum",
3975 ulConfig);
3976 }
3977
3979 szKeyName,
3980 0,
3982 &hKey) != ERROR_SUCCESS)
3983 return CR_REGISTRY_ERROR;
3984
3985 if (ulAction == PNP_GET_HWPROFFLAGS)
3986 {
3987 if (RegOpenKeyExW(hKey,
3988 pDeviceID,
3989 0,
3991 &hDeviceKey) != ERROR_SUCCESS)
3992 {
3993 *pulValue = 0;
3994 }
3995 else
3996 {
3997 dwSize = sizeof(DWORD);
3998 if (RegQueryValueExW(hDeviceKey,
3999 L"CSConfigFlags",
4000 NULL,
4001 NULL,
4002 (LPBYTE)pulValue,
4003 &dwSize) != ERROR_SUCCESS)
4004 {
4005 *pulValue = 0;
4006 }
4007
4008 RegCloseKey(hDeviceKey);
4009 }
4010 }
4011 else if (ulAction == PNP_SET_HWPROFFLAGS)
4012 {
4013 /* FIXME: not implemented yet */
4015 }
4016
4018
4019 return ret;
4020}

Referenced by CM_Get_HW_Prof_Flags_ExW(), and CM_Set_HW_Prof_Flags_ExW().

◆ PNP_InitDetection()

DWORD WINAPI PNP_InitDetection ( handle_t  hBinding)

Definition at line 697 of file rpcserver.c.

699{
701
702 DPRINT("PNP_InitDetection(%p)\n",
703 hBinding);
704
705 return CR_SUCCESS;
706}

Referenced by CMP_Init_Detection().

◆ PNP_InstallDevInst()

DWORD WINAPI PNP_InstallDevInst ( handle_t  hBinding)

Definition at line 5018 of file rpcserver.c.

5020{
5023}

◆ PNP_IsDockStationPresent()

CONFIGRET WINAPI PNP_IsDockStationPresent ( handle_t  hBinding,
BOOL Present 
)

Definition at line 3854 of file rpcserver.c.

3857{
3858 HKEY hKey;
3859 DWORD dwType;
3860 DWORD dwValue;
3861 DWORD dwSize;
3863
3865
3866 DPRINT1("PNP_IsDockStationPresent(%p %p)\n",
3867 hBinding, Present);
3868
3869 *Present = FALSE;
3870
3872 L"CurrentDockInfo",
3873 0,
3874 KEY_READ,
3875 &hKey) != ERROR_SUCCESS)
3876 return CR_REGISTRY_ERROR;
3877
3878 dwSize = sizeof(DWORD);
3880 L"DockingState",
3881 NULL,
3882 &dwType,
3883 (LPBYTE)&dwValue,
3884 &dwSize) != ERROR_SUCCESS)
3886
3888
3889 if (ret == CR_SUCCESS)
3890 {
3891 if (dwType != REG_DWORD || dwSize != sizeof(DWORD))
3892 {
3894 }
3895 else if (dwValue != 0)
3896 {
3897 *Present = TRUE;
3898 }
3899 }
3900
3901 DPRINT1("PNP_IsDockStationPresent() done (returns %lx)\n", ret);
3902
3903 return ret;
3904}
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15

Referenced by CM_Is_Dock_Station_Present_Ex().

◆ PNP_ModifyResDes()

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 
)

Definition at line 4576 of file rpcserver.c.

4587{
4590}

◆ PNP_NOTIFY_HANDLE_rundown()

VOID __RPC_USER PNP_NOTIFY_HANDLE_rundown ( PNP_NOTIFY_HANDLE  pHandle)

Definition at line 623 of file rpcserver.c.

625{
626 DPRINT1("PNP_NOTIFY_HANDLE_rundown(%p)\n", pHandle);
627}

◆ PNP_QueryArbitratorFreeData()

DWORD WINAPI PNP_QueryArbitratorFreeData ( handle_t  hBinding,
BYTE pData,
DWORD  DataLen,
LPWSTR  pDeviceID,
RESOURCEID  ResourceID,
DWORD  ulFlags 
)

Definition at line 4647 of file rpcserver.c.

4654{
4656}

Referenced by CM_Query_Arbitrator_Free_Data_Ex().

◆ PNP_QueryArbitratorFreeSize()

DWORD WINAPI PNP_QueryArbitratorFreeSize ( handle_t  hBinding,
DWORD pulSize,
LPWSTR  pDeviceID,
RESOURCEID  ResourceID,
DWORD  ulFlags 
)

Definition at line 4662 of file rpcserver.c.

4668{
4669 if (pulSize != NULL)
4670 *pulSize = 0;
4671
4673}
_Check_return_ _Out_ PULONG pulSize
Definition: winddi.h:2120

Referenced by CM_Query_Arbitrator_Free_Size_Ex().

◆ PNP_QueryRemove()

DWORD WINAPI PNP_QueryRemove ( handle_t  hBinding,
LPWSTR  pszDeviceID,
PPNP_VETO_TYPE  pVetoType,
LPWSTR  pszVetoName,
DWORD  ulNameLength,
DWORD  ulFlags 
)

Definition at line 3757 of file rpcserver.c.

3764{
3768
3769 DPRINT1("PNP_QueryRemove(%p %S %p %p %lu 0x%lx)\n",
3770 hBinding, pszDeviceID, pVetoType, pszVetoName,
3771 ulNameLength, ulFlags);
3772
3773 if (ulFlags & ~CM_REMOVE_BITS)
3774 return CR_INVALID_FLAG;
3775
3776 if (!IsValidDeviceInstanceID(pszDeviceID) ||
3777 IsRootDeviceInstanceID(pszDeviceID))
3778 return CR_INVALID_DEVINST;
3779
3780 if (pVetoType != NULL)
3781 *pVetoType = PNP_VetoTypeUnknown;
3782
3783 if (pszVetoName != NULL && ulNameLength > 0)
3784 *pszVetoName = UNICODE_NULL;
3785
3786 RtlZeroMemory(&PlugPlayData, sizeof(PlugPlayData));
3788 pszDeviceID);
3789 PlugPlayData.VetoName = pszVetoName;
3790 PlugPlayData.NameLength = ulNameLength;
3791// PlugPlayData.Flags =
3792
3794 &PlugPlayData,
3795 sizeof(PlugPlayData));
3796 if (!NT_SUCCESS(Status))
3798
3799 return ret;
3800}
@ PNP_VetoTypeUnknown
Definition: cfg.h:180
#define CM_REMOVE_BITS
Definition: cfgmgr32.h:780
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by CM_Query_And_Remove_SubTree_ExW().

◆ PNP_QueryResConfList()

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 
)

Definition at line 4617 of file rpcserver.c.

4626{
4629}

Referenced by CM_Query_Resource_Conflict_List().

◆ PNP_RegisterDeviceClassAssociation()

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 
)

Definition at line 2696 of file rpcserver.c.

2705{
2708}

Referenced by CM_Register_Device_Interface_ExW().

◆ PNP_RegisterDriver()

DWORD WINAPI PNP_RegisterDriver ( handle_t  hBinding,
LPWSTR  pszDeviceID,
DWORD  ulFlags 
)

Definition at line 3734 of file rpcserver.c.

3738{
3739 DPRINT("PNP_RegisterDriver(%p %S 0x%lx)\n",
3740 hBinding, pszDeviceID, ulFlags);
3741
3742 if (ulFlags & ~CM_REGISTER_DEVICE_DRIVER_BITS)
3743 return CR_INVALID_FLAG;
3744
3745 if (!IsValidDeviceInstanceID(pszDeviceID))
3746 return CR_INVALID_DEVINST;
3747
3748 SetDeviceStatus(pszDeviceID, 0, 0);
3749
3750 return CR_SUCCESS;
3751}
static CONFIGRET SetDeviceStatus(_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
Definition: rpcserver.c:264
#define CM_REGISTER_DEVICE_DRIVER_BITS
Definition: cfgmgr32.h:798

Referenced by CM_Register_Device_Driver_Ex().

◆ PNP_RegisterNotification()

DWORD WINAPI PNP_RegisterNotification ( handle_t  hBinding,
DWORD_PTR  hRecipient,
LPWSTR  pszName,
BYTE pNotificationFilter,
DWORD  ulNotificationFilterSize,
DWORD  ulFlags,
PNP_NOTIFY_HANDLE pNotifyHandle,
DWORD  ulProcessId,
DWORD pulUnknown9 
)

Definition at line 4690 of file rpcserver.c.

4700{
4701 PDEV_BROADCAST_DEVICEINTERFACE_W pBroadcastDeviceInterface;
4702 PDEV_BROADCAST_HANDLE pBroadcastDeviceHandle;
4703 PNOTIFY_ENTRY pNotifyData = NULL;
4704
4705 DPRINT1("PNP_RegisterNotification(%p %p '%S' %p %lu 0x%lx %p %lx %p)\n",
4706 hBinding, hRecipient, pszName, pNotificationFilter,
4707 ulNotificationFilterSize, ulFlags, pNotifyHandle, ulProcessId, pulUnknown9);
4708
4709 if (pNotifyHandle == NULL)
4710 return CR_INVALID_POINTER;
4711
4712 *pNotifyHandle = NULL;
4713
4714 if (pNotificationFilter == NULL ||
4715 pulUnknown9 == NULL)
4716 return CR_INVALID_POINTER;
4717
4718 if (ulFlags & ~0x7)
4719 return CR_INVALID_FLAG;
4720
4721 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_HDR)) ||
4722 (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_size < sizeof(DEV_BROADCAST_HDR)))
4723 return CR_INVALID_DATA;
4724
4725 if (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
4726 {
4727 DPRINT1("DBT_DEVTYP_DEVICEINTERFACE\n");
4728 pBroadcastDeviceInterface = (PDEV_BROADCAST_DEVICEINTERFACE_W)pNotificationFilter;
4729
4730 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_DEVICEINTERFACE_W)) ||
4731 (pBroadcastDeviceInterface->dbcc_size < sizeof(DEV_BROADCAST_DEVICEINTERFACE_W)))
4732 return CR_INVALID_DATA;
4733
4735 if (pNotifyData == NULL)
4736 return CR_OUT_OF_MEMORY;
4737
4738 if (pszName != NULL)
4739 {
4740 pNotifyData->pszName = RtlAllocateHeap(GetProcessHeap(),
4742 (wcslen(pszName) + 1) * sizeof(WCHAR));
4743 if (pNotifyData->pszName == NULL)
4744 {
4745 RtlFreeHeap(GetProcessHeap(), 0, pNotifyData);
4746 return CR_OUT_OF_MEMORY;
4747 }
4748 }
4749
4750 /* Add the entry to the notification list */
4752
4753 DPRINT("pNotifyData: %p\n", pNotifyData);
4754 *pNotifyHandle = (PNP_NOTIFY_HANDLE)pNotifyData;
4755 }
4756 else if (((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype == DBT_DEVTYP_HANDLE)
4757 {
4758 DPRINT1("DBT_DEVTYP_HANDLE\n");
4759 pBroadcastDeviceHandle = (PDEV_BROADCAST_HANDLE)pNotificationFilter;
4760
4761 if ((ulNotificationFilterSize < sizeof(DEV_BROADCAST_HANDLE)) ||
4762 (pBroadcastDeviceHandle->dbch_size < sizeof(DEV_BROADCAST_HANDLE)))
4763 return CR_INVALID_DATA;
4764
4765 if (ulFlags & DEVICE_NOTIFY_ALL_INTERFACE_CLASSES)
4766 return CR_INVALID_FLAG;
4767 }
4768 else
4769 {
4770 DPRINT1("Invalid device type %lu\n", ((PDEV_BROADCAST_HDR)pNotificationFilter)->dbch_devicetype);
4771 return CR_INVALID_DATA;
4772 }
4773
4774 return CR_SUCCESS;
4775}
LIST_ENTRY NotificationListHead
Definition: rpcserver.c:41
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define DBT_DEVTYP_HANDLE
Definition: dbt.h:25
struct _DEV_BROADCAST_DEVICEINTERFACE_W DEV_BROADCAST_DEVICEINTERFACE_W
struct _DEV_BROADCAST_HANDLE DEV_BROADCAST_HANDLE
#define DBT_DEVTYP_DEVICEINTERFACE
Definition: dbt.h:24
struct _DEV_BROADCAST_HANDLE * PDEV_BROADCAST_HANDLE
struct _DEV_BROADCAST_DEVICEINTERFACE_W * PDEV_BROADCAST_DEVICEINTERFACE_W
#define InsertTailList(ListHead, Entry)
void * PNP_NOTIFY_HANDLE
Definition: pnp.idl:7
Definition: precomp.h:43
PWSTR pszName
Definition: precomp.h:45
LIST_ENTRY ListEntry
Definition: precomp.h:44

Referenced by CMP_RegisterNotification().

◆ PNP_RegisterServiceNotification()

DWORD WINAPI PNP_RegisterServiceNotification ( handle_t  hBinding)

Definition at line 5062 of file rpcserver.c.

5064{
5067}

◆ PNP_ReportLogOn()

DWORD WINAPI PNP_ReportLogOn ( handle_t  hBinding,
BOOL  Admin,
DWORD  ProcessId 
)

Definition at line 712 of file rpcserver.c.

716{
719
721
722 DPRINT("PNP_ReportLogOn(%p %u, %u)\n",
723 hBinding, Admin, ProcessId);
724
725 /* Fail, if the caller is not an interactive user */
727 goto cleanup;
728
729 /* Get the users token */
731
732 if (!hProcess)
733 {
734 DPRINT1("OpenProcess failed with error %u\n", GetLastError());
735 goto cleanup;
736 }
737
738 if (hUserToken)
739 {
742 }
743
745 {
746 DPRINT1("OpenProcessToken failed with error %u\n", GetLastError());
747 goto cleanup;
748 }
749
750 /* Trigger the installer thread */
751 if (hInstallEvent)
753
755
756cleanup:
757 if (hProcess)
759
760 return ReturnValue;
761}
UINT32 void void ** ReturnValue
Definition: acevents.h:216
HANDLE hInstallEvent
Definition: install.c:40
HANDLE hUserToken
Definition: install.c:39
static BOOL IsCallerInteractive(_In_ handle_t hBinding)
Definition: rpcserver.c:573
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
static void cleanup(void)
Definition: main.c:1335
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define TOKEN_DUPLICATE
Definition: setypes.h:926
#define TOKEN_ASSIGN_PRIMARY
Definition: setypes.h:925

Referenced by CMP_Report_LogOn().

◆ PNP_RequestDeviceEject()

DWORD WINAPI PNP_RequestDeviceEject ( handle_t  hBinding,
LPWSTR  pszDeviceID,
PPNP_VETO_TYPE  pVetoType,
LPWSTR  pszVetoName,
DWORD  ulNameLength,
DWORD  ulFlags 
)

Definition at line 3806 of file rpcserver.c.

3813{
3817
3818 DPRINT1("PNP_RequestDeviceEject(%p %S %p %p %lu 0x%lx)\n",
3819 hBinding, pszDeviceID, pVetoType, pszVetoName,
3820 ulNameLength, ulFlags);
3821
3822 if (ulFlags != 0)
3823 return CR_INVALID_FLAG;
3824
3825 if (!IsValidDeviceInstanceID(pszDeviceID))
3826 return CR_INVALID_DEVINST;
3827
3828 if (pVetoType != NULL)
3829 *pVetoType = PNP_VetoTypeUnknown;
3830
3831 if (pszVetoName != NULL && ulNameLength > 0)
3832 *pszVetoName = UNICODE_NULL;
3833
3834 RtlZeroMemory(&PlugPlayData, sizeof(PlugPlayData));
3836 pszDeviceID);
3837 PlugPlayData.VetoName = pszVetoName;
3838 PlugPlayData.NameLength = ulNameLength;
3839// PlugPlayData.Flags =
3840
3842 &PlugPlayData,
3843 sizeof(PlugPlayData));
3844 if (!NT_SUCCESS(Status))
3846
3847 return ret;
3848}

Referenced by CM_Request_Device_Eject_ExW(), and PNP_RequestEjectPC().

◆ PNP_RequestEjectPC()

DWORD WINAPI PNP_RequestEjectPC ( handle_t  hBinding)

Definition at line 3910 of file rpcserver.c.

3912{
3913 WCHAR szDockDeviceInstance[MAX_DEVICE_ID_LEN];
3916
3917 DPRINT("PNP_RequestEjectPC(%p)\n", hBinding);
3918
3919 /* Retrieve the dock device */
3920 DockData.DeviceInstanceLength = ARRAYSIZE(szDockDeviceInstance);
3921 DockData.DeviceInstance = szDockDeviceInstance;
3922
3924 &DockData,
3925 sizeof(DockData));
3926 if (!NT_SUCCESS(Status))
3927 return NtStatusToCrError(Status);
3928
3929 /* Eject the dock device */
3931 szDockDeviceInstance,
3932 NULL,
3933 NULL,
3934 0,
3935 0);
3936}
DWORD WINAPI PNP_RequestDeviceEject(handle_t hBinding, LPWSTR pszDeviceID, PPNP_VETO_TYPE pVetoType, LPWSTR pszVetoName, DWORD ulNameLength, DWORD ulFlags)
Definition: rpcserver.c:3806
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
@ PlugPlayControlRetrieveDock
Definition: cmtypes.h:228

Referenced by CM_Request_Eject_PC_Ex().

◆ PNP_RunDetection()

CONFIGRET WINAPI PNP_RunDetection ( handle_t  hBinding,
DWORD  ulFlags 
)

Definition at line 4679 of file rpcserver.c.

4682{
4684}

Referenced by CM_Run_Detection_Ex().

◆ PNP_SetActiveService()

DWORD WINAPI PNP_SetActiveService ( handle_t  hBinding,
LPWSTR  pszFilter,
DWORD  ulFlags 
)

Definition at line 5073 of file rpcserver.c.

5077{
5080}

◆ PNP_SetClassRegProp()

DWORD WINAPI PNP_SetClassRegProp ( handle_t  hBinding,
LPWSTR  pszClassGuid,
DWORD  ulProperty,
DWORD  ulDataType,
BYTE Buffer,
PNP_PROP_SIZE  ulLength,
DWORD  ulFlags 
)

Definition at line 2853 of file rpcserver.c.

2861{
2863 LPWSTR lpValueName = NULL;
2864 HKEY hInstKey = 0;
2865 HKEY hPropKey = 0;
2866 LONG lError;
2867
2869
2870 DPRINT("PNP_SetClassRegProp(%p %S %lu %lu %p %lu 0x%08lx)\n",
2871 hBinding, pszClassGuid, ulProperty, ulDataType,
2872 Buffer, ulLength, ulFlags);
2873
2874 if (ulFlags != 0)
2875 return CR_INVALID_FLAG;
2876
2877 switch (ulProperty)
2878 {
2879 case CM_CRP_SECURITY:
2880 lpValueName = L"Security";
2881 break;
2882
2883 case CM_CRP_DEVTYPE:
2884 lpValueName = L"DeviceType";
2885 break;
2886
2887 case CM_CRP_EXCLUSIVE:
2888 lpValueName = L"Exclusive";
2889 break;
2890
2892 lpValueName = L"DeviceCharacteristics";
2893 break;
2894
2895 default:
2896 return CR_INVALID_PROPERTY;
2897 }
2898
2899 lError = RegOpenKeyExW(hClassKey,
2900 pszClassGuid,
2901 0,
2902 KEY_WRITE,
2903 &hInstKey);
2904 if (lError != ERROR_SUCCESS)
2905 {
2907 goto done;
2908 }
2909
2910 /* FIXME: Set security descriptor */
2911 lError = RegCreateKeyExW(hInstKey,
2912 L"Properties",
2913 0,
2914 NULL,
2917 NULL,
2918 &hPropKey,
2919 NULL);
2920 if (lError != ERROR_SUCCESS)
2921 {
2923 goto done;
2924 }
2925
2926 if (ulLength == 0)
2927 {
2928 if (RegDeleteValueW(hPropKey,
2929 lpValueName))
2931 }
2932 else
2933 {
2934 if (RegSetValueExW(hPropKey,
2935 lpValueName,
2936 0,
2937 ulDataType,
2938 Buffer,
2939 ulLength))
2941 }
2942
2943done:
2944 if (hPropKey != NULL)
2945 RegCloseKey(hPropKey);
2946
2947 if (hInstKey != NULL)
2948 RegCloseKey(hInstKey);
2949
2950 return ret;
2951}
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330

◆ PNP_SetDeviceProblem()

DWORD WINAPI PNP_SetDeviceProblem ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulProblem,
DWORD  ulFlags 
)

Definition at line 3489 of file rpcserver.c.

3494{
3495 ULONG ulOldStatus, ulOldProblem;
3497
3499
3500 DPRINT1("PNP_SetDeviceProblem(%p %S %lu 0x%08lx)\n",
3501 hBinding, pDeviceID, ulProblem, ulFlags);
3502
3503 if (ulFlags & ~CM_SET_DEVNODE_PROBLEM_BITS)
3504 return CR_INVALID_FLAG;
3505
3506 if (!IsValidDeviceInstanceID(pDeviceID))
3507 return CR_INVALID_DEVINST;
3508
3509 ret = GetDeviceStatus(pDeviceID,
3510 &ulOldStatus,
3511 &ulOldProblem);
3512 if (ret != CR_SUCCESS)
3513 return ret;
3514
3515 if (((ulFlags & CM_SET_DEVNODE_PROBLEM_OVERRIDE) == 0) &&
3516 (ulOldProblem != 0) &&
3517 (ulOldProblem != ulProblem))
3518 {
3519 return CR_FAILURE;
3520 }
3521
3522 if (ulProblem == 0)
3523 {
3524 ret = ClearDeviceStatus(pDeviceID,
3526 ulOldProblem);
3527 }
3528 else
3529 {
3530 ret = SetDeviceStatus(pDeviceID,
3532 ulProblem);
3533 }
3534
3535 return ret;
3536}
static CONFIGRET ClearDeviceStatus(_In_ LPWSTR pszDeviceID, _In_ DWORD ulStatus, _In_ DWORD ulProblem)
Definition: rpcserver.c:199
#define CM_SET_DEVNODE_PROBLEM_BITS
Definition: cfgmgr32.h:808
#define CM_SET_DEVNODE_PROBLEM_OVERRIDE
Definition: cfgmgr32.h:807

Referenced by CM_Set_DevNode_Problem_Ex().

◆ PNP_SetDeviceRegProp()

DWORD WINAPI PNP_SetDeviceRegProp ( handle_t  hBinding,
LPWSTR  pDeviceId,
DWORD  ulProperty,
DWORD  ulDataType,
BYTE Buffer,
PNP_PROP_SIZE  ulLength,
DWORD  ulFlags 
)

Definition at line 2112 of file rpcserver.c.

2120{
2122 LPWSTR lpValueName = NULL;
2123 HKEY hKey = 0;
2124
2126 UNREFERENCED_PARAMETER(ulFlags);
2127
2128 DPRINT("PNP_SetDeviceRegProp(%p %S %lu %lu %p %lu 0x%08lx)\n",
2129 hBinding, pDeviceId, ulProperty, ulDataType, Buffer,
2130 ulLength, ulFlags);
2131
2132 if (!IsValidDeviceInstanceID(pDeviceId))
2133 return CR_INVALID_DEVINST;
2134
2135 switch (ulProperty)
2136 {
2137 case CM_DRP_DEVICEDESC:
2138 lpValueName = L"DeviceDesc";
2139 break;
2140
2141 case CM_DRP_HARDWAREID:
2142 lpValueName = L"HardwareID";
2143 break;
2144
2146 lpValueName = L"CompatibleIDs";
2147 break;
2148
2149 case CM_DRP_SERVICE:
2150 lpValueName = L"Service";
2151 break;
2152
2153 case CM_DRP_CLASS:
2154 lpValueName = L"Class";
2155 break;
2156
2157 case CM_DRP_CLASSGUID:
2158 lpValueName = L"ClassGUID";
2159 break;
2160
2161 case CM_DRP_DRIVER:
2162 lpValueName = L"Driver";
2163 break;
2164
2165 case CM_DRP_CONFIGFLAGS:
2166 lpValueName = L"ConfigFlags";
2167 break;
2168
2169 case CM_DRP_MFG:
2170 lpValueName = L"Mfg";
2171 break;
2172
2174 lpValueName = L"FriendlyName";
2175 break;
2176
2178 lpValueName = L"LocationInformation";
2179 break;
2180
2182 lpValueName = L"UpperFilters";
2183 break;
2184
2186 lpValueName = L"LowerFilters";
2187 break;
2188
2189 case CM_DRP_SECURITY:
2190 lpValueName = L"Security";
2191 break;
2192
2193 case CM_DRP_DEVTYPE:
2194 lpValueName = L"DeviceType";
2195 break;
2196
2197 case CM_DRP_EXCLUSIVE:
2198 lpValueName = L"Exclusive";
2199 break;
2200
2202 lpValueName = L"DeviceCharacteristics";
2203 break;
2204
2206 lpValueName = L"UINumberDescFormat";
2207 break;
2208
2210 lpValueName = L"RemovalPolicy";
2211 break;
2212
2213 default:
2214 return CR_INVALID_PROPERTY;
2215 }
2216
2217 DPRINT("Value name: %S\n", lpValueName);
2218
2220 pDeviceId,
2221 0,
2223 &hKey))
2224 return CR_INVALID_DEVNODE;
2225
2226 if (ulLength == 0)
2227 {
2229 lpValueName))
2231 }
2232 else
2233 {
2234 if (RegSetValueExW(hKey,
2235 lpValueName,
2236 0,
2237 ulDataType,
2238 Buffer,
2239 ulLength))
2241 }
2242
2244
2245 DPRINT("PNP_SetDeviceRegProp() done (returns %lx)\n", ret);
2246
2247 return ret;
2248}

Referenced by CM_Set_DevNode_Registry_Property_ExW(), and PNP_GetClassInstance().

◆ PNP_SetHwProf()

DWORD WINAPI PNP_SetHwProf ( handle_t  hBinding,
DWORD  ulHardwareProfile,
DWORD  ulFlags 
)

Definition at line 4635 of file rpcserver.c.

4639{
4641}

Referenced by CM_Set_HW_Prof_Ex().

◆ PNP_SetObjectProp()

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 
)

Definition at line 4999 of file rpcserver.c.

5009{
5012}

◆ PNP_UninstallDevInst()

DWORD WINAPI PNP_UninstallDevInst ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulFlags 
)

Definition at line 3572 of file rpcserver.c.

3576{
3579}

Referenced by CM_Uninstall_DevNode_Ex().

◆ PNP_UnregisterDeviceClassAssociation()

DWORD WINAPI PNP_UnregisterDeviceClassAssociation ( handle_t  hBinding,
LPWSTR  pszInterfaceDevice,
DWORD  ulFlags 
)

Definition at line 2714 of file rpcserver.c.

2718{
2721}

Referenced by CM_Unregister_Device_Interface_ExW().

◆ PNP_UnregisterNotification()

DWORD WINAPI PNP_UnregisterNotification ( handle_t  hBinding,
PNP_NOTIFY_HANDLE pNotifyHandle 
)

Definition at line 4781 of file rpcserver.c.

4784{
4786
4787 DPRINT1("PNP_UnregisterNotification(%p %p)\n",
4788 hBinding, pNotifyHandle);
4789
4790 pEntry = (PNOTIFY_ENTRY)*pNotifyHandle;
4791 if (pEntry == NULL)
4792 return CR_INVALID_DATA;
4793
4794 RemoveEntryList(&pEntry->ListEntry);
4795 if (pEntry->pszName)
4796 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry->pszName);
4797 RtlFreeHeap(RtlGetProcessHeap(), 0, pEntry);
4798 *pNotifyHandle = NULL;
4799
4800 return CR_SUCCESS;
4801}
struct NOTIFY_ENTRY * PNOTIFY_ENTRY
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by CMP_UnregisterNotification().

◆ PNP_ValidateDeviceInstance()

DWORD WINAPI PNP_ValidateDeviceInstance ( handle_t  hBinding,
LPWSTR  pDeviceID,
DWORD  ulFlags 
)

Definition at line 767 of file rpcserver.c.

771{
773 HKEY hDeviceKey = NULL;
774
776 UNREFERENCED_PARAMETER(ulFlags);
777
778 DPRINT("PNP_ValidateDeviceInstance(%p %S 0x%08lx)\n",
779 hBinding, pDeviceID, ulFlags);
780
781 if (!IsValidDeviceInstanceID(pDeviceID))
782 return CR_INVALID_DEVINST;
783
785 pDeviceID,
786 0,
787 KEY_READ,
788 &hDeviceKey))
789 {
790 DPRINT("Could not open the Device Key!\n");
792 goto Done;
793 }
794
795 /* FIXME: add more tests */
796
797Done:
798 if (hDeviceKey != NULL)
799 RegCloseKey(hDeviceKey);
800
801 DPRINT("PNP_ValidateDeviceInstance() done (returns %lx)\n", ret);
802
803 return ret;
804}
#define CR_NO_SUCH_DEVNODE
Definition: cfgmgr32.h:857

Referenced by CM_Locate_DevNode_ExW().

◆ ReenumerateDeviceInstance()

static CONFIGRET ReenumerateDeviceInstance ( _In_ LPWSTR  pszDeviceInstance,
_In_ ULONG  ulMinorAction 
)
static

Definition at line 3330 of file rpcserver.c.

3333{
3334 PLUGPLAY_CONTROL_ENUMERATE_DEVICE_DATA EnumerateDeviceData;
3337
3338 DPRINT1("ReenumerateDeviceInstance(%S 0x%08lx)\n",
3339 pszDeviceInstance, ulMinorAction);
3340
3341 if (ulMinorAction & ~CM_REENUMERATE_BITS)
3342 return CR_INVALID_FLAG;
3343
3344 if (ulMinorAction & CM_REENUMERATE_RETRY_INSTALLATION)
3345 {
3346 DPRINT1("CM_REENUMERATE_RETRY_INSTALLATION not implemented!\n");
3347 }
3348
3349 RtlInitUnicodeString(&EnumerateDeviceData.DeviceInstance,
3350 pszDeviceInstance);
3351 EnumerateDeviceData.Flags = 0;
3352
3354 &EnumerateDeviceData,
3356 if (!NT_SUCCESS(Status))
3358
3359 return ret;
3360}
#define CM_REENUMERATE_BITS
Definition: cfgmgr32.h:793
#define CM_REENUMERATE_RETRY_INSTALLATION
Definition: cfgmgr32.h:790
@ PlugPlayControlEnumerateDevice
Definition: cmtypes.h:209

Referenced by PNP_DeviceInstanceAction().

◆ RpcServerThread()

DWORD WINAPI RpcServerThread ( LPVOID  lpParameter)

Definition at line 46 of file rpcserver.c.

47{
49 BOOLEAN RegisteredProtSeq = FALSE;
50
51 UNREFERENCED_PARAMETER(lpParameter);
52
53 DPRINT("RpcServerThread() called\n");
54
56
57#if 0
58 /* 2k/XP/2k3-compatible protocol sequence/endpoint */
60 20,
61 L"\\pipe\\ntsvcs",
62 NULL); // Security descriptor
63 if (Status == RPC_S_OK)
64 RegisteredProtSeq = TRUE;
65 else
66 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
67#endif
68
69 /* Vista/7-compatible protocol sequence/endpoint */
71 20,
72 L"\\pipe\\plugplay",
73 NULL); // Security descriptor
74 if (Status == RPC_S_OK)
75 RegisteredProtSeq = TRUE;
76 else
77 DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
78
79 /* Make sure there's a usable endpoint */
80 if (RegisteredProtSeq == FALSE)
81 return 0;
82
83 Status = RpcServerRegisterIf(pnp_v1_0_s_ifspec,
84 NULL,
85 NULL);
86 if (Status != RPC_S_OK)
87 {
88 DPRINT1("RpcServerRegisterIf() failed (Status %lx)\n", Status);
89 return 0;
90 }
91
93 20,
94 FALSE);
95 if (Status != RPC_S_OK)
96 {
97 DPRINT1("RpcServerListen() failed (Status %lx)\n", Status);
98 return 0;
99 }
100
101 /* ROS HACK (this should never happen...) */
102 DPRINT1("*** Other devices won't be installed correctly. If something\n");
103 DPRINT1("*** doesn't work, try to reboot to get a new chance.\n");
104
105 DPRINT("RpcServerThread() done\n");
106
107 return 0;
108}
unsigned char BOOLEAN
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
RPC_STATUS WINAPI RpcServerListen(UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait)
Definition: rpc_server.c:1520
RPC_STATUS WINAPI RpcServerRegisterIf(RPC_IF_HANDLE IfSpec, UUID *MgrTypeUuid, RPC_MGR_EPV *MgrEpv)
Definition: rpc_server.c:1116
RPC_STATUS WINAPI RpcServerUseProtseqEpW(RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor)
Definition: rpc_server.c:927

Referenced by ServiceMain().

◆ SetDeviceStatus()

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

Definition at line 264 of file rpcserver.c.

268{
269 PLUGPLAY_CONTROL_STATUS_DATA PlugPlayData;
272
273 DPRINT1("SetDeviceStatus(%S 0x%lx 0x%lx)\n",
274 pszDeviceID, ulStatus, ulProblem);
275
277 pszDeviceID);
278 PlugPlayData.Operation = PNP_SET_DEVICE_STATUS;
279 PlugPlayData.DeviceStatus = ulStatus;
280 PlugPlayData.DeviceProblem = ulProblem;
281
283 (PVOID)&PlugPlayData,
285 if (!NT_SUCCESS(Status))
287
288 return ret;
289}
#define PNP_SET_DEVICE_STATUS
Definition: cmtypes.h:60

Referenced by PNP_RegisterDriver(), and PNP_SetDeviceProblem().

◆ SetupDeviceInstance()

static CONFIGRET SetupDeviceInstance ( _In_ LPWSTR  pszDeviceInstance,
_In_ DWORD  ulMinorAction 
)
static

Definition at line 3228 of file rpcserver.c.

3231{
3233 HKEY hDeviceKey = NULL;
3234 DWORD dwDisableCount, dwSize;
3235 DWORD ulStatus, ulProblem;
3236 DWORD dwError;
3239
3240 DPRINT1("SetupDeviceInstance(%S 0x%08lx)\n",
3241 pszDeviceInstance, ulMinorAction);
3242
3243 if (IsRootDeviceInstanceID(pszDeviceInstance))
3244 return CR_INVALID_DEVINST;
3245
3246 if (ulMinorAction & ~CM_SETUP_BITS)
3247 return CR_INVALID_FLAG;
3248
3249 if ((ulMinorAction == CM_SETUP_DOWNLOAD) ||
3250 (ulMinorAction == CM_SETUP_WRITE_LOG_CONFS))
3251 return CR_SUCCESS;
3252
3253 dwError = RegOpenKeyExW(hEnumKey,
3254 pszDeviceInstance,
3255 0,
3256 KEY_READ,
3257 &hDeviceKey);
3258 if (dwError != ERROR_SUCCESS)
3259 return CR_INVALID_DEVNODE;
3260
3261 dwSize = sizeof(dwDisableCount);
3262 dwError = RegQueryValueExW(hDeviceKey,
3263 L"DisableCount",
3264 NULL,
3265 NULL,
3266 (LPBYTE)&dwDisableCount,
3267 &dwSize);
3268 if ((dwError == ERROR_SUCCESS) &&
3269 (dwDisableCount > 0))
3270 {
3271 goto done;
3272 }
3273
3274 GetDeviceStatus(pszDeviceInstance,
3275 &ulStatus,
3276 &ulProblem);
3277
3278 if (ulStatus & DN_STARTED)
3279 {
3280 goto done;
3281 }
3282
3283 if (ulStatus & DN_HAS_PROBLEM)
3284 {
3285 ret = ClearDeviceStatus(pszDeviceInstance,
3287 ulProblem);
3288 }
3289
3290 if (ret != CR_SUCCESS)
3291 goto done;
3292
3293 /* Start the device */
3295 pszDeviceInstance);
3297 &ControlData,
3299 if (!NT_SUCCESS(Status))
3301
3302done:
3303 if (hDeviceKey != NULL)
3304 RegCloseKey(hDeviceKey);
3305
3306 return ret;
3307}
#define DN_STARTED
Definition: cfg.h:121
#define CM_SETUP_DOWNLOAD
Definition: cfgmgr32.h:821
#define CM_SETUP_BITS
Definition: cfgmgr32.h:828
#define CM_SETUP_WRITE_LOG_CONFS
Definition: cfgmgr32.h:822

Referenced by PNP_DeviceInstanceAction().

◆ SplitDeviceInstanceID()

static VOID SplitDeviceInstanceID ( IN LPWSTR  pszDeviceInstanceID,
OUT LPWSTR  pszEnumerator,
OUT LPWSTR  pszDevice,
OUT LPWSTR  pszInstance 
)
static

Definition at line 153 of file rpcserver.c.

157{
158 WCHAR szLocalDeviceInstanceID[MAX_DEVICE_ID_LEN];
159 LPWSTR lpEnumerator = NULL;
160 LPWSTR lpDevice = NULL;
161 LPWSTR lpInstance = NULL;
162 LPWSTR ptr;
163
164 wcscpy(szLocalDeviceInstanceID, pszDeviceInstanceID);
165
166 *pszEnumerator = 0;
167 *pszDevice = 0;
168 *pszInstance = 0;
169
170 lpEnumerator = szLocalDeviceInstanceID;
171
172 ptr = wcschr(lpEnumerator, L'\\');
173 if (ptr != NULL)
174 {
175 *ptr = 0;
176 lpDevice = ++ptr;
177
178 ptr = wcschr(lpDevice, L'\\');
179 if (ptr != NULL)
180 {
181 *ptr = 0;
182 lpInstance = ++ptr;
183 }
184 }
185
186 if (lpEnumerator != NULL)
187 wcscpy(pszEnumerator, lpEnumerator);
188
189 if (lpDevice != NULL)
190 wcscpy(pszDevice, lpDevice);
191
192 if (lpInstance != NULL)
193 wcscpy(pszInstance, lpInstance);
194}

Referenced by CreateDeviceInstance(), PNP_GetDeviceList(), and PNP_GetDeviceListSize().

Variable Documentation

◆ NotificationListHead

LIST_ENTRY NotificationListHead

Definition at line 41 of file rpcserver.c.

Referenced by PNP_RegisterNotification(), and RpcServerThread().

◆ szRootDeviceInstanceID

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