CmpLinkKeyToHive

UINT8 __stdcall CmpLinkKeyToHive(_WCHAR *KeyPath, _WCHAR *HivePath){
  NTSTATUS v3; 
  UINT64 CreateOptions; 
  UINT64 CreateOptionsa; 
  _UNICODE_STRING Data; 
  _UNICODE_STRING DestinationString; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  UINT64 Disposition; 
  VOID *KeyHandle; 

  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  KeyHandle = 0i64;
  LODWORD(Disposition) = 0;
  DestinationString = 0i64;
  Data = 0i64;
  RtlInitUnicodeString(&DestinationString, KeyPath);
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.ObjectName = &DestinationString;
  ObjectAttributes.Length = 48;
  LODWORD(CreateOptions) = 3;
  ObjectAttributes.Attributes = 576;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  if( ZwCreateKey(&KeyHandle, 0x20ui64, &ObjectAttributes, 0i64, 0i64, CreateOptions, &Disposition) >= 0 )
  {
    if( (_DWORD)Disposition == 1 )
    {
      RtlInitUnicodeString(&Data, HivePath);
      LODWORD(CreateOptionsa) = Data.Length;
      v3 = ZwSetValueKey(KeyHandle, &CmSymbolicLinkValueName, 0i64, 6ui64, Data.Buffer, CreateOptionsa);
      ZwClose((_HANDLE)KeyHandle);
      if( v3 >= 0 )
        return 1;
    }
    else
    {
      ZwClose((_HANDLE)KeyHandle);
    }
  }
  return 0;
}

Referenced by:

CmpFinishSystemHivesLoad