CmpFindTagIndex

__int64 __fastcall CmpFindTagIndex(PVOID BugCheckParameter3, __int64 a2, unsigned int a3, __int64 a4){
  unsigned int v6; 
  __int64(__fastcall *v8)(PVOID, __int64, int *); 
  _CM_KEY_VALUE *v9; 
  _CELL_DATA *v10; 
  __int64 v11; 
  unsigned int ValueByName; 
  _CM_KEY_VALUE *v13; 
  unsigned int v14; 
  UINT64 v16; 
  int v17[2]; 
  int v18[2]; 
  int v19[2]; 
  INT64 v20; 
  _HV_GET_CELL_CONTEXT CellContext; 
  void *P[2]; 
  INT64 v23; 

  LODWORD(v16) = 0;
  P[0] = 0i64;
  *(_DWORD *)&CellContext.BinContext._bf_0 = 0;
  v17[1] = 0;
  v6 = a2;
  v18[1] = 0;
  v19[1] = 0;
  LOBYTE(v23) = 0;
  v8 = (__int64(__fastcall *)(PVOID, __int64, int *))*((_QWORD *)BugCheckParameter3 + 1);
  CellContext.Cell = -1;
  v17[0] = -1;
  v18[0] = -1;
  v20 = 0xFFFFFFFFi64;
  v19[0] = -1;
  v9 = (_CM_KEY_VALUE *)v8(BugCheckParameter3, a2, v17);
  if( !v9 )
    return(unsigned int)-2;
  v10 = CmpValueToData((_HHIVE *)BugCheckParameter3, v6, v9, (UINT *)&v16, &CellContext);
  (*((void(__fastcall **)(PVOID, int *))BugCheckParameter3 + 2))(BugCheckParameter3, v17);
  if( !v10 )
    return(unsigned int)-2;
  v11 = (*((__int64(__fastcall **)(PVOID, _QWORD, int *))BugCheckParameter3 + 1))(BugCheckParameter3, a3, v18);
  if( v11 )
  {
    ValueByName = CmpFindValueByName((__int64)BugCheckParameter3, v11, a4);
    (*((void(__fastcall **)(PVOID, int *))BugCheckParameter3 + 2))(BugCheckParameter3, v18);
    if( ValueByName == -1 )
    {
      v14 = v10->u.KeyList[0];
      goto LABEL_13;
    }
    v13 = (_CM_KEY_VALUE *)(*((__int64(__fastcall **)(PVOID, _QWORD, int *))BugCheckParameter3 + 1))(
                             BugCheckParameter3,
                             ValueByName,
                             v19);
    if( v13 )
    {
      CmpGetValueData(
        (_HHIVE *)BugCheckParameter3,
        ValueByName,
        v13,
        (unsigned int *)&v16,
        P,
        (unsigned __int8 *)&v23,
        (_HV_GET_CELL_CONTEXT *)&v20);
      (*((void(__fastcall **)(PVOID, int *))BugCheckParameter3 + 2))(BugCheckParameter3, v19);
      if( P[0] )
      {
        v14 = 1;
        if( *(_DWORD *)P[0] )
        {
          while( *((_DWORD *)P[0] + v14) != v10->u.KeyList[0] )
          {
            if( ++v14 > *(_DWORD *)P[0] )
              goto LABEL_10;
          }
        }
        else
        {
LABEL_10:
          v14 = -2;
        }
        if( (_BYTE)v23 )
          ExFreePoolWithTag(P[0], 0);
        else(*((void(__fastcall **)(PVOID, INT64 *))BugCheckParameter3 + 2))(BugCheckParameter3, &v20);
        goto LABEL_13;
      }
    }
  }
  v14 = -2;
LABEL_13:
  (*((void(__fastcall **)(PVOID, _HV_GET_CELL_CONTEXT *))BugCheckParameter3 + 2))(BugCheckParameter3, &CellContext);
  return v14;
}

Referenced by:

CmpAddDriverToList