阅读:2231回复:4
求助,DeviceIoControl返回87
各位大牛,我在使用DDK中自带的filespy驱动及应用测试驱动和应用的相互通信,但是我用createfile创建是成功的,但是用deviceiocontrol发送控制码到驱动就返回错误代码87,不正确的参数。我在驱动中设置了断点,deviceiocontrol发送的控制信息没有到达驱动(我在驱动中响应了该控制码)。我的代码如下:
#include <windows.h> #include <stdlib.h> #include <stdio.h> #include <winioctl.h> #include <string.h> #include <crtdbg.h> #define FILESPY_PARAM_WATI (ULONG) CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x831, METHOD_BUFFERED, FILE_ANY_ACCESS ) #define FILESPY_W32_DEVICE_NAME L"\\\\.\\FileSpy" #define BUFFER_SIZE 8192 int _cdecl main( __in int argc, __in_ecount(argc) char *argv[] ) { DWORD bytesNeeded; HANDLE hDevice = NULL; BOOL bResult; DWORD result; CHAR buffer[BUFFER_SIZE]; DWORD bufferLength = 0; BYTE obuffer[sizeof(IOCTLWAIT)]; DWORD obufferLength = 0; ULONG bytesReturned; hDevice = CreateFile( FILESPY_W32_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if ( hDevice == INVALID_HANDLE_VALUE ) { result = GetLastError(); printf( "ERROR opening device...\n" ); } bResult = DeviceIoControl( hDevice, FILESPY_PARAM_WATI, NULL, 0, buffer, BUFFER_SIZE, &bytesReturned, NULL ); if (!bResult) { result = GetLastError(); printf( "ERROR attaching to device...\n" ); printf("error code:%d",result); } CloseHandle(hDevice); printf( "FileSpy: All done\n" ); return 0; } 各位指点一下,发生错误的原因。谢谢了! |
|
沙发#
发布于:2010-12-02 22:30
有谁知道的,指点一下
|
|
板凳#
发布于:2010-12-03 01:36
I believe you have to provide input buffer and length as well.
|
|
地板#
发布于:2010-12-04 21:35
先谢谢了,我试了,不是这个问题,继续求助。。。
|
|
地下室#
发布于:2010-12-05 13:52
Doesn't you think you could check the handle and IOCTL code? Because you said that the IOCTL code was NOT retrieved by FileSpy. And I am interested in how do you know that?
|
|