Communication between file system minifilter and mfc application

I have created a Device object and SymbolicLink on driver entry function.
following code section is used for creating the Device

UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\FileSystem\Filters\mini123CDO");
UNICODE_STRING SymLinkName = RTL_CONSTANT_STRING(L"\DosDevices\mini123SL");

status = IoCreateDevice(DriverObject,0,&DeviceName,FILE_DEVICE_DISK_FILE_SYSTEM,FILE_DEVICE_SECURE_OPEN,FALSE,&DeviceObject);
if (!NT_SUCCESS( status ))
{
return status;
}
status = IoCreateSymbolicLink(&SymLinkName,&DeviceName);

if (!NT_SUCCESS( status ))
{	
        IoDeleteDevice(DeviceObject);
        return status;
  }

I verified the device and link object using WinObj tool.
then i created a MFC application for creating a handle of the device

deviceHandle= CreateFile(“\\.\min123SL”,GENERIC_ALL,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM,0);

but createfile failed with error number 1 and description -Incorrect function.
how to solve this issue .

deviceHandle= CreateFile("\\.\min123SL",GENERIC_ALL,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM,0);
I see a typo in the symbolic name. Don’t you want \\.\mini123SL ?

@Gaurav_Sehgal sorry its a typo
correct line code
deviceHandle= CreateFile("\\\\.\\min123SL",GENERIC_ALL,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_SYSTEM,0);

thank you @Gaurav_Sehgal

You also need to handle IRP_MJ_CREATE…

Why not use a Communication Port?

Like @“Scott_Noone_(OSR)” said. Look up FltCreateCommunicationPort(). It’s easy to use and lets Filter Manager take care of all the dirty work

Thank you @“Scott_Noone_(OSR)” and @rstruempf
Is there any tutorial available .I am a beginner to mini filter development.

Well, we do teach a seminar on the topic B)

You should probably read this article, from last year’s issue of The NT Insider, just as an introduction… if you haven’t already. It’ll at least warn you of some of the potential complexity in certain types of Minifilters.

The general problem with writing Minifilters, and what makes them NOT very amenable to writing a simple tutorial, is that the interfaces (the APIs) themselves are really pretty simple. However, to actually assemble a useful Minifilters that does anything beyond the trivial requires that you understand how Windows file systems work. And that is complex, and ever increasing in subtlety and complexity.

Good luck on your journey!

Peter

And for information specific to using a communications port, I would search for the function name I gave you, FltCreateCommunicationPort(). Reading the docs and clicking the links to related items will provide a ton of information. Then search the sample filters for that function and you ought to be able to find an example, and then search for “site:osr.com FltCreateCommunicationPort” to find all of the discussions on here about it. It’s reasonably simple to use, especially if you just need synchronous messages sent from user land to your driver. Asynch messages from the driver to user land are a bit more complex

thank you @rstruempf

@“Peter_Viscarola_(OSR)”

Sorry I am unable to attend the seminar.Are you providing any online tutorial section ? Then it will be Helpfull

Are you providing any online tutorial section ? Then it will be Helpfull

Later this year, we will make attendance at our seminars via the Internet possible, yes…

Peter

thank you @“Peter_Viscarola_(OSR)”
I am waiting for your updates

Thank you all