Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32: Prevent folder modification?

Tags:

c++

winapi

I want to make sure no other process changes the contents of a particular folder. I'd like to stop other processes from creating, deleting, or modifying files within a folder. Further, I'd like this restriction to nest down into subfolders.

I can get close to what I want by enumerating the contents of the folder and calling CreateFile on each file. This has problems in that it doesn't stop new files from being created and requires I acquire lots of handles.

Is there an easier way to get what I want?


Update: Addressing some comments, what I want to do is to prevent modification while my program is running. It's OK if the file get modified between runs.

In terms of ACLS, the app has read access to all files within the folder.

like image 476
Justin R Avatar asked Apr 01 '26 02:04

Justin R


1 Answers

ACLs would be the best way to go but if you can't get that to work for whatever reason (you're fairly thin on the details) then use a file system filter driver. Note that this isn't very straightforward. Not rocket science either, but you have to be extra careful with driver development.

http://www.microsoft.com/whdc/driver/filterdrv/default.mspx

like image 124
martona Avatar answered Apr 02 '26 20:04

martona



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!