IOCTL_DISK_READ
- From: "frank433@xxxxxx" <frank433@xxxxxx>
- Date: 10 Oct 2005 03:00:28 -0700
Hi,
is it possible to read some sectors of a sdcard with a call of
DeviceIoControl/IOCTL_DISK_READ from a normal application? Or does this
only works from within a device driver? I tried the following code, but
it does not work (but I also don't get an error.)
HANDLE hDevice = CreateFile(_T("DSK1:"),
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
// hDevice is ok and GetLastError returns 0;
SG_REQ lpInBuf;
DWORD dwDummy = 0;
LPBYTE lpOutBuf;
lpOutBuf = (unsigned char *)malloc(512);
memset(lpOutBuf, 0xFF, 512); // only to see the changes
lpInBuf.sr_start = 1; // 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 = callbackDiskRead;
lpInBuf.sr_sglist[0].sb_buf = ((LPBYTE) MapPtrToProcess(lpOutBuf,
GetCurrentProcess()));
lpInBuf.sr_sglist[0].sb_len = 512 * lpInBuf.sr_num_sec;
DeviceIoControl(hDevice, // Handle to the device
IOCTL_DISK_READ, // IOCTL for the operation
&lpInBuf, // LP to a buffer (input data)
sizeof(lpInBuf), // Size in Bytes of input data
buffer
NULL, // LP to a buffer for output data
0, // Size in Bytes of output buffer
&dwDummy, // LP to variable (size of data in out
buffer)
NULL);
DeviceIoControl returns true and GetLastError returns 0. But all bytes
im my outputbuffer lpOutBuf are zero. I also tried lpInBuf.sr_callback
= NULL; because my callback function is never called.
Thanks,
Frank
.
- Follow-Ups:
- Re: IOCTL_DISK_READ
- From: Andrew Rogers [MSFT]
- Re: IOCTL_DISK_READ
- Prev by Date: Re: One more IIC driver question
- Next by Date: RE: VoIP with mobile 5.0
- Previous by thread: Re: voip
- Next by thread: Re: IOCTL_DISK_READ
- Index(es):
Relevant Pages
|
Loading