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


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:

Calling FilterSendMessage from a detached thread

dilawardilawar Member Posts: 5
edited October 2021 in NTFSD

I have a minifilter and a simple C++ client that connects to this minifilter over a port. The client receives and sends message to minifilter using FilterGetMessage and FilterSendMessage. The client receives a message from the minifilter, performs tasks foo, updates the minifilter about the status by calling FilterSendMessage and waits for another message. Things were working fine.

Recently, I moved the function (foo) that calls FilterSendMessage to a detached thread e.g. std::thread(foo, ...).detach(). Now when foo is called by the client, FilterSendMessage blocks indefinitely. I also don't see the log message from MessageNotifyCallback. I am assuming that calling foo from a detached thread has caused this but I can't be sure.

foo communicates over the network and can have quite large latency. I don't want to wait for it to finish before calling the FilterGetMessage again. Hence, it was called from a detached thread.

So the question is, is it possible to call FilterSendMessage from a detached thread? If not, I'd like to know the details. Docs don't mention much. If yes, then I need to debug more.

PS: I am very new to the Win32 platform. Mostly a Linux developer.


  • Peter_Viscarola_(OSR)Peter_Viscarola_(OSR) Administrator Posts: 8,996

    There should be no problem calling FilterSendMessage from a thread... either attached or detached.

    I'd look elsewhere for the underlying probem.


    Peter Viscarola

  • dilawardilawar Member Posts: 5

    Thank you Peter for your reply.

    If FilterSendMessage and FilterGetMessage are called from the same thread, (detached or attached), everything works fine. When each of them has their separate threads, then one one blocks indefinitely.

  • dilawardilawar Member Posts: 5

    Found the issue.

    When I changed

     auto t = std::thread([&] { foo(); }).detach();


     auto t = std::thread([=] { foo(); }).detach();

    It worked fine! I think I vaguely understand what could be the issue: Capturing by value worked but capturing by reference didn't.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

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!
Writing WDF Drivers 12 September 2022 Live, Online
Internals & Software Drivers 23 October 2022 Live, Online
Kernel Debugging 14 November 2022 Live, Online
Developing Minifilters 5 December 2022 Live, Online