{"record":{"id":"9a3619b8997a443d","repo":"peass-ng/PEASS-ng","slug":"path","errorCode":null,"errorMessage":"path","messagePattern":"path","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"warning","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetVolumePathName.cs","lineNumber":42,"sourceCode":"using System.Security;\nusing System.Text;\n\nnamespace Alphaleonis.Win32.Filesystem\n{\n   public static partial class Volume\n   {\n      /// <summary>[AlphaFS] Retrieves the volume mount point where the specified path is mounted.</summary>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <param name=\"path\">The path to the volume, for example: \"C:\\Windows\".</param>\n      /// <returns>\n      ///   <para>Returns the nearest volume root path for a given directory.</para>\n      ///   <para>The volume path name, for example: \"C:\\Windows\" returns: \"C:\\\".</para>\n      /// </returns>\n      [SecurityCritical]\n      public static string GetVolumePathName(string path)\n      {\n         if (Utils.IsNullOrWhiteSpace(path))\n            throw new ArgumentNullException(\"path\");\n\n\n         using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))\n         {\n            var volumeRootPath = new StringBuilder(NativeMethods.MaxPathUnicode / 32);\n            var pathLp = Path.GetFullPathCore(null, false, path, GetFullPathOptions.AsLongPath | GetFullPathOptions.FullCheck);\n\n\n            // GetVolumePathName()\n            // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.\n\n            var success = NativeMethods.GetVolumePathName(pathLp, volumeRootPath, (uint) volumeRootPath.Capacity);\n\n            var lastError = Marshal.GetLastWin32Error();\n\n            if (success)\n               return Path.GetRegularPathCore(volumeRootPath.ToString(), GetFullPathOptions.None, false);\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetVolumePathName.cs#L24-L60","documentation":"GetVolumePathName(string path) throws ArgumentNullException with paramName \"path\" when the argument is null, empty, or whitespace. This wraps the Win32 GetVolumePathName API and validates the input before calling Path.GetFullPathCore and the native function.","triggerScenarios":"Calling Volume.GetVolumePathName(null)/\"\" — e.g. from volInfo1/volInfo2 helpers with an unset path, or from GetUniqueVolumeNameForPath after passing a blank string (which throws here first).","commonSituations":"Deriving the volume root of a file path that is null because a file-listing entry was empty; environment/config variables holding the path not set.","solutions":["Pass a non-empty absolute or relative path (e.g. \"C:\\Windows\")","Check string.IsNullOrWhiteSpace at the call site before resolving the volume","Catch ArgumentNullException when paths originate from user input or external data"],"exampleFix":"// before\nvar root = Volume.GetVolumePathName(filePath);\n// after\nvar root = string.IsNullOrWhiteSpace(filePath) ? null : Volume.GetVolumePathName(filePath);","handlingStrategy":"validation","validationCode":"var root = string.IsNullOrWhiteSpace(path) ? null : Volume.GetVolumePathName(path);","typeGuard":"static bool HasPathValue(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { root = Volume.GetVolumePathName(path); }\ncatch (ArgumentNullException) { root = null; Log.Warn(\"Path was null/empty; no volume root\"); }","preventionTips":["Resolve file paths to absolute strings before extracting volume roots","Treat blank config path values as fatal config errors early in startup","When chaining GetVolumePathName→GetVolumeGuid, validate each intermediate result"],"tags":["argument-null","alphafs","volume","windows"],"backgroundTag":"null-or-empty-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}