Monday, July 27, 2009

How do I read a BYTE [not a sector] from a CD, preferably in C++?

I do apologize for having to include this in my question, but because the programming section is usually plagued full of slackers, pranksters, embeciles, and just plain ignorant individuals that interfere with those of us that wish to use this sub-site as a learning tool, it must be included: Please READ the darn question before you answer it. Please give an INTELLIGENT answer, not Huh? wot? I dunno, etc. ... Please PAY attention Do not give me code for VB5 under WinNT, DJCPP, or GCC on Linux, when all you had to DO was READ the whole question to realize I do not want that particular information. Thank you all for letting me speak my piece. Now on to the rest of myt question. I can use code in VC6, Visual C++ 2005, and Visual C# 2005. Managed / .NET is acceptable as well. I can use code for any Win32 OS. However, I do NOT do VB6, VB.NET, .VBS, Linux or any code developed for a Non-Microsoft OS. Thanks for all the help.

How do I read a BYTE [not a sector] from a CD, preferably in C++?
Hmmm, I never tried that, but assuming the byte is in a known file, I would think you could just open the file (same as on your hard drive), and read it out as characters. You would most likely have to open it as read (not write or read/write). Thats what I would try first.
Reply:It really won't matter which language you use, you are probably going to have to do a lot of low level OS interfacing, because reading at that level potentially violates a lot of OS protections that have been put in place to keep random programs from reading and writing random bytes to random positions your IO devices. Its just like reading from the 1537614th byte from your NTFS filesystem... you're supposed to be interfacing with the filesystem at the conceptual filesystem level, not the byte level, and its a good thing that most programs cannot.





BTW, VB.NET is easily translated to C# so even if you had a VB.NET solution, you probably could find something that would automatically translate it to C#. But I really doubt you'd find either.





CD's, Hard disks, etc, all read in blocks of data at one time so, like G. Whilikers said, even if you read in one byte, at some place in your memory the CD reader has read in the whole 512 bytes... so if you have code to read in the sector, the're really no other way to do it. Just pick the specific byte you need from that sector block.
Reply:Either find a way to treat the disk as an i/o stream, or grit your teeth and read the sector then pick up the byte you want. Even if you had a getSpecificByteFromCD() function available, underneath it's going to be reading the whole sector behind your back anyway.


No comments:

Post a Comment