Skip to content

Crash when creating an "Unused Space" erase task with the Workstation (LanmanWorkstation) service disabled #4

Description

@Digital-Toxin

Summary

Eraser crashes with an unhandled Win32Exception when creating an Unused Space erase task if the Workstation (LanmanWorkstation) service is disabled.

The application appears to enumerate network drives during configuration and does not gracefully handle the case where network drive enumeration fails.

Environment
Eraser: 6.2.0.2996
.NET Framework: 4.8
Windows: Modified installation with the Workstation (LanmanWorkstation) service disabled

Steps to Reproduce

  1. Disable the*Workstation (LanmanWorkstation) service.
  2. Launch Eraser.
  3. Create a new task.
  4. Select Unused Space as the target.

Expected Behavior
The application should continue to function normally.

If network drives cannot be enumerated, Eraser should either:
Ignore network drives and continue with local volumes only, or present an empty network drive list.

The inability to enumerate network drives should not prevent creating an unused-space erase task.

Actual Behavior

Eraser crashes with an unhandled exception:

System.ComponentModel.Win32Exception (0x80004005): There are no more files

at Eraser.Util.VolumeInfo.GetNetworkDrivesInternal()
at Eraser.Util.VolumeInfo.get_NetworkDrives()
at Eraser.DefaultPlugins.UnusedSpaceErasureTargetConfigurer..ctor()
...

Root Cause
The crash occurs while constructing UnusedSpaceErasureTargetConfigurer, specifically during a call to:

VolumeInfo.NetworkDrives

When the Workstation service is disabled, network drive enumeration appears to return a condition that is converted into a Win32Exception, which is allowed to propagate to the UI.

This is reproducible on my system and disappears immediately if the Workstation service is started.

Suggested Fix
Treat failure to enumerate network drives as a non-fatal condition.

For example:

IEnumerable<VolumeInfo> networkDrives;

try
{
    networkDrives = VolumeInfo.NetworkDrives;
}
catch (Win32Exception)
{
    networkDrives = Enumerable.Empty<VolumeInfo>();
}

or alternatively, handle the expected Win32 error(s) inside GetNetworkDrivesInternal() and return an empty collection instead of throwing.

Since network drives are optional for an unused-space erase task, failing to enumerate them should not terminate the UI.

Additional Notes
This issue is triggered by a non-default Windows configuration (Workstation service disabled), but applications should generally tolerate the absence of network provider functionality and continue operating with local drives only.

I can consistently reproduce the crash when LanmanWorkstation is disabled and can consistently avoid it by starting the service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions