case IOCTL_READ_BUFFERED:
{
DbgPrint("Driver_Info: IOCTL_READ_BUFFERED is invoked.");
outBuffer = Irp->AssociatedIrp.SystemBuffer;
outLength = ioStackLocation->Parameters.DeviceIoControl.OutputBufferLength;
Irp->IoStatus.Information = strlen(outBuffer) + 1;
if(outBuffer){
driverExtension = ExAllocatePoolWithTag(NonPagedPool, sizeof (FOO_DRIVER_EXTENSION), BUFFERTAG);
RtlZeroMemory(driverExtension->buffer, BUFFERSIZE);
RtlCopyBytes(driverExtension->buffer,outBuffer, outLength);
DbgPrint("Read Buffered: ");
DbgPrint("%s \n",driverExtension->buffer);
}
break;
}
case IOCTL_WRITE_BUFFERED:
{
DbgPrint("Driver_Info: IOCTL_WRITE_BUFFERED is invoked.");
inBuffer = Irp->AssociatedIrp.SystemBuffer;
inLength = ioStackLocation->Parameters.DeviceIoControl.InputBufferLength;
Irp->IoStatus.Information = strlen(inBuffer) + 1;
if(inBuffer){
driverExtension = ExAllocatePoolWithTag(NonPagedPool, sizeof (FOO_DRIVER_EXTENSION), BUFFERTAG);
RtlZeroMemory(driverExtension->buffer, BUFFERSIZE);
RtlCopyBytes(driverExtension->buffer,inBuffer, inLength);
DbgPrint("Write Buffered: ");
DbgPrint("%s \n",driverExtension->buffer);
}
break;
}
//The readDrive File
hDevice = CreateFile(
"\\\\.\\FETCH_DRIVER_VERSION",
GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(!DeviceIoControl(
hDevice, IOCTL_READ_BUFFERED,
NULL, 0, &read, sizeof(read), &nb, NULL)){
printf("error in deviceioControl: (%d)\n", GetLastError());
return;
}
else{
printf("check debugprint now!\n");
printf("read: %s \n", read );
}
I want the string i inputted into writeDriver to be displayed in the readDriver.exe. but when I run the readDriver.exe file, its an empty string. whats wrong with this?
It's my first day of training today and my first time doing device driver dev. And i just cant understand where to find the error