ExpVerifyFilePath

NTSTATUS __stdcall ExpVerifyFilePath(_FILE_PATH *FilePath, VOID *Max){
  unsigned __int8 *v2; 
  __int64 Length; 
  char *v4; 
  unsigned int Type; 
  _FILE_PATH *i; 
  unsigned __int64 v7; 
  char v8; 
  char *v9; 
  __int64 v10; 
  unsigned int v12; 
  VOID *v13; 
  __int64 v14; 
  int v15; 
  int v16; 

  if( FilePath > Max )
    return -1073741811;
  v2 = FilePath->FilePath;
  if( FilePath->FilePath > Max )
    return -1073741811;
  Length = FilePath->Length;
  if( (unsigned int)Length < 0xC )
    return -1073741811;
  v4 = (char *)FilePath + Length;
  if( (_FILE_PATH *)((char *)FilePath + Length) < FilePath )
    return -1073741811;
  if( v4 > Max )
    return -1073741811;
  if( FilePath->Version != 1 )
    return -1073741811;
  Type = FilePath->Type;
  if( Type - 1 > 4 )
    return -1073741811;
  if( v4 < Max )
    Max = (char *)FilePath + Length;
  if( !Type )
    return -1073741811;
  if( Type <= 2 )
  {
    v15 = ExpSafeWcslen((WCHAR *)FilePath->FilePath, Max);
    v16 = -1;
  }
  else
  {
    if( Type != 3 )
    {
      if( Type == 4 )
      {
        for( i = FilePath + 1; v2 + 4 <= Max; i = (_FILE_PATH *)(v2 + 4) )
        {
          if( *((unsigned __int16 *)v2 + 1) < 4u )
            break;
          v7 = (unsigned __int64)&v2[*((unsigned __int16 *)v2 + 1)];
          if( v7 > (unsigned __int64)Max )
            break;
          v8 = *v2 & 0x7F;
          if( v8 == 127 )
            return 0;
          if( v8 == 4 && v2[1] == 4 )
          {
            v9 = (char *)i;
            if( (unsigned __int64)i >= v7 )
              goto LABEL_25;
            do
            {
              if( !*(_WORD *)v9 )
                break;
              v9 += 2;
            }
            while( (unsigned __int64)v9 < v7 );
            if( (unsigned __int64)v9 >= v7 )
LABEL_25:
              LODWORD(v10) = -1;
            else
              v10 = (v9 - (char *)i) >> 1;
            if( (_DWORD)v10 == -1 )
              break;
          }
          v2 += (v2[3] << 8) | (unsigned __int64)v2[2];
        }
      }
      return -1073741811;
    }
    v12 = ExpSafeWcslen((WCHAR *)FilePath->FilePath, Max);
    if( v12 == -1 )
      return -1073741811;
    v15 = ExpSafeWcslen((WCHAR *)(v14 + 2 * (v12 + 1i64)), v13);
  }
  if( v15 == v16 )
    return -1073741811;
  return 0;
}

Referenced by:

ExpSetBootEntry
ExpSetDriverEntry
ExpVerifyWindowsOsOptions
NtEnumerateBootEntries
NtTranslateFilePath