Reputation: 1
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?
Upvotes: 0
Views: 99
Reputation: 52471
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.
Upvotes: 2