CmAppendDeclarativeFilterLevel

__int64 __fastcall CmAppendDeclarativeFilterLevel(
        __int64 a1,
        char *a2,
        const WCHAR *a3,
        wchar_t *a4,
        int a5,
        _DWORD *a6){
  ULONG v6; 
  wchar_t *v7; 
  unsigned int v8; 
  int v9; 
  void *PoolWithTag; 
  unsigned int v11; 
  __int64 v12; 
  int v13; 
  __int64 v14; 
  __int64 v15; 
  int v16; 
  char v17; 
  HANDLE Handle; 
  wchar_t *v20; 
  int v21; 
  unsigned int v22; 
  v6 = 0;
  Handle = 0i64;
  v7 = a4;
  v20 = a4;
  v8 = 0;
  v22 = 0;
  v9 = 0;
  *a6 = 0;
  PoolWithTag = 0i64;
  v21 = 0;
  v11 = 0;
  if( a1 )
    v12 = *(_QWORD *)(a1 + 224);
  else
    v12 = 0i64;
  v13 = SysCtxRegOpenKey(v12, a2, a3, 0, 0x80000000, &Handle);
  if( v13 < 0 || (v13 = PnpCtxRegQueryInfoKey(v14, Handle, 0i64, 0i64, &v22, &v21, 0i64), v13 < 0) )
  {
    v8 = v13;
  }
  else if( !v7
         || (v11 = v21 + 1,
             (PoolWithTag = ExAllocatePoolWithTag(PagedPool, 2i64 * (unsigned int)(v21 + 1), 0x52504E50ui64)) != 0i64) )
  {
    if( v22 )
    {
      do
      {
        v21 = v11;
        v16 = PnpCtxRegEnumValue(v15, Handle, v6, PoolWithTag, &v21, 0i64, 0i64, 0i64);
        v15 = 3221225507i64;
        if( v16 == -1073741789 )
        {
          v8 = -1073741789;
        }
        else if( v16 < 0 )
        {
          v8 = v16;
          break;
        }
        v9 += v21;
        if( v16 >= 0 )
        {
          if( v7 )
          {
            v21 = a5;
            ++v9;
            v17 = PnpMultiSzAppend(v7, (unsigned int *)&v21, (const wchar_t *)PoolWithTag, &v20);
            v7 = v20;
            if( !v17 )
              v8 = -1073741789;
          }
        }
        ++v6;
      }
      while( v6 < v22 );
    }
    *a6 = 2 * v9;
    if( PoolWithTag )
      ExFreePoolWithTag(PoolWithTag, 0);
  }
  else
  {
    v8 = -1073741801;
  }
  if( Handle )
    ZwClose(Handle);
  return v8;
}

Referenced by:

CmAppendDeclarativeDefaultFilters
CmGetDeclarativeFilterList