【问题标题】:DeviceIoControl, passing an int to driverDeviceIoControl,将 int 传递给驱动程序
【发布时间】:2015-02-25 12:53:52
【问题描述】:

司机:

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”)

我做错了什么?

【问题讨论】:

  • 您的驱动程序代码正在打印指针,而不是 int 值。你想要*pBuf

标签: c++ driver wdk kmdf


【解决方案1】:

正如之前的用户所说,您打印的是变量的地址,而不是内容。

我强烈建议您查看以下驱动程序开发教程:

http://www.opferman.com/Tutorials/

【讨论】:

    猜你喜欢
    • 2018-08-27
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 2012-12-02
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 2016-07-25
    相关资源
    最近更新 更多