Example #1
0
            public static void GetTableOfContents(UnixFileDescriptor fd, out MMC.TOCDescriptor rawtoc)
            {
                var msf = false;
                var cmd = MMC.CDB.ReadTocPmaAtip.TOC(msf);

                try { NativeApi.SendSCSIRequest(fd, ref cmd, out rawtoc); }
                catch (Exception e) { throw new IOException("Failed to retrieve table of contents.", e); }
                rawtoc.FixUp(msf);
            }
Example #2
0
            public static void GetTableOfContents(SafeFileHandle hDevice, out MMC.TOCDescriptor rawtoc)
            {
                var req       = new NativeApi.TOCRequest(MMC.TOCRequestFormat.TOC);
                var reqlen    = Util.SizeOfStructure <TOCRequest>();
                var rawtoclen = Util.SizeOfStructure <MMC.TOCDescriptor>();
                // LIB-44: Apparently for some multi-session discs, the first TOC read can be wrong. So issue two reads.
                var ok = NativeApi.DeviceIoControl(hDevice, IOCTL.CDROM_READ_TOC_EX, ref req, reqlen, out rawtoc, rawtoclen, out int returned, IntPtr.Zero);

                if (ok)
                {
                    ok = NativeApi.DeviceIoControl(hDevice, IOCTL.CDROM_READ_TOC_EX, ref req, reqlen, out rawtoc, rawtoclen, out returned, IntPtr.Zero);
                }
                if (!ok)
                {
                    throw new IOException("Failed to retrieve TOC.", new Win32Exception(Marshal.GetLastWin32Error()));
                }
                rawtoc.FixUp(req.AddressAsMSF);
            }