{"record":{"id":"fe195f001e9e5f77","repo":"peass-ng/PEASS-ng","slug":"volumepathname","errorCode":null,"errorMessage":"volumePathName","messagePattern":"volumePathName","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"warning","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetUniqueVolumeNameForPath.cs","lineNumber":46,"sourceCode":"   public static partial class Volume\n   {\n      /// <summary>[AlphaFS] Get the unique volume name for the given path.</summary>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <param name=\"volumePathName\">\n      ///   A path string. Both absolute and relative file and directory names, for example \"..\", is acceptable in this path. If you specify a\n      ///   relative file or directory name without a volume qualifier, GetUniqueVolumeNameForPath returns the Drive letter of the current\n      ///   volume.\n      /// </param>\n      /// <returns>\n      ///   <para>Returns the unique volume name in the form: \"\\\\?\\Volume{GUID}\\\",</para>\n      ///   <para>or <c>null</c> on error or if unavailable.</para>\n      /// </returns>\n      [SuppressMessage(\"Microsoft.Design\", \"CA1031:DoNotCatchGeneralExceptionTypes\")]\n      [SecurityCritical]\n      public static string GetUniqueVolumeNameForPath(string volumePathName)\n      {\n         if (Utils.IsNullOrWhiteSpace(volumePathName))\n            throw new ArgumentNullException(\"volumePathName\");\n\n         try\n         {\n            return GetVolumeGuid(GetVolumePathName(volumePathName));\n         }\n         catch\n         {\n            return null;\n         }\n      }\n   }\n}\n","sourceCodeStart":28,"sourceCodeEnd":59,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetUniqueVolumeNameForPath.cs#L28-L59","documentation":"GetUniqueVolumeNameForPath(string volumePathName) throws ArgumentNullException with paramName \"volumePathName\" when the argument is null, empty, or whitespace. The method resolves a normal path to its unique \\\\?\\Volume{GUID}\\ form and validates input up front.","triggerScenarios":"Calling Volume.GetUniqueVolumeNameForPath(null), \"\", or \"   \" — e.g. when the source path came from a failed lookup or empty config value.","commonSituations":"Processing file paths from user input or environment where the value may be unset; chained lookups (GetVolumePathName → GetVolumeGuid) where an earlier failure yielded an empty string.","solutions":["Ensure a real filesystem path (e.g. \"C:\\Windows\") is passed before calling","Add a null/whitespace check at the call site and handle the empty case explicitly","Catch ArgumentNullException when resolving paths from untrusted sources"],"exampleFix":"// before\nvar unique = Volume.GetUniqueVolumeNameForPath(path);\n// after\nvar unique = string.IsNullOrWhiteSpace(path) ? null : Volume.GetUniqueVolumeNameForPath(path);","handlingStrategy":"validation","validationCode":"var unique = string.IsNullOrWhiteSpace(volumePathName) ? null : Volume.GetUniqueVolumeNameForPath(volumePathName);","typeGuard":"static bool HasPathValue(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { unique = Volume.GetUniqueVolumeNameForPath(path); }\ncatch (ArgumentNullException) { Log.Warn(\"Cannot resolve unique volume name: path is null/empty\"); }","preventionTips":["Guard paths coming from user input/config before volume resolution","Handle empty list entries when bulk-resolving paths","Prefer explicit null handling over catching ArgumentNullException in loops"],"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"}