PiControlGetRelatedDevice
INT64 __stdcall PiControlGetRelatedDevice(
_PLUGPLAY_CONTROL_CLASS PnPControlClass,
_PLUGPLAY_CONTROL_RELATED_DEVICE_DATA *RelatedData,
UINT64 PnPControlDataLength,
CHAR CallerMode){
unsigned __int16 Length;
PWCHAR v7;
ULONG v8;
UINT64 v9;
int BufferForUserModeCaller;
int UserModeCallersCopy;
UINT64 AllocateDestination;
UINT64 AllocateDestinationa;
PWCHAR RelatedDeviceInstance;
UNICODE_STRING Destination;
UINT64 RelatedDeviceInstanceLength;
Length = RelatedData->TargetDeviceInstance.Length;
Destination = 0i64;
Destination.MaximumLength = Length;
Destination.Length = Length;
if( (unsigned __int16)(Length - 1) > 0x18Fu || (Length & 1) != 0 )
return 3221225485i64;
RelatedDeviceInstance = 0i64;
Destination.Buffer = 0i64;
v7 = RelatedData->RelatedDeviceInstance;
if( v7 && (v8 = RelatedData->RelatedDeviceInstanceLength) != 0 )
v9 = 2 * v8;
else
v9 = 0i64;
LODWORD(RelatedDeviceInstanceLength) = v9;
BufferForUserModeCaller = PiControlAllocateBufferForUserModeCaller(
(PVOID *)&RelatedDeviceInstance,
v9,
CallerMode,
v7);
if( BufferForUserModeCaller >= 0 )
{
LODWORD(AllocateDestination) = 1;
BufferForUserModeCaller = PiControlMakeUserModeCallersCopy(
(VOID **)&Destination.Buffer,
RelatedData->TargetDeviceInstance.Buffer,
Destination.Length,
2ui64,
CallerMode,
AllocateDestination);
if( BufferForUserModeCaller >= 0 )
{
BufferForUserModeCaller = PiGetRelatedDevice(
&Destination,
RelatedDeviceInstance,
&RelatedDeviceInstanceLength,
RelatedData->Relation);
if( RelatedDeviceInstance )
{
LODWORD(AllocateDestinationa) = 0;
UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
(VOID **)&RelatedData->RelatedDeviceInstance,
RelatedDeviceInstance,
2 * RelatedData->RelatedDeviceInstanceLength,
2ui64,
CallerMode,
AllocateDestinationa);
if( UserModeCallersCopy < 0 )
BufferForUserModeCaller = UserModeCallersCopy;
}
RelatedData->RelatedDeviceInstanceLength = (unsigned int)RelatedDeviceInstanceLength >> 1;
}
}
PiControlFreeUserModeCallersBuffer(CallerMode, Destination.Buffer);
PiControlFreeUserModeCallersBuffer(CallerMode, RelatedDeviceInstance);
return(unsigned int)BufferForUserModeCaller;
}Referenced by:
No references.