#include <mono/metadata/reflection.h>
#include <mono/metadata/coree.h>
#include <mono/utils/mono-io-portability.h>
+#include <mono/utils/atomic.h>
#ifndef HOST_WIN32
#include <sys/types.h>
{"System.Management", 0},
{"System.Messaging", 0},
{"System.Runtime.Remoting", 0},
+ {"System.Runtime.Serialization", 3},
{"System.Runtime.Serialization.Formatters.Soap", 0},
{"System.Security", 0},
{"System.ServiceProcess", 0},
check_path_env (void)
{
const char* path;
-#ifdef __native_client__
- path = nacl_mono_path;
-#else
path = g_getenv ("MONO_PATH");
+#ifdef __native_client__
+ if (!path)
+ path = nacl_mono_path;
#endif
if (!path || assemblies_path != NULL)
return;
return NULL;
/* Not a well known Mono executable, we are embedded, cant guess the base */
- if (strcmp (p, "/mono") && strcmp (p, "/monodis") && strcmp (p, "/mint") && strcmp (p, "/monodiet"))
+ if (strcmp (p, "/mono") && strcmp (p, "/mono-sgen") && strcmp (p, "/pedump") && strcmp (p, "/monodis") && strcmp (p, "/mint") && strcmp (p, "/monodiet"))
return NULL;
*p = 0;
InterlockedIncrement (&assembly->ref_count);
}
-#ifndef DISABLE_ASSEMBLY_REMAPPING
+#define SILVERLIGHT_KEY "7cec85d7bea7798e"
+#define WINFX_KEY "31bf3856ad364e35"
+#define ECMA_KEY "b77a5c561934e089"
+#define MSFINAL_KEY "b03f5f7f11d50a3a"
+
+typedef struct {
+ const char *name;
+ const char *from;
+ const char *to;
+} KeyRemapEntry;
+
+static KeyRemapEntry key_remap_table[] = {
+ { "Microsoft.CSharp", WINFX_KEY, MSFINAL_KEY },
+ { "System", SILVERLIGHT_KEY, ECMA_KEY },
+ { "System.ComponentModel.Composition", WINFX_KEY, ECMA_KEY },
+ { "System.ComponentModel.DataAnnotations", "ddd0da4d3e678217", WINFX_KEY },
+ { "System.Core", SILVERLIGHT_KEY, ECMA_KEY },
+ { "System.Numerics", WINFX_KEY, ECMA_KEY },
+ { "System.Runtime.Serialization", SILVERLIGHT_KEY, ECMA_KEY },
+ { "System.ServiceModel", WINFX_KEY, ECMA_KEY },
+ { "System.ServiceModel.Web", SILVERLIGHT_KEY, WINFX_KEY },
+ { "System.Windows", SILVERLIGHT_KEY, MSFINAL_KEY },
+ { "System.Xml", SILVERLIGHT_KEY, ECMA_KEY },
+ { "System.Xml.Linq", WINFX_KEY, ECMA_KEY },
+ { "System.Xml.Serialization", WINFX_KEY, MSFINAL_KEY }
+};
+
+static void
+remap_keys (MonoAssemblyName *aname)
+{
+ int i;
+ for (i = 0; i < G_N_ELEMENTS (key_remap_table); i++) {
+ const KeyRemapEntry *entry = &key_remap_table [i];
+
+ if (strcmp (aname->name, entry->name) ||
+ !mono_public_tokens_are_equal (aname->public_key_token, (const unsigned char*) entry->from))
+ continue;
+
+ memcpy (aname->public_key_token, entry->to, MONO_PUBLIC_KEY_TOKEN_LENGTH);
+
+ mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
+ "Remapped public key token of retargetable assembly %s from %s to %s",
+ aname->name, entry->from, entry->to);
+ return;
+ }
+}
+
static MonoAssemblyName *
mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_aname)
{
/* Remap assembly name */
if (!strcmp (aname->name, "System.Net"))
dest_aname->name = g_strdup ("System");
+
+ remap_keys (dest_aname);
mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
"The request to load the retargetable assembly %s v%d.%d.%d.%d was remapped to %s v%d.%d.%d.%d",
return dest_aname;
}
-
+
+#ifndef DISABLE_ASSEMBLY_REMAPPING
first = 0;
last = G_N_ELEMENTS (framework_assemblies) - 1;
first = pos + 1;
}
}
+#endif
+
return aname;
}
-#endif
/*
* mono_assembly_get_assemblyref:
{
MonoAssembly *res;
MonoAssemblyName *aname, base_name;
-#ifndef DISABLE_ASSEMBLY_REMAPPING
- MonoAssemblyName maped_aname;
-#endif
+ MonoAssemblyName mapped_aname;
gchar *fullname, *gacpath;
gchar **paths;
if (!mono_assembly_name_parse (name, aname))
return NULL;
-#ifndef DISABLE_ASSEMBLY_REMAPPING
/*
* If no specific version has been requested, make sure we load the
* correct version for system assemblies.
*/
if ((aname->major | aname->minor | aname->build | aname->revision) == 0)
- aname = mono_assembly_remap_version (aname, &maped_aname);
-#endif
+ aname = mono_assembly_remap_version (aname, &mapped_aname);
res = mono_assembly_loaded (aname);
if (res) {
{
MonoAssembly *result;
char *fullpath, *filename;
-#ifndef DISABLE_ASSEMBLY_REMAPPING
MonoAssemblyName maped_aname;
-#endif
MonoAssemblyName maped_name_pp;
int ext_index;
const char *ext;
int len;
-#ifndef DISABLE_ASSEMBLY_REMAPPING
aname = mono_assembly_remap_version (aname, &maped_aname);
-#endif
/* Reflection only assemblies don't get assembly binding */
if (!refonly)
mono_assembly_loaded_full (MonoAssemblyName *aname, gboolean refonly)
{
MonoAssembly *res;
-#ifndef DISABLE_ASSEMBLY_REMAPPING
MonoAssemblyName maped_aname;
aname = mono_assembly_remap_version (aname, &maped_aname);
-#endif
res = mono_assembly_invoke_search_hook_internal (aname, refonly, FALSE);