PiControlGetPropertyData

VOID __fastcall PiControlGetPropertyData(
        _PLUGPLAY_CONTROL_CLASS PnPControlClass,
        _PLUGPLAY_CONTROL_PROPERTY_DATA *PropertyData,
        UINT64 PnPControlDataLength,
        CHAR CallerMode){
  unsigned int v4; 
  unsigned int v5; 
  _DEVICE_OBJECT *v8; 
  __int64 DeviceNode; 
  _PLUGPLAY_CONTROL_PROPERTY_DATA *v10; 
  VOID **v11; 
  UINT64 v12; 
  unsigned int v13; 
  unsigned int v14; 
  unsigned int v15; 
  unsigned int v16; 
  unsigned int v17; 
  unsigned int v18; 
  unsigned int v19; 
  _DEVICE_REGISTRY_PROPERTY v20; 
  NTSTATUS DeviceStack; 
  NTSTATUS DevicePowerData; 
  INT8 v23; 
  unsigned int v24; 
  unsigned int v25; 
  unsigned int v26; 
  unsigned int v27; 
  NTSTATUS DeviceRegProp; 
  unsigned int v29; 
  int v30; 
  NTSTATUS DeviceDependencyList; 
  unsigned int v32; 
  INT64 CallerModea; 
  VOID *Src; 
  VOID *Srca; 
  UINT64 v36; 
  VOID *Dest; 
  VOID *Destination[2]; 
  UINT64 CmRegPropType; 
  INT8 v40; 

  v40 = CallerMode;
  v4 = *(unsigned __int16 *)PropertyData;
  v5 = 0;
  LODWORD(CmRegPropType) = 0;
  Dest = 0i64;
  *(_OWORD *)Destination = 0i64;
  WORD1(Destination[0]) = v4;
  LOWORD(Destination[0]) = v4;
  if( (unsigned __int16)(v4 - 1) > 0x18Fu )
    return;
  if( (v4 & 1) != 0 )
    return;
  LODWORD(Src) = 1;
  if( PiControlMakeUserModeCallersCopy(
         &Destination[1],
         *((VOID **)PropertyData + 1),
         v4,
         2ui64,
         CallerMode,
         (UINT64)Src) < 0 )
    return;
  PpDevNodeLockTree(PPL_SIMPLE_READ);
  v8 = (_DEVICE_OBJECT *)PnpDeviceObjectFromDeviceInstanceWithTag((__int64)Destination, 0x43706E50u);
  PiControlFreeUserModeCallersBuffer(CallerMode, Destination[1]);
  if( !v8 )
    goto LABEL_37;
  DeviceNode = (__int64)v8->DeviceObjectExtension->DeviceNode;
  if( !DeviceNode )
    goto LABEL_37;
  if( (unsigned int)(*(_DWORD *)(DeviceNode + 300) - 787) <= 1 )
  {
    DevicePowerData = -1073741738;
    goto LABEL_19;
  }
  v10 = PropertyData + 8;
  v5 = PropertyData[8];
  v11 = (VOID **)(PropertyData + 6);
  if( PiControlAllocateBufferForUserModeCaller(&Dest, v5, CallerMode, *((VOID **)PropertyData + 3)) < 0 )
    goto LABEL_37;
  v13 = PropertyData[4];
  if( v13 > 8 )
  {
    v24 = v13 - 10;
    if( !v24 )
    {
      if( v5 < 4 )
      {
        DevicePowerData = -1073741789;
      }
      else
      {
        PpHotSwapGetDevnodeRemovalPolicy((_DEVICE_NODE *)DeviceNode, 0, (_DEVICE_REMOVAL_POLICY *)Dest);
        DevicePowerData = 0;
      }
      *v10 = 4;
      goto LABEL_19;
    }
    v25 = v24 - 1;
    if( !v25 )
    {
      v20 = 18;
      goto LABEL_17;
    }
    v26 = v25 - 2;
    if( v26 )
    {
      v27 = v26 - 1;
      if( !v27 )
      {
        DeviceStack = PiControlGetDeviceStack(
                        (_DEVICE_NODE *)DeviceNode,
                        v5,
                        Dest,
                        (UINT64 *)PropertyData + 4,
                        CallerModea);
        goto LABEL_18;
      }
      v29 = v27 - 1;
      if( v29 )
      {
        if( v29 != 1 )
          goto LABEL_37;
        v30 = 1;
      }
      else
      {
        v30 = 0;
      }
      DeviceDependencyList = PnpGetDeviceDependencyList(DeviceNode, v30, (__int64)Dest, v5 >> 1, PropertyData + 8);
      v32 = 2 * *v10;
      DevicePowerData = DeviceDependencyList;
      *v10 = v32;
      if( ((int)(DeviceDependencyList + 0x80000000) < 0 || DeviceDependencyList == -1073741789) && v32 <= 2 )
      {
        *v10 = 0;
        DevicePowerData = -1073741772;
      }
      goto LABEL_19;
    }
    *v10 = 4;
    if( v5 >= 4 )
    {
      *(_DWORD *)Dest = *(_DWORD *)(DeviceNode + 684);
      goto LABEL_21;
    }
LABEL_37:
    v23 = v40;
    goto LABEL_22;
  }
  if( v13 == 8 )
  {
    v20 = 16;
    goto LABEL_17;
  }
  v14 = v13 - 1;
  if( !v14 )
  {
    v20 = 11;
    goto LABEL_17;
  }
  v15 = v14 - 1;
  if( !v15 )
  {
    v20 = 12;
    goto LABEL_17;
  }
  v16 = v15 - 1;
  if( !v16 )
  {
    v20 = 13;
    goto LABEL_17;
  }
  v17 = v16 - 1;
  if( !v17 )
  {
    v20 = 14;
    goto LABEL_17;
  }
  v18 = v17 - 1;
  if( v18 )
  {
    v19 = v18 - 1;
    if( !v19 )
    {
      v20 = 19;
LABEL_17:
      DeviceStack = IoGetDeviceProperty(v8, v20, v5, Dest, (UINT64 *)PropertyData + 4);
LABEL_18:
      DevicePowerData = DeviceStack;
      goto LABEL_19;
    }
    if( v19 != 1 )
      goto LABEL_37;
    LODWORD(v36) = 0;
    DeviceRegProp = CmGetDeviceRegProp(
                      *(&stru_140CF2E80 + 607),
                      *(const WCHAR **)(DeviceNode + 48),
                      0i64,
                      34i64,
                      &CmRegPropType,
                      (UINT8 *)Dest,
                      (UINT64 *)PropertyData + 4,
                      v36);
    DevicePowerData = DeviceRegProp;
    if( DeviceRegProp >= 0 && (_DWORD)CmRegPropType != 4 )
      goto LABEL_37;
    if( DeviceRegProp == -1073741275 )
      DevicePowerData = -1073741772;
  }
  else
  {
    DevicePowerData = PiControlGetDevicePowerData((_DEVICE_NODE *)DeviceNode, v12, (VOID *)v5, (UINT64 *)Dest);
    if( DevicePowerData == -2147483643 )
      DevicePowerData = -1073741789;
  }
LABEL_19:
  if( DevicePowerData < 0 )
    goto LABEL_37;
  v11 = (VOID **)(PropertyData + 6);
LABEL_21:
  v23 = v40;
  LODWORD(Srca) = 0;
  PiControlMakeUserModeCallersCopy(v11, Dest, v5, 1ui64, v40, (UINT64)Srca);
LABEL_22:
  PpDevNodeUnlockTree(PPL_SIMPLE_READ);
  if( v8 )
    ObfDereferenceObjectWithTag(v8, 0x43706E50ui64);
  PiControlFreeUserModeCallersBuffer(v23, Dest);
}

Referenced by:

No references.