错误的编组

时间:2013-08-08 11:01:57

标签: c++ com marshalling out-of-process

我开发了一个out-of-proc服务器并尝试编组输入参数,但它失败了。 我的.idl文件是:

[
    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;
    };
};

我的服务器代码:

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);

我的客户代码:

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);

我调试了这个客户端调用,它发送了正确的值。但是服务器收到了这个:

enter image description here

我创建了一个proxy \ stub库,用regsvr注册了它,并在客户端和服务器代码中包含了_i.c和_h.h文件,而且每个都很好。

在解锁Unlock函数后客户端显示我的错误:

运行时检查失败#0 - ESP的值未在函数调用中正确保存。这通常是调用使用一个调用约定声明的函数和使用不同调用约定声明的函数指针的结果。

0 个答案:

没有答案