Skip to content
Browse files

Allow pointers to structures to be passed in pinvoke, MS seems to all…

…ow this at least in some cases. Fixes bxc #158.

This partially reverts c4d9097.
  • Loading branch information...
1 parent c740311 commit 1e910229a84f8be19ce30e53be0e7e6f2bf6e262 @vargaz vargaz committed
Showing with 6 additions and 0 deletions.
  1. +3 −0 mono/metadata/marshal.c
  2. +3 −0 mono/tests/pinvoke2.cs
View
3 mono/metadata/marshal.c
@@ -7878,10 +7878,13 @@ emit_marshal_ptr (EmitMarshalContext *m, int argnum, MonoType *t,
switch (action) {
case MARSHAL_ACTION_CONV_IN:
+ /* MS seems to allow this in some cases, ie. bxc #158 */
+ /*
if (MONO_TYPE_ISSTRUCT (t->data.type) && !mono_class_from_mono_type (t->data.type)->blittable) {
char *msg = g_strdup_printf ("Can not marshal 'parameter #%d': Pointers can not reference marshaled structures. Use byref instead.", argnum + 1);
mono_mb_emit_exception_marshal_directive (m->mb, msg);
}
+ */
break;
case MARSHAL_ACTION_PUSH:
View
3 mono/tests/pinvoke2.cs
@@ -1300,6 +1300,8 @@ public struct Amd64Struct1Gen<T> {
* Pointers to structures can not be passed
*/
+ /* This seems to be allowed by MS in some cases */
+ /*
public struct CharInfo {
public char Character;
public short Attributes;
@@ -1321,6 +1323,7 @@ public struct CharInfo {
}
return 1;
}
+ */
/*
* LPWStr marshalling

0 comments on commit 1e91022

Please sign in to comment.
Something went wrong with that request. Please try again.