CmpReadBuildLab

__int64 __fastcall CmpReadBuildLab(_QWORD *a1, unsigned int *a2, WCHAR a3){
  _PRIVILEGE_SET *TransientPoolWithTag; 
  INT64 v6; 
  NTSTATUS v7; 
  VOID *v8; 
  INT64 Length; 
  UINT64 Lengtha; 
  UINT64 Lengthb; 
  UINT64 *ResultLength; 
  VOID *KeyHandle; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  UINT64 Tag; 
  UINT64 v18; 

  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  LODWORD(v18) = 0;
  LODWORD(Tag) = 0;
  DestinationString = 0i64;
  TransientPoolWithTag = 0i64;
  RtlInitUnicodeString(&DestinationString, L"\\REGISTRY\\MACHINE\\SOFTWARE\\MICROSOFT\\WINDOWS NT\\CURRENTVERSION");
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &DestinationString;
  ObjectAttributes.Length = 48;
  ObjectAttributes.Attributes = 576;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v7 = ZwOpenKey(
         &KeyHandle,
         0x20019ui64,
         &ObjectAttributes,
         v6,
         Length,
         (INT64)ResultLength,
         0i64,
         *(INT64 *)&DestinationString.Length);
  if( v7 >= 0 )
  {
    RtlInitUnicodeString(&DestinationString, L"BuildLab");
    LODWORD(Lengtha) = 0;
    v7 = ZwQueryValueKey(KeyHandle, &DestinationString, KeyValuePartialInformation, 0i64, Lengtha, &Tag);
    if( v7 == -1073741789 )
    {
      TransientPoolWithTag = (_PRIVILEGE_SET *)CmpAllocateTransientPoolWithTag(1ui64, (unsigned int)Tag);
      if( !TransientPoolWithTag )
      {
LABEL_4:
        v7 = -1073741670;
        goto LABEL_8;
      }
      LODWORD(Lengthb) = Tag;
      v7 = ZwQueryValueKey(
             KeyHandle,
             &DestinationString,
             KeyValuePartialInformation,
             TransientPoolWithTag,
             Lengthb,
             &v18);
      if( v7 >= 0 )
      {
        v8 = CmpAllocateTransientPoolWithTag(1ui64, TransientPoolWithTag->Privilege[0].Luid.LowPart);
        *a1 = v8;
        if( !v8 )
          goto LABEL_4;
        memmove(v8, &TransientPoolWithTag->Privilege[0].Luid.HighPart, TransientPoolWithTag->Privilege[0].Luid.LowPart);
        *a2 = TransientPoolWithTag->Privilege[0].Luid.LowPart;
      }
    }
  }
LABEL_8:
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  if( TransientPoolWithTag )
    CmSiFreeMemory(TransientPoolWithTag);
  return(unsigned int)v7;
}

Referenced by:

CmpRecordShutdownStopTime