Re: Rip audio from USB CD device?

From: Rolf Nilsson (nospam_at_nomail.nu)
Date: 04/08/04


Date: Thu, 8 Apr 2004 16:27:55 +0200


Alexander,

I'm happy to tell you I was wrong, with your help IOCTL_CDROM_RAW_READ works
fine under all circumstanes.
Great to get rid of the SPTI stuff.

I have some problems though.
I would like to get the name and version of the CD devices

If I get it right the way to go is to use IOCTL_STORAGE_QUERY_PROPERTY?

But the code snippet below won't compile

error C2065: 'STORAGE_DEVICE_DESCRIPTOR' : undeclared identifier

even though it's defined in ntddstor.h

It seems I'm not the only person having this problem

#include <windows.h>
#include <winioctl.h>

#include <devioctl.h>

#include <ntddstor.h>

void TestQueryProperties()

{

HANDLE hDevice = CreateFile("\\\\.\\%d:", GENERIC_READ, FILE_SHARE_READ |
FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );

LPVOID lpOutput = NULL ;

DWORD dwSizeOfOutputBuffer = 0, dwSizeReturned = 0 ;

STORAGE_DEVICE_DESCRIPTOR *lpDeviceOutput = NULL ;

STORAGE_PROPERTY_QUERY sStorageInfo /*= {0}*/ ;

sStorageInfo.QueryType = PropertyStandardQuery ;

sStorageInfo.PropertyId = StorageDeviceProperty ;

dwSizeOfOutputBuffer = sizeof(STORAGE_DEVICE_HEADER) +
sizeof(STORAGE_DEVICE_DESCRIPTOR) ;

lpOutput = new BYTE[dwSizeOfOutputBuffer] ;

assert(lpOutput != NULL) ;

lpDeviceOutput =
reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(reinterpret_cast<LPSTR>(lpOutpu
t) + sizeof(STORAGE_DEVICE_HEADER)) ;

DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, &sStorageInfo,

sizeof(sStorageInfo), lpOutput, dwSizeOfOutputBuffer, &dwSizeReturned,
NULL);

//........

CloseHandle(hDevice);

}

also I use IOCTL_STORAGE_EJECT_MEDIA and IOCTL_STORAGE_LOAD_MEDIA
to eject and close the CD which works fine.

and IOCTL_STORAGE_CHECK_VERIFY to check if a CD is in

If IOCTL_STORAGE_CHECK_VERIFY returns TRUE, the CD should be ejected
if it returns FALSE I assume the door is open and should be closed

but if the door is closed with no CD in, it should be ejected. How to
determine this?

Any hints appreciated

Thanks
Rolf

