Also you may find this info about METHOD_BUFFERED useful:
user-mode perspective about this:
InBuffer - optional, contains data that is written to the driver
OutBuffer - optional, contains data that is read from the driver after the
call has completed
InBuffer and OutBuffer can be two buffers or a single shared buffer. If a
shared buffer, InBuffer is overwritten by OutBuffer.
I/O Manager perspective about this:
examines InBufferSize and OutBufferSize. Allocates memory from non-paged
pool and puts the address of this pool in Irp->AssociatedIrp.SystemBuffer.
The size of this buffer is equal to the size of the larger of the two
buffers. This buffer is accessible at any IRQL.
copies InBufferSize to irpSp->Parameters.DeviceIoControl.InputBufferLength
copies OutBufferSize to irpSp->Parameters.DeviceIoControl.OutputBufferLength
copies contents of InBuffer to SystemBuffer allocated above
calls your driver
Device Driver perspective about this:
you have one buffer, Irp->AssociatedIrp.SystemBuffer. You read input data
from this buffer and you write output data to the same buffer, overwriting
the input data.
Before calling IoCompleteRequest, you must
- set IoStatus.Status to an appropriate NtStatus
- if IoStatus.Status == STATUS_SUCCESS
set IoStatus.Information to the number of bytes you want copied from the
SystemBuffer back into OutBuffer.
I/O Manager Completion Routine perspective:
looks at IoStatus block, if IoStatus.Status = STATUS_SUCCESS, then copies
the number of bytes specified by IoStatus.Information from
Irp->AssociatedIrp.SystemBuffer into OutBuffer
completes the request
Dev
-----Original Message-----
From: dsingh@IN.rainbow.com [mailto:dsingh@IN.rainbow.com]
Sent: Wednesday, February 11, 2004 10:34 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] system buffer address?
No, result of CTL_CODE will be 0x20220008,so access method will become
FILE_DEVICE_TAPE_FILE_SYSTEM. So Rob is right.
Hope this help,
Dev
-----Original Message-----
From: Bill Wandel [mailto:xxxxx@bwandel.com]
Sent: Wednesday, February 11, 2004 6:30 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] system buffer address?
The function code is wrong but if you apply the CTL_CODE macro then the
results will be 0x00220008. The access method is still FILE_ANY_ACCESS and
the device type is still 0x0022. If both the application and driver use the
CTL_CODE macro then they should get the same result.
Bill Wandel
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]
On Behalf Of Rob Green
Sent: Tuesday, February 10, 2004 6:39 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] system buffer address?
Function codes are only 12 bits. IOW 0x8002 is too big, and you are
screwing with the access method. The function number must be less than
0x1000.
Thanks,
Rob
#define V3_IOCTL_READ_SWITCHES CTL_CODE (FILE_DEVICE_UNKNOWN, \
0x8002, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS);
In user app:
long unsigned int switch_data = 0;
if(DeviceIoControl(hV3Device,
V3_IOCTL_READ_SWITCHES,
NULL,
0,
&switch_data,
sizeof(switch_data),
&nBytesTransferred,
NULL) == 0)
{
// ERROR, could not communicate to
device!!!
printf(“ERROR: could not communicate to
device!\n”);
printf(“Press return to quit”);
getc(stdin);
exit(1);
}
And from the driver (via windbg):
v3driver: Opened!!
v3driver: v3Ioctl
v3driver: Doing a “read switches”
v3driver: read switches >
ioStack->Parameters.DeviceIoControl.IoControlCode = 0x8002
v3driver: read switches >
ioStack->Parameters.DeviceIoControl.OutputBufferLength = 0x4
v3driver: read switches >
ioStack->Parameters.DeviceIoControl.InputBufferLength = 0x0
v3driver: read switches >
ioStack->Parameters.DeviceIoControl.Type3InputBuffer = 0x0
v3driver: read switches > Irp->AssociatedIrp.SystemBuffer = 0x0
Breakpoint 1 hit
v3driver!v3Ioctl+0x260:
Now I was under the impression that the System Buffer would be
defined by the output buffer if the input buffer was NULL. So why
would the address be 0x0? This, of course is causing an access
violation shortly after. If I were to specify the output and input
buffer, I would get a reasonable address for the system buffer. This
is strange.
Thanks in advance,
Howard Keller
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@cdp.com To unsubscribe
send a blank email to xxxxx@lists.osr.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@bwandel.com To
unsubscribe send a blank email to xxxxx@lists.osr.com
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: dsingh@in.rainbow.com
To unsubscribe send a blank email to xxxxx@lists.osr.com