SiGetDriveLayoutInformation

NTSTATUS __stdcall SiGetDriveLayoutInformation(WCHAR *DriveName, _DRIVE_LAYOUT_INFORMATION_EX **DriveLayout){
  int v3; 
  ULONG OutputBufferLength; 
  VOID **OutputBuffer; 
  _DRIVE_LAYOUT_INFORMATION_EX *v6; 
  NTSTATUS v7; 
  _IO_STATUS_BLOCK IoStatusBlock; 
  void *FileHandle; 

  FileHandle = 0i64;
  IoStatusBlock = 0i64;
  v3 = SiOpenDevice(DriveName, &FileHandle);
  if( v3 >= 0 )
  {
    OutputBufferLength = 18480;
    OutputBuffer = ExAllocatePoolWithTag(1ui64, 0x4830ui64, 1263556947i64);
    v6 = (_DRIVE_LAYOUT_INFORMATION_EX *)OutputBuffer;
    if( OutputBuffer )
    {
      while( 1 )
      {
        v7 = ZwDeviceIoControlFile(
               (_HANDLE)FileHandle,
               0,
               0i64,
               0i64,
               &IoStatusBlock,
               0x70050u,
               0i64,
               0,
               OutputBuffer,
               OutputBufferLength);
        v3 = v7;
        if( v7 != -1073741789 )
          break;
        ExFreePoolWithTag(v6, 0);
        OutputBufferLength += 9216;
        OutputBuffer = ExAllocatePoolWithTag(1ui64, OutputBufferLength, 1263556947i64);
        v6 = (_DRIVE_LAYOUT_INFORMATION_EX *)OutputBuffer;
        if( !OutputBuffer )
        {
          v3 = -1073741670;
          goto LABEL_6;
        }
      }
      if( v7 < 0 )
        goto LABEL_13;
      *DriveLayout = v6;
LABEL_6:
      if( v3 >= 0 )
        goto LABEL_7;
LABEL_13:
      if( v6 )
        ExFreePoolWithTag(v6, 0);
    }
    else
    {
      v3 = -1073741670;
    }
  }
LABEL_7:
  if( FileHandle )
    ZwClose((_HANDLE)FileHandle);
  return v3;
}

Referenced by:

SiFindSystemPartition
SiGetBiosSystemPartition
SiGetEfiSystemDevice