DeviceIoControl,将int传递给驱动程序
DeviceIoControl, passing an int to driver
驱动程序:
PIO_STACK_LOCATION pIoStackLocation = IoGetCurrentIrpStackLocation(pIrp);
PVOID pBuf = pIrp->AssociatedIrp.SystemBuffer;
switch (pIoStackLocation->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_TEST:
DbgPrint("IOCTL IOCTL_TEST.");
DbgPrint("int received : %i", pBuf);
break;
}
用户空间应用程序:
int test = 123;
int outputBuffer;
DeviceIoControl(hDevice, IOCTL_SET_PROCESS, &test, sizeof(test), &outputBuffer, sizeof(outputBuffer), &dwBytesRead, NULL);
std::cout << "Output reads as : " << outputBuffer << std::endl;
用户空间应用程序打印出通过输出缓冲区返回的正确值,但在调试视图中,打印出的值似乎是垃圾(即:"int received:169642096")
我做错了什么?
正如前一位用户所说,您打印的是变量的地址,而不是内容。
我强烈建议您查看以下驱动程序开发教程:
http://www.opferman.com/Tutorials/
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- C++ Windows 驱动程序MSB3030无法复制该文件,因为它找不到
- 使用mongocxx驱动程序时包含头文件问题
- void*到驱动程序中的UnicodeString
- C++驱动程序看不到头文件
- 用于创建/注册虚拟存储设备的 IOKit 驱动程序
- 员工测试驱动程序数据结构
- 获取 OID(类型::b_oid)作为 MongoDB C++驱动程序中的字符串
- 如何在 c++ 中映射驱动程序?
- 如何在 cuda 中将 kd 树从主机复制到驱动程序
- Visual Studio 如何在内核模式驱动程序项目中使用C++标准库?
- 为什么我的驱动程序只读取部分字符串?
- 为 Sql 服务器实现 odbc 包装器.将数据库数据读取为字符或要求驱动程序将数据转换为 C 类型
- 如何在C++中将OID_PM_WOL_PATTERN_LIST发送到NDIS驱动程序?
- C++ 创建 NdisProt 驱动程序的句柄
- 使用 mongo c++ 驱动程序查询嵌套的 BSON 文档
- 有没有办法使用 mongocxx 驱动程序从 GridFS 集合的文件下载任意范围?
- 使用CMake ExternalProject_Add构建mongo cxx驱动程序
- SQL Server-未找到数据源名称,也未指定默认驱动程序
- DeviceIoControl,将int传递给驱动程序