I created an IOCTL for my FMD driver which works OK (DeviceIoControl
called with my IOCTL successfully calls FMD_OEMIoControl).
Now, the problem is, all parameters to FMD_OEMIoControl (pInBuf,
nInBufSize etc.) are 0. The help says that all parameters are set to
zero if the dwIoControlCode parameter does not specify to require
these data.
So how do I have to setup my dwIoControlCode? The CTL_CODE macro does
not seem to be the right place to configure this, so where else do I
have to look? Or am I missing something here?

Thanks in advance.
Marc

Re: FMD_OEMIoControl - Passing parameters? by Steve

Steve
Wed Dec 03 11:43:52 CST 2003

What does your call to DeviceIoControl() look like. What you pass in there
should get assed on to the FMD driver.

--
Steve Maillet (eMVP)
Entelechy Consulting
smaillet_AT_EntelechyConsulting_DOT_com



Re: FMD_OEMIoControl - Passing parameters? by Marc

Marc
Thu Dec 04 02:25:00 CST 2003

My intention is to read a physical sector from the flash.
I set up the buffers and call DeviceIoControl as follows:

SG_REQ lpInBuf;
LPDWORD dwDummy = 0;
LPBYTE lpOutBuf;
lpOutBuf = (unsigned char *)malloc(512);
lpInBuf.sr_start = SectNo; // physical sector to read
lpInBuf.sr_num_sec = 1; // read 1 sector
lpInBuf.sr_num_sg = 1;
lpInBuf.sr_status = 0; //ERROR_SUCCESS;
lpInBuf.sr_callback = NULL;
lpInBuf.sr_sglist[0].sb_buf = ((LPBYTE) MapPtrToProcess(lpOutBuf,
GetCurrentProcess()));
lpInBuf.sr_sglist[0].sb_len = 512 * lpInBuf.sr_num_sec;


if (!DeviceIoControl(hStore, // Handle to the device
IOCTL_DISK_READSECTOR, // IOCTL for the operation
&lpInBuf, // LP to a buffer (input data)
sizeof(lpInBuf), // Size in Bytes of input data buffer
lpInBuf.sr_sglist[0].sb_buf, // LP to a buffer for output data
lpInBuf.sr_sglist[0].sb_len, // Size in Bytes of output buffer
dwDummy, // LP to variable (size of data in out buffer)
NULL)) { // Ignored, set to NULL


This works great if I call IOCTL_DISK_READ (read logical sector) for
example, so I figured I might use the same buffer setup for my own IOCTL.


Steve Maillet (eMVP) wrote:

> What does your call to DeviceIoControl() look like. What you pass in there
> should get assed on to the FMD driver.
>


Re: FMD_OEMIoControl - Passing parameters? by Marc

Marc
Thu Dec 04 04:06:03 CST 2003

UPDATE:

Obviously the problem is using IOCTL_DISK_USER_START directly as my IOCTL.
I increased the value (#define IOCTL_DISK_MYIOCTL
IOCTL_DISK_USER_START+1), and now it works, the parameters are passed to
FMD_OEMIoControl... :D

However, the bug mentioned by Danny on Oct 21 2003 ("Cannot send user
IOCTL's to FMD") prevents the use of the CTL_CODE macro to define
IOCTLs. If I define my IOCTK this way, it doesn't make it to
FMD_OEMIoControl. But it works OK using a simple #define (see above).

Cheers
Marc


Marc wrote:

> My intention is to read a physical sector from the flash.
> I set up the buffers and call DeviceIoControl as follows:
>
> SG_REQ lpInBuf;
> LPDWORD dwDummy = 0;
> LPBYTE lpOutBuf;
> lpOutBuf = (unsigned char *)malloc(512);
> lpInBuf.sr_start = SectNo; // physical sector to read
> lpInBuf.sr_num_sec = 1; // read 1 sector
> lpInBuf.sr_num_sg = 1;
> lpInBuf.sr_status = 0; //ERROR_SUCCESS;
> lpInBuf.sr_callback = NULL;
> lpInBuf.sr_sglist[0].sb_buf = ((LPBYTE) MapPtrToProcess(lpOutBuf,
> GetCurrentProcess()));
> lpInBuf.sr_sglist[0].sb_len = 512 * lpInBuf.sr_num_sec;
>
>
> if (!DeviceIoControl(hStore, // Handle to the device
> IOCTL_DISK_READSECTOR, // IOCTL for the operation
> &lpInBuf, // LP to a buffer (input data)
> sizeof(lpInBuf), // Size in Bytes of input data buffer
> lpInBuf.sr_sglist[0].sb_buf, // LP to a buffer for output data
> lpInBuf.sr_sglist[0].sb_len, // Size in Bytes of output buffer
> dwDummy, // LP to variable (size of data in out buffer)
> NULL)) { // Ignored, set to NULL
>
>
> This works great if I call IOCTL_DISK_READ (read logical sector) for
> example, so I figured I might use the same buffer setup for my own IOCTL.
>
>
> Steve Maillet (eMVP) wrote:
>
>> What does your call to DeviceIoControl() look like. What you pass in
>> there
>> should get assed on to the FMD driver.
>>
>