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

EnumerateHardLinksCore throws PlatformNotSupportedException when the OS is below Windows Vista (ERROR_OLD_WIN_VERSION). Hard link enumeration relies on FindFirstFileNameW APIs introduced in Vista, so AlphaFS refuses to run on older systems. Like error 70, this is a capability gate at method entry.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File Core Methods/File.EnumerateHardLinksCore.cs:41

using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;

namespace Alphaleonis.Win32.Filesystem
{
   public static partial class File
   {
      /// <summary>[AlphaFS] Creates an enumeration of all the hard links to the specified <paramref name="path"/>.</summary>
      /// <returns>An enumerable collection of <see cref="string"/> of all the hard links to the specified <paramref name="path"/></returns>
      /// <exception cref="PlatformNotSupportedException">The operating system is older than Windows Vista.</exception>
      /// <param name="transaction">The transaction.</param>
      /// <param name="path">The name of the file.</param>
      /// <param name="pathFormat">Indicates the format of the path parameter(s).</param>
      internal static IEnumerable<string> EnumerateHardLinksCore(KernelTransaction transaction, string path, PathFormat pathFormat)
      {
         if (!NativeMethods.IsAtLeastWindowsVista)
            throw new PlatformNotSupportedException(new Win32Exception((int) Win32Errors.ERROR_OLD_WIN_VERSION).Message);

         var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);

         // Default buffer length, will be extended if needed, although this should not happen.
         uint length = NativeMethods.MaxPathUnicode;
         var builder = new StringBuilder((int) length);


      getFindFirstFileName:

         using (var safeHandle = null == transaction

            // FindFirstFileNameW() / FindFirstFileNameTransactedW() / FindNextFileNameW()
            // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
            // 2017-05-30: FindFirstFileNameW() MSDN confirms LongPath usage: Starting with Windows 10, version 1607

            ? NativeMethods.FindFirstFileNameW(pathLp, 0, out length, builder)

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Run on Windows Vista or later
  2. Check NativeMethods.IsAtLeastWindowsVista before enumerating and skip gracefully on legacy OS
  3. Catch PlatformNotSupportedException and fall back to fsutil hardlink list or skip link analysis

Example fix

// before
var links = File.EnumerateHardLinks(path);
// after
if (NativeMethods.IsAtLeastWindowsVista)
    var links = File.EnumerateHardLinks(path);
else
    LogSkip("hard link enumeration unsupported on this OS");
Defensive patterns

Strategy: validation

Validate before calling

if (!NativeMethods.IsAtLeastWindowsVista) return; // hard link enumeration unsupported

Type guard

bool SupportsHardLinkEnumeration => Environment.OSVersion.Version.Major >= 6;

Try / catch

try { foreach (var l in File.EnumerateHardLinks(path)) { ... } }
catch (PlatformNotSupportedException ex) { Log(ex.Message); SkipLinkAnalysis(); }

Prevention

When it happens

Trigger: Calling File.EnumerateHardLinks / EnumerateHardlinks / their Transacted variants on Windows XP/Server 2003 or an environment reporting an old OS version.

Common situations: Forensic/inventory tooling (winPEAS) run on legacy Windows images; deprecated XP-based POS or kiosk machines; shimmed OS version strings under compatibility mode.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/55bab4bf57706be0. Report an issue: GitHub.