Question

I am trying to hook the function enumobjects in Ishellfolder . I am doing it because I want to display the user non existing files in explorer. I was success to hook FindNextFile and FindFirstFile but unfortunately this function not always call by explorer according to this question Which APIs are used by explorer.exe in Windows 7 to list files?

Now I try to hook IShellFolder::EnumObjects so I hook

MyCoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv)

And inside this function I have the following code:

if (IsEqualCLSID(rclsid, (REFGUID) __uuidof (IShellFolder)) || 
    IsEqualCLSID(rclsid, (REFGUID) __uuidof (IShellFolder2)) ||
    IsEqualCLSID(rclsid, (REFGUID) CLSID_ShellDesktop) ||
    IsEqualCLSID(rclsid, (REFGUID) IID_IShellFolder) )
{

    PDEBUG(L"IID_IShellFolder.2");
    IShellFolderCast *shellFolder = (IShellFolderCast *) *ppv;

    orig_EnumObjects = (type_EnumObjects) GetInterfaceMethod(shellFolder->lpVtbl, 4);
    if (!Mhook_SetHook((void **) &orig_EnumObjects, MyEnumObjects))
    {
        PDEBUG(L". CoCreateInstance. Failed to set EnumObjects!");
    }else
    {
        PDEBUG(L". CoCreateInstance. success to set EnumObjects!");
    }
}

but it never go inside that if anyone know why?

Was it helpful?

Solution 2

Just change to

if (IsEqualCLSID(rclsid, (REFGUID) CLSID_ShellFSFolder) )

and now it works

OTHER TIPS

The following lays out how the windows API enumerates files in a directory. Look here.

[EDIT] Missed the intent of your question on my first entry. You want to know how to trap an event when iShellFolder is accessed? You have probably already Looked Here?. It has some example code, and discusses topics around what I think may be useful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top