DrvDbOpenContext

NTSTATUS __stdcall DrvDbOpenContext(){
  HPNPCTX *v0; 
  _DRVDB_NODE *v1; 
  int v2; 
  VOID **PoolWithTag; 
  VOID **v4; 
  _QWORD *v5; 
  VOID **v6; 
  int v7; 
  NTSTATUS DatabaseNode; 
  void *v10; 
  INT64 a5; 
  INT64 a8; 

  v0 = (HPNPCTX *)*(&stru_140CF2E80 + 607);
  v1 = 0i64;
  *(&stru_140CF2E80 + 608) = 0i64;
  a8 = 0i64;
  v2 = **(&stru_140CF2E80 + 607);
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x38ui64, 1111770192i64);
  v4 = PoolWithTag;
  if( !PoolWithTag )
    return -1073741801;
  PoolWithTag[3] = 0i64;
  PoolWithTag[4] = 0i64;
  PoolWithTag[5] = 0i64;
  PoolWithTag[6] = 0i64;
  *PoolWithTag = v0;
  *((_DWORD *)PoolWithTag + 2) = v2;
  *((_DWORD *)PoolWithTag + 3) = -805306368;
  v5 = PoolWithTag + 2;
  v5[1] = v5;
  *v5 = v5;
  v6 = ExAllocatePoolWithTag(0x200ui64, 0x68ui64, 1111770192i64);
  v4[6] = v6;
  if( v6 )
  {
    v7 = ExInitializeResourceLite((INT64)v6);
    if( v7 < 0 )
    {
      ExFreePoolWithTag(v4[6], 0);
      v4[6] = 0i64;
    }
  }
  else
  {
    v7 = -1073741670;
  }
  if( v7 >= 0 )
  {
    LODWORD(a5) = 3;
    DatabaseNode = DrvDbCreateDatabaseNode(
                     (_DRVDB_CONTEXT *)v4,
                     (WCHAR *)L"SYSTEM",
                     1i64,
                     (WCHAR *)L"DriverDatabase",
                     a5,
                     0i64,
                     0i64,
                     (INT64)&a8);
    v1 = (_DRVDB_NODE *)a8;
    v7 = DatabaseNode;
    if( DatabaseNode >= 0 )
    {
      v7 = DrvDbLoadDatabaseNode((_DRVDB_CONTEXT *)v4, (_DRVDB_NODE *)a8);
      if( v7 >= 0 )
      {
        v7 = DrvDbRegisterObjects(v0, (_DRVDB_CONTEXT *)v4);
        if( v7 >= 0 )
        {
          *(&stru_140CF2E80 + 608) = v4;
          v4 = 0i64;
        }
      }
    }
  }
  if( v4 )
  {
    if( v1 )
      DrvDbDestroyDatabaseNode((_DRVDB_CONTEXT *)v4, v1);
    v10 = v4[6];
    if( v10 )
    {
      ExDeleteResourceLite((UINT64)v4[6]);
      ExFreePoolWithTag(v10, 0);
    }
    ExFreePoolWithTag(v4, 0);
  }
  return v7;
}

Referenced by:

PiDrvDbInit