peass-ng/PEASS-ng · error · PlatformNotSupportedException
The operation is not supported on this version of Windows.
Error message
The operation is not supported on this version of Windows.
What it means
EnumerateFileIdBothDirectoryInfoCore throws PlatformNotSupportedException with the ERROR_OLD_WIN_VERSION message ('The operation is not supported on this version of Windows.') when NativeMethods.IsAtLeastWindowsVista is false. The underlying FileIdBothDirectoryInformation enumeration via NtQueryDirectoryFile requires NTFS and Vista+ kernel support, so AlphaFS explicitly refuses to run on older systems (XP/Server 2003).
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.EnumerateFileIdBothDirectoryInfoCore.cs:57
/// <remarks>
/// <para>Either use <paramref name="path"/> or <paramref name="safeFileHandle"/>, not both.</para>
/// <para>
/// The number of files that are returned for each call to GetFileInformationByHandleEx depends on the size of the buffer that is passed to the function.
/// Any subsequent calls to GetFileInformationByHandleEx on the same handle will resume the enumeration operation after the last file is returned.
/// </para>
/// </remarks>
/// <exception cref="PlatformNotSupportedException">The operating system is older than Windows Vista.</exception>
/// <param name="transaction">The transaction.</param>
/// <param name="safeFileHandle">An open handle to the directory from which to retrieve information.</param>
/// <param name="path">A path to the directory.</param>
/// <param name="shareMode">The <see cref="FileShare"/> mode with which to open a handle to the directory.</param>
/// <param name="continueOnException"><c>true</c> suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or non-accessible reparse points.</param>
/// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
[SecurityCritical]
internal static IEnumerable<FileIdBothDirectoryInfo> EnumerateFileIdBothDirectoryInfoCore(KernelTransaction transaction, SafeFileHandle safeFileHandle, string path, FileShare shareMode, bool continueOnException, PathFormat pathFormat)
{
if (!NativeMethods.IsAtLeastWindowsVista)
throw new PlatformNotSupportedException(new Win32Exception((int) Win32Errors.ERROR_OLD_WIN_VERSION).Message);
var pathLp = path;
var callerHandle = null != safeFileHandle;
if (!callerHandle)
{
if (Utils.IsNullOrWhiteSpace(path))
throw new ArgumentNullException("path");
pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
safeFileHandle = File.CreateFileCore(transaction, true, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, shareMode, true, false, PathFormat.LongFullPath);
}
try
{View on GitHub (pinned to 53fb989abc)
Solutions
- Run on Windows Vista / Server 2008 or later where the API is supported.
- Add an OS check (Environment.OSVersion or Environment.IsWindowsVistaOrLater) and fall back to Directory.EnumerateFileSystemEntries for older systems.
- Catch PlatformNotSupportedException and switch to an alternative enumeration that does not need file IDs.
- If using file IDs for tracking, redesign to use paths or the FindFirstFile/FindNextFile stream on legacy systems.
Example fix
// before
var entries = Directory.EnumerateFileIdBothDirectoryInfo(dir); // throws pre-Vista
// after
if (!NativeMethods.IsAtLeastWindowsVista)
entries = Directory.EnumerateFileSystemEntries(dir).Select(p => new FileIdBothDirectoryInfo(p));
else
entries = Directory.EnumerateFileIdBothDirectoryInfo(dir); Defensive patterns
Strategy: fallback
Validate before calling
if (!NativeMethods.IsAtLeastWindowsVista)
throw new PlatformNotSupportedException("FileIdBothDirectoryInfo requires Windows Vista or later"); Try / catch
try { entries = Directory.EnumerateFileIdBothDirectoryInfo(dir); }
catch (PlatformNotSupportedException) { entries = FallbackEnumeration(dir); } Prevention
- Gate advanced NTFS APIs behind OS version checks at startup
- Provide a path-based enumeration fallback for legacy/limited environments
- Document minimum OS requirements for features using file IDs
- Test on the oldest supported OS in CI to catch version gates early
When it happens
Trigger: Calling Directory.EnumerateFileIdBothDirectoryInfo (or the Transacted variant) on Windows XP / Server 2003 or any environment where the OS version check fails; running under a compatibility shim that reports an old version; rare cases where the check misfires in non-Windows or mocked environments.
Common situations: Legacy deployments still on XP/2003; CI containers or Wine environments misreporting version; code moved from desktop .NET Framework usage into an environment where version detection fails.
Related errors
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/1c808a4abc75d784.
Report an issue: GitHub.