EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Can I silently prevent a rename operation?

Posted: 06/22/2015 01:52:22
by Dimitrios Koubaroulis (Standard support level)
Joined: 02/13/2014
Posts: 3

Hi again,

I am trying to detect and conditionally prevent a rename operation from happening. I can achieve this by handling OnRenameOrMoveFileN but when I cancel that operation I see a Windows message box saying 'The file or folder does not exist.'

Is there something I can do to not see that Windows message box when I cancel the rename operation?

Posted: 06/22/2015 06:12:13
by Vladimir Cherniga (Team)

How did you exactly prevent rename operation ?
Posted: 06/22/2015 20:53:06
by Dimitrios Koubaroulis (Standard support level)
Joined: 02/13/2014
Posts: 3

I am doing something like this:

public void Attach() {
   _filter.OnRenameOrMoveFileC = CbFlt_OnRenameOrMoveFileC_SynchronousCallback;

   CbFltCallbackFlags flags = 0;

   if (OnRenameOrMove_SynchronousCallback != null) {
      flags |= CbFltCallbackFlags.RenameCallback;
   foreach (var path in _paths) {
      _filter.AddFilterCallbackRule(path, flags);

private void CbFlt_OnRenameOrMoveFileC_SynchronousCallback(
   CallbackFilter sender,
   string fileName,
   string newFileName,
   ref bool replaceIfExists,
   ref IntPtr userContext,
   ref bool processRequest) {
      processRequest = MyCallbackToDecideIfRenameIsAllowed(fileName, newFileName);
Posted: 06/23/2015 03:00:41
by Vladimir Cherniga (Team)

With a processRequest parameter set FALSE you silently complete request without renaming. But in the case when target application (explorer.exe, etc.) tries to open target file and obviously doesn't find it, it may report with highlighted message box. You should check exactly, what kind of operation failed to complete with a ProcMon tool from sysinternals.com. Most likely this is IRP_MJ_CREATE that returned with corresponding error.



Topic viewed 6006 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!