http://bugs.winehq.org/show_bug.cgi?id=20296
--- Comment #53 from Amos Wenger amos@official.fm 2011-04-10 15:28:18 CDT --- (In reply to comment #52)
I checked for svchost.exe on Windows: The process that starts dllhost.exe has the commandline "svchost.exe -k DcomLaunch". This is the "DCOM Server Process Launcher" Windows Service. Process Explorer shows the DLL rpcss.dll for this service.
Okay, thanks a lot for the service name, so it means I could modify wine so that it registers dllhost.exe as a service with the name DcomLaunch?
It's weird that Process Explorer shows rpcss.dll for this service because rpcss.dll "primarily provides the infrastructure for COM, but a portion of rpcss.dll is used for the EPM. An RPC server contacts the EPM to receive dynamic endpoints and register those endpoints in the EPM database. RPC clients contact the EPM from the protocol-engine level to resolve endpoints when establishing a connection with an unknown RPC server endpoint." (see http://technet.microsoft.com/en-us/library/cc738291(v=ws.10).aspx )
Then again, I don't think we can register services as .exe, but only, DLLs right? I've just checked in regedit (in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DcomLaunch\Parameters), and it's indeed rpcss.dll I've also just grepped wine for rpcss and.. well there's an rpcss.exe (itself not exactly interface-compatible with windows') but no trace of a .dll whatsoever. Afaik it needs to be a DLL that has a Service EntryPoint, so it could be any DLL we create, really?
One thing is bugging me though - even if we could do svchost.exe -k DcomLaunch, how do we finally know which CLSID (and thus which dll) to load? At least when we do CreateProcess(dllhost.exe) we can pass an argument to dllhost.exe. But passing through svchost.exe I don't see how we can do the same?
When I run a program with Wine there is already another svchost.exe running, so Wine is already able to run services. It is started by services.exe just like it is on Windows. I guess that the process that needs the surrogate sends a "message" to the DCOM Server Process Launcher service and the service then starts dllhost.exe.
Ah.. so let me recap:
- A process needs a DLL to be loaded in a surrogate - This process tries to communicate with the service DcomLaunch - If it fails, it starts it with svchost.exe -k DcomLaunch - It somehow "sends a signal" to the DcomLaunch service that it needs such CLSID to be loaded - The DcomLaunch service (apparently implemented in rpcss.dll) starts dllhost.exe via CreateProcess, with the right command-line argument - When the process knows that dllhost.exe has correctly registered the required CLSID, it retrieves it via CoGetClassObject and uses it
Now the remaining fuzzy parts are: how do we "send a signal" to a service (via COM, too?), and when do we know when a CLSID is registered (currently I do an optimistic Sleep(5000L) but it's fugly)