CmpAddSubKeyToList

CHAR __fastcall CmpAddSubKeyToList(UINT64 a1, UINT64 *a2, UINT64 a3){
  __int64(__fastcall *v5)(UINT64, _QWORD, int *); 
  UINT64 *v6; 
  __int64 v7; 
  __int64 v8; 
  CHAR v9; 
  unsigned __int16 v10; 
  __int64(__fastcall *v11)(_QWORD, _QWORD, __int64); 
  unsigned int v12; 
  wchar_t *v13; 
  wchar_t *v14; 
  unsigned int v15; 
  _WORD *v16; 
  int v17; 
  int v19[2]; 
  UINT64 *v20; 
  _WORD *v21; 
  UNICODE_STRING v22; 
  char v23; 
  unsigned int v25; 
  int v26; 
  int v27; 
  v25 = a3;
  *(_DWORD *)(&v22.MaximumLength + 1) = 0;
  v19[0] = -1;
  v19[1] = 0;
  v26 = -1;
  v27 = 0;
  v5 = *(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8);
  v20 = 0i64;
  v6 = 0i64;
  v22.Buffer = 0i64;
  v22.Length = 0;
  v7 = v5(a1, (unsigned int)a3, &v26);
  v8 = v7;
  if( !v7 )
    return 0;
  v9 = 1;
  v10 = *(_WORD *)(v7 + 72);
  if( (*(_BYTE *)(v7 + 2) & 0x20) != 0 )
  {
    v11 = *(__int64(__fastcall **)(_QWORD, _QWORD, __int64))(a1 + 24);
    v12 = (unsigned __int16)(2 * v10);
    v22.Length = 2 * v10;
    v22.MaximumLength = 2 * v10;
    v13 = (wchar_t *)v11((unsigned __int16)(2 * v10), 0i64, 540560707i64);
    v22.Buffer = v13;
    v14 = v13;
    if( !v13 )
    {
      v9 = 0;
LABEL_14:
      if( v8 )
        (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v26);
      return v9;
    }
    v23 = 1;
    CmpCopyCompressedName(v13, v12, (PWCHAR)(v8 + 76), *(unsigned __int16 *)(v8 + 72));
  }
  else
  {
    v23 = 0;
    LOWORD(v12) = *(_WORD *)(v7 + 72);
    v14 = (wchar_t *)(v7 + 76);
    v22.Length = v12;
    v22.Buffer = (wchar_t *)(v7 + 76);
    v22.MaximumLength = v10;
  }
  (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, &v26);
  v15 = *(_DWORD *)a2;
  v8 = 0i64;
  v16 = (_WORD *)(*(__int64(__fastcall **)(UINT64, _QWORD, int *))(a1 + 8))(a1, v15, v19);
  v21 = v16;
  if( !v16 )
    goto LABEL_22;
  if( *v16 == 26994 )
  {
    v15 = CmpSelectLeaf(a1, a2, &v22, v25 >> 31, &v20);
    if( v15 == -1 )
      goto LABEL_22;
    v6 = v20;
  }
  v17 = CmpAddToLeaf(a1, v15, v25, &v22);
  if( v17 == -1 )
  {
LABEL_22:
    v9 = 0;
    goto LABEL_10;
  }
  if( v6 )
    *(_DWORD *)v6 = v17;
  else
    *(_DWORD *)a2 = v17;
LABEL_10:
  if( v23 )
    (*(void(__fastcall **)(wchar_t *, _QWORD))(a1 + 32))(v14, (unsigned __int16)v12);
  if( v21 )
  {
    (*(void(__fastcall **)(UINT64, int *))(a1 + 16))(a1, v19);
    goto LABEL_14;
  }
  return v9;
}

Referenced by:

CmRenameKey
CmpAddSubKeyEx
CmpLightWeightPrepareAddKeyUoW
CmpLightWeightPrepareRenameKeyUoW