"Alexander Grigoriev" <alegr@earthlink.net> skrev i meddelandet
news:%23S7ZRE%23GEHA.2664@TK2MSFTNGP11.phx.gbl...
> You don't need GENERIC_WRITE for opening CD drive to send
IOCTL_CDROM_*,they
> all are defined with FILE_READ_ACCESS:
>
> #define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F,
> METHOD_OUT_DIRECT, FILE_READ_ACCESS)
>
> Specify GENERIC_READ in CreateFile. Some of IOCTL_STORAGE_ codes will only
> work if you specify zero as access mask, so you may need to open two
> handles. Specify both FILE_SHARE_READ and FILE_SHARE_WRITE. You should not
> care whether anybody is trying to open the CD drive with GENERIC_WRITE
> access. In fact, only Administrators can do it in Win2K/XP.
>
> You only need GENERIC_WRITE if you want to send IOCTL_SCSI_PASSTROUGH, but
> this access right is allowed for administrators only, and in general
should
> be avoided in commercial software.
>
> For an example of software which uses IOCTL_CDROM_RAW_READ, download
> Audiograbber from http://www.audiograbber.com-us.net/ (check "WinNT/2000
> calls" option).
>
> In Windows 2000, Windows Media Player uses cdral.dll for CD recording,
> licenced by MS from Roxio. CDRAL.DLL is also installed by other Roxio
> software, such as WinOnCD. This DLL provides the same functions (the same
> names and data structures) as ASPI, but only works for CD/DVD devices.
> Because
> this is not MS' own library, they don't expect you to use it in your
> applications. Even if you're smart enough to figure it out in Win2K, in
> Windows XP it's gone (nobody promised it would be there!). Such is fate of
> undocumented features.
> CD reading in WMP for Win2K and XP is still done by IOCTL_CDROM_RAW_READ.
>
> "Rolf Nilsson" <nospam@nomail.nu> wrote in message
> news:%23Z8n130GEHA.744@TK2MSFTNGP09.phx.gbl...
> >
> > Hi,
> >
> > Thanks for responding!
> >
> >
> > "Alexander Grigoriev" <alegr@earthlink.net> skrev i meddelandet
> > news:ebNingsGEHA.1180@TK2MSFTNGP09.phx.gbl...
> > > No need to blame Microsoft for "secrecy".
> > > Do your homework: read about IOCTL_CDROM_RAW_READ.
> >
> > I've done that homework a long time ago
> >
> > anyway,
> >
> > IOCTL_CDROM_RAW_READ works fine as long as you are able to open the
> device.
> >
> > If another process has opened the same device in the same way with say:
> >
> > HANDLE hFile = CreateFile(\\\\.\\D:, GENERIC_READ | GENERIC_WRITE,
> > FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL/*0*/,
NULL );
> >
> > the second one will fail with the following message:
> > "Can not access the file since it's in use by another process"
> >
> > If there is a way to open it I would be happy to know about that, I've
> tried
> > for years.
> >
> >
> > As far as I know there are three options to get hold of the raw audio
data
> >
> > 1. ASPI - works fine on all Windows platforms, must be installed by the
> user
> > on Windows NT, 2000 and XP
> > and this is not easy for an average user. Does not work with USB
devices.
> >
> > 2. SPTI (SCSII Pass Thru Interface) - works on Windows NT, 2000 and
XP,
> is
> > sinilar to ASPI but one must login
> > with administrator rights and no other process can use the device, if so
> it
> > fails. Does not work with USB devices.
> >
> > 3. IOCTL_CDROM_RAW_READ - works on Windows NT, 2000 and XP and does work
> > with USB devices.
> > Using it without administrator rights works fine BUT other processes can
> use
> > the device only if it's NOT opened in the same way.
> >
> > >
> > > "The only software that can extract audio of an audio CD at any time,
> > > without any restrictions is WMP, period"
> > >
> > > You seem to want to read more from EU lawsuit proceedings,
> >
> > I don't care about it, it's just big news here in Europe at the moment.
> >
> > > rather than
> > > Windows SDK/DDK programming docimentation. There are tons of software
> that
> > > can do it, even open source.
> >
> > Please let me know what software you are thinking of besides WMP and
> iTunes
> > that can access the raw data, not just playing the CD, without being
> > disturbed by another process
> > accessing the same CD device and not using third party drivers/software.
> >
> >
> > I would love to be proved being wrong
> >
> > Thanks
> > Rolf
> >
> >
> >
> > > Check sourceforge.net.
> > >
> > > "Rolf Nilsson" <nospam@nomail.nu> wrote in message
> > > news:eSKzWnnGEHA.580@TK2MSFTNGP11.phx.gbl...
> > > >
> > > > " Thomas Osthege" <onlyspam@gmx.net> skrev i meddelandet
> > > > news:%23Pl7BBmGEHA.2052@TK2MSFTNGP12.phx.gbl...
> > > > > "Rolf Nilsson" <nospam@nomail.nu> schrieb im Newsbeitrag
> > > > > news:Or9iYNYGEHA.264@TK2MSFTNGP12.phx.gbl...
> > > > > |
> > > > > | Hi,
> > > > > |
> > > > > | Is there a way to extract the info in the .cda files that
Windows
> > > > > displays
> > > > > | to us or are they just "dummy" files with no particular meaning?
> > > > > |
> > > > > | Any hints, help or information appreciated
> > > > > |
> > > > > | Thanks
> > > > > | Rolf
> > > > >
> > > > >
> > > > > Hi Rolf,
> > > > >
> > > > > I did it with with the burning software. I use WinOnCD version 5.
> This
> > > > > works great for me.
> > > >
> > > >
> > > > thanks for the info
> > > >
> > > > but this newsgroups is about programming, not using software
> > > >
> > > > The easist solution to my problem is to simply use Windows Media
> Player
> > to
> > > > do the job
> > > > and that's what Microsoft wants us to do, use WMP for everything and
> > kill
> > > > all competitors.
> > > >
> > > > I'm one of the competitors and want to programatically solve this
> > problem,
> > > > not to be able to
> > > > rip CD audio tracks to create MP3 files but to be able to playback
> audio
> > > and
> > > > process the content before sending it out,
> > > > i.e. add some reverb, maybe do some EQ on the music or whatever. On
> the
> > > Mac
> > > > platform this is simple, easy, documented etc.
> > > > If you can't get it working you can even ask for help from the guys
> > behind
> > > > the scene (the Mac OS sytem people) and you get help.
> > > > Not so with MS.
> > > >
> > > > The problem is (and the Eurpean Union has just sued Micorsoft to pay
> 500
> > > > millions of Euro, they will of course not succeed and maybe they
> should
> > > > not?)
> > > > but they point to the problem that Microsoft hides a lot of
> information
> > > and
> > > > monopolize certain things.
> > > >
> > > > Ever since the old DOS days, all programmers knows, there is a lot
of
> > > > undocumented API calls that are not available to the public
> > > > and I would guess (without knowing), this is stil the case.
> > > >
> > > > The only software that can extract audio of an audio CD at any time,
> > > without
> > > > any restrictions is WMP, period, well OK it seems Apples iTunes
> > > > can as well, but no other to my knowledge without installing third
> party
> > > > software as ASPI drivers etc.
> > > >
> > > > You can get around it by logging in as administrator, install third
> > party
> > > > drivers, etc, etc but we need a documented and working solution, not
> > > > potential hacks that may or may not work. Microsoft needs it as well
> to
> > > not
> > > > be left behind. I love programming Windows as much as any other OS
but
> > it
> > > > must not be impossible to do what is/should be simple.
> > > >
> > > > Rolf
> > > >
> > > >
> > > >
> > > > >
> > > > > Thomas
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: USB devices slow boot time of Windows XP Professional
    ... I found that the pc would take excessive time between the text boot ... of windows xp and the gui during the inialization of the usb devices only ... Then when in windows the mouse wouldnt ... the standard hid compliant drivers. ...
    (microsoft.public.windowsxp.hardware)
  • Re: Serious Question - Mainstream Use - No Troll
    ... USB devices such as memory sticks, external drives, MP3 ... etc. just don't work automatically like in Windows XP. ... >> they get it to work with SuSE (or ANY Linux System). ... In any case, I'll bite too. ...
    (alt.os.linux.suse)
  • Re: Error 800A0046 while running a vbs script on a remote computer
    ... do I need administrator rights? ... Windows 2000 and I just ran the script on a Windows 2000 and it works. ... Microsoft MVP Scripting and ADSI ... You need administrative rights on the remote computer. ...
    (microsoft.public.scripting.vbscript)
  • RE: Security with USB Devices
    ... "The buffer-overflow flaw is in device drivers that Windows loads ... operating systems, including Windows XP and Windows 2000, said Caleb ... but will not release details of the security hole. ... > Subject: Security with USB Devices ...
    (Pen-Test)
  • Re: unmountable boot volume blue screen error
    ... this, there are no usb devices connected, i tried running the acer D2D ... going to the windows screen telling you windows did not start successfully, ... Try booting with all hardware peripherals, except keyboard, mouse. ... safemode-safe mode with networking- safe mode with command promt- ...
    (microsoft.public.windowsxp.general)