FltSendMessage doesn't get reply

I am using FltsendMessage to send some information to user space and the decision made in user space is conveyed back to driver using FilterReplyMessage. Given below is the code I am using. I fail to get any reply from user space and receive STATUS_TIMEOUT error code.
can someone guide me about this?

structure common to user and kernel space:

typedef struct REPLY_BUFFER
{
FILTER_REPLY_HEADER Header;
int Allow;
}REPLY_BUFFER, *PREPLY_BUFFER;

Driver code:

REPLY_BUFFER Reply ;
ULONG ReplyLength = sizeof( REPLY_BUFFER );

timeout.QuadPart = -(LONGLONG) 150000000;

status = FltSendMessage(gFilterHandle,
&gClientPort,
&buffer,
sizeof(buffer),
& Reply,
&ReplyLength,
&timeout) ;

User space code:

REPLY_BUFFER Reply;

//some decision making
Reply.Allow = 1;
else
Reply.Allow = 0;

FilterReplyMessage( hPort,(PFILTER_REPLY_HEADER) &Reply,
sizeof(REPLY_BUFFER) );

FSF’s are not my thing, but here a couple of ideas:

Why is this negative: timeout.QuadPart = -(LONGLONG) 150000000;

Unless that encodes some special meaning, that would seem like a problem.

Good luck,

mm

Negative values indicate relative time starting from current time. If I specify positive value of time, then it will start counting from 1 Jan 1601 and will return immediately without waiting.
BTW, I checked the return value of FilterReplyMessage and it says ERROR_FLT_NO_WAITER_FOR_REPLY. However the driver is actually waiting for reply. I don’t understand why this is happening.

As Daniel pointed you to, get rid of this bull:

timeout.QuadPart = -(LONGLONG) 150000000;

For God sakes, look at the docs and think about it a little…

If need be, go too " http://www.justfuckinggoogleit.com/ "…

That single timeout statement is 100% of your problem.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Tuesday, November 17, 2009 6:37 AM
To: Windows File Systems Devs Interest List
Subject: RE:[ntfsd] FltSendMessage doesn’t get reply

Negative values indicate relative time starting from current time. If I
specify positive value of time, then it will start counting from 1 Jan 1601
and will return immediately without waiting.
BTW, I checked the return value of FilterReplyMessage and it says
ERROR_FLT_NO_WAITER_FOR_REPLY. However the driver is actually waiting for
reply. I don’t understand why this is happening.


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars
(including our new fs mini-filter seminar) visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Please check that you are sending a message on same
port that you are listening on.

When you call FilterReplyMessage are you setting the Message ID in the reply header? This tells it how to route the reply:

replyMessage.ReplyHeader.MessageId = ReceivedMessage->MessageHeader.MessageId;

Not doing this is likely the reason for the error you are getting. The mini-filter example code shows how to use the message API’s. They are a better resource that the docs in this case.

The relevant thing that is missing from this post is the usermode call to
receive your message (FilterGetMessage). BTW are you sure that negative
values are working ? It’s not mentioned in the doc but it makes sense if
TimeOut is immediately passed to a call to KeWaitForSingleObject. Does it
actually wait for 15 seconds ?

//Daniel

wrote in message news:xxxxx@ntfsd…
> I am using FltsendMessage to send some information to user space and the
> decision made in user space is conveyed back to driver using
> FilterReplyMessage. Given below is the code I am using. I fail to get any
> reply from user space and receive STATUS_TIMEOUT error code.
> can someone guide me about this?
>
> structure common to user and kernel space:
>
> typedef struct REPLY_BUFFER
> {
> FILTER_REPLY_HEADER Header;
> int Allow;
> }REPLY_BUFFER, *PREPLY_BUFFER;
>
>
> Driver code:
>
> REPLY_BUFFER Reply ;
> ULONG ReplyLength = sizeof( REPLY_BUFFER );
>
> timeout.QuadPart = -(LONGLONG) 150000000;
>
> status = FltSendMessage(gFilterHandle,
> &gClientPort,
> &buffer,
> sizeof(buffer),
> & Reply,
> &ReplyLength,
> &timeout) ;
>
> User space code:
>
> REPLY_BUFFER Reply;
>
> //some decision making
> Reply.Allow = 1;
> else
> Reply.Allow = 0;
>
> FilterReplyMessage( hPort,(PFILTER_REPLY_HEADER) &Reply,
> sizeof(REPLY_BUFFER) );
>

Negative values should work. I’ll file a doc bug.

Regards,
Alex.
This posting is provided “AS IS” with no warranties, and confers no rights.

Thank you one and all.
The problem was, I didn’t specify MessageId in header ( as rightly pointed out by Rick W). After specifying the MessageId, the problem is solved.
Thank you Rick.