If you're calling from C++ there isn't really any marshaling.
I'd guess that your calling code is not compiled with the right
defines. Specifically, you may not be defining XP_WIN and thus
the calling convention being used is incorrect. The interface
mathods you are calling expect the __stdcall convention. And this
is indicated by the #ifdefs in nsCOM.h -
http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsCom.h#50
The code you are calling was compiled with XP_WIN defined. The
calling code must have also been compiled with XP_WIN defined for
this to work right. Otherwise the passing of params will be wrong
- Oh and it will probably crash later too.
> I have tried to use xpcom.dll instead of xpcom.dll
huh?
Hope this helps.
John.
Dan Lange wrote:
>
> I am trying to use the RDF service, which I obtained through XPCOM. I
> didn't have any difficulty getting the service from the service manager.
> Whenever I call any methods of the RDF service, however, the method recieves
> a different set of arguments then I passed in, and it crashes. It looks to
> me like a DLL related problem marshalling the arguments, but I am at a loss
> as to how to fix it. Any help would be appreciated.
>
> Details:
> I am writing a DLL that makes XPCOM calls. It is not itself an XPCOM
> object.
> I am compiling on my DLL a windows NT platform using my own makefile, not
> the Mozilla makefile. I use the DLL from within a mozilla browser.
>
> My code:
> static nsIRDFService* gRDFService = NULL;
> ...
> rv = nsServiceManager::GetService(kRDFServiceCID,
> NS_GET_IID(nsIRDFService),
> (nsISupports**) &gRDFService);
> ...
> printf("NbRdfInterface: gRDFService: %X\n",gRDFService);
> printf("NbRdfInterface: url: %s\n",url);
> ...
> rv = gRDFService->GetDataSource(url, NULL);
> // originally: rv =
> gRDFService->GetDataSource(url,getterAddRefs(datasource)); I changed it to
> isolate the problem.
> ...
>
> Instrumentation that I have put into nsRDFService.cpp:
> NS_IMETHODIMP
> RDFServiceImpl::GetDataSource(const char* aURI, nsIRDFDataSource**
> aDataSource)
> {
> printf("\nRDFService: GetDataSource: this = %X\n",this);
> printf("RDFService: GetDataSource: aURI = %s\n",aURI);
> printf("RDFService: GetDataSource: mNamedDataSources =
> %X\n\n",mNamedDataSources);
> ...
>
> Mozilla Debug output:
> ...
> // Other components calling the RDF service. It works for them...
> RDFService: GetDataSource: this = A11410
> RDFService: GetDataSource: aURI = rdf:local-store
> RDFService: GetDataSource: mNamedDataSources = A11320
>
> RDFService: GetDataSource: this = A11410
> RDFService: GetDataSource: aURI = rdf:charset-menu
> RDFService: GetDataSource: mNamedDataSources = A11320
>
> RDFService: GetDataSource: this = A11410
> RDFService: GetDataSource: aURI = rdf:local-store
> RDFService: GetDataSource: mNamedDataSources = A11320
> ...
>
> // My component has a valid set of arguments.
> NbRdfInterface: gRDFService: A11410
> NbRdfInterface: url: file:/C:/jsrc/rdfTest.rdf
>
> // My Component calls the RDF service.
> RDFService: GetDataSource: this = 1C8A0450
> RDFService: GetDataSource: aURI =
> RDFService: GetDataSource: mNamedDataSources = 64722F63
> ...
> // Boom!
> ...
>
> For reasons that I don't understand, the parameters that I passed to
> GetDataSource are not the ones that it recieves. I have tried working the
> problem from the following angles:
>
> 1) Calling GetServiceManager in an attempt to initialize the service
> manager.
> This didn't help. Plus, you will observe that the service manager
> is giving me the correct pointer to the RDF service, I just can't seem to
> use it.
>
> 2) Calling a different RDF service method.
> No dice. The other method had exactly the same problem.
>
> 3) Fiddling with different ways of linking things.
> As near as I can figure out, my DLL statically links xpcom.lib, but
> not any rdf libraries.
> I have tried to use xpcom.dll instead of xpcom.dll, but I couldn't get
> it to link. I have also tried linking rdf.lib, which is a step in the wrong
> direction, but that didn't work either.
>
> -- Dan Lange