CmpDoReDoCreateKey

INT64 __fastcall CmpDoReDoCreateKey(__int64 a1, __int64 a2){
  wchar_t *v2; 
  __int64 v3; 
  unsigned __int16 v4; 
  __int16 v5; 
  INT64 result; 
  _HANDLE v7; 
  int v8; 
  NTSTATUS v9; 
  UINT64 CreateOptions; 
  _UNICODE_STRING KeyName; 
  __int128 v12; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  UINT64 Disposition; 
  VOID *Handle; 
  VOID *KeyHandle; 

  v2 = *(wchar_t **)(a2 + 40);
  v3 = a2;
  Handle = 0i64;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  v4 = *(_WORD *)(a2 + 34);
  KeyHandle = 0i64;
  *(_DWORD *)(&KeyName.MaximumLength + 1) = 0;
  v5 = *(_WORD *)(a2 + 32);
  LODWORD(Disposition) = 0;
  LOWORD(a2) = v5;
  KeyName.MaximumLength = v4;
  v12 = 0i64;
  KeyName.Buffer = v2;
  do
  {
    a2 = (unsigned __int16)(a2 - 2);
    KeyName.Length = a2;
  }
  while( v2[(unsigned __int64)(unsigned int)a2 >> 1] != 92 );
  *((_QWORD *)&v12 + 1) = (char *)v2 + a2 + 2;
  LOWORD(v12) = v5 - a2 - 2;
  WORD1(v12) = v12;
  result = CmpDoReOpenTransKey((_CM_TRANS *)a1, &KeyName, 0x20006ui64, &Handle);
  if( (int)result >= 0 )
  {
    ObjectAttributes.SecurityQualityOfService = 0i64;
    v7 = (int)Handle;
    ObjectAttributes.ObjectName = (_UNICODE_STRING *)&v12;
    ObjectAttributes.SecurityDescriptor = *(void **)(v3 + 56);
    v8 = *(_DWORD *)(v3 + 48) - 1;
    ObjectAttributes.Length = 48;
    ObjectAttributes.RootDirectory = Handle;
    ObjectAttributes.Attributes = 4928;
    LODWORD(CreateOptions) = 9 - (v8 != 0);
    v9 = ZwCreateKey(&KeyHandle, 0xF003Fui64, &ObjectAttributes, 0i64, 0i64, CreateOptions, &Disposition);
    ZwClose(v7);
    if( v9 >= 0 )
      ZwClose((_HANDLE)KeyHandle);
    return(unsigned int)v9;
  }
  return result;
}

Referenced by:

CmpDoReDoRecord