Calling convention error while trying to call COM sever function
I am relatively new to COM programming and I am trying to get access to third party DCOM component (EXE module) from my client program on C++(VC6). I suppose that this component was written in VB6. First I have made a simple client program on VB6 and it work smooth with DCOM component.
Below is the example of client's VB6 code, which I’am tring translate to: VC++
Private cDevConnector As DevControlC.DevControlConnector
Private WithEvents cCtrl As DevControlC.DevControl
Set cDevConnector = New DevControlC.DevControlConnector
Set cCtrl = cDevConnector.DevControl
Call cCtrl.DevControlInitialize
I’ve used OLE View utility to get interface’s definitions (idl, tlb, h files) from the component and use these data.
pCtrl = pDevConnector ->GetDevControl ();
if (NULL!= pCtrl) {
short status;
hr = pObj->SemControlInitialize (&status);
//here error rises...
}
pDevConnector.Release();
CoUninitialize() ;
return;
}
I can get pointer to _DevControl interface (pCtrl) via _DevControlConnector interface (I can’t call it directly because of its properties). The error arises when I’am trying to call DevControlInitialize() method of the _DevControl interface. The error message is:
Module:
"File: i386/chkesp.c
Line: 42
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."
The _ DevControl:evControlInitialize() method is declared in header file (header was extracted from component by OLE View utility ) as:
Re: Calling convention error while trying to call COM sever function
The ESP corruption is typically a result of compiling with different calling convention, but not limited to. So in your case it's most probably a trivial stack corruption because of buffer overflow or something.
Re: Calling convention error while trying to call COM sever function
Thank you for your answer.
Using the description of the third party component interfaces, I wrote a similar COM component (emulation) in VB. Similar code of VC client works with my new component without problems.
Bookmarks