PiControlGetRelatedDevice

VOID __fastcall PiControlGetRelatedDevice(
        _EX_RUNDOWN_REF *PnPControlClass,
        _PLUGPLAY_CONTROL_RELATED_DEVICE_DATA *RelatedData,
        UINT64 PnPControlDataLength,
        CHAR CallerMode){
  unsigned __int16 v4; 
  VOID *v7; 
  _PLUGPLAY_CONTROL_RELATED_DEVICE_DATA v8; 
  UINT64 v9; 
  UINT64 AllocateDestination; 
  UINT64 AllocateDestinationa; 
  VOID *Dest; 
  _UNICODE_STRING Destination; 
  UINT64 RelatedDeviceInstanceLength; 

  v4 = *(_WORD *)RelatedData;
  Destination = 0i64;
  Destination.MaximumLength = v4;
  Destination.Length = v4;
  if( (unsigned __int16)(v4 - 1) <= 0x18Fu && (v4 & 1) == 0 )
  {
    Dest = 0i64;
    Destination.Buffer = 0i64;
    v7 = (VOID *)*((_QWORD *)RelatedData + 3);
    if( v7 && (v8 = RelatedData[8]) != 0 )
      v9 = (unsigned int)(2 * v8);
    else
      v9 = 0i64;
    LODWORD(RelatedDeviceInstanceLength) = v9;
    if( PiControlAllocateBufferForUserModeCaller(&Dest, v9, CallerMode, v7) >= 0 )
    {
      LODWORD(AllocateDestination) = 1;
      if( PiControlMakeUserModeCallersCopy(
             (VOID **)&Destination.Buffer,
             *((VOID **)RelatedData + 1),
             Destination.Length,
             2ui64,
             CallerMode,
             AllocateDestination) >= 0 )
      {
        PiGetRelatedDevice(&Destination, (WCHAR *)Dest, &RelatedDeviceInstanceLength, (unsigned int)RelatedData[4]);
        if( Dest )
        {
          LODWORD(AllocateDestinationa) = 0;
          PiControlMakeUserModeCallersCopy(
            (VOID **)RelatedData + 3,
            Dest,
            (unsigned int)(2 * RelatedData[8]),
            2ui64,
            CallerMode,
            AllocateDestinationa);
        }
        RelatedData[8] = (unsigned int)RelatedDeviceInstanceLength >> 1;
      }
    }
    PiControlFreeUserModeCallersBuffer(CallerMode, Destination.Buffer);
    PiControlFreeUserModeCallersBuffer(CallerMode, Dest);
  }
}

Referenced by:

No references.