{"record":{"id":"5110d73ea7be03c8","repo":"peass-ng/PEASS-ng","slug":"devicename-5110d7","errorCode":null,"errorMessage":"deviceName","messagePattern":"deviceName","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"warning","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.QueryDosDevice.cs","lineNumber":52,"sourceCode":"      /// <summary>[AlphaFS] Retrieves a sorted list of all existing MS-DOS device names.</summary>\n      /// <returns>An <see cref=\"IEnumerable{String}\"/> sorted list of all existing MS-DOS device names.</returns>\n      [SecurityCritical]\n      public static IEnumerable<string> QueryAllDosDevices()\n      {\n         return QueryDosDeviceCore(null, true);\n      }\n\n\n      /// <summary>[AlphaFS] Retrieves the current mapping for a particular MS-DOS device name.</summary>\n      /// <returns>The current mapping for a particular MS-DOS device name.</returns>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <exception cref=\"FileNotFoundException\"/>\n      /// <param name=\"deviceName\">An MS-DOS device name string specifying the target of the query, such as: \"C:\", \"D:\" or \"\\\\?\\Volume{GUID}\".</param>\n      [SecurityCritical]\n      public static string QueryDosDevice(string deviceName)\n      {\n         if (Utils.IsNullOrWhiteSpace(deviceName))\n            throw new ArgumentNullException(\"deviceName\");\n\n\n         var devName = QueryDosDeviceCore(deviceName, false).ToArray()[0];\n\n         return !Utils.IsNullOrWhiteSpace(devName) ? devName : null;\n      }\n\n\n\n\n      /// <summary>[AlphaFS] Retrieves the current mapping for a particular MS-DOS device name. The function can also obtain a list of all existing MS-DOS device names.</summary>\n      /// <returns>An <see cref=\"IEnumerable{String}\"/> sorted list of all existing MS-DOS device names or the .</returns>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <exception cref=\"FileNotFoundException\"/>\n      /// <param name=\"deviceName\">An MS-DOS device name string specifying the target of the query, such as: \"C:\", \"D:\" or \"\\\\?\\Volume{GUID}\".</param>\n      /// <param name=\"sort\"><c>true</c> to sort the list with MS-DOS device names.</param>\n      [SecurityCritical]\n      internal static IEnumerable<string> QueryDosDeviceCore(string deviceName, bool sort)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.QueryDosDevice.cs#L34-L70","documentation":"QueryDosDevice(string deviceName) throws ArgumentNullException with paramName \"deviceName\" when the argument is null, empty, or whitespace. It wraps the Win32 QueryDosDevice API to translate an MS-DOS device name (e.g. \"C:\") into its target device string, and validates input before the native call.","triggerScenarios":"Calling Volume.QueryDosDevice(null)/\"\" when looking up a drive mapping; GetVolumeDeviceName passing through an empty device name from a parsed volume entry.","commonSituations":"Resolving drive letters from a list where some entries are blank; a mount-point parse produced an empty device name; drive-letter variable not initialized.","solutions":["Pass a valid MS-DOS device name such as \"C:\" or \"\\\\?\\Volume{GUID}\\\"","Guard with string.IsNullOrWhiteSpace before calling","Catch ArgumentNullException and treat blank device names as unresolved"],"exampleFix":"// before\nvar target = Volume.QueryDosDevice(devName);\n// after\nvar target = string.IsNullOrWhiteSpace(devName) ? null : Volume.QueryDosDevice(devName);","handlingStrategy":"validation","validationCode":"var target = string.IsNullOrWhiteSpace(deviceName) ? null : Volume.QueryDosDevice(deviceName);","typeGuard":"static bool IsValidDosDeviceName(string s) => !string.IsNullOrWhiteSpace(s) && (Regex.IsMatch(s, @\"^[A-Za-z]:$\") || s.StartsWith(@\"\\\\?\\Volume{\"));","tryCatchPattern":"try { target = Volume.QueryDosDevice(devName); }\ncatch (ArgumentNullException) { Log.Warn($\"Device name blank: {devName}\"); }","preventionTips":["Validate drive-letter strings match \"X:\" before querying DOS devices","Skip blank entries when bulk-resolving device names","Remember the method may return null on valid-but-unresolved names — null-check the result too"],"tags":["argument-null","alphafs","dos-device","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"}