Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've coded a mini-filter that blocks all JPG images with relative success. Except when the file is being opened by 'Windows Photos'. The mini-filter is registered to all MJ_CREATE's and in WinDbg I can see my code being called to block JPG images when being opened by Windows Photos. However, the image still loads successfully.

Testing Environment:

Images are copied over before the filter is loaded. The filter is installed then the system is rebooted.

Problem:

Images can still be accessed by Windows Photos after system reboot. (Filter is loaded on start-up so technically the images should be blocked after reboot).

All other operations are blocked successfully, e.g. (Copy,Paste, Opening with another program like paint). Any new JPG images attempting to be opened or transferred after boot are blocked successfully as well.

What I have tried:

PostOperatonCallback:

if (RtlCompareUnicodeString(&fileDetails->Extension, &jpgExt, TRUE) == 0)
{

    DbgPrint("Blocking JPG file...\n");
    FltCancelFileOpen(FltObjects->Instance, FltObjects->FileObject);

    Data->IoStatus.Status = STATUS_ACCESS_DENIED;
    Data->IoStatus.Information = 0;

    FltReleaseFileNameInformation(fileDetails);

    return FLT_POSTOP_FINISHED_PROCESSING;
}


Filter Startup parameters:

StartType = 0
Class = "ActivityMonitor"
Altitude= "370030"


I'm wondering what I am missing? Are some images being loaded so early that it bypasses the FilterManager? Is there an IRP I may be missing? My end goal for now is just to block all JPG's from being loaded (if possible including the thumbnail).

A massive thank-you to everyone who has taken the time to read my question and to anyone who can help.

Cheers,

Bryce Woods
Posted
Updated 2-May-18 20:56pm

1 solution

Your filter is working well. But the photo application is using it's own cache from where images are loaded even when the source does not exist anymore (or access is blocked by your filter).
 
Share this answer
 
Comments
Member 13809184 3-May-18 3:10am    
Hey thanks so much for your reply really appreciate it. Do you have any ideas on how I can catch the IRP when it’s being loaded into the cache? I’d assume there is some kind of I/O when the image is being loaded into cache? I’m thinking this could happen before my filter loads, however changing the load order group and the altitude hasn’t made much of a difference. Thanks so much again.
Jochen Arndt 3-May-18 3:24am    
If your filter is active, new images can't be loaded and should be therefore not put into the cache. But images which has been loaded (or scanned) when your filter was not active will be in the cache.
Member 13809184 4-May-18 7:20am    
Hey Jochen, thanks so much for your replies. It turns out, Windows 10 caches the images and stores them in .db files not normal image files. After I blocked .db files my problem was solved. Thank you again for your help.
Jochen Arndt 4-May-18 7:29am    
Thank you for your feedback and accepting my answer.

However, I hope you will not get unwanted side effects by blocking a system database file (or even any file with a .db extension?).
Member 13809184 4-May-18 7:33am    
Thanks for your concern, I've specifically blocked db files coming from C:\
users\%username%\AppData\local\Microsoft\Windows\Explorer to try and minimize side affects. The rest will be decided by testing. Thank you again.

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