How To Disable Shell Extension In FileOpen Dialog - shell-extensions

I am talking about windows shell extensions.
I have a shell extension which could show the specific properties of my customized file type, say, *.filetype. And of course it will cause my shell extension dlls being loaded into the explorer.exe process. But now if I fire the FileOpen dialog in any application and check the file properties inside that dialog(notepad as an example), then these shell extension dlls would be loaded into notepad.exe process, which is the case I want to avoid.
So is it possible to disable a specific shell extension in FileOpen Dialog?
Thanks.

Create a shim dll which does nothing but load your real (big) shell extension dll.
The only job of that shim dll is to check whether the current process is "explorer.exe". If it is, the shim loads the real dll and forwards all calls there. If it's not, the shim doesn't load your real dll but simply returns E_NOTIMPL or something like that to all requests.

Related

Is it possible on windows to prevent other applications hooking in system DLLs

I am desperately looking for a cause of crashes in my Qt-based Application.
After some observation I've detected, that alone opening a QFileDialog, which is standard windows file dialog, even without selecting any file, causes the application to crash after some minutes. It doesn't happen on all machines.
I've opened my application in dependency walker and the profiling revealed, that opening of file dialog loads tons of DLLs, which I don't need in my application - all the tools which hooked in windows shell. Among the others - TortoiseSVN, which even makes depends to freeze.
Is it possible in an application context to prevent other DLLs like codecs or shell-hooks to be loaded?
Is it at least possible to create a QFileDialog without loading all the tool hooked in windows?
This is definitely possible, but it's not trivial. What you have to do is insert an API hook on LoadLibrary (and/or the Native API equivalent.) When your hook is called, you can examine the DLL filename and decide whether you want to pass it along to the real LoadLibrary or return an error.
A couple places to find more info on API hooks:
A tutorial on CodeProject
Microsoft Detours is Microsoft's library for API hooking.
Now all of that said, for your specific situation you may be better off just changing your TortoiseSVN settings. If you set the include/exclude paths in Tortoise to only look at directories on your computer that contain SVN repos, I bet this freeze will go away as long as you avoid those directories.

Write to a file from Windows Explorer extension with UAC dialog

I need to copy a virtual file from my Windows Explorer namespace extension to a restricted location (for example to C:). Normally for such task one need to run a new process elevated that should do the operation.
However in this case I'm running in explorer.exe process context, and I need to get the same "You'll need to provide administrator permission to copy..." dialog that Windows Explorer presents, rather than a UAC dialog for a new process.
Anyone knows what function Windows Explorer uses to achieve this? ShFileOperation does what I need, but seems to work only for file system objects. How Windows Explorer copies files from zip archives which are represented via namespsace extensions too? Thank you

Different processes are using same xml file

I wrote mfc c++ console application. This Application is using "a dll" and this dll use one "xml file" for store some datas.
I need multiple process for my design and also I can start multiple process from my application at the start time with "Windows Service Application".They are running as a "System Process".They work nice.
Normally if my application runs as a user process,XML File is created in same directory with process. But If it runs as System process, XML File is created in "C:\Windows\SysWOW64" folder by dll. So all processes are using same xml file.
Problem is Dll wasn't written by me so i cant change anything on it. Can i do something for this?
My OS is "Windows Server 2008 R2"
thnx in advance
During installation of service, you can set command line parameter for example: -directory c:\MyAppFolder. In your application get this parameter and change working directory by SetCurrentDirectory method. Dll you are calling creates xml file in working directory, which will be c:\MyAppFolder. If you create more services make sure each of them has unique directory.

DLL registering and Unregistering

I have created a context menu dll (C++ COM DLL) to show iconoverlays (using IShellIconOverlayIdentifier interface). To show the iconoverlays initially I have restarted the explorer. If the system restarts, to display the icon overlays, I need to manually register the dll and restart the explorer once again.
Is there any way to register my com dll before explorer starts. ??
Also, if I uninstall my application the DLL can not be removed. To remove the dll, I need to stop the explorer and other applications (For eg, thunderbird, visual studio) which use my dll, then unregister the dll. Then only I am able to delete the Dll. Is this correct.. Or any thing else I can do.
Thanks in Advance.
I wonder why you have to register your DLL on every restart of your system.
On the other hand it is quite normal that you have to restart explorer.exe and related programs to let the changes - especially done by shell extensions - take effect.
Further, the beahivour you encounter upon deletion is the standard procedure one has to go through when you want to delete your shell extension DLL.
You may want to use self-registrating DLLs. They include information required to store themselves in the operating system's registry and will automatically store themselves on your machine and become accessible when needed.
A detailed explanation can be found here : Self-Registration (COM)

Recompile MFC DLL while client exe is running

Is it possible to recompile an MFC DLL while its "client" executable is running, and have the executable detect and pick up the new changes? If it's possible, is it foolish? Being able to recompile the DLL without restarting the exe would save some time in my coding workflow. I am using Visual Studio 2008, code is written in native C++/MFC. My code changes are entirely contained in the DLL, not the EXE.
Thanks!
Unfortunately, unless the executable has support for hot-swapping DLLs, you can't do it. The standard DLL loading mechanism in Windows will load it either at the start of the process or at first use of a function exported by the DLL and will not watch the file for changes in order to reload it. Also, depending on how the DLL is loaded, the file might be locked for changes.
You will have to stop your client executable before recompiling.
Yes, it's possible. You'll need to make sure the executable explicitly loads your DLL (via LoadLibrary). If your executable implicitly loads your DLL you'll have the issues that Franci described.
To update the library while the executable is running:
Define some convention for staging the new version of the DLL. It could be in a separate folder, or with a different file name/extension.
Have a means of checking for a new version of the DLL. This could be in response to some specific gesture in the user interface, or you could monitor the directory for changes from a background thread.
When you see a new version, unload the old version (FreeLibrary), then delete it and move the new version to the desired location and reload it (LoadLibrary).
If your DLL implements any COM objects, let me know and I'll give you some additional tips.