SiGetFirmwareSystemPartition

__int64 __fastcall SiGetFirmwareSystemPartition(WCHAR *a1, WCHAR **a2, __int64 a3, UINT64 *a4){
  int v5; 
  INT64 v6; 
  UINT8 IsWinPEBoot; 
  INT64 v8; 
  int BootDeviceName; 
  int BiosSystemPartition; 
  PARTITION_STYLE v12; 
  WCHAR *ResultName; 
  ResultName = 0i64;
  v5 = (int)a1;
  v12 = PARTITION_STYLE_GPT;
  IsWinPEBoot = SiIsWinPEBoot();
  if( IsWinPEBoot
    || (LOBYTE(v8) = 1,
        BootDeviceName = SiGetBootDeviceName(1i64, (WCHAR *)L"FirmwareBootDevice", v8, 0i64, 0, a2),
        BootDeviceName < 0) )
  {
    if( v5 == 1 )
    {
      BiosSystemPartition = SiGetBiosSystemPartition(a2);
    }
    else
    {
      if( v5 != 2 )
      {
        BootDeviceName = -1073741637;
LABEL_7:
        if( BootDeviceName < 0 )
        {
          if( BootDeviceName != -1073740719 )
            return(unsigned int)BootDeviceName;
          if( !IsWinPEBoot )
            return(unsigned int)BootDeviceName;
          if( v5 != 2 )
            return(unsigned int)BootDeviceName;
          LOBYTE(v8) = 1;
          if( (int)SiGetBootDeviceName(1i64, (WCHAR *)L"FirmwareBootDevice", v8, &v12, 1, a2) < 0 )
            return(unsigned int)BootDeviceName;
        }
        else
        {
          BootDeviceName = SiTranslateSymbolicLink(*a2, &ResultName);
          if( BootDeviceName >= 0 )
          {
            ExFreePoolWithTag(*a2, 0);
            *a2 = ResultName;
            return(unsigned int)BootDeviceName;
          }
        }
        return 0;
      }
      BiosSystemPartition = SiGetEfiSystemDevice(1i64, v6, (CHAR **)a2);
    }
    BootDeviceName = BiosSystemPartition;
    goto LABEL_7;
  }
  return(unsigned int)BootDeviceName;
}

Referenced by:

SiGetSystemPartition