[Mono-bugs] [Bug 43074][Nor] New - unmanaged function returns wrong value

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 15 May 2003 10:39:04 -0400 (EDT)


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 ryabchuk@yahoo.com.

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

--- shadow/43074	Thu May 15 10:39:04 2003
+++ shadow/43074.tmp.26452	Thu May 15 10:39:04 2003
@@ -0,0 +1,83 @@
+Bug#: 43074
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: Window 2000
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: ryabchuk@yahoo.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: unmanaged function returns wrong value
+
+Description of Problem:
+unmanaged function returns wrong value
+
+Steps to reproduce the problem:
+1. 
+Create and comiple simple DLL using the following
+command line
+
+cl /LD dlltest.c
+
+/* ----------- dlltest.c --------------- */
+__declspec( dllexport ) int __stdcall createWindow(
+  int dwExStyle,      
+  char* lpClassName,  
+  char* lpWindowName, 
+  int dwStyle,        
+  int x
+)
+{
+return 0;
+}
+/* ----------- dlltest.c --------------- */
+
+Create and compile test application in C#:
+csc test.cs
+
+/* ----------- test.cs --------------- */
+using System;
+using System.Runtime.InteropServices;
+
+class Hello
+{
+[DllImport ("dlltest.dll",
+            EntryPoint="_createWindow@20",
+            CharSet=CharSet.Ansi,
+            CallingConvention=CallingConvention.StdCall)]
+internal static extern int createWindow (
+                        int dwExStyle, string lpClassName, 
+                        string lpWindowName, int dwStyle, 
+                        int x);
+
+public static void Main(String[] args)
+{
+        int res = createWindow (0, "classname", "windowName", 0, 10);
+        Console.WriteLine ( "res = " + res.ToString());
+}
+}
+/* ----------- test.cs --------------- */
+
+Actual Results:
+
+When I execute it using mono test.exe the output is:
+
+res = 16006969
+
+
+Expected Results:
+
+When I execute test.exe using MS runtime I get the following
+output, which is correct:
+
+res = 0
+
+How often does this happen? 
+always