PopOpenThermalLoggingKey

__int64 __fastcall PopOpenThermalLoggingKey(char a1, VOID **a2, WCHAR a3){
  NTSTATUS PersistedStateLocation; 
  int v5; 
  INT64 a6; 
  VOID *KeyHandle; 
  INT64 a7; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  WCHAR SourceString[264]; 

  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  KeyHandle = 0i64;
  DestinationString = 0i64;
  if( a1 )
  {
    RtlInitUnicodeString(
      &DestinationString,
      L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Power\\LastThermalEvent");
    v5 = 1;
  }
  else
  {
    LODWORD(a6) = 520;
    PersistedStateLocation = RtlGetPersistedStateLocation(
                               (WCHAR *)L"ThermalLogging",
                               0i64,
                               L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power",
                               0i64,
                               SourceString,
                               a6,
                               (INT64)&a7);
    if( PersistedStateLocation < 0 )
      return(unsigned int)PersistedStateLocation;
    RtlInitUnicodeString(&DestinationString, SourceString);
    v5 = 0;
  }
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &DestinationString;
  LODWORD(a6) = v5;
  ObjectAttributes.Length = 48;
  ObjectAttributes.Attributes = 576;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  PersistedStateLocation = ZwCreateKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, 0i64, 0i64, a6, 0i64);
  if( PersistedStateLocation >= 0 )
    *a2 = KeyHandle;
  return(unsigned int)PersistedStateLocation;
}

Referenced by:

PopThermalHandlePreviousShutdown
PopThermalWriteShutdownToRegistry