能力值:
( LV2,RANK:10 )
|
-
-
2 楼
DO_BUFFERED_IO,读写时,如何传递参数指针NULL,则对应DispatchRead/DispatchWrite不会有任何处理,你可以通过打印信息测试一下;其他方式没有试过。
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
感谢回复,我用过 DeviceIoControl 也是一样的。
|
能力值:
( LV2,RANK:10 )
|
-
-
4 楼
case IOCTL_GET_READSIZE:
{
DbgPrint("IOCTL_GET_READSIZE\r\n");
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = (wcslen(L"Read Something...") + 1) * sizeof(WCHAR);
ntStatus = STATUS_SUCCESS;
}
break;
case IOCTL_READ_CONTENT:
{
ULONG uMin = 0;
DbgPrint("IOCTL_READ_CONTENT\r\n");
//KdBreakPoint();
pBuffRead = pIrp->AssociatedIrp.SystemBuffer;
pStack = IoGetCurrentIrpStackLocation(pIrp);
uLenRead = pStack->Parameters.Read.Length;
uMin = (wcslen(L"Read Something...") + 1) * sizeof(WCHAR);
uMin = (uMin>uLenRead) ? uLenRead : uMin;
RtlCopyMemory(pBuffRead, L"Read Something...", uMin);
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = uMin;
ntStatus = STATUS_SUCCESS;
}
break;
DWORD dwSize = 0, dwRed = 0;
if (::DeviceIoControl(systool.GetDevice(),
IOCTL_GET_READSIZE,
NULL,
0,
NULL,
0,
&dwRed,
NULL))
{
printf("%d\r\n", dwRed);
memset(szCurrent, 0, MAX_PATH);
if (::DeviceIoControl(systool.GetDevice(),
IOCTL_READ_CONTENT,
NULL,
0,
szCurrent,
dwRed,
&dwRed,
NULL))
{
printf("%S\r\n", szCurrent);
}
}
我试了下,可以分次取长度和内容呀,你再检查一下?代码看看?
36
Read Something...
一个ctrlcode,
if (!pBuffRead)
{
//get size
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = (wcslen(L"Read Something...") + 1) * sizeof(WCHAR);
}
else
{
//get content
uMin = (wcslen(L"Read Something...") + 1) * sizeof(WCHAR);
uMin = (uMin>uLenRead) ? uLenRead : uMin;
RtlCopyMemory(pBuffRead, L"Read Something...", uMin);
pIrp->IoStatus.Status = STATUS_SUCCESS;
pIrp->IoStatus.Information = uMin;
}
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
我晚上回家试试,我在驱动返回的是 BUFFER_TOO_SMALL 不是 SUATUS_SUCCESS
|