WmipQueryWmiDataBlock

INT64 __stdcall WmipQueryWmiDataBlock(
        _DEVICE_OBJECT *DeviceObject,
        _IRP *Irp,
        UINT64 GuidIndex,
        UINT64 InstanceIndex,
        UINT64 InstanceCount,
        UINT64 *InstanceLengthArray,
        UINT64 BufferAvail,
        UINT8 *Buffer){
  UINT8 *v8; 
  int DeviceInstanceName; 
  UINT64 *v10; 
  int v11; 
  unsigned int v12; 
  UINT8 *v13; 
  int v14; 
  UINT8 *v15; 
  int SMBiosEventlog; 
  int v18; 
  int v19; 
  int v20; 
  LIST_ENTRY *v21; 
  void *v22; 
  DEVICE_OBJECT *v23; 
  unsigned int v24; 
  wchar_t *v25; 
  __int64 v26; 
  LIST_ENTRY *RegEntryByDevice; 
  DEVICE_OBJECT *Blink; 
  int v29; 
  UINT64 Length; 
  __int64 v31; 
  wchar_t *v32; 
  UINT8 *v33; 
  UINT64 SysIdUuidCount; 
  SYSID_1394 *SysId1394; 
  struct _UNICODE_STRING UnicodeString; 
  void *Src; 
  _IRP *v38; 
  __int64 v39; 
  int v40; 
  const wchar_t *v41; 
  UINT64 *p_SysIdUuidCount; 
  int v43; 
  __int64 v44; 
  int v45; 
  const wchar_t *v46; 
  __int64 v47; 
  int v48; 
  __int64 v49; 
  int v50; 
  const wchar_t *v51; 
  SYSID_1394 **p_SysId1394; 
  int v53; 
  __int64 v54; 
  int v55; 
  v8 = Buffer;
  DeviceInstanceName = 0;
  v10 = InstanceLengthArray;
  v11 = GuidIndex;
  v38 = Irp;
  v12 = 0;
  v13 = 0i64;
  switch( (_DWORD)GuidIndex )
  {
    case 0:
      UnicodeString = 0i64;
      RegEntryByDevice = WmipFindRegEntryByDevice(DeviceObject);
      Src = RegEntryByDevice;
      v22 = RegEntryByDevice;
      if( !RegEntryByDevice )
        goto LABEL_44;
      Blink = (DEVICE_OBJECT *)RegEntryByDevice[1].Blink;
      if( Blink )
      {
        DeviceInstanceName = IoGetDeviceInstanceName(Blink, &UnicodeString);
        if( DeviceInstanceName >= 0 )
        {
          v29 = UnicodeString.Length + 2;
          v12 = v29 + (InstanceCount - 1) * ((UnicodeString.Length + 9) & 0xFFFFFFF8);
          LODWORD(SysIdUuidCount) = v12;
          if( v12 <= (unsigned int)BufferAvail )
          {
            memset((INT64)Buffer, 0i64);
            if( (_DWORD)InstanceCount )
            {
              Length = UnicodeString.Length;
              v31 = (unsigned int)InstanceCount;
              do
              {
                v32 = UnicodeString.Buffer;
                *(_DWORD *)v10 = v29;
                v33 = (UINT8 *)((unsigned __int64)(v8 + 7) & 0xFFFFFFFFFFFFFFF8ui64);
                v10 = (UINT64 *)((char *)v10 + 4);
                *(_WORD *)v33 = Length;
                v33 += 2;
                memmove(v33, (UINT8 *)v32, Length);
                v8 = &v33[Length];
                --v31;
              }
              while( v31 );
              v12 = SysIdUuidCount;
              v22 = Src;
            }
            goto LABEL_40;
          }
          goto LABEL_39;
        }
LABEL_41:
        DeviceInstanceName = -1073741163;
        goto LABEL_43;
      }
LABEL_42:
      DeviceInstanceName = -1073741823;
      goto LABEL_43;
    case 1:
      UnicodeString = 0i64;
      v21 = WmipFindRegEntryByDevice(DeviceObject);
      v22 = v21;
      if( !v21 )
        goto LABEL_44;
      v23 = (DEVICE_OBJECT *)v21[1].Blink;
      if( v23 )
      {
        DeviceInstanceName = IoGetDeviceInstanceName(v23, &UnicodeString);
        if( DeviceInstanceName >= 0 )
        {
          v24 = UnicodeString.Length;
          v12 = UnicodeString.Length + 10;
          if( v12 <= (unsigned int)BufferAvail )
          {
            v25 = UnicodeString.Buffer;
            *(_DWORD *)Buffer = 1;
            *(_DWORD *)InstanceLengthArray = v12;
            v26 = v24;
            *((_WORD *)Buffer + 2) = v24 + 4;
            memmove(Buffer + 6, (UINT8 *)v25, v24);
            *(_DWORD *)&Buffer[v26 + 6] = 3145823;
LABEL_40:
            RtlFreeAnsiString(&UnicodeString);
LABEL_43:
            WmipUnreferenceRegEntry((INT64)v22);
            return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
          }
LABEL_39:
          DeviceInstanceName = -1073741789;
          goto LABEL_40;
        }
        goto LABEL_41;
      }
      goto LABEL_42;
    case 2:
      SysIdUuidCount = 0i64;
      v43 = 0x4000000;
      v40 = 292;
      v41 = L"BootArchitecture";
      v45 = 292;
      p_SysIdUuidCount = &SysIdUuidCount;
      v48 = 0x4000000;
      v46 = L"PreferredProfile";
      v47 = (__int64)&SysIdUuidCount + 4;
      v51 = L"Capabilities";
      v50 = 292;
      v53 = 0x4000000;
      p_SysId1394 = &SysId1394;
      LODWORD(SysId1394) = 0;
      v39 = 0i64;
      v44 = 0i64;
      v49 = 0i64;
      v54 = 0i64;
      v55 = 0;
      LOBYTE(v20) = RtlpQueryRegistryValues(0i64, (_KEXCEPTION_FRAME *)&stru_1407D8100);
      if( v20 < 0 )
        goto LABEL_44;
      v12 = 12;
      if( (unsigned int)BufferAvail >= 0xC )
      {
        *(_QWORD *)Buffer = SysIdUuidCount;
        *((_DWORD *)Buffer + 2) = (_DWORD)SysId1394;
        goto LABEL_9;
      }
      goto LABEL_25;
  }
  if( (_DWORD)GuidIndex != 3 )
  {
    if( (unsigned int)GuidIndex > 5 )
    {
      if( (_DWORD)GuidIndex == 6 )
      {
        HIDWORD(SysIdUuidCount) = BufferAvail;
        SMBiosEventlog = WmipGetSMBiosEventlog(
                           (UINT8 *)((unsigned __int64)Buffer & -(__int64)((_DWORD)BufferAvail != 0)),
                           (UINT64 *)((char *)&SysIdUuidCount + 4));
        v12 = HIDWORD(SysIdUuidCount);
        DeviceInstanceName = SMBiosEventlog;
        if( SMBiosEventlog < 0 )
          return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
        goto LABEL_9;
      }
LABEL_44:
      DeviceInstanceName = -1073741163;
      return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
    }
    Src = 0i64;
    SysIdUuidCount = 0i64;
    SysId1394 = 0i64;
    DeviceInstanceName = WmipGetSysIds(
                           (SYSID_UUID **)&Src,
                           &SysIdUuidCount,
                           &SysId1394,
                           (UINT64 *)((char *)&SysIdUuidCount + 4));
    if( DeviceInstanceName < 0 )
      return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
    if( v11 == 5 )
    {
      v18 = HIDWORD(SysIdUuidCount);
      Irp = (_IRP *)SysId1394;
      v19 = 8 * HIDWORD(SysIdUuidCount);
    }
    else
    {
      v18 = SysIdUuidCount;
      Irp = (_IRP *)Src;
      v19 = 16 * SysIdUuidCount;
    }
    v12 = v19 + 4;
    if( (unsigned int)BufferAvail >= v12 )
    {
      *(_DWORD *)InstanceLengthArray = v12;
      *(_DWORD *)Buffer = v18;
      memmove(Buffer + 4, (UINT8 *)Irp, v12 - 4i64);
      DeviceInstanceName = 0;
      return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
    }
LABEL_25:
    DeviceInstanceName = -1073741789;
    return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
  }
  if( (unsigned int)BufferAvail < 8 )
  {
    v15 = 0i64;
    v8 = 0i64;
    v14 = 0;
  }
  else
  {
    v13 = Buffer + 4;
    v14 = BufferAvail - 8;
    v15 = Buffer + 8;
  }
  LODWORD(SysIdUuidCount) = v14;
  DeviceInstanceName = WmipGetSMBiosTableData(v15, (int *)&SysIdUuidCount, v8);
  v12 = SysIdUuidCount + 8;
  if( DeviceInstanceName >= 0 )
  {
    *(_DWORD *)v13 = SysIdUuidCount;
LABEL_9:
    *(_DWORD *)InstanceLengthArray = v12;
  }
  return IoWMICompleteRequest((__int64)DeviceObject, (__int64)Irp, (__int64)v38, DeviceInstanceName, v12);
}

Referenced by:

IoWMISystemControl