0

I have a icon handler for my custom file. How I can restrict icon handler functionality so that it can be called by explorer.exe threads only?

1 Answers1

2

Well, you could use GetModuleFileName(NULL) to find out which EXE your handler is loaded into. You could do that in a COM method (and return, say, E_FAIL if you think are in a wrong process), or in DllMain so that your handler fails to even load.

However, it's not clear why you would want to do this. For example, an icon handler is used by the standard Open File dialog in any application; do you not want your icon to appear there?

If you envision this as some kind of a security measure, then it won't work very well. A determined attacker would write their own shell extension, get loaded into Explorer, and access your handler from there.

Igor Tandetnik
  • 50,461
  • 4
  • 56
  • 85
  • Thanks!! It works. I also found same suggestion here http://www.codeproject.com/Articles/8027/Restricting-DLL-loading . I want to do this because I can manage read/write of my custom file from the threads coming from explorer.exe only. Threads coming from other processes like standard Open File dialog are creating deadlock. Yes I will not be able to see correct icon in those dialogs. – Harish Surana Aug 06 '13 at 07:46
  • 2
    I think it may be more productive to correct the deadlock and other flaws that prevent use outside Explorer. – Medinoc Aug 06 '13 at 09:07
  • Especially since explorer.exe may be multiple processes as well. – Jonathan Potter Aug 06 '13 at 20:11
  • multiple explorer.exe is not a problem for me. – Harish Surana Aug 09 '13 at 08:50