BcdGetSystemStorePath

INT64 __fastcall BcdGetSystemStorePath(WCHAR **a1){
  WCHAR *v2; 
  int v3; 
  const WCHAR *v4; 
  int SystemPartition; 
  wchar_t *v6; 
  int v7; 
  __int64 v8; 
  __int64 v9; 
  __int64 v10; 
  WCHAR *PoolWithTag; 
  wchar_t *Src; 
  v2 = 0i64;
  Src = 0i64;
  BiGetFirmwareType(a1);
  if( v3 == 1 )
  {
    v4 = L"\\Boot\\BCD";
  }
  else
  {
    if( (unsigned int)(v3 - 2) > 1 )
    {
      v7 = -1073741637;
      BiLogMessage();
      return(unsigned int)v7;
    }
    v4 = L"\\EFI\\Microsoft\\Boot\\BCD";
  }
  BiLogMessage();
  SystemPartition = BiGetSystemPartition(&Src);
  v6 = Src;
  v7 = SystemPartition;
  if( SystemPartition < 0 )
  {
    BiLogMessage();
  }
  else
  {
    BiLogMessage();
    v8 = -1i64;
    v9 = -1i64;
    do
      ++v9;
    while( v6[v9] );
    do
      ++v8;
    while( v4[v8] );
    v10 = (unsigned int)(v9 + v8 + 1);
    PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2 * v10, 0x4B444342ui64);
    v2 = PoolWithTag;
    if( PoolWithTag )
    {
      wcscpy_s(PoolWithTag, (unsigned int)v10, v6);
      wcscat_s(v2, (unsigned int)v10, v4);
      *a1 = v2;
    }
    else
    {
      v7 = -1073741801;
    }
  }
  if( v6 )
    ExFreePoolWithTag(v6, 0x4B444342u);
  if( v7 < 0 && v2 )
    ExFreePoolWithTag(v2, 0x4B444342u);
  return(unsigned int)v7;
}

Referenced by:

BiLoadSystemStore