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?

1 Answers1

0

As said by the previous user, you are printing the address of the variable, not the content.

I strongly suggest you to take a look to the following Driver Development tutorials:

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