Does anyone know how an application can write to a CD
(burn) using SCSI PASS THROUGH IOCTL? I use an
application but as soon as I write, the driver returns
back with an invalid parameter status.
Do we have to implement some special functions before
doing the first write to the CD?
Thanks,
Satyeshwar
Well sir, as you describe it, it could be a whole plethora of things, and
then it could be something as simple as “shove a disk in the slot”. Does
your driver (scsi-miniport) properly support SCSI pass through? Buffered IO
or Direct IO? Did you use the proper IOCTL? Whats the error code? Are all
your parameters valid? Are pointers pointers and the IOCTL properly built?
–
Gary G. Little
Seagate Technologies, LLC
wrote in message news:xxxxx@ntdev…
>
> Does anyone know how an application can write to a CD
> (burn) using SCSI PASS THROUGH IOCTL? I use an
> application but as soon as I write, the driver returns
> back with an invalid parameter status.
> Do we have to implement some special functions before
> doing the first write to the CD?
> Thanks,
> Satyeshwar
>
>
I think PASSTHROUGH request will fail if there is a class driver loaded for
the device; IOW: The class driver claims the device and blocks access from
others.
You may want to double check.
Jamey Kirby, Windows DDK MVP
StorageCraft Inc.
xxxxx@storagecraft.com
http://www.storagecraft.com
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Gary G. Little
Sent: Friday, August 29, 2003 5:13 PM
To: Windows System Software Developers Interest List
Subject: [ntdev] Re: How to write to a CD using SCSI PASS THROUGH?
Well sir, as you describe it, it could be a whole plethora of things, and
then it could be something as simple as “shove a disk in the slot”. Does
your driver (scsi-miniport) properly support SCSI pass through? Buffered IO
or Direct IO? Did you use the proper IOCTL? Whats the error code? Are all
your parameters valid? Are pointers pointers and the IOCTL properly built?
–
Gary G. Little
Seagate Technologies, LLC
wrote in message news:xxxxx@ntdev…
>
> Does anyone know how an application can write to a CD
> (burn) using SCSI PASS THROUGH IOCTL? I use an
> application but as soon as I write, the driver returns
> back with an invalid parameter status.
> Do we have to implement some special functions before
> doing the first write to the CD?
> Thanks,
> Satyeshwar
>
>
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@storagecraft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Sayeshwar,
-
check the name you’ve used to open the device. If you’re using
\.\ScsiPort%ld and trying to send the CDBs setting correct SCSI address
in SPTI structure fields – it’s wrong! You need to open \.%C: or
\.\CdRom%ld device (first one is preferred as USB & FireWire devices may
not have CdRom symbolic link created). I do not think you’ll ever run into
situation when CD/DVD device will be unclaimed by class driver. -
check the amount of data you’re trying to write. First of all you need
to get SCSI capabilities (or storage properties) of the port. And select
smaller value from:
- number of physical pages single tranfer can held
- single transfer size in bytes
So if you’re trying to write 256K bytes to the port that does support 64K
byte tranfers only – you’ll get “invalid parameter”.
-
data buffer alignment…
-
…
In any case a good place to start is SPTI sample from DDK. Start playing
with it. And reimplement it’s functionality in your code. Trivial. That’s
what SCSI pass-through related.
If you’ll have a problems please let me know and I’ll send you the code to
open the device and send CDBs to it (wrappers over SPTI). There are a lot
of issues that are CD/DVD burning related (actual buffer size to avoid DMA
problems with ATAPI burners, device handle management, uninterruptable
data streaming support etc etc etc) and has nothing to do with SCSI
transport. Or if you do not have an extra man-years we can license you
cross-platform (Win32, NT native, NT driver, Linux & Solaris) CD/DVD
burning engine (with of w/o file system management related part). It’s up
to you.
Regards,
Anton Kolomyeytsev
Does anyone know how an application can write to a CD
(burn) using SCSI PASS THROUGH IOCTL? I use an
application but as soon as I write, the driver returns
back with an invalid parameter status.
Do we have to implement some special functions before
doing the first write to the CD?
Thanks,
Satyeshwar
Read the SCSI spec. It must describe the CDBs which are used for burners.
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
----- Original Message -----
From:
To: “Windows System Software Developers Interest List”
Sent: Saturday, August 30, 2003 2:51 AM
Subject: [ntdev] How to write to a CD using SCSI PASS THROUGH?
> Does anyone know how an application can write to a CD
> (burn) using SCSI PASS THROUGH IOCTL? I use an
> application but as soon as I write, the driver returns
> back with an invalid parameter status.
> Do we have to implement some special functions before
> doing the first write to the CD?
> Thanks,
> Satyeshwar
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
First of all, Thanks to everyone who replied to my original post. I will
try to answer everyone’s questions in this one post:
1). Does your driver (scsi-miniport) properly support SCSI pass through?
Ans. I didn’t write the miniport driver and have no intentions of writing
one either. I am 100 % sure that SPT IOCTLs can burn to a CD just with the
Microsoft Native Port-Miniport Driver. Why am I so sure? Because I was
present when the Microsoft Filter Driver expert showed us an app using SPT
IOCTLs to burn to CDs. If I could somehow get him to reply to this post,
then I think that all matters would become clearer. In fact, his position
was that they (MSFT) want everyone to use that interface rather than the
current IMAPI interface.
2). Buffered IO or Direct IO?
Ans. The IOCTL itself is Buffered IO, I don’t know what Microsoft’s driver
has defined in their AddDevice routine.
3). Did you use the proper IOCTL?
Ans. uhhh Yes. I used IOCTL_SCSI_PASS_THROUGH_DIRECT (Similar to SPT but
it just lets you have a buffer that is non contiguous to your SPT data
structure).
4). Whats the error code?
Ans. Win32 Error Code 87 = STATUS_INVALID_PARAMETER from Kernel Mode
5). Are all your parameters valid?
Ans. I think so. All I am trying to do is just write 1 sector (512) bytes
of data. I also tried other values for sector size (2048, 2356) with the
same result. All other parameters look valid to me as well.
6). Are pointers pointers and the IOCTL properly built?
Ans. I think so.
7). I think PASSTHROUGH request will fail if there is a class driver
loaded for the device; IOW: The class driver claims the device and blocks
access from others.
Ans. This MAY BE what is happening but I don’t think that you can have a
CD ROM device on the system without a class driver claiming the device.
8). check the name you’ve used to open the device. If you’re using
\.\ScsiPort%ld and trying to send the CDBs setting correct SCSI address
in SPTI structure fields – it’s wrong! You need to open \.%C: or
\.\CdRom%ld device (first one is preferred as USB & FireWire devices may
not have CdRom symbolic link created). I do not think you’ll ever run into
situation when CD/DVD device will be unclaimed by class driver.
Ans. I am using \.\CdRom1 i.e. the CD Burner. I cross check that the
CdRom1 is indeed E: which is my CD burner by looking at WinObj.
9). check the amount of data you’re trying to write. First of all you need
to get SCSI capabilities (or storage properties) of the port. And select
smaller value from:
- number of physical pages single tranfer can held
- single transfer size in bytes
Ans. Only sending 1 sector worth of data (tried sector sizes like 512,
2048, 2356 etc… without any good results).
10). data buffer alignment…
Ans. I think I know where you are going with this but I thought that it
was the class/port driver’s responsiblity to check for this. Meaning if
the user mode’s buffers are non aligned, the drivers should check for that
and correct it.
11). In any case a good place to start is SPTI sample from DDK. Start
playing with it. And reimplement it’s functionality in your code. Trivial.
That’s what SCSI pass-through related.
Ans. I started with SPTI and that’s how I built this app.
12). Read the SCSI spec. It must describe the CDBs which are used for
burners.
Ans. I guess this is the only place to look at.
Finally, I have been able to write to CDs through the IMAPI interface but
quite frankly, it sucks! We can’t do multiple simultaneous writes with it.
Anyways, I compiled the CD Class Driver from the DDK and loaded that to
see what IOCTLs does it get from IMAPI. The IOCTL code that it gets is
wierd (to say the least). I used OSR’s IOCTL utility and that didn’t help
either, the hex code is 0x90dae040 which can’t seem to be translated into
anything.
Again, any help will be much appreciated.
-Satyeshwar
From the thread:
10). data buffer alignment…
Ans. I think I know where you are going with this but I thought that it
was the class/port driver’s responsiblity to check for this. Meaning if
the user mode’s buffers are non aligned, the drivers should check for
that
and correct it.
Actually, for IOCTL_SCSI_PASS_THROUGH_DIRECT, it is the requirement of
the user-mode program to ensure that all buffers are properly aligned.
Realistically, the maximum alignment of a buffer is
MEMORY_ALLOCATION_ALIGNMENT (defined in NTDEF.H, WDM.H, WINNT.H), as it
would otherwise require a whole page aligned for each transfer.
You have two options to ensure memory alignment:
- request the adapter properties (as in #9 below) and get the alignment
mask. When you allocate memory, add this alignment mask to the size you
allocate. When the pointer comes back, you keep track of two pointers;
the one returned by your memory management API and the aligned pointer.
Use the aligned pointer for SPTI. Algorithm to go from pointer to
aligned pointer:
PVOID p = Alloc().
ULONG_PTR tmp = (ULONG_PTR)p;
// first, add the alignment mask
// this ensures when you AND the result
// you won’t get a smaller value
tmp += alignmentMask;
// then AND the alignment mask
// to get the aligned pointer.
tmp &= alignmentMask;
// put it into the new pointer.
// keep both, since you need to
// free() using the original pointer
PVOID new = (PVOID)tmp;
- Allocate a multiple of pages using available page-allocation
routines. This ensures that you get a page-aligned pointer, which is
always valid.
#1 is more complex, but more memory-efficient. In practice, you
normally won’t hit this edge case as a problem unless you are allocating
your memory on the stack, typically as a UCHAR or BYTE array. If you
want to minimize code changes, and have already allocated on the stack,
you can change the following line:
-----Original Message-----
From: Satyeshwar Singh [mailto:xxxxx@hotmail.com]
Sent: Friday, September 05, 2003 3:15 PM
Subject: Re: How to write to a CD using SCSI PASS THROUGH?
First of all, Thanks to everyone who replied to my original post. I will
try to answer everyone’s questions in this one post:
1). Does your driver (scsi-miniport) properly support SCSI pass through?
Ans. I didn’t write the miniport driver and have no intentions of
writing
one either. I am 100 % sure that SPT IOCTLs can burn to a CD just with
the
Microsoft Native Port-Miniport Driver. Why am I so sure? Because I was
present when the Microsoft Filter Driver expert showed us an app using
SPT
IOCTLs to burn to CDs. If I could somehow get him to reply to this post,
then I think that all matters would become clearer. In fact, his
position
was that they (MSFT) want everyone to use that interface rather than the
current IMAPI interface.
2). Buffered IO or Direct IO?
Ans. The IOCTL itself is Buffered IO, I don’t know what Microsoft’s
driver
has defined in their AddDevice routine.
3). Did you use the proper IOCTL?
Ans. uhhh Yes. I used IOCTL_SCSI_PASS_THROUGH_DIRECT (Similar to SPT but
it just lets you have a buffer that is non contiguous to your SPT data
structure).
4). Whats the error code?
Ans. Win32 Error Code 87 = STATUS_INVALID_PARAMETER from Kernel Mode
5). Are all your parameters valid?
Ans. I think so. All I am trying to do is just write 1 sector (512)
bytes
of data. I also tried other values for sector size (2048, 2356) with the
same result. All other parameters look valid to me as well.
6). Are pointers pointers and the IOCTL properly built?
Ans. I think so.
7). I think PASSTHROUGH request will fail if there is a class driver
loaded for the device; IOW: The class driver claims the device and
blocks
access from others.
Ans. This MAY BE what is happening but I don’t think that you can have a
CD ROM device on the system without a class driver claiming the device.
8). check the name you’ve used to open the device. If you’re using
\.\ScsiPort%ld and trying to send the CDBs setting correct SCSI address
in SPTI structure fields – it’s wrong! You need to open \.%C: or
\.\CdRom%ld device (first one is preferred as USB & FireWire devices
may
not have CdRom symbolic link created). I do not think you’ll ever run
into
situation when CD/DVD device will be unclaimed by class driver.
Ans. I am using \.\CdRom1 i.e. the CD Burner. I cross check that the
CdRom1 is indeed E: which is my CD burner by looking at WinObj.
9). check the amount of data you’re trying to write. First of all you
need
to get SCSI capabilities (or storage properties) of the port. And select
smaller value from:
- number of physical pages single tranfer can held
- single transfer size in bytes
Ans. Only sending 1 sector worth of data (tried sector sizes like 512,
2048, 2356 etc… without any good results).
10). data buffer alignment…
Ans. I think I know where you are going with this but I thought that it
was the class/port driver’s responsiblity to check for this. Meaning if
the user mode’s buffers are non aligned, the drivers should check for
that
and correct it.
11). In any case a good place to start is SPTI sample from DDK. Start
playing with it. And reimplement it’s functionality in your code.
Trivial.
That’s what SCSI pass-through related.
Ans. I started with SPTI and that’s how I built this app.
12). Read the SCSI spec. It must describe the CDBs which are used for
burners.
Ans. I guess this is the only place to look at.
Finally, I have been able to write to CDs through the IMAPI interface
but
quite frankly, it sucks! We can’t do multiple simultaneous writes with
it.
Anyways, I compiled the CD Class Driver from the DDK and loaded that to
see what IOCTLs does it get from IMAPI. The IOCTL code that it gets is
wierd (to say the least). I used OSR’s IOCTL utility and that didn’t
help
either, the hex code is 0x90dae040 which can’t seem to be translated
into
anything.
Again, any help will be much appreciated.
-Satyeshwar