阅读:1353回复:3
实现应用层程序与win2k下wdm驱动程序的通信有几种方法,请详细说明!(50分)
如题,来个基础性的讨论吧!
|
|
最新喜欢:abc009...
|
沙发#
发布于:2002-12-12 11:28
可以利用Win32API函数实现,如:CreateFile、Read/WriteFile,以及DeviceIoControl等等。对于自己的io代码可以使用最后一个函数
|
|
|
板凳#
发布于:2002-12-13 07:53
1) Create a named pipe from WIN32 using CreateNamedPipe(), for example, \"\\\\.\\pipe\\mypipe\"
hPipe = CreateNamedPipe( \"\\\\\\\\.\\\\pipe\\\\mypipe\", PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, 256,256, 10000, NULL); 2)kernel mode use ZwCreateFile() to open it, the above \"\\\\.\\pipe\\mypipe\" will be mapped with \"\\NamedPipe\\mypipe\", then use ZwReadFile() and ZwWriteFile() just like a normal file. Or, you may create a thread to handle it 3)user mode, a reader may be as simple as: ConnectNamedPipe (hPipe, NULL); while (1) { if (!ReadFile(hPipe, msg, sizeof (msg), &count, NULL) ) if (GetLastError() == ERROR_BROKEN_PIPE ) break; ... } additionally, you can try those block/non-block features like a socket connection good luck and have fun |
|
地板#
发布于:2002-12-13 10:44
可以利用Win32API函数实现,如:CreateFile、Read/WriteFile,以及DeviceIoControl等等。对于自己的io代码可以使用最后一个函数 再加CloseHandle,CancelIo等也就差不多了 |
|
|