The premise:
I have an old, 32-bit COM shell extension (written in C++). After years of incompatibility with newer, 64-bit systems, we are now updating it to work in a 64-bit Windows environment.
The trick:
The 32-bit COM DLL contains dependencies on third-party libraries, for which there are no 64-bit builds available. As such, we cannot simply 'recompile in 64-bit.' Given this restriction, we have decided the easiest approach will be to create a 'thin' 64-bit DLL; essentially an empty DLL defining only the required interfaces, and redirecting all calls to the underlying 32-bit COM DLL.
I believe this communication between a 64-bit COM DLL and a 32-bit COM DLL is possible, through the use of COM surrogates. Unfortunately, this appears to be a very specific/niche topic, and I have been unable to find many resources about how to call 32-bit COM APIs from a 64-bit COM DLL.
The questions:
Clarifications:
This question has a number of aspects which make it unique, setting it apart from the question "Using 32-bit shell extensions in Windows 7 64-bit."
I am not asking if a 32-bit shell extension can be loaded in a 64-bit explorer process, as the referenced question does. Rather, I am asking if it is possible to create a thin 64-bit implementation of the DLL, which acts as a bridge between the 64-bit explorer process and the 32-bit implementation.
To be clear, this is not possible.
But maybe this is?
Yes, it is doable with DCOM and your worst problems will be setting up permissions for the DCOM "component" and making data marshaling work.
Is this 'thin COM wrapper' a reasonable approach, for enabling 64-bit functionality of a 32-bit COM DLL?
Yes, we've done this once when we had to provide an in-proc COM server with both 32-bit and 64-bit implementations. We basically had such thin server which would be implemented in both 32 and 64 bits (the consumer would load the appropriate one) and redirect calls to a 32-bit outproc server hosted in DCOM.
Is there any reason this approach would not work specifically for Windows Shell Extensions?
You may be unable to proper setup permissions for the outproc server. Most likely this will work. Cannot imagine any other reason.
Would the 64-bit interface definitions use identical GUIDs as their 32-bit counterparts?
Yes. A COM interface is a contract. You can have as many implementations of a contract as you wish.
Are there any good resources for calling a 32-bit COM API from within a 64-bit COM DLL?
Nothing special required. Just call CoCreateInstance()
with CLSCTX_ALL
and that's it.
Your primary concern will be marshaling. You have to marshal data between client and server which will now be in different processes. Your best bet is using Automation marshaling (aka typelib marshaling). If it happens that the original interface is not Automation compatible then try introducing a new interface which is Automation compatible and your wrapper will then server as an adapter. It may so happen that you will be unable to design a new Automation compatible interface for your task but try this because this is your best bet.
Whenever anything fails to work - something doesn't marshal, some dependent files are not found - use Process Monitor to see what's going on that fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With