SmcCacheManagerStart

NTSTATUS __stdcall SmcCacheManagerStart(_SMC_CACHE_MANAGER *CacheMgr, _KEVENT *CachesUpdatedEvent){
  _DEVICE_OBJECT **v2; 
  unsigned int v5; 
  int v6; 
  NTSTATUS result; 
  __int64 v8; 
  const _KEXCEPTION_FRAME *v9; 
  __int64 v10; 
  const wchar_t *v11; 
  __int64 v12; 
  __int64 v13; 
  UINT64 CreateOptions; 
  struct _UNICODE_STRING v15; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  VOID *KeyHandle; 

  v2 = (_DEVICE_OBJECT **)&unk_140D23110;
  KeyHandle = 0i64;
  v5 = 0;
  v15 = 0i64;
  memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
  do
  {
    v6 = *(_DWORD *)v2;
    if( (*(_DWORD *)v2 & 1) == 0 )
    {
      if( !v5 )
      {
        result = SmpUtilsGetControlDevice((VOID **)CacheMgr, v2 + 1, v2 + 2);
        if( result < 0 )
          return result;
        v6 = *(_DWORD *)v2;
      }
      *(_DWORD *)v2 = v6 | 1;
    }
    ++v5;
    v2 += 3;
  }
  while( v5 < 2 );
  v8 = 0x7FFFi64;
  v9 = &stru_1407D7500;
  do
  {
    if( !LOWORD(v9->P1Home) )
      break;
    v9 = (const _KEXCEPTION_FRAME *)((char *)v9 + 2);
    --v8;
  }
  while( v8 );
  v10 = (0x7FFF - v8) & ((unsigned __int128)-(__int128)(unsigned __int64)v8 >> 64);
  if( v8 )
  {
    v15.Buffer = (wchar_t *)&stru_1407D7500;
    v15.Length = 2 * v10;
    v15.MaximumLength = 2 * v10 + 2;
  }
  LODWORD(CreateOptions) = 0;
  ObjectAttributes.ObjectName = &v15;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  ObjectAttributes.Attributes = 576;
  result = ZwCreateKey(&KeyHandle, 0x20006ui64, &ObjectAttributes, 0i64, 0i64, CreateOptions, 0i64);
  if( result >= 0 )
  {
    ZwClose((_HANDLE)KeyHandle);
    v15 = 0i64;
    v11 = L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager\\Memory Management\\StoreParameters\\CacheInfo";
    v12 = 0x7FFFi64;
    do
    {
      if( !*v11 )
        break;
      ++v11;
      --v12;
    }
    while( v12 );
    v13 = (0x7FFF - v12) & -(__int64)(v12 != 0);
    if( v12 )
    {
      v15.Buffer = L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager\\Memory Management\\StorePar"
                    "ameters\\CacheInfo";
      v15.Length = 2 * v13;
      v15.MaximumLength = 2 * v13 + 2;
    }
    result = SmKmKeyGenStart((__int64)(CacheMgr + 128), &v15);
    if( result >= 0 )
    {
      *((_QWORD *)CacheMgr + 69) = CachesUpdatedEvent;
      return 0;
    }
  }
  return result;
}

Referenced by:

SmcCacheCreatePrepare