PiControlGetPropertyData

INT64 __stdcall PiControlGetPropertyData(
        _PLUGPLAY_CONTROL_CLASS PnPControlClass,
        _PLUGPLAY_CONTROL_PROPERTY_DATA *PropertyData,
        UINT64 PnPControlDataLength,
        CHAR CallerMode){
  unsigned int Length; 
  ULONG BufferSize; 
  INT64 result; 
  _DEVICE_OBJECT *v9; 
  __int64 v10; 
  ULONG *p_BufferSize; 
  VOID **p_Buffer; 
  __int64 v13; 
  int DevicePowerData; 
  ULONG Property; 
  ULONG v16; 
  ULONG v17; 
  ULONG v18; 
  ULONG v19; 
  ULONG v20; 
  ULONG v21; 
  DEVICE_REGISTRY_PROPERTY v22; 
  int DeviceStack; 
  INT8 v24; 
  int UserModeCallersCopy; 
  ULONG v26; 
  ULONG v27; 
  ULONG v28; 
  ULONG v29; 
  int DeviceRegProp; 
  ULONG v31; 
  int v32; 
  int DeviceDependencyList; 
  unsigned int v34; 
  UINT64 AllocateDestination; 
  UINT64 AllocateDestinationa; 
  PVOID PropertyBuffer; 
  VOID *Destination[2]; 
  int v39; 
  INT8 CallerModea; 
  CallerModea = CallerMode;
  Length = PropertyData->DeviceInstance.Length;
  BufferSize = 0;
  v39 = 0;
  PropertyBuffer = 0i64;
  *(_OWORD *)Destination = 0i64;
  WORD1(Destination[0]) = Length;
  LOWORD(Destination[0]) = Length;
  if( (unsigned __int16)(Length - 1) > 0x18Fu || (Length & 1) != 0 )
    return 3221225485i64;
  LODWORD(AllocateDestination) = 1;
  result = PiControlMakeUserModeCallersCopy(
             &Destination[1],
             PropertyData->DeviceInstance.Buffer,
             Length,
             2ui64,
             CallerMode,
             AllocateDestination);
  if( (int)result >= 0 )
  {
    PpDevNodeLockTree(0);
    v9 = (_DEVICE_OBJECT *)PnpDeviceObjectFromDeviceInstanceWithTag((INT64)Destination, 0x43706E50ui64);
    PiControlFreeUserModeCallersBuffer(CallerMode, Destination[1]);
    if( !v9 || (v10 = *(_QWORD *)(*((_QWORD *)v9 + 39) + 40i64)) == 0 )
    {
      DevicePowerData = -1073741810;
      goto LABEL_39;
    }
    if( (unsigned int)(*(_DWORD *)(v10 + 300) - 787) <= 1 )
    {
      DevicePowerData = -1073741738;
    }
    else
    {
      p_BufferSize = &PropertyData->BufferSize;
      BufferSize = PropertyData->BufferSize;
      p_Buffer = &PropertyData->Buffer;
      DevicePowerData = PiControlAllocateBufferForUserModeCaller(
                          &PropertyBuffer,
                          BufferSize,
                          CallerMode,
                          PropertyData->Buffer);
      if( DevicePowerData < 0 )
        goto LABEL_39;
      Property = PropertyData->Property;
      if( Property > 8 )
      {
        v26 = Property - 10;
        if( v26 )
        {
          v27 = v26 - 1;
          if( !v27 )
          {
            v22 = DevicePropertyInstallState;
            goto LABEL_17;
          }
          v28 = v27 - 2;
          if( !v28 )
          {
            *p_BufferSize = 4;
            if( BufferSize >= 4 )
            {
              DevicePowerData = 0;
              *(_DWORD *)PropertyBuffer = *(_DWORD *)(v10 + 684);
LABEL_21:
              v24 = CallerModea;
              LODWORD(AllocateDestinationa) = 0;
              UserModeCallersCopy = PiControlMakeUserModeCallersCopy(
                                      p_Buffer,
                                      PropertyBuffer,
                                      BufferSize,
                                      1ui64,
                                      CallerModea,
                                      AllocateDestinationa);
              if( UserModeCallersCopy < 0 )
                DevicePowerData = UserModeCallersCopy;
              goto LABEL_23;
            }
            DevicePowerData = -1073741789;
LABEL_39:
            v24 = CallerModea;
LABEL_23:
            PpDevNodeUnlockTree(0);
            if( v9 )
              ObfDereferenceObjectWithTag(v9, 0x43706E50ui64);
            PiControlFreeUserModeCallersBuffer(v24, PropertyBuffer);
            return(unsigned int)DevicePowerData;
          }
          v29 = v28 - 1;
          if( !v29 )
          {
            DeviceStack = PiControlGetDeviceStack(v10, BufferSize, (__int64)PropertyBuffer, &PropertyData->BufferSize);
            goto LABEL_18;
          }
          v31 = v29 - 1;
          if( v31 )
          {
            if( v31 != 1 )
              goto LABEL_54;
            v32 = 1;
          }
          else
          {
            v32 = 0;
          }
          DeviceDependencyList = PnpGetDeviceDependencyList(
                                   v10,
                                   v32,
                                   (wchar_t *)PropertyBuffer,
                                   BufferSize >> 1,
                                   &PropertyData->BufferSize);
          v34 = 2 * *p_BufferSize;
          DevicePowerData = DeviceDependencyList;
          *p_BufferSize = v34;
          if( ((int)(DeviceDependencyList + 0x80000000) < 0 || DeviceDependencyList == -1073741789) && v34 <= 2 )
          {
            *p_BufferSize = 0;
            DevicePowerData = -1073741772;
          }
        }
        else
        {
          if( BufferSize < 4 )
          {
            DevicePowerData = -1073741789;
          }
          else
          {
            PpHotSwapGetDevnodeRemovalPolicy((_DEVICE_NODE *)v10, 0, (_DEVICE_REMOVAL_POLICY *)PropertyBuffer);
            DevicePowerData = 0;
          }
          *p_BufferSize = 4;
        }
      }
      else
      {
        if( Property == 8 )
        {
          v22 = DevicePropertyAddress;
          goto LABEL_17;
        }
        v16 = Property - 1;
        if( !v16 )
        {
          v22 = DevicePropertyPhysicalDeviceObjectName;
          goto LABEL_17;
        }
        v17 = v16 - 1;
        if( !v17 )
        {
          v22 = DevicePropertyBusTypeGuid;
          goto LABEL_17;
        }
        v18 = v17 - 1;
        if( !v18 )
        {
          v22 = DevicePropertyLegacyBusType;
          goto LABEL_17;
        }
        v19 = v18 - 1;
        if( !v19 )
        {
          v22 = DevicePropertyBusNumber;
          goto LABEL_17;
        }
        v20 = v19 - 1;
        if( v20 )
        {
          v21 = v20 - 1;
          if( !v21 )
          {
            v22 = DevicePropertyRemovalPolicy;
LABEL_17:
            DeviceStack = IoGetDeviceProperty(v9, v22, BufferSize, PropertyBuffer, &PropertyData->BufferSize);
LABEL_18:
            DevicePowerData = DeviceStack;
            goto LABEL_19;
          }
          if( v21 == 1 )
          {
            DeviceRegProp = CmGetDeviceRegProp(
                              PiPnpRtlCtx,
                              *(const wchar_t **)(v10 + 48),
                              0i64,
                              34,
                              (__int64)&v39,
                              (__int64)PropertyBuffer,
                              (__int64)&PropertyData->BufferSize,
                              0);
            DevicePowerData = DeviceRegProp;
            if( DeviceRegProp >= 0 && v39 != 4 )
            {
              DevicePowerData = -1073741584;
              goto LABEL_39;
            }
            if( DeviceRegProp == -1073741275 )
              DevicePowerData = -1073741772;
            goto LABEL_19;
          }
LABEL_54:
          DevicePowerData = -1073741811;
          goto LABEL_39;
        }
        DevicePowerData = PiControlGetDevicePowerData(v10, v13, BufferSize, PropertyBuffer, &PropertyData->BufferSize);
        if( DevicePowerData == -2147483643 )
          DevicePowerData = -1073741789;
      }
    }
LABEL_19:
    if( DevicePowerData >= 0 )
    {
      p_Buffer = &PropertyData->Buffer;
      goto LABEL_21;
    }
    goto LABEL_39;
  }
  return result;
}

Referenced by:

No references.