PoThermalCounterSetCallback

NTSTATUS __stdcall PoThermalCounterSetCallback(PCW_CALLBACK_TYPE Type, PCW_CALLBACK_INFORMATION *Info, VOID *Context){
  int v5; 
  char v6; 
  struct _PCW_BUFFER *Buffer; 
  POP_THERMAL_ZONE *i; 
  _DEVICE_OBJECT *DeviceAttachmentBaseRefWithTag; 
  _DEVICE_OBJECT *v10; 
  const _UNICODE_STRING *DeviceNode; 
  wchar_t *v12; 
  signed __int64 v13; 
  int v14; 
  int v15; 
  UINT64 v16; 
  _PCW_DATA Data; 
  _THERMAL_ZONE_COUNTERS Counters; 

  Counters = 0i64;
  v5 = 0;
  v6 = 0;
  PopAcquireRwLockShared((UINT64)&PopPolicyDeviceLock);
  if( Type == PcwCallbackEnumerateInstances )
  {
    Buffer = Info->EnumerateInstances.Buffer;
LABEL_6:
    v6 = 1;
    goto LABEL_7;
  }
  if( Type != PcwCallbackCollectData )
    goto LABEL_27;
  Buffer = Info->EnumerateInstances.Buffer;
  if( wcspbrk(Info->AddCounter.InstanceMask->Buffer, (WCHAR *)L"*?") )
    goto LABEL_6;
LABEL_7:
  for( i = (POP_THERMAL_ZONE *)*(&stru_140C23628 + 181);
        i != (POP_THERMAL_ZONE *)((char *)&stru_140C23628 + 1448);
        i = *(POP_THERMAL_ZONE **)i )
  {
    if( (*((_BYTE *)i + 65) & 2) != 0 )
    {
      DeviceAttachmentBaseRefWithTag = IoGetDeviceAttachmentBaseRefWithTag(*((_DEVICE_OBJECT **)i + 6), 0x6D546F50ui64);
      v10 = DeviceAttachmentBaseRefWithTag;
      if( DeviceAttachmentBaseRefWithTag )
        DeviceNode = (const _UNICODE_STRING *)DeviceAttachmentBaseRefWithTag->DeviceObjectExtension->DeviceNode;
      else
        DeviceNode = 0i64;
      if( DeviceNode )
      {
        if( v6 )
          goto LABEL_19;
        v12 = Info->AddCounter.InstanceMask->Buffer;
        v13 = (char *)DeviceNode[8].Buffer - (char *)v12;
        do
        {
          v14 = *(wchar_t *)((char *)v12 + v13);
          v15 = *v12 - v14;
          if( v15 )
            break;
          ++v12;
        }
        while( v14 );
        if( !v15 )
        {
LABEL_19:
          Counters = 0i64;
          if( Type == PcwCallbackCollectData )
          {
            v5 = PopThermalReadCounters(i, Info->AddCounter.CounterMask, &Counters);
            if( v5 < 0 )
            {
              ObfDereferenceObjectWithTag(v10, 0x6D546F50ui64);
              break;
            }
          }
          v16 = (unsigned int)i[124];
          Data.Data = &Counters;
          Data.Size = 16;
          v5 = PcwAddInstance(Buffer, DeviceNode + 8, v16, 1ui64, &Data);
        }
        ObfDereferenceObjectWithTag(v10, 0x6D546F50ui64);
        if( v5 < 0 )
          break;
      }
      else
      {
        ObfDereferenceObjectWithTag(DeviceAttachmentBaseRefWithTag, 0x6D546F50ui64);
      }
    }
  }
LABEL_27:
  PopReleaseRwLock((_POP_RW_LOCK *)&PopPolicyDeviceLock);
  return v5;
}

Referenced by:

No references.