SiFindSystemPartition

INT64 __fastcall SiFindSystemPartition(INT64 a1){
  int DriveLayoutInformation; 
  void *v3; 
  unsigned int v4; 
  unsigned int v5; 
  __int64 v6; 
  __int64 v7; 
  unsigned int v9; 
  _BYTE *v10; 
  void *P[2]; 
  wchar_t Dst[32]; 
  P[0] = 0i64;
  swprintf_s(Dst, 0x20ui64, (WCHAR *)L"\\??\\PhysicalDrive%d");
  DriveLayoutInformation = SiGetDriveLayoutInformation(Dst, (DRIVE_LAYOUT_INFORMATION_EX **)P);
  v3 = P[0];
  v4 = DriveLayoutInformation;
  if( DriveLayoutInformation >= 0 )
  {
    if( *(_DWORD *)P[0] )
    {
      if( *(_DWORD *)P[0] == 1 )
      {
        v5 = *((_DWORD *)P[0] + 1);
        v6 = 0i64;
        if( v5 )
        {
          while( 1 )
          {
            v7 = *((_QWORD *)P[0] + 18 * v6 + 10) - *(_QWORD *)&PARTITION_SYSTEM_GUID.Data1;
            if( !v7 )
              v7 = *((_QWORD *)P[0] + 18 * v6 + 11) - *(_QWORD *)PARTITION_SYSTEM_GUID.Data4;
            if( !v7 )
              break;
            v6 = (unsigned int)(v6 + 1);
            if( (unsigned int)v6 >= v5 )
              goto LABEL_9;
          }
LABEL_18:
          *(_DWORD *)(a1 + 8) = *((_DWORD *)P[0] + 36 * v6 + 18);
          goto LABEL_10;
        }
      }
    }
    else
    {
      v9 = *((_DWORD *)P[0] + 1);
      v6 = 0i64;
      if( v9 )
      {
        v10 = (char *)P[0] + 81;
        while( !*v10 )
        {
          v6 = (unsigned int)(v6 + 1);
          v10 += 144;
          if( (unsigned int)v6 >= v9 )
            goto LABEL_9;
        }
        goto LABEL_18;
      }
    }
LABEL_9:
    v4 = -1073741275;
  }
LABEL_10:
  if( v3 )
    ExFreePoolWithTag(v3, 0);
  return v4;
}

Referenced by:

SyspartGetPhysicalPartitions