Click here to Skip to main content
15,887,246 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
//Switch cases from my main file

case  IOCTL_READ_BUFFERED: // Reads data from the driver
    {

        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);
            // page

            RtlZeroMemory(driverExtension->buffer, BUFFERSIZE); //reinitialization
            RtlCopyBytes(driverExtension->buffer,outBuffer, outLength); 
                    DbgPrint("Read Buffered: ");
                    DbgPrint("%s \n",driverExtension->buffer);
        }

        break;
    }


case  IOCTL_WRITE_BUFFERED: // Writes data into the driver
    {
        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);
            // page

            RtlZeroMemory(driverExtension->buffer, BUFFERSIZE); //reinitialization
            RtlCopyBytes(driverExtension->buffer,inBuffer, inLength); 
                    DbgPrint("Write Buffered: ");
                    DbgPrint("%s \n",driverExtension->buffer);
        }
        break;
    }





//The readDrive File
C#
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
Posted
Updated 15-Jan-15 0:42am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900