IopGetLegacyVetoListDrivers

VOID __stdcall IopGetLegacyVetoListDrivers(_IO_GET_LEGACY_VETO_LIST_CONTEXT *Context){
  VOID **PoolWithTag; 
  UINT8 RestartScan; 
  NTSTATUS v4; 
  unsigned int v5; 
  unsigned __int16 MaximumLength; 
  VOID **v7; 
  wchar_t *Buffer; 
  NTSTATUS v9; 
  unsigned __int16 v10; 
  _ADAPTER_OBJECT *v11; 
  PADAPTER_OBJECT DmaAdapter; 
  _UNICODE_STRING ObjectName; 
  __int64 v14[2]; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  UINT64 NumberOfBytes; 
  UINT64 v17; 
  VOID *DirectoryHandle; 

  *(_QWORD *)&ObjectAttributes.Length = 48i64;
  DmaAdapter = 0i64;
  *(_QWORD *)&ObjectAttributes.Attributes = 576i64;
  v14[1] = (__int64)L"\\Driver";
  v14[0] = 1048590i64;
  LODWORD(NumberOfBytes) = 0;
  LODWORD(v17) = 0;
  DirectoryHandle = 0i64;
  ObjectAttributes.RootDirectory = 0i64;
  PoolWithTag = 0i64;
  ObjectAttributes.ObjectName = (_UNICODE_STRING *)v14;
  RestartScan = 1;
  ObjectName = 0i64;
  *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
  v4 = ZwOpenDirectoryObject(&DirectoryHandle, 1, &ObjectAttributes);
  if( v4 < 0 )
  {
    **((_DWORD **)Context + 3) = v4;
LABEL_20:
    Buffer = ObjectName.Buffer;
    goto LABEL_13;
  }
  v5 = 202;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0xCAui64, 1869181008i64);
  if( !PoolWithTag )
  {
    **((_DWORD **)Context + 3) = -1073741670;
    goto LABEL_20;
  }
  MaximumLength = 188;
  *(_DWORD *)&ObjectName.Length = 12320768;
  v7 = ExAllocatePoolWithTag(1ui64, 0xBCui64, 1869181008i64);
  ObjectName.Buffer = (wchar_t *)v7;
  Buffer = (wchar_t *)v7;
  if( !v7 )
  {
    **((_DWORD **)Context + 3) = -1073741670;
    goto LABEL_15;
  }
  *(_WORD *)v7 = 0;
  while( 1 )
  {
    v9 = ZwQueryDirectoryObject(DirectoryHandle, PoolWithTag, v5, 1u, RestartScan, &v17, &NumberOfBytes);
    if( v9 == -1073741789 )
    {
      v5 = NumberOfBytes;
      ExFreePoolWithTag(PoolWithTag, 0);
      PoolWithTag = ExAllocatePoolWithTag(1ui64, v5, 1869181008i64);
      if( !PoolWithTag )
        break;
      v9 = ZwQueryDirectoryObject(DirectoryHandle, PoolWithTag, v5, 1u, RestartScan, &v17, &NumberOfBytes);
    }
    RestartScan = 0;
    if( v9 < 0 )
      goto LABEL_13;
    v10 = *(_WORD *)PoolWithTag + 18;
    if( v10 > MaximumLength )
    {
      ExFreePoolWithTag(Buffer, 0);
      ObjectName.MaximumLength = v10;
      MaximumLength = v10;
      ObjectName.Buffer = (wchar_t *)ExAllocatePoolWithTag(1ui64, v10, 1869181008i64);
      Buffer = ObjectName.Buffer;
      if( !ObjectName.Buffer )
        break;
    }
    ObjectName.Length = v10 - 2;
    RtlStringCbPrintfW(Buffer, MaximumLength, (WCHAR *)L"\\Driver\\%ws");
    if( ObReferenceObjectByName(&ObjectName, 0x240ui64, 0i64, 0i64, IoDriverObjectType, 0, 0i64, (VOID **)&DmaAdapter) >= 0 )
    {
      v11 = DmaAdapter;
      if( ((__int64)DmaAdapter->AdapterObject.ContiguousMapRegisters & 0x40) != 0 )
      {
        **((_DWORD **)Context + 2) = 11;
        if( *(_QWORD *)Context )
          IopAppendLegacyVeto((const VOID ***)Context, (const VOID **)PoolWithTag);
      }
      HalPutDmaAdapter(v11);
      if( **((_DWORD **)Context + 2) == 11 && !*(_QWORD *)Context )
        goto LABEL_20;
      if( **((int **)Context + 3) < 0 )
        goto LABEL_20;
    }
    Buffer = ObjectName.Buffer;
    MaximumLength = ObjectName.MaximumLength;
  }
  **((_DWORD **)Context + 3) = -1073741670;
LABEL_13:
  if( Buffer )
    ExFreePoolWithTag(Buffer, 0);
LABEL_15:
  if( PoolWithTag )
    ExFreePoolWithTag(PoolWithTag, 0);
  if( DirectoryHandle )
    ZwClose((_HANDLE)DirectoryHandle);
}

Referenced by:

IoGetLegacyVetoList