SiGetBootDeviceName

INT64 __fastcall SiGetBootDeviceName(INT64 a1, WCHAR *a2, INT64 a3, PARTITION_STYLE *a4, CHAR a5, WCHAR **a6){
  WCHAR *v6; 
  WCHAR *v7; 
  PVOID v8; 
  char v9; 
  int BootDeviceNameFromRegistry; 
  wchar_t *v11; 
  int v12; 
  __int64 v13; 
  __int64 v14; 
  UINT64 v15; 
  WCHAR *PoolWithTag; 
  WCHAR *v18; 
  UINT64 v19; 
  UINT8 *v20; 
  int v21; 
  int v22; 
  int v23; 
  int v24; 
  PVOID P; 
  wchar_t *Src; 
  int v27; 
  v27 = a1;
  v22 = 0;
  v21 = 0;
  v6 = 0i64;
  v23 = 0;
  v7 = 0i64;
  v24 = 0;
  v8 = 0i64;
  P = 0i64;
  v9 = a3;
  Src = 0i64;
  BootDeviceNameFromRegistry = SiGetBootDeviceNameFromRegistry(a2, (INT64)&Src, a3, (UINT64 *)a4);
  v11 = Src;
  v12 = BootDeviceNameFromRegistry;
  if( BootDeviceNameFromRegistry < 0 )
    goto LABEL_17;
  v13 = -1i64;
  v14 = -1i64;
  do
    ++v14;
  while( Src[v14] );
  if( snwscanf_s(Src, v14 + 1, L"multi(%d)disk(%d)rdisk(%d)partition(%d)", &v21, &v22, &v24, &v23) != 4 )
  {
    v12 = -1073741823;
    goto LABEL_17;
  }
  if( !v21 && !v22 )
  {
    v15 = v14 + 11;
    PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2 * v15, 0x4B505953ui64);
    v7 = PoolWithTag;
    if( !PoolWithTag )
    {
      v12 = -1073741670;
      goto LABEL_17;
    }
    swprintf_s(PoolWithTag, v15, (WCHAR *)L"%s%s");
    v12 = SiTranslateSymbolicLink(v7, (WCHAR **)&P);
    if( v12 >= 0 )
    {
      v8 = P;
      if( v9 )
      {
        v12 = SiValidateSystemPartition((PWCHAR)P);
        if( v12 < 0 )
        {
LABEL_11:
          if( v8 )
            ExFreePoolWithTag(v8, 0);
          goto LABEL_13;
        }
      }
      if( v27 )
        goto LABEL_21;
      v18 = wcsstr(v7, L"partition");
      if( v18 )
        *v18 = 0;
      do
        ++v13;
      while( v7[v13] );
      v19 = 2 * v13 + 2;
      v20 = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v19, 0x4B505953ui64);
      v6 = (WCHAR *)v20;
      if( !v20 )
      {
        v12 = -1073741670;
        goto LABEL_11;
      }
      memmove(v20, (UINT8 *)v7, v19);
      ExFreePoolWithTag(v8, 0);
      P = 0i64;
      v12 = SiTranslateSymbolicLink(v6, (WCHAR **)&P);
      if( v12 >= 0 )
      {
        v8 = P;
LABEL_21:
        *a6 = (WCHAR *)v8;
        goto LABEL_22;
      }
    }
    v8 = P;
    goto LABEL_11;
  }
  v12 = -1073741823;
LABEL_22:
  if( v12 < 0 )
    goto LABEL_11;
LABEL_13:
  if( v7 )
    ExFreePoolWithTag(v7, 0);
  if( v6 )
    ExFreePoolWithTag(v6, 0);
LABEL_17:
  if( v11 )
    ExFreePoolWithTag(v11, 0);
  return(unsigned int)v12;
}

Referenced by:

SiGetFirmwareSystemPartition
SiGetSystemDisk
SiGetSystemPartition