{"record":{"id":"e81143b0d51f8def","repo":"peass-ng/PEASS-ng","slug":"value-cannot-be-null-parameter-name-path-e81143","errorCode":null,"errorMessage":"Value cannot be null.\r\nParameter name: path","messagePattern":"Value cannot be null\\.\r\nParameter name: path","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.EnumerateFileIdBothDirectoryInfoCore.cs","lineNumber":66,"sourceCode":"      /// <param name=\"safeFileHandle\">An open handle to the directory from which to retrieve information.</param>\n      /// <param name=\"path\">A path to the directory.</param>\n      /// <param name=\"shareMode\">The <see cref=\"FileShare\"/> mode with which to open a handle to the directory.</param>\n      /// <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>\n      /// <param name=\"pathFormat\">Indicates the format of the path parameter(s).</param>\n      [SecurityCritical]\n      internal static IEnumerable<FileIdBothDirectoryInfo> EnumerateFileIdBothDirectoryInfoCore(KernelTransaction transaction, SafeFileHandle safeFileHandle, string path, FileShare shareMode, bool continueOnException, PathFormat pathFormat)\n      {\n         if (!NativeMethods.IsAtLeastWindowsVista)\n            throw new PlatformNotSupportedException(new Win32Exception((int) Win32Errors.ERROR_OLD_WIN_VERSION).Message);\n\n\n         var pathLp = path;\n\n         var callerHandle = null != safeFileHandle;\n         if (!callerHandle)\n         {\n            if (Utils.IsNullOrWhiteSpace(path))\n               throw new ArgumentNullException(\"path\");\n\n            pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);\n\n            safeFileHandle = File.CreateFileCore(transaction, true, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, shareMode, true, false, PathFormat.LongFullPath);\n         }\n\n\n         try\n         {\n            if (!NativeMethods.IsValidHandle(safeFileHandle, Marshal.GetLastWin32Error(), !continueOnException))\n               yield break;\n\n            var fileNameOffset = (int) Marshal.OffsetOf(typeof(NativeMethods.FILE_ID_BOTH_DIR_INFO), \"FileName\");\n\n            using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize))\n            {\n               while (true)\n               {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.EnumerateFileIdBothDirectoryInfoCore.cs#L48-L84","documentation":"ArgumentNullException thrown by AlphaFS's Directory.EnumerateFileIdBothDirectoryInfoCore when the path argument is null, empty, or whitespace. The core method opens a directory handle via CreateFileCore to enumerate FILE_ID_BOTH_DIR_INFORMATION entries, and a null path cannot be resolved to a full path. AlphaFS validates the input explicitly before touching the filesystem, so this is a caller-side argument error, not an OS error.","triggerScenarios":"Calling Directory.EnumerateFileIdBothDirectoryInfo(null) (or a path that is \"\" or all whitespace) without a pre-opened safeFileHandle; passing an uninitialized variable or the result of a failed path lookup into the enumerate API.","commonSituations":"winPEAS/AlphaFS-driven enumeration where a drive letter or folder path variable was never populated (e.g. a failed config read or empty registry value feeding the path), or refactored code that stopped passing a default path.","solutions":["Check the path argument before calling: if string.IsNullOrWhiteSpace(path) log and skip instead of calling the enumerator.","If a handle-based overload is used, ensure the safeFileHandle passed is actually a valid open handle — with a valid handle the null-path check is bypassed.","Fix the upstream source that produced the empty path (failed lookup, unset config, unmounted drive).","Fall back to a known-good root (e.g. \"C:\\\\\") when the intended path cannot be resolved."],"exampleFix":"// before\nforeach (var info in Directory.EnumerateFileIdBothDirectoryInfo(path)) { ... }\n// after\nif (string.IsNullOrWhiteSpace(path)) { LogSkip(nameof(path)); return; }\nforeach (var info in Directory.EnumerateFileIdBothDirectoryInfo(path)) { ... }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException(\"path must be a non-empty directory path\", nameof(path));","typeGuard":"static bool HasPath(string? path) => !string.IsNullOrWhiteSpace(path);","tryCatchPattern":"try { foreach (var i in Directory.EnumerateFileIdBothDirectoryInfo(path)) Process(i); } catch (ArgumentNullException ex) { Log.Error(\"null path passed to enumerator\", ex); }","preventionTips":["Validate path inputs at API boundaries (string.IsNullOrWhiteSpace) before filesystem calls.","Never pass results of failed lookups directly into enumerators.","Prefer the handle-based overload only when you actually hold a valid SafeFileHandle."],"tags":["csharp","argument-null","alphafs","filesystem"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}