Typelib marshalling BSTRs

Ove Kaaven ovek at arcticnet.no
Sun Jul 20 06:29:13 CDT 2003


fre, 18.07.2003 kl. 17.53 skrev Mike Hearn:
> Well, I've made pretty good progress, but am a bit stuck with this
> problem. Basically:
> 
> 003d:trace:ole:TL_Marshal   parameter 1
> 003d:trace:ole:TL_Marshal    name   : L"rgszNames"
> 003d:trace:ole:TL_Marshal    type   : 26
> 003d:trace:ole:TL_Marshal    flags  : 01
> 003d:trace:ole:TL_MarshalType    dereferencing PTR 0x52edf7d0 =>
> 0x54331260
> 003d:trace:ole:TL_MarshalType    dereferencing PTR 0x54331260 =>
> 0x54331270
> 003d:trace:ole:TL_MarshalType    marshaling byte 100
> 
> As you can see, it's marshalling IDispatch across apartment boundaries,
> but it gets this parameter wrong. The double dereference seems correct,
> but marshalling a byte is not - I think it should be a BSTR.
> 
> rgszNames is a parameter of IDispatch::GetIDsFromNames, which is defined
> as an OLECHAR FAR* FAR*

Sorry for the late answer, I've been busy attending debconf3...

IDispatch should not be marshalled by the typelib marshaller, the method
arguments it use cannot be represented by a typelib, as you've seen. The
MIDL code in oaidl_p.c must be used instead. You need to change the
registry to use the right marshaller, I think the necessary
winedefault.reg changes were included in my patch, but I'm not sure.

> I can't figure out where the typeinfo data for IDispatch is coming from
> though, hence my stuckness.

stdole32.tlb

>  BTW, is this line really correct:
> 
> TL_Unmarshal(pStm, pInfo, pDesc, PARAMFLAG_FIN, args, &argc, pChannel,
> &is_iid);
> 
> shouldn't it be:
> 
> TL_Unmarshal(pStm, pInfo, pDesc, PARAMFLAG_FIN, (DWORD*)&args[0], &argc,
> pChannel, &is_iid);

That should be the same thing. In expressions, the compiler will treat
an array variable as a pointer to its first element. This feature has
always been in C (and have been useful for no ends of code obfuscation
tricks, as well as numerous novice-programmer bugs). In my opinion,
&args[0] is more unredable than just using args, so the latter is my
preferred style. But I'm not sure what you thought it meant?





More information about the wine-devel mailing list