[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 08:39:23 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 gert.driesen at pandora.be.

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

--- shadow/79117	2006-08-21 15:26:47.000000000 -0400
+++ shadow/79117.tmp.18666	2006-08-23 08:39:23.000000000 -0400
@@ -116,6 +116,56 @@
 
 
 ------- Additional Comments From robertj at gmx.net  2006-08-21 15:26 -------
 Created an attachment (id=17489)
 icall.diff
 
+
+------- Additional Comments From gert.driesen at pandora.be  2006-08-23 08:39 -------
+Robert, some observations/questions:
+
+- SystemDefaultCharSize is hardcoded to 2, that doesn't seem to be 
+right. 
+
+- Are unix systems always ANSI (since all Marshal.***Auto methods are 
+mapped to Ansi icalls) ?
+
+- If SystemDefaultCharSize would return the correct results, then 
+wouldn't it be better modify the Marshal class to invoke the right 
+icall depending on SystemDefaultCharSize instead of using compile 
+time conditionals ?
+
+- mono_lookup_pinvoke_call in loader.c seems to use a wrong mechanism 
+for looking up the entrypoint in the unmanaged dll. If exactspelling 
+is false on the DllImport (PINVOKE_ATTRIBUTE_NO_MANGLE is not set), 
+then it only searches for the mangled name instead of first searching 
+for the unmangled name. 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. More 
+information on this topic is available here: 
+http://msdn2.microsoft.com/en-us/library/7b93s42f.aspx
+
+- Marshal.StringToHGlobalAuto appears to be broken in the same way as
+PtrToStringAuto is. My initial repro demonstrates this as I get the 
+following output after I applied your patch:
+
+395
+395
+Windows saved user ?????????♥???ï registry while an application or 
+service was ......
+
+Updating your patch for StringToHGlobalAuto  fixes this problem, but 
+a better solution would probably be to fix 
+SystemDefaultCharSize.
+
+Can you confirm my observations ?
+
+What do you propose ? Should I split this bug report into separate 
+ones for:
+
+- SystemDefaultCharSize
+- mono_lookup_pinvoke_call
+- PtrToString*/SStringToHGlobal*
+
+Gert


More information about the mono-bugs mailing list