Bugzilla – Bug 324429
[PATCH] [WIN32] EntryPointNotFoundException locating CopyMemory function in kernel32
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by gert.driesen@pandora.be 2007-05-28 07:23:08 MST ---- Running the following code using Mono results in an EntryPointNotFoundException: using System; using System.Runtime.InteropServices; class Program { [DllImport ("kernel32.dll", EntryPoint="CopyMemory")] internal extern static void Win32CopyMemory( IntPtr Destination, IntPtr Source, int length); static void Main () { Win32CopyMemory (IntPtr.Zero, IntPtr.Zero, 5); } } ---- Additional Comments From robertj@gmx.net 2007-05-28 08:36:03 MST ---- According to the MSDN docs of CopyMemory, this export doesn't exist. It hat a macro or inline implementation. The export list of kernel32.dll doesn't contain CopyMemory either, so the MS.NET's runtime seems to map CopyMemory to something else, maybe to RtlCopyMemory or to an internal (safer) implementation. ---- Additional Comments From gert.driesen@pandora.be 2007-05-28 08:42:04 MST ---- It's being used in the MWD Drag&Drop implementation for Windows. I guess it never worked then. ---- Additional Comments From gert.driesen@pandora.be 2007-05-28 09:23:32 MST ---- that should've been MWF of course ---- Additional Comments From robertj@gmx.net 2007-05-28 14:06:05 MST ---- Created an attachment (id=172070) kernel32-inline-symbols.diff ---- Additional Comments From robertj@gmx.net 2007-05-28 14:10:35 MST ---- Any idea where to put these wrappers? I've chosen loader.c merely at will (while looking whether the <dllentry dll="__Internal"> trick will do). ---- Additional Comments From vargaz@gmail.com 2007-05-29 08:20:45 MST ---- This patch looks ok to check in. I think the functions should go to marshal.c with the other interop icalls. ---- Additional Comments From lupus@ximian.com 2007-05-29 09:46:34 MST ---- As zoltan says, marshal.c is likely a better place, but please change the names to have a mono_win32_compat_ prefix and provide also the non-windows implementation using memcpy etc. ---- Additional Comments From robertj@gmx.net 2007-05-29 17:51:12 MST ---- Fixed in SVN r78159. ---- Additional Comments From miguel@ximian.com 2007-05-29 18:08:35 MST ---- Mhm, somehow my comment from this morning did not get posted. We decided some time ago that we would not be trying to emulate the Win32 API in Mono. And for the cases that we did (and we later decided this was also a bad idea) we would put them in support/supportw.so library. What changed? ---- Additional Comments From robertj@gmx.net 2007-05-29 18:32:30 MST ---- The fix was necessary for Windows. It works under Unix just because the dllmap doesn't restrict it (like it did in my first patch). Imported an attachment (id=172070) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>Windows XP SP2</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".