0

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;
}

User-space App:

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;

The user-space application prints out the correct value received back through the output buffer, but in debug view, the value printed out seems to be garbage (ie: "int received : 169642096")

What am I doing wrong?

4

1 回答 1

0

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

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

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

于 2015-02-27T18:18:12.733 回答