[Mono-bugs] [Bug 79117][Nor] Changed - [PATCH] Marshal.StringToHGlobalAuto & PtrToStringAuto not working as expected

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Aug 23 11:20:37 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by robertj at gmx.net.

http://bugzilla.ximian.com/show_bug.cgi?id=79117

--- shadow/79117	2006-08-23 08:57:54.000000000 -0400
+++ shadow/79117.tmp.19599	2006-08-23 11:20:37.000000000 -0400
@@ -173,6 +173,51 @@
 ------- Additional Comments From gert.driesen at pandora.be  2006-08-23 08:57 -------
 Small correction, mono_lookup_pinvoke_call only uses the mangled name 
 first if charset is PINVOKE_ATTRIBUTE_CHAR_SET_AUTO and the platform 
 is WIN32. This is still wrong of course.
 
 
+
+------- Additional Comments From robertj at gmx.net  2006-08-23 11:20 -------
+Gert, if you'd look at the attached patch, you'll see that
+it already addresses both PtrToString*/StringToHGlobal* :-)
+
+SystemDefaultCharSize is a constant by now.
+
+Maybe something like that:
+
+
+Index: System.Runtime.InteropServices/Marshal.cs
+===================================================================
+--- System.Runtime.InteropServices/Marshal.cs	(revision 61596)
++++ System.Runtime.InteropServices/Marshal.cs	(working copy)
+@@ -54,6 +54,11 @@
+ 		public static readonly int SystemMaxDBCSCharSize = 2; // don't know
+what this is
+ 		public static readonly int SystemDefaultCharSize = 2;
+ 
++		static Marshal ()
++		{
++			SystemDefaultCharSize = Environment.OSVersion.Platform ==
+PlatformID.Win32NT ? 2 : 1;
++		}
++
+ #if !NET_2_0
+ 		private Marshal () {}
+ #endif
+
+
+
+> Also, when the charset is set to 
+> PINVOKE_ATTRIBUTE_CHAR_SET_AUTO, it should use the character size of 
+> the system (1 or 2) to determine whether to look for the ANSI ("A") 
+> or Unicode ("W") function. Right now, the unicode function is always 
+> used on WIN32, and the ANSI one on all other platforms. 
+
+This is not a bug, because Mono doesn't run on Win9x/ME,
+and, if it would do, the unicode emulation layer must
+be used anyway, which leads to a SystemDefaultCharSize = 2
+again.
+
+
+BTW, all patches assume that Mono doesn't run on Win9x/ME.
+


More information about the mono-bugs mailing list