Bug report in VfsCDReader class

Jan 23, 2011 at 8:09 AM
Edited Jan 23, 2011 at 2:05 PM

First of all thanks to you for doing such a great job.

This library has been of immense help to me and i appreciate the hardwork you have put in to this project.

 

I am using DiscUtilsSrc-0.10  and i mostly works with ISO files.

i have seen the CDReader class . it is good for doing casual stuff,  but i also want know about the following information in ISO files

1) BootOffset of bootimage file(eg. isolinux.bin , stage2_eltorito  etc.) in ISO file.

2) Bootoffsets of all the files in "ISO file".

3) Name of the bootimage file(eg. isolinux.bin , stage2_eltorito  etc.)  so that i can extract it.

 

I have found the VfsCDReader class can expose much more information about ISO files then CDReader class.

so i start using VfsCDReader class.

All was working fine till i got an error in the following code snippet.

 

VfsCDReader vfsread = new VfsCDReader(System.IO.File.OpenRead(textBox1.Text), true, true);
string [] files = vfsread.GetFiles(@"", @"*.*", SearchOption.AllDirectories)

Here's the Exception information:
System.ArgumentException was unhandled
  Message=Illegal characters in path.
  Source=mscorlib
  StackTrace:
       at System.IO.Path.CheckInvalidPathChars(String path)
       at System.IO.Path.Combine(String path1, String path2)
       at DiscUtils.Vfs.VfsFileSystem`4.DoSearch(List`1 results, String path, Regex regex, Boolean subFolders, Boolean dirs, Boolean files) in H:\Users\xxxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\DiscUtils\Vfs\VfsFileSystem.cs:line 684
       at DiscUtils.Vfs.VfsFileSystem`4.GetFiles(String path, String searchPattern, SearchOption searchOption) in H:\Users\xxxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\DiscUtils\Vfs\VfsFileSystem.cs:line 191
       at DiskUtilities.Form1.button1_Click(Object sender, EventArgs e) in H:\Users\xxxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\Form1.cs:line 38
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at DiskUtilities.Program.Main() in H:\users\xxxxxx\documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

 

Jan 23, 2011 at 8:12 AM
Edited Jan 23, 2011 at 8:17 AM

Her's the link of ISO file in which this error occured 

Offline NT Password  Registry & Editor.iso

http://www.mediafire.com/?fccl6ezrtc6xb6u

 

ps: I have checked many other files and they worked fine , only this file is giving error.

Jan 23, 2011 at 2:04 PM
Edited Jan 23, 2011 at 2:09 PM

I also tried the following code snippet.

 

CDReader cread = new CDReader(System.IO.File.OpenRead(textBox1.Text), true, true);

string[] ListOfFiles = cread.GetFiles(@"\", @"*.*", SearchOption.AllDirectories);

it also gave the same error.
Exception:
System.ArgumentException was unhandled
  Message=Illegal characters in path.
  Source=mscorlib
  StackTrace:
       at System.IO.Path.CheckInvalidPathChars(String path)
       at System.IO.Path.Combine(String path1, String path2)
       at DiscUtils.Vfs.VfsFileSystem`4.DoSearch(List`1 results, String path, Regex regex, Boolean subFolders, Boolean dirs, Boolean files) in H:\Users\xxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\DiscUtils\Vfs\VfsFileSystem.cs:line 684
       at DiscUtils.Vfs.VfsFileSystem`4.GetFiles(String path, String searchPattern, SearchOption searchOption) in H:\Users\xxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\DiscUtils\Vfs\VfsFileSystem.cs:line 191
       at DiscUtils.Vfs.VfsFileSystemFacade.GetFiles(String path, String searchPattern, SearchOption searchOption) in H:\Users\xxxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\DiscUtils\Vfs\VfsFileSystemFacade.cs:line 251
       at DiskUtilities.Form1.button1_Click(Object sender, EventArgs e) in H:\Users\xxxxxx\Documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\Form1.cs:line 35
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at DiskUtilities.Program.Main() in H:\users\xxxxxx\documents\visual studio 2010\Projects\DiskUtilities\DiskUtilities\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


The error ocurred at following code in VfsFileSystem.cs :
private void DoSearch(List<string> results, string path, Regex regex, bool subFolders, bool dirs, bool files)
        {
            TDirectory parentDir = GetDirectory(path);
            if (parentDir == null)
            {
                throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "The directory '{0}' was not found", path));
            }

            string resultPrefixPath = path;
            if (IsRoot(path))
            {
                resultPrefixPath = @"\";
            }

            foreach (TDirEntry de in parentDir.AllEntries)
            {
                bool isDir = de.IsDirectory;

                if ((isDir && dirs) || (!isDir && files))
                {
                    if (regex.IsMatch(de.SearchName))
                    {
                            results.Add(Path.Combine(resultPrefixPath, FormatFileName(de.FileName))); 
                    }
                }

                if (subFolders && isDir)
                {
                    DoSearch(results, Path.Combine(resultPrefixPath, FormatFileName(de.FileName)), regex, subFolders, dirs, files);
                }
            }
        }


This error is occurring only with this file all other files are working fine.

 

Offline NT Password  Registry & Editor.iso

http://www.mediafire.com/?fccl6ezrtc6xb6u

 


 

Coordinator
Jan 23, 2011 at 3:12 PM

Hi,

That ISO has an unusual directory entry - the hidden directory record in the root directory that points to the 'parent' directory (the name is the byte 0x1), is marked as a 'file', rather than a 'directory' - so DiscUtils tries to treat it as a valid file, rather than a special directory record.

The code throwing the exception has already been updated in mercurial, but wasn't released yet.  I've just uploaded a new version of the 0.10 release that should not throw an exception.

I'll also take a look at changing DiscUtils to ignore the 'directory' flag when identifying special directory entries - until then, you'll see an extra (bogus) entry at the start of the directory listing.

 

Cheers,

Ken

Jan 23, 2011 at 5:10 PM

Thanks festive Ken.

It's working now. :)