[Mono-dev] Problem with Marshing c arrays as UnmanagedType.LPArray using SizeParamIndex when doing Native -> Managed COM method calls.

Zoltan Varga vargaz at gmail.com
Fri Jun 12 14:39:04 EDT 2009


That looks ok.

           Zoltan

On Fri, Jun 12, 2009 at 8:08 PM, Robert Jordan <robertj at gmx.net> wrote:

> Tom Hindle wrote:
>
>> When checking param index type (which is 1 as SizeParamIndex == 1)
>> (about line 6778) the Array itself is being checked (byte[] pv) as
>> m->sig has had and extra parameter inserted at the beginning of its
>> parameter list. (which I assume is for communicating the HRESULT return
>> value back to the C++ as this is a COM method call.)
>>
>
> It's the converted "this" arg of the managed sig at the front
> of the unmanaged sig.
>
>  Could someone tell me if this is the correct place to adjust the
>> param_num or should spec->data.array_data.param_num be expected to contain
>> the adjusted
>> value?
>>
>
> There are apparently 2 places in cominterop.c where
> spec->data.array_data.param_num has to be increased by one.
>
> The attached patch is fixing one place, but there seems
> to be another one in cominterop_get_native_wrapper_adjusted.
>
> Please try it out as I don't have a test case.
>
> Robert
>
>
> Index: cominterop.c
> ===================================================================
> --- cominterop.c        (revision 135665)
> +++ cominterop.c        (working copy)
> @@ -1917,6 +1917,12 @@
>                                                mspecs[mspec_index] = g_new0
> (MonoMarshalSpec, 1);
>                                                mspecs[mspec_index]->native
> = MONO_NATIVE_VARIANTBOOL;
>                                        }
> +                               } else {
> +                                       /* increase SizeParamIndex because
> we've added a param */
> +                                       if
> (sig_adjusted->params[param_index]->type == MONO_TYPE_ARRAY ||
> +
> sig_adjusted->params[param_index]->type == MONO_TYPE_SZARRAY)
> +                                               if
> (mspecs[mspec_index]->data.array_data.param_num != -1)
> +
> mspecs[mspec_index]->data.array_data.param_num++;
>                                }
>                        }
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090612/861f1e8b/attachment-0001.html 


More information about the Mono-devel-list mailing list