Hello,
I want to send an ioctl to muy device driver where i want to send a
buffer of information to the device driver and then get some
information back from the driver , is this possible ? Can i supply
input and output bufer in DeviceIoControl at the same time? when i try
to do this , which of the passed user buffers will be given to my
driver's ioctl processor in the following:

IRP->AssociatedIrp.SystemBuffer

what is the correct way to do this?

regards
Taha

Re: input as well output through DeviceIoControl by Peter

Peter
Wed Jul 21 14:31:07 CDT 2004

set the METHOD_BUFFERED flags in your I/O control when you define it (if
you're using the CTL_CODE macro, just provide this as the method).

IRP->AssociatedIrp.SystemBuffer will point to a block of kernel pool that is
the larger of the input & output buffer sizes. When you receive the IRP it
will contain a copy of the client's InputBuffer. When you complete the IRP
it shoudl contain the data you wish to have copied back to the client's
OutputBuffer (and IRP->IoStatus.Information shoudl contain the number of
bytes of data to copy back - this must be <= the output buffer size in the
irp stack location)

-p

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"M Taha Masood" <m.tahamasood@gmail.com> wrote in message
news:a350f7d.0407211125.3f613dab@posting.google.com...
> Hello,
> I want to send an ioctl to muy device driver where i want to send a
> buffer of information to the device driver and then get some
> information back from the driver , is this possible ? Can i supply
> input and output bufer in DeviceIoControl at the same time? when i try
> to do this , which of the passed user buffers will be given to my
> driver's ioctl processor in the following:
>
> IRP->AssociatedIrp.SystemBuffer
>
> what is the correct way to do this?
>
> regards
> Taha



Re: input as well output through DeviceIoControl by Maxim

Maxim
Wed Jul 21 14:52:32 CDT 2004

> I want to send an ioctl to muy device driver where i want to send a
> buffer of information to the device driver and then get some
> information back from the driver , is this possible ?

Surely.

>Can i supply
> input and output bufer in DeviceIoControl at the same time?

Surely?

> to do this , which of the passed user buffers will be given to my
> driver's ioctl processor in the following:
>
> IRP->AssociatedIrp.SystemBuffer

The valid allocation length of AssociatedIrp.SystemBuffer is the larger of
InputBufferLength and OutputBufferLength. You must never touch the buffer
beyound this length - this will cause BSOD.

On entry to your driver, the InputBufferLength in it are filled from the app's
input buffer.
Before completing the IRP, you must fill the desired number of the output
bytes, and set Irp->IoStatus.Information to the number of output bytes filled -
must be <= OutputBufferLength.

Irp->IoStatus.Information is the &BytesReceived parameter value returned by
DeviceIoControl.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: input as well output through DeviceIoControl by Thomas

Thomas
Wed Jul 21 16:45:59 CDT 2004

Lookup the topic "Using I/O Control Codes" in the DDK Help file.

Good luck,

Thomas F. Divine
http://www.pcausa.com

"M Taha Masood" <m.tahamasood@gmail.com> wrote in message
news:a350f7d.0407211125.3f613dab@posting.google.com...
> Hello,
> I want to send an ioctl to muy device driver where i want to send a
> buffer of information to the device driver and then get some
> information back from the driver , is this possible ? Can i supply
> input and output bufer in DeviceIoControl at the same time? when i try
> to do this , which of the passed user buffers will be given to my
> driver's ioctl processor in the following:
>
> IRP->AssociatedIrp.SystemBuffer
>
> what is the correct way to do this?
>
> regards
> Taha



Re: input as well output through DeviceIoControl by Gary

Gary
Thu Jul 22 08:10:10 CDT 2004

What is in IRP->AssociatedIrp.SystemBuffer is strictly controlled by how you
set buffering in the definition of the IOCTL. Like Thomas said ... read the
docs. Here is a summary of buffering:

METHOD_NEITHER (access at == PASSIVE_LEVEL)
SystemBuffer = Input
UserBuffer = Output

METHOD_BUFFERED (access at >= DISPATCH_LEVEL)
SystemBuffer = Input = Output
UserBuffer = Best left alone

METHOD_IN/OUT_DIRECT (access at >= DISPATCH_LEVEL)
SystemBuffer = Input
MdlAddress = Output

--
Gary G. Little
Seagate Technologies, LLC

"Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message
news:uWE1hw2bEHA.1004@TK2MSFTNGP11.phx.gbl...
> Lookup the topic "Using I/O Control Codes" in the DDK Help file.
>
> Good luck,
>
> Thomas F. Divine
> http://www.pcausa.com
>
> "M Taha Masood" <m.tahamasood@gmail.com> wrote in message
> news:a350f7d.0407211125.3f613dab@posting.google.com...
> > Hello,
> > I want to send an ioctl to muy device driver where i want to send a
> > buffer of information to the device driver and then get some
> > information back from the driver , is this possible ? Can i supply
> > input and output bufer in DeviceIoControl at the same time? when i try
> > to do this , which of the passed user buffers will be given to my
> > driver's ioctl processor in the following:
> >
> > IRP->AssociatedIrp.SystemBuffer
> >
> > what is the correct way to do this?
> >
> > regards
> > Taha
>
>



Re: input as well output through DeviceIoControl by Maxim

Maxim
Thu Jul 22 11:23:25 CDT 2004

> METHOD_NEITHER (access at == PASSIVE_LEVEL)
> SystemBuffer = Input
> UserBuffer = Output

No.
METHOD_NEITHER (access at == PASSIVE_LEVEL)
Type3InputBuffer = Input
UserBuffer = Output

> METHOD_IN/OUT_DIRECT (access at >= DISPATCH_LEVEL)
> SystemBuffer = Input
> MdlAddress = Output

No.
MdlAddress = Second Input/Output - depending on IN or OUT_DIRECT.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: input as well output through DeviceIoControl by Gary

Gary
Fri Jul 23 08:45:02 CDT 2004

<sigh> Yes Max, you are correct on METHOD_NEITHER

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message
news:urePxgAcEHA.1152@TK2MSFTNGP09.phx.gbl...
> > METHOD_NEITHER (access at == PASSIVE_LEVEL)
> > SystemBuffer = Input
> > UserBuffer = Output
>
> No.
> METHOD_NEITHER (access at == PASSIVE_LEVEL)
> Type3InputBuffer = Input
> UserBuffer = Output
>

I should have looked at my code instead of "flying from memory". In
METHOD_NEITHER, the Input buffer is indeed in the Type3InputBuffer, where
as SystemBuffer is NULL.

> > METHOD_IN/OUT_DIRECT (access at >= DISPATCH_LEVEL)
> > SystemBuffer = Input
> > MdlAddress = Output
>
> No.
> MdlAddress = Second Input/Output - depending on IN or OUT_DIRECT.
>
Here I shall disagree. The Input buffer from the DeviceIoControl call is
always in SystemBuffer and the Output buffer has been locked down and placed
in the MdlAddress pointer. I find viewing Input as a control or command
buffer and Output as a data buffere is helpful (ala Hanrahan)

At least that is where where I get things, but what do you mean by "Second
Input/Output"?

--
Gary G. Little
Seagate Technologies, LLC

> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>



Re: input as well output through DeviceIoControl by Maxim

Maxim
Fri Jul 23 17:16:19 CDT 2004

> At least that is where where I get things, but what do you mean by "Second
> Input/Output"?

METHOD_OUT_DIRECT uses 2 output buffers and no input. It is "write with
additional info" IOCTL.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: input as well output through DeviceIoControl by Tim

Tim
Fri Jul 23 22:33:11 CDT 2004

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote:

>> At least that is where where I get things, but what do you mean by "Second
>> Input/Output"?
>
>METHOD_OUT_DIRECT uses 2 output buffers and no input. It is "write with
>additional info" IOCTL.

I think you have that backwards, although there is a bit of a terminology
problem.

METHOD_IN_DIRECT treats both buffers as inputs to the driver -- outputs
from the app. METHOD_OUT_DIRECT treats the inBuffer as an input to the
driver, and the outBuffer as an output from the driver.

However, from a driver's perspective, the two are identical. The IRP
contains an MDL to the outBuffer; if you want to read from it AND write to
it, there is nothing to stop you, regardless of which one you use. The
only difference is that, for METHOD_OUT_DIRECT, the I/O manager makes sure
that the calling process is allowed to write to the pages.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc

Re: input as well output through DeviceIoControl by Eliyas

Eliyas
Sat Jul 24 11:13:49 CDT 2004

Take a look at the src\general\ioctl sample in the DDK. It explains how four
different types of ioctls work.

--
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/driver/default.mspx
http://www.microsoft.com/whdc/driver/kernel/KB-drv.mspx



Re: input as well output through DeviceIoControl by Maxim

Maxim
Sun Jul 25 09:07:26 CDT 2004

> However, from a driver's perspective, the two are identical. The IRP
> contains an MDL to the outBuffer; if you want to read from it AND write to
> it, there is nothing to stop you, regardless of which one you use. The
> only difference is that, for METHOD_OUT_DIRECT, the I/O manager makes sure
> that the calling process is allowed to write to the pages.

Yes, one of these IOCTLs is "bulk write with small additional info", while the
other is "bulk read in a response of small request sent".

The only difference between them 2 is the way MmProbeAndLockPages is called by
the IO manager to set up Irp->MdlAddress. The parameter which governs the page
access mode depends on this.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com



Re: input as well output through DeviceIoControl by m

m
Mon Jul 26 12:38:55 CDT 2004

thanks all

"Maxim S. Shatskih" <maxim@storagecraft.com> wrote in message news:<#Hq9xClcEHA.3044@TK2MSFTNGP10.phx.gbl>...
> > However, from a driver's perspective, the two are identical. The IRP
> > contains an MDL to the outBuffer; if you want to read from it AND write to
> > it, there is nothing to stop you, regardless of which one you use. The
> > only difference is that, for METHOD_OUT_DIRECT, the I/O manager makes sure
> > that the calling process is allowed to write to the pages.
>
> Yes, one of these IOCTLs is "bulk write with small additional info", while the
> other is "bulk read in a response of small request sent".
>
> The only difference between them 2 is the way MmProbeAndLockPages is called by
> the IO manager to set up Irp->MdlAddress. The parameter which governs the page
> access mode depends on this.