first of all the exception means that there has been a GPF somewhere. This may *not* be in Squeak itself -- I'd rather think that something strange is going on in the DLL you're trying to access. However, since exceptions are handled by the allocation manager it gets reported there. As far as I see there are three possible causes:
Well, the DLL is a very small implementation of the IUnknown interface, and a factory for object creation. I kinda expect it to be fine (got it from "INSIDE OLE"), but will check it anyway.
a) Calling conventions. I'm not sure that COM uses the __stdcall convention which is used throughout Squeak. If it's not using __stdcall your arguments may be passed in wrong order or the stack might not be cleaned up correctly. Note that functions having no arguments (such as when retrieving a COM interface) *will* work correctly b) You're trying to pass arguments which have to be pointers to some structure and these arguments are wrong. Try checking *what* you're passing on. c) You might have forgotten to pass on the pointer to the interface itself. This is in principle equal to b) since there is just one parameter wrong which is quite a significant pointer.
Unfortunatly, the function I am trying to call is simply AddRef of the IUnknown interface, and thus I am passing no arguments at all. Any other ideas?
Hope this helps,
Thanks. but still looking.
Dave Anderson deandrsn@uiuc.edu
c) You might have forgotten to pass on the pointer to the interface itself. This is in principle equal to b) since there is just one parameter wrong which is quite a significant pointer.
Unfortunatly, the function I am trying to call is simply AddRef of the IUnknown interface, and thus I am passing no arguments at all. Any other ideas?
That's point c) since COM uses C++ calls which always have the pointer to the instance (in your case the interface) as argument. Taken from the Win32 SDK "unknwn.h" file the C style declaration looks like:
ULONG AddRef(IUnknown * This);
You should also keep in mind that all COM functions use C++ virtual methods meaning that the actual function pointer is obtained by a lookup in the interface which is basically an array with all sorts of function pointers. Don't even *think* of interpreting the interface you obtain as a function address. BTW, I'm really interested how you want to interface COM without parsing the entire header files for making sure that you're not coding the indices for the functions wrong. I've tried this once but given up and decided to stay with a wrapper DLL instead.
Bye, Andreas
squeak-dev@lists.squeakfoundation.org