Skip to content

Commit

Permalink
2005-02-05 Zoltan Varga <vargaz@freemail.hu>
Browse files Browse the repository at this point in the history
	* loader.c (mono_lookup_pinvoke_call): Add brute-force checking for mangled function names
	under win32.

svn path=/trunk/mono/; revision=40174


Commit migrated from mono/mono@dc89344
  • Loading branch information
vargaz committed Feb 5, 2005
1 parent 0adf397 commit 1797944
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/mono/mono/metadata/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
#ifdef PLATFORM_WIN32
/* Try the stdcall mangled name */
if (!piinfo->addr) {
/* FIX: Compute this correctly */
mangled_name = g_strdup_printf ("%s@%d", import, mono_method_signature (method)->param_count * sizeof (gpointer));
g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
Expand All @@ -779,6 +778,21 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
}
if (!piinfo->addr) {
/* Try brute force, since it would be very hard to compute the stack usage correctly */
for (i = 0; i < 256; i += 4) {
if (!piinfo->addr) {
mangled_name = g_strdup_printf ("%s@%d", import, i);
g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
}
if (!piinfo->addr) {
mangled_name = g_strdup_printf ("_%s@%d", import, i);
g_module_symbol (gmodule, mangled_name, &piinfo->addr);
g_free (mangled_name);
}
}
}
#endif
}

Expand Down

0 comments on commit 1797944

Please sign in to comment.