{"record":{"id":"3eb11345e035dbd3","repo":"peass-ng/PEASS-ng","slug":"resources-invaliddriveletterargument-3eb113","errorCode":null,"errorMessage":"Resources.InvalidDriveLetterArgument","messagePattern":"Resources\\.InvalidDriveLetterArgument","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/VolumeInfo.cs","lineNumber":67,"sourceCode":"      {\n         if (Utils.IsNullOrWhiteSpace(volumeName))\n            throw new ArgumentNullException(\"volumeName\");\n\n\n         if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.Ordinal))\n            volumeName = Path.IsUncPathCore(volumeName, false, false) ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) : Path.LongPathPrefix + volumeName;\n\n         else\n         {\n            volumeName = volumeName.Length == 1 ? volumeName + Path.VolumeSeparatorChar : Path.GetPathRoot(volumeName, false);\n\n            if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))\n               volumeName = Path.GetPathRoot(volumeName, false);\n         }\n\n\n         if (Utils.IsNullOrWhiteSpace(volumeName))\n            throw new ArgumentException(Resources.InvalidDriveLetterArgument, \"volumeName\");\n\n\n         Name = Path.AddTrailingDirectorySeparator(volumeName, false);\n\n         _volumeHandle = null;\n      }\n\n\n      /// <summary>Initializes a VolumeInfo instance.</summary>\n      /// <param name=\"driveName\">A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \"\\\\server\\share\".</param>\n      /// <param name=\"refresh\">Refreshes the state of the object.</param>\n      /// <param name=\"continueOnException\"><c>true</c> suppress any Exception that might be thrown as a result from a failure, such as unavailable resources.</param>\n      [SecurityCritical]\n      public VolumeInfo(string driveName, bool refresh, bool continueOnException) : this(driveName)\n      {\n         _continueOnAccessError = continueOnException;\n\n         if (refresh)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/VolumeInfo.cs#L49-L85","documentation":"After normalizing volumeName (adding LongPathPrefix, converting UNC, or extracting the path root), the VolumeInfo constructor re-checks the result. If it is still null or whitespace, it throws ArgumentException(Resources.InvalidDriveLetterArgument, \"volumeName\"), meaning the input did not resolve to a usable drive letter or volume root.","triggerScenarios":"Passing a string that survives null checks but is not a real drive path: e.g. \"C\" without a separator in a code path where GetPathRoot returned empty, a UNC fragment like \"\\\\\\\\server\" without a share, or a prefix-only string like \"\\\\\\\\?\\\" or \"\\\\\\\\.\\\".","commonSituations":"Parsing paths from logs or user input where only a drive letter (no backslash) was captured; network shares where the share component was stripped; virtual device paths (\\\\\\\\.\\PhysicalDrive0) fed to a constructor expecting a file-system volume root.","solutions":["Pass a full root path with trailing separator: \"C:\\\" instead of \"C\".","For UNC, include both server and share: \"\\\\\\\\server\\\\share\\\\\".","Validate beforehand that Path.GetPathRoot(value) returns a non-empty result, or catch ArgumentException and surface a message asking for a valid drive letter."],"exampleFix":"// before\nvar info = new VolumeInfo(\"C\"); // no root separator\n// after\nstring root = Path.GetPathRoot(\"C:\\\\some\\\\path\"); // \"C:\\\"\nif (!string.IsNullOrWhiteSpace(root))\n    var info = new VolumeInfo(root);","handlingStrategy":"validation","validationCode":"string root = Path.GetPathRoot(volumeName);\nif (!string.IsNullOrWhiteSpace(root) && root != volumeName.TrimEnd('\\\\') + \"\\\\\")\n{\n    var info = new VolumeInfo(root);\n}","typeGuard":"static bool ResolvesToDriveRoot(string s) =>\n    !string.IsNullOrWhiteSpace(s) && !string.IsNullOrWhiteSpace(Path.GetPathRoot(s));","tryCatchPattern":"try { var info = new VolumeInfo(volumeName); }\ncatch (ArgumentException ex) when (ex.ParamName == \"volumeName\")\n{\n    // input did not resolve to a drive root; prompt for a valid drive letter\n}","preventionTips":["Always pass drive roots with trailing separator: \"C:\\\" not \"C\"","For UNC include server and share: \"\\\\\\\\server\\\\share\\\\\"","Do not feed device paths (\\\\\\\\.\\...) into VolumeInfo; it expects file-system volumes","Normalize input with Path.GetPathRoot before constructing"],"tags":["csharp","alphafs","argument-validation","drive-letter","filesystem"],"backgroundTag":"invalid-drive-letter","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}