CmpKeyEnumStackCreateResumeContext

INT64 __fastcall CmpKeyEnumStackCreateResumeContext(INT64 a1, INT64 a2, INT64 a3, CHAR a4, INT64 a5){
  int v5; 
  unsigned int v7; 
  int v9; 
  __int64 v10; 
  size_t v11; 
  char *TransientPoolWithTag; 
  char *v13; 
  INT16 v14; 
  INT64 v15; 
  _QWORD *v16; 
  INT64 EntryAtLayerHeight; 
  INT16 v18; 
  INT64 KcbAtLayerHeight; 
  _DWORD *v20; 
  __int64 v21; 
  INT64 v22; 

  v5 = *(__int16 *)(a1 + 2);
  v7 = 0;
  v9 = a3;
  v10 = v5 + 1;
  v11 = 24 * v10 + 8;
  TransientPoolWithTag = (char *)CmpAllocateTransientPoolWithTag(1ui64, 24 * v10 + 8);
  v13 = TransientPoolWithTag;
  if( TransientPoolWithTag )
  {
    memset(TransientPoolWithTag, 0i64, v11);
    v13[2] = a4;
    v14 = 0;
    *((_DWORD *)v13 + 1) = v9;
    *(_WORD *)v13 = v5;
    if( (v5 & 0x8000u) == 0 )
    {
      v15 = a2;
      v16 = v13 + 8;
      do
      {
        EntryAtLayerHeight = CmpKeyEnumStackGetEntryAtLayerHeight(v15, v14);
        KcbAtLayerHeight = CmpGetKcbAtLayerHeight(a1, v18);
        CmpReferenceKeyControlBlockUnsafe((volatile INT64 *)KcbAtLayerHeight);
        v20 = v16 + 2;
        v21 = 2i64;
        v16[1] = KcbAtLayerHeight;
        v22 = EntryAtLayerHeight - (_QWORD)v16;
        *v16 = *(_QWORD *)(KcbAtLayerHeight + 304);
        do
        {
          *v20 = *(_DWORD *)((char *)v20 + v22 + 8);
          ++v20;
          --v21;
        }
        while( v21 );
        ++v14;
        v16 += 3;
        v15 = a2;
      }
      while( v14 <= (__int16)v5 );
      v7 = 0;
    }
    *(_QWORD *)a5 = v13;
  }
  else
  {
    return(unsigned int)-1073741670;
  }
  return v7;
}

Referenced by:

CmpEnumerateLayeredKey