SHFileOperation: accidentally getting exceptions when deleting files

I use SHFileOperation () to remove directories from a specific path. This is done in multiple threads, and the remote directory is always different.

From time to time, it throws exceptions:

An exception was thrown at 0x00007FF8AF5D9D2A (ntdll.dll) in del.exe: 0xC0000008: An invalid handle was specified

and this one:

The exception that occurred when 0x00007FF8ACC90A36 (shell32.dll) in del.exe: 0xC0000005: A place to read access violation 0x0000000000000001.

modules:

shell32.dll 00007FF8ACBD0000-00007FF8AE0D8000 ntdll.dll 00007FF8AF530000-00007FF8AF701000 

This is the code:

 SHFILEOPSTRUCTW tFileOptions = { 0 }; /* Initialize the file options structure for the deletion process */ tFileOptions.pFrom = pwstrPath; tFileOptions.wFunc = FO_DELETE; tFileOptions.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; /* Execute the deletions with the Shell operation */ iResult = SHFileOperationW(&tFileOptions); if (0 != iResult) { printf("WTF\n"); goto lbl_cleanup; } SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, pwstrPath, NULL); 

At the end, pwstrPath has a double null terminator.

What is the reason for these exceptions?

EDIT

Stack trace:

enter image description here

+5
source share
1 answer

from the stack trace (even without pdb characters - it will be much better with it) it is clear that the exception is not only inside the Windows shell, but also in a third-party product - dragext64.dll (this is not a native window image), which is implemented by Copy Hook Handler - I advise delete this or disable through the registry key

 HKEY_CLASSES_ROOT Directory shellex CopyHookHandlers MyCopyHandler (Default) = {MyCopyHandler CLSID GUID} 

and check after that. think that exceptions should disappear.


also look like some other shell extensions have errors here - google search SHELL32_CallFileCopyHooks . for example TortoiseGit.dll error - pay attention to shell32.dll!SHELL32_CallFileCopyHooks() stack trace shell32.dll!SHELL32_CallFileCopyHooks()

therefore, all these errors in the implementation of the ICopyHook :: CopyCallback method

+3
source

All Articles