1

I developed an out-of-proc server and trying to marshal input params, but it fails. My .idl file is:

[
    uuid(6a4791c0-f69f-4d78-a591-f549c90c0620),
    object,
    oleautomation
]
interface IBrowserInterraction : IUnknown
{
    HRESULT Unlock([in] BSTR str, [in] int value);
};

[
    uuid(4d36f1c6-9ee6-4d9a-b0aa-6b7195cc5666),
    version(1.0)
]

library BrowserInterractionInterfaceLibrary
{
    [
        uuid(cdebf15b-f12c-4559-a6ac-81620c5056c4)
    ]
    coclass BrowserInterractionInterface
    {
        interface IBrowserInterraction;
    };
};

My server code:

m_bpFactory = boost::make_shared<BrowserPluginInterractionClassFactory>(m_synchronizer);
IUnknown* pUnk;
m_bpFactory->QueryInterface(__uuidof(IUnknown), (void**)&pUnk);
CoRegisterClassObject(__uuidof(BrowserInterractionInterface), pUnk, CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &magic);

My client code:

std::string data("some value")
std::wstring wstr = std::wstring(password.begin(), password.end());
BSTR bs = SysAllocStringLen(wstr.data(), wstr.size());

IBrowserInterraction* interraction = NULL;
CoCreateInstance(__uuidof(BrowserInterractionInterface), NULL, CLSCTX_ALL, __uuidof(IBrowserInterraction), (void**)&interraction);

interraction->Unlock(bs, 123);

I debugged this client call it sends the right value. But server receives this:

enter image description here

I created a proxy\stub library, registered it with regsvr, and included _i.c and _h.h files in client and server code, and everythong was fine.

And client after call of Unlock functions shows me this error:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

fryme
  • 281
  • 4
  • 15
  • 2
    You somehow have a calling convention mismatch between the client and the server. That's *very* hard to explain with the info in the question, nothing looks particularly out of whack although it doesn't use standard COM programming style. Only the proxy could be a candidate, very hard to get wrong as well. Consider the possibility that the proxy is an old version. Rebuild + re-register is advisable. – Hans Passant Aug 08 '13 at 11:44
  • But what is not in style of COM programming in my code? Ok, i'm trying to do it in-process. – fryme Aug 08 '13 at 11:51
  • 2
    Perhaps it's something with PS. It could so happen that you have an earlier built PS library registered, e.g. before you added BSTR parameter to your method. So PS is incorrectly taking your call between client and server. In general, you are on the right track. – Roman R. Aug 08 '13 at 11:55

0 Answers0