tyranid / oleviewdotnet

A .net OLE/COM viewer and inspector to merge functionality of OleView and Test Container
GNU General Public License v3.0
1.14k stars 185 forks source link

Invalid characters in path exception #10

Closed smourier closed 6 years ago

smourier commented 6 years ago

Hi,

Running as 64-bit I get an error:

 System.ArgumentException
  HResult=0x80070057
  Message=Illegal characters in path.
  Source=mscorlib
  StackTrace:
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.IO.Path.GetFileName(String path)
   at OleViewDotNet.COMCLSIDEntry.LoadFromKey(RegistryKey key) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMCLSIDEntry.cs:line 590
   at OleViewDotNet.COMCLSIDEntry..ctor(COMRegistry registry, Guid clsid, RegistryKey rootKey) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMCLSIDEntry.cs:line 659
   at OleViewDotNet.COMRegistry.LoadCLSIDs(RegistryKey rootKey) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMRegistry.cs:line 848
   at OleViewDotNet.COMRegistry..ctor(COMRegistryMode mode, Sid user, IProgress`1 progress) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMRegistry.cs:line 689
   at OleViewDotNet.COMRegistry.Load(COMRegistryMode mode, Sid user, IProgress`1 progress) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMRegistry.cs:line 304
   at OleViewDotNet.COMUtilities.<>c__DisplayClass104_0.<LoadRegistry>b__0(IProgress`1 progress, CancellationToken token) in d:\github\oleviewdotnet\OleViewDotNet.Main\COMUtilities.cs:line 1786
   at OleViewDotNet.WaitingDialog.<>c__DisplayClass4_1.<.ctor>b__1(Object sender, DoWorkEventArgs e) in d:\github\oleviewdotnet\OleViewDotNet.Main\WaitingDialog.cs:line 60
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

I debugged it and what happens is for some reason, I have a weird registry key value, here is a screenshot of it:

image

The value (in PSDispatch CLSID) is read by the standard Microsoft classes, and as you can see, it contains zero characters after the valid path. I can assure you my machine is working fine though :-).

I don't know if it's a bug in Registry classes or a problem in my registry, but anyway, I suggest to change the code that reads server_string and RawServer in COMCLSIDEntry.cs line 365 to handle those weird cases, otherwise, I can't use the tool at all, because it stops at the very beginning. If you're prefer, I can build a PR.

Oh and BTW, thanks for this great tool I just discovered today!

tyranid commented 6 years ago

Thanks, yes it seems this issue comes up a lot. That string looks total garbage as well. I should perhaps replace all calls to the making the path safe with one which does its best to clean it up including stopping on the first null and removing invalid path characters. I'll fix that today.

tyranid commented 6 years ago

I've added a fix, if you can could you check it out and see if the problem goes away?

smourier commented 6 years ago

It works fine now on my machine. Thanks a lot!

tyranid commented 6 years ago

Thanks for checking.