Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTFSD
Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


Minifilter communication with user app

kriankrian Member Posts: 5

Hello, I'm trying to communicate my Minifilter with a user application to send and process some messages,

I'm doing this with the FltCreateCommunicationPort routine and sending messages from the user with FilterSendMessage routine.

I know this is working because I can see the message printed but I am unable to copy the InputBuffer into a local PCHAR to work with, My MessageNotifyCallback is:

NTSTATUS MiniRecieveSend(PVOID PortCookie, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Reference) {
    NTSTATUS status;
    KdPrint(("DEBUG_CONN: Message recieved from user: %s \r\n"), (PCHAR)InputBuffer); //This prints the correct message
    KdPrint(("DEBUG_CONN: Buffer Length: %d \r\n"), InputBufferLength); //This prints the correct length of the message, that it is like 131
    KdPrint(("DEBUG_CONN: Buffer Length: %d \r\n"), InputBufferLength); //this prints a random number, always between 30-50
}

However, with this implementation:

NTSTATUS MiniRecieveSend(PVOID PortCookie, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength, PULONG Reference) {
    NTSTATUS status;
    PCHAR UserMessage= (PCHAR) ExAllocatePoolWithTag(NonPagedPool, 512, "1gaT");
    RtlCopyMemory(UserMessage, InputBuffer, InputBufferLength);

    KdPrint(("DEBUG_CONN: Message recieved from user: %s \r\n"), (PCHAR)InputBuffer); //This prints "DEBUG_CONN: Message recieved from user: „»tÕÿÿÀo»tÕÿÿ "
    KdPrint(("DEBUG_CONN: Buffer Length: %d \r\n"), InputBufferLength); //This prints a number like if `InputBufferLength` was Null (sometimes it is 32042389193792 and other times -123193429)
    KdPrint(("DEBUG_CONN: Buffer Length: %d \r\n"), InputBufferLength); //this prints a random number (from 30 to 50)
}

If I try to use the buffer after printing it for the first time, I cannot copy it succesfully

Can anyone help me with this error, why I am not able to copy the buffer into a local variable, is there something that I am missing?

Thank you very much for your time

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Developing Minifilters 15 Jun 2020 LIVE ONLINE
Writing WDF Drivers 22 June 2020 LIVE ONLINE
Internals & Software Drivers 28 Sept 2020 Dulles, VA