Fixing size of a folder

Dear all,

I am developing an application for Windows NT/2000/XP in which I want to
create a folder whose size should not exceed 5MB. And should promt for error
if data exceeds 5MB
Is there any way to fix the size of folder ?

Please comment!

Rohit

----Here is the solution to fix the size at user level-
Implement a ICopyHook, each time a file has been copied, the
ICopyHook::CopyCallback will be called, in that place you can check if the
target folder size exceed the MAX limit, if so just return FALSE from this
function to deny the action.

I suppose there may be a lot of methods for doing it at kernel level.
Good Luck!

Dear All,
How can we proceed the same from kernel level ? ie. how can we get the
size of folder ?? and stop sending the IRP after the limit of folder
exceeds the given limit of folder.
Thanks in advance.

You have two choices:

  • Have your driver deny access to the folder (so no changes occur!)
    while your application gets the size of the folder and gives it to your
    driver (this is easier)
  • Count the folder size in your driver (very boring coding task, due
    to recursion of the stack - or making IRPs yourself)
    After that, just watch for any event that would change the folder
    size:
  • Non paging I/O Write
  • Overwrite call
  • Compress/decompress calls if you count the size on disk, and not
    logical size.
  • Delete
  • Set Information/FileEndOfFileInformation except with PAGING_IO bit
    set. (maybe some other exception here)
  • Rename - if a file or folder is moved out of your folder. For folder
    moves, you can, either:
  • return STATUS_NOT_SAVE_DEVICE, which would make it easier for
    your driver, but will cost time.
  • get the size of the folder that would be moved.

Regards, Dejan.

“Lalit S. Rana” wrote:

Dear All,
How can we proceed the same from kernel level ? ie. how can we get the
size of folder ?? and stop sending the IRP after the limit of folder
exceeds the given limit of folder.
Thanks in advance.


You are currently subscribed to ntfsd as: xxxxx@alfasp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa File Monitor - File monitoring library for Win32 developers.

I’ve always thought the ICopyHook only worked for folders:

“You do not call this Shell extension directly. ICopyHook::CopyCallback
is called by the Shell prior to moving, copying, deleting, or renaming a
Shell folder object.” (MSDN)

You’ve seen it work for files also? If so, this will be very useful for
my purposes as well.

  • Nick Ryan

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Lalit S. Rana
Sent: Wednesday, June 04, 2003 3:51 AM
To: File Systems Developers
Subject: [ntfsd] Re: Fixing size of a folder

----Here is the solution to fix the size at user level-
Implement a ICopyHook, each time a file has been copied, the
ICopyHook::CopyCallback will be called, in that place you can
check if the target folder size exceed the MAX limit, if so
just return FALSE from this function to deny the action.

I suppose there may be a lot of methods for doing it at
kernel level. Good Luck!


You are currently subscribed to ntfsd as: xxxxx@nryan.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

No, this won’t work for files - I’m sure, as I’ve tried it:-)
And even for folders it doesn’t work unless the SHELL is used to work
with them. I.e.: Command Prompt, any application not using SHFileOperation
API etc.

Nick Ryan wrote:

I’ve always thought the ICopyHook only worked for folders:

“You do not call this Shell extension directly. ICopyHook::CopyCallback
is called by the Shell prior to moving, copying, deleting, or renaming a
Shell folder object.” (MSDN)

You’ve seen it work for files also? If so, this will be very useful for
my purposes as well.


Kind regards, Dejan M. MVP for DDK
http://www.alfasp.com E-mail: xxxxx@alfasp.com
Alfa Transparent File Encryptor - Transparent file encryption services.
Alfa File Protector - File protection and hiding library for Win32
developers.
Alfa File Monitor - File monitoring library for Win32 developers.

Dear All,
Thanks a lot for your comments ,Dejan

Rohit