How to restrict icon handler to be accessed by a particular process?

94 views Asked by At

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

There are 1 answers

4
Igor Tandetnik On

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.