Calling DCOM/COM+ methods with x86 binary targeting x64 server fails, any idea why?

1

Apologies for any foolish mistakes I've made in my code - I'm new to DCOM and VC++ as a whole. I know the basics but unfortunately not enough to figure this out.

Currently, I have some VC++ code that calls the equivalent of this in Powershell

$excel = [activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Application", "127.0.0.1")); $excel.RegisterXLL("Path\to\x64\dll.dll"). Now if i use this PS Snippet on both x86 Powershell and x64 Powershell targeting an x64 COM server, it, well, suprinsingly works.

I then tried replicating it in C++, and got this far. For clarification, SimpleDLL is a extremely simple DLL that calls WinExec() in DLLmain and pops a calculator App.

https://gist.githubusercontent.com/realoriginal/4178718ee114e3e23c5ebe4651763044/raw/425ce397ed4788c9fac25ae39dcfe1db779c8d99/source.c

This code works fine if the server is x64 and its compiled as an x64 binary. Additionally, it also works if the server is x86 and the binary is compiled to x86.

The problems start arising if I target an x64 server with an x86 binary. I tried using CLSCTX_ACTIVATE_32_BIT_SERVER but that doesnt work at all, as the method is only available in x64.

On the other hand, if I keep it as it is, it sometimes works. To explain what I mean by sometimes, here are my results that I get from it x86 client targeting an x64 Windows server calling this method.

  1. The client triggers an ACCESS VIOLATION with 0x000001 (no idea why)
  2. The client errors at CoCreateInstanceEx() with 0x8007000E: Not enough storage is available to complete this operation.
  3. It loads the x64 DLL and pops the calculator on the remote server

My question is, what could be causing it to fail in those instances that it did, and how could I make it work 100% of the time with x86 client towards x64 COM+ Windows Server?

windows
visual-c++
com+
dcom
asked on Stack Overflow Dec 30, 2018 by walkamile

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0