示例#1
0
            public static void GetCdTextInfo(SafeFileHandle hDevice, out MMC.CDTextDescriptor cdtext)
            {
                var req       = new NativeApi.TOCRequest(MMC.TOCRequestFormat.CDText);
                var reqlen    = Util.SizeOfStructure <TOCRequest>();
                var cdtextlen = Util.SizeOfStructure <MMC.CDTextDescriptor>();
                var ok        = NativeApi.DeviceIoControl(hDevice, IOCTL.CDROM_READ_TOC_EX, ref req, reqlen, out cdtext, cdtextlen, out int _, IntPtr.Zero);

                if (!ok)
                {
                    throw new IOException("Failed to retrieve CD-TEXT information.", new Win32Exception(Marshal.GetLastWin32Error()));
                }
                cdtext.FixUp();
            }
示例#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);
            }