Need to acces the class and method whose scopes are internal.

Jun 15, 2011 at 8:50 PM

I am writing a piece of code which requires to access the class

DiscUtils.Iso9660.VfsCDReader

and a method defined inside this class

DiscUtils.Iso9660.VfsCDReader.GetBootInitialEntry()

Both the class and the method's scope is defined as internal, hence can't be accessible from outside the assembly.

Here is the piece of code i am writing.the purpose of this code is to find the eltorito-boot-image file inside a ISO file.(examples isolinux.bin,grldr etc.)




/// <summary>
        /// Determine the eltorito_boot_image file in a ISO file.
        /// </summary>
        /// <param name="isoFile">ISO file</param>
        /// <returns>Path of eltorito_boot_image relative to root directory.(eg. boot\isolinux\isolinux.bin)</returns>
        private static string GetEltoritoImageInIso(string isoFile)
        {
            using (FileStream fileStream = File.OpenRead(isoFile))
            {
                using (DiscUtils.Iso9660.VfsCDReader vreader = new DiscUtils.Iso9660.VfsCDReader(fileStream, true, true))
                {
                    uint bootOffset = vreader.GetBootInitialEntry().ImageStart;
                    string[] files = vreader.GetFiles("", @"*.*", SearchOption.AllDirectories);
                    return (from str in files let drecord = vreader.GetDirectoryEntry(str) let offset = drecord.LocationOfExtent where offset == bootOffset select str).FirstOrDefault();
                }
            }
        }



My request here is to make this class and the method public, so that developers can get more mileage from this library.Or if you have any better suggestion,then please do specify.

Thanks.

Coordinator
Jun 25, 2011 at 10:48 AM

Are you looking for the file name, or just the file content?

There's the method OpenBootImage on the CDReader class, which will give you the contents of the boot image.  Although mkisofs puts the boot image as a file in the file system, this doesn't seem to be a hard requirement - so you can have a bootable ISO without the boot image having a file path.

Does OpenBootImage do what you need?

Cheers,

Ken

Jun 25, 2011 at 2:33 PM
Edited Jun 25, 2011 at 4:17 PM

Thanks, festive ken

What i want ultimately is to Edit a ISO file by first extracting it then recreating it with mkisofs.exe.

OpenBootImage just give the first 2KB  of the boot image file. In case of isolinux.bin and other boot loader, the size of boot image file is far much greater.For example size of isolinux.bin is about 24 KB.

when i have to Recreate the ISO file which have been using a isolinux.bin as boot loader.I still need whole 24 KB file(isolinux.bin) and not just the first 2KB of boot image file (as given by  OpenBootImage method).

 

So I need to know the file name of boot image for recreating the ISO file, so that i can pass it as parameter in mkisofs.exe.

 (eg.  -b boot/isolinux/isolinux.bin)

 

Till now i have to modify the discutils source code by adding

[assembly:System.Runtime.CompilerServices.InternalsVisibleTo("xboot")]

  in AssemblyInfo.cs file of discUtils source code for accessing the internal classes and methods.

Every time a new version of DiscUtils comes, I have to modify the source code and recreate the  binary file.

 

 

Or you can  suggest some better strategy for recreating file with mkisofs.exe.

 

 

 

Thanks again.


Coordinator
Jun 25, 2011 at 4:50 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jun 25, 2011 at 5:02 PM

I've just checked in a change (4cd12ace7c3f), which should fix this for you.

You can now do cdReader.BootImageStart, and you can do:

ClusterMap cm = cdReader.BuildClusterMap();

cm.ClusterToPaths(cdreader.OffsetToCluster(cdReader.BootImageStart));

Cheers,

Ken