fremag / MemoScope.Net

Dump and analyze .Net applications memory ( a gui for WinDbg and ClrMd )
The Unlicense
693 stars 75 forks source link

Unhandled exception when trying to access system directories #193

Closed IanKemp closed 7 years ago

IanKemp commented 7 years ago

Tested with latest release (0.99) and a build I made on my local machine using the latest master source, same issue on both. I simply pointed the app to my D:\ drive.

Fix is to not attempt to enumerate directories that have the System flag set.

Additionally, because the last directory you specified is stored in the application's XML configuration file, every subsequent run of the app will cause it to attempt to read that directory, which causes the aforementioned exception, which means the app can't be launched again until the XML config file is deleted or manually modified to point to a directory that doesn't cause this issue.

System.UnauthorizedAccessException: Access to the path 'D:\System Volume Information' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)
   at MemoScope.Modules.Explorer.DirectoryData.get_CanExpand() in C:\projects\memoscope-net\MemoScope\Modules\Explorer\DirectoryData.cs:line 28
   at WinFwk.UITools.DefaultTreeListView.<>c__1`1.<InitData>b__1_0(Object o) in C:\projects\memoscope-net\WinFwk\UITools\DefaultTreeListView.cs:line 18
   at BrightIdeasSoftware.TreeListView.TreeRenderer.HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, Int32 x, Int32 y)
   at BrightIdeasSoftware.BaseRenderer.HitTest(OlvListViewHitTestInfo hti, Int32 x, Int32 y)
   at BrightIdeasSoftware.ObjectListView.OlvHitTest(Int32 x, Int32 y)
   at BrightIdeasSoftware.ObjectListView.BuildCellEvent(CellEventArgs args, Point location)
   at BrightIdeasSoftware.ObjectListView.HandleMouseMove(Point pt)
   at BrightIdeasSoftware.ObjectListView.OnMouseMove(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseMove(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ListView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
fremag commented 7 years ago

Thanks for your help. I will add some try/catch to avoid this.

fremag commented 7 years ago

43

I've added some try/catch and exceptions are displayed in tooltip (in screenshot, the message is in french but means: "Access to path xxx is denied", on your computer it will be displayed in your language of course) The node background color is set to red to identify errors.