ObpCreateDirectoryObject

NTSTATUS __stdcall ObpCreateDirectoryObject(
        PVOID *DirectoryHandle,
        UINT64 DesiredAccess,
        OBJECT_ATTRIBUTES *ObjectAttributes,
        PVOID ShadowDirectoryHandle,
        UINT64 Flags){
  unsigned int v6; 
  char v8; 
  __int64 v9; 
  NTSTATUS inserted; 
  PADAPTER_OBJECT v12; 
  int v13; 
  int v14; 
  int v15; 
  PVOID *Object; 
  PVOID *Objecta; 
  struct _DMA_ADAPTER *DmaAdapter; 
  PADAPTER_OBJECT v19; 
  PVOID v20; 
  PVOID Handle; 
  v6 = DesiredAccess;
  Handle = 0i64;
  v19 = 0i64;
  DmaAdapter = 0i64;
  if( (Flags & 0xFFFFFFFC) != 0 )
    goto LABEL_25;
  v8 = *((_BYTE *)KeGetCurrentThread() + 562);
  if( v8 )
  {
    if( (Flags & 2) == 0 )
    {
      v9 = 0x7FFFFFFF0000i64;
      if( (unsigned __int64)DirectoryHandle < 0x7FFFFFFF0000i64 )
        v9 = (__int64)DirectoryHandle;
      *(_QWORD *)v9 = *(_QWORD *)v9;
      goto LABEL_7;
    }
LABEL_25:
    inserted = -1073741581;
    goto LABEL_9;
  }
LABEL_7:
  if( !ShadowDirectoryHandle
    || (v20 = 0i64,
        inserted = ObReferenceObjectByHandle(ShadowDirectoryHandle, 3u, ObpDirectoryObjectType, v8, &v20, 0i64),
        DmaAdapter = (struct _DMA_ADAPTER *)v20,
        inserted >= 0) )
  {
    inserted = ObCreateObjectEx(
                 v8,
                 ObpDirectoryObjectType,
                 (__int64)ObjectAttributes,
                 v8,
                 (__int64)Object,
                 344,
                 0,
                 0,
                 &v19,
                 0i64);
    if( inserted >= 0 )
    {
      v12 = v19;
      memset((INT64)v19, 0i64);
      v12[18].DmaOperations = 0i64;
      *(_DWORD *)(&v12[21].Size + 1) = -1;
      v13 = 0;
      if( DmaAdapter )
      {
        v13 = 4;
        v12[19].DmaOperations = (_DMA_OPERATIONS *)DmaAdapter;
        DmaAdapter = 0i64;
        if( (unsigned __int8)RtlIsSandboxedToken(0i64, v8) )
          v13 = 20;
      }
      v14 = v13 | 8;
      if( (Flags & 1) == 0 )
        v14 = v13;
      v15 = v14 | 0x20;
      if( (Flags & 2) == 0 )
        v15 = v14;
      *(_DWORD *)&v12[21].Version |= v15;
      LODWORD(Objecta) = 0;
      inserted = ObInsertObjectEx(v12, 0i64, v6, 0i64, (UINT64)Objecta, 0i64, &Handle);
      v19 = 0i64;
      *DirectoryHandle = Handle;
    }
  }
LABEL_9:
  if( DmaAdapter )
    HalPutDmaAdapter(DmaAdapter);
  if( v19 )
    HalPutDmaAdapter(v19);
  return inserted;
}

Referenced by:

NtCreateDirectoryObject
NtCreateDirectoryObjectEx