This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mono / metadata / icall.c
index cfad9c843f4219e8d681dc16b0d03902238b1992..7e76bf279d4e6c2d0bb1b30e0aa728ef2eff92d5 100644 (file)
@@ -13,6 +13,7 @@
 #include <glib.h>
 #include <stdarg.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/time.h>
 #include <unistd.h>
 #if defined (PLATFORM_WIN32)
@@ -21,6 +22,7 @@
 
 #include <mono/metadata/object.h>
 #include <mono/metadata/threads.h>
+#include <mono/metadata/threads-types.h>
 #include <mono/metadata/threadpool.h>
 #include <mono/metadata/monitor.h>
 #include <mono/metadata/reflection.h>
@@ -32,7 +34,9 @@
 #include <mono/metadata/mono-endian.h>
 #include <mono/metadata/tokentype.h>
 #include <mono/metadata/unicode.h>
-#include <mono/metadata/appdomain.h>
+#include <mono/metadata/domain-internals.h>
+#include <mono/metadata/metadata-internals.h>
+#include <mono/metadata/class-internals.h>
 #include <mono/metadata/marshal.h>
 #include <mono/metadata/gc-internal.h>
 #include <mono/metadata/rand.h>
 #include <mono/metadata/locales.h>
 #include <mono/metadata/filewatcher.h>
 #include <mono/metadata/char-conversions.h>
+#include <mono/metadata/security.h>
+#include <mono/metadata/mono-config.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/utils/strtod.h>
 #include <mono/utils/monobitset.h>
 
 #if defined (PLATFORM_WIN32)
 #include <windows.h>
+#include <shlobj.h>
 #endif
 #include "decimal.h"
 
@@ -897,6 +904,17 @@ ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder *mb, MonoObject *o
        return mono_image_create_token (mb->dynamic_image, obj);
 }
 
+static gint32
+ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb,
+                                       MonoReflectionMethod *method,
+                                       MonoArray *opt_param_types)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return mono_image_create_method_token (
+               mb->dynamic_image, (MonoObject *) method, opt_param_types);
+}
+
 static gint32
 ves_icall_ModuleBuilder_getDataChunk (MonoReflectionModuleBuilder *mb, MonoArray *buf, gint32 offset)
 {
@@ -926,26 +944,18 @@ ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder *mb)
        mono_image_build_metadata (mb);
 }
 
-static MonoReflectionType*
-ves_icall_type_from_name (MonoString *name,
-                         MonoBoolean throwOnError,
-                         MonoBoolean ignoreCase)
+static MonoReflectionType *
+type_from_name (const char *str, MonoBoolean ignoreCase)
 {
-       gchar *str;
        MonoType *type = NULL;
        MonoAssembly *assembly;
        MonoTypeNameParse info;
 
        MONO_ARCH_SAVE_REGS;
 
-       str = mono_string_to_utf8 (name);
        if (!mono_reflection_parse_type (str, &info)) {
-               g_free (str);
                g_list_free (info.modifiers);
                g_list_free (info.nested);
-               if (throwOnError) /* uhm: this is a parse error, though... */
-                       mono_raise_exception (mono_get_exception_type_load (name));
-
                return NULL;
        }
 
@@ -964,19 +974,43 @@ ves_icall_type_from_name (MonoString *name,
        if (!info.assembly.name && !type) /* try mscorlib */
                type = mono_reflection_get_type (NULL, &info, ignoreCase);
 
-       g_free (str);
        g_list_free (info.modifiers);
        g_list_free (info.nested);
-       if (!type) {
-               if (throwOnError)
-                       mono_raise_exception (mono_get_exception_type_load (name));
-
+       if (!type) 
                return NULL;
-       }
 
        return mono_type_get_object (mono_domain_get (), type);
 }
 
+MonoReflectionType *
+mono_type_get (const char *str)
+{
+       char *copy = g_strdup (str);
+       MonoReflectionType *type = type_from_name (copy, FALSE);
+
+       g_free (copy);
+       return type;
+}
+
+static MonoReflectionType*
+ves_icall_type_from_name (MonoString *name,
+                         MonoBoolean throwOnError,
+                         MonoBoolean ignoreCase)
+{
+       char *str = mono_string_to_utf8 (name);
+       MonoReflectionType *type;
+
+       type = type_from_name (str, ignoreCase);
+       g_free (str);
+       if (type == NULL){
+               if (throwOnError)
+                       mono_raise_exception (mono_get_exception_type_load (name));
+       }
+       
+       return type;
+}
+
+
 static MonoReflectionType*
 ves_icall_type_from_handle (MonoType *handle)
 {
@@ -1181,11 +1215,12 @@ ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
        info->implattrs = method->iflags;
        if (method->signature->call_convention == MONO_CALL_DEFAULT)
                info->callconv = 1;
-       else
+       else {
                if (method->signature->call_convention == MONO_CALL_VARARG)
                        info->callconv = 2;
                else
                        info->callconv = 0;
+       }
        info->callconv |= (method->signature->hasthis << 5) | (method->signature->explicit_this << 6); 
 }
 
@@ -1339,6 +1374,17 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
        }
 }
 
+static MonoReflectionField*
+ves_icall_MonoField_Mono_GetGenericFieldDefinition (MonoReflectionField *field)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       if (field->field->generic_info && field->field->generic_info->reflection_info)
+               return field->field->generic_info->reflection_info;
+
+       return field;
+}
+
 /* From MonoProperty.cs */
 typedef enum {
        PInfo_Attributes = 1,
@@ -1607,7 +1653,7 @@ ves_icall_MonoType_GetArrayRank (MonoReflectionType *type)
 }
 
 static MonoArray*
-ves_icall_Type_GetGenericArguments (MonoReflectionType *type)
+ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type)
 {
        MonoArray *res;
        MonoClass *klass, *pklass;
@@ -1759,22 +1805,6 @@ ves_icall_TypeBuilder_get_IsGenericParameter (MonoReflectionTypeBuilder *tb)
        return FALSE;
 }
 
-static MonoReflectionGenericParam*
-ves_icall_TypeBuilder_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoString *name, int index)
-{
-       MONO_ARCH_SAVE_REGS;
-
-       return mono_reflection_define_generic_parameter (tb, NULL, name, index);
-}
-
-static MonoReflectionGenericParam*
-ves_icall_MethodBuilder_define_generic_parameter (MonoReflectionMethodBuilder *mb, MonoString *name, int index)
-{
-       MONO_ARCH_SAVE_REGS;
-
-       return mono_reflection_define_generic_parameter (NULL, mb, name, index);
-}
-
 static MonoReflectionType*
 ves_icall_MonoGenericInst_GetParentType (MonoReflectionGenericInst *type)
 {
@@ -1831,41 +1861,6 @@ ves_icall_MonoGenericInst_GetInterfaces (MonoReflectionGenericInst *type)
        return res;
 }
 
-static MonoArray*
-ves_icall_MonoGenericInst_GetNestedTypes (MonoReflectionGenericInst *type)
-{
-       static MonoClass *System_Reflection_MonoGenericInst;
-       MonoGenericInst *ginst;
-       MonoDomain *domain;
-       MonoArray *res;
-       int i;
-
-       MONO_ARCH_SAVE_REGS;
-
-       if (!System_Reflection_MonoGenericInst) {
-               System_Reflection_MonoGenericInst = mono_class_from_name (
-                       mono_defaults.corlib, "System.Reflection", "MonoGenericInst");
-               g_assert (System_Reflection_MonoGenericInst);
-       }
-
-       domain = mono_object_domain (type);
-
-       ginst = type->type.type->data.generic_inst;
-       mono_reflection_generic_inst_get_nested_types (type);
-
-       res = mono_array_new (domain, System_Reflection_MonoGenericInst, ginst->count_nested);
-       for (i = 0; i < ginst->count_nested; i++) {
-               MonoClass *nc = mono_class_from_mono_type (ginst->nested [i]);
-               MonoReflectionType *type;
-
-               mono_class_init (nc);
-               type = mono_type_get_object (domain, ginst->nested [i]);
-               mono_array_set (res, gpointer, i, type);
-       }
-
-       return res;
-}
-
 static MonoArray*
 ves_icall_MonoGenericInst_GetMethods (MonoReflectionGenericInst *type,
                                      MonoReflectionType *reflected_type)
@@ -2021,13 +2016,6 @@ ves_icall_MonoGenericInst_GetEvents (MonoReflectionGenericInst *type,
        return res;
 }
 
-static void
-ves_icall_MonoGenericParam_initialize (MonoReflectionGenericParam *gparam)
-{
-       MONO_ARCH_SAVE_REGS;
-       mono_reflection_initialize_generic_parameter (gparam);
-}
-
 static MonoReflectionMethod *
 ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *type)
 {
@@ -2106,25 +2094,48 @@ ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod *method
 }
 
 static MonoArray*
-ves_icall_MonoMethod_GetGenericParameters (MonoReflectionMethod *method)
+ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method)
 {
-       MonoMethodNormal *mn;
        MonoArray *res;
+       MonoDomain *domain;
+       MonoMethodNormal *mn;
        int count, i;
        MONO_ARCH_SAVE_REGS;
 
+       domain = mono_object_domain (method);
+
        if ((method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
            (method->method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
-               return mono_array_new (mono_object_domain (method), mono_defaults.monotype_class, 0);
+               return mono_array_new (domain, mono_defaults.monotype_class, 0);
+
+       if (method->method->signature->is_inflated) {
+               MonoMethodInflated *imethod = (MonoMethodInflated *) method->method;
+               MonoGenericMethod *gmethod = imethod->context->gmethod;
+
+               if (gmethod) {
+                       count = gmethod->mtype_argc;
+                       res = mono_array_new (domain, mono_defaults.monotype_class, count);
+
+                       for (i = 0; i < count; i++) {
+                               MonoType *t = gmethod->mtype_argv [i];
+                               mono_array_set (
+                                       res, gpointer, i, mono_type_get_object (domain, t));
+                       }
+
+                       return res;
+               }
+       }
 
        mn = (MonoMethodNormal *) method->method;
        count = method->method->signature->generic_param_count;
-       res = mono_array_new (mono_object_domain (method), mono_defaults.monotype_class, count);
+       res = mono_array_new (domain, mono_defaults.monotype_class, count);
 
        for (i = 0; i < count; i++) {
                MonoGenericParam *param = &mn->header->gen_params [i];
-               MonoClass *pklass = mono_class_from_generic_parameter (param, method->method->klass->image, TRUE);
-               mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (method), &pklass->byval_arg));
+               MonoClass *pklass = mono_class_from_generic_parameter (
+                       param, method->method->klass->image, TRUE);
+               mono_array_set (res, gpointer, i,
+                               mono_type_get_object (domain, &pklass->byval_arg));
        }
 
        return res;
@@ -2140,6 +2151,7 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
         */
        MonoMethod *m = method->method;
        int pcount;
+       void *obj = this;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -2147,6 +2159,9 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
                if (!mono_object_isinst (this, m->klass))
                        mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
                m = mono_object_get_virtual_method (this, m);
+               /* must pass the pointer to the value for valuetype methods */
+               if (m->klass->valuetype)
+                       obj = mono_object_unbox (this);
        } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor") && !m->wrapper_type)
                mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
 
@@ -2175,7 +2190,7 @@ ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoAr
 
                return (MonoObject*)mono_array_new_full (mono_object_domain (params), m->klass, lengths, lower_bounds);
        }
-       return mono_runtime_invoke_array (m, this, params, NULL);
+       return mono_runtime_invoke_array (m, obj, params, NULL);
 }
 
 static MonoObject *
@@ -2199,23 +2214,27 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
 
                        str = mono_string_to_utf8 (name);
                
-                       for (i = 0; i < k->field.count; i++) {
-                               if (!strcmp (k->fields [i].name, str)) {
-                                       MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
-                                       if (field_klass->valuetype)
-                                               result = mono_value_box (domain, field_klass,
-                                                                        (char *)this + k->fields [i].offset);
-                                       else 
-                                               result = *((gpointer *)((char *)this + k->fields [i].offset));
-                               
-                                       g_assert (result);
-                                       out_args = mono_array_new (domain, mono_defaults.object_class, 1);
-                                       *outArgs = out_args;
-                                       mono_array_set (out_args, gpointer, 0, result);
-                                       g_free (str);
-                                       return NULL;
+                       do {
+                               for (i = 0; i < k->field.count; i++) {
+                                       if (!strcmp (k->fields [i].name, str)) {
+                                               MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
+                                               if (field_klass->valuetype)
+                                                       result = mono_value_box (domain, field_klass,
+                                                                                (char *)this + k->fields [i].offset);
+                                               else 
+                                                       result = *((gpointer *)((char *)this + k->fields [i].offset));
+                                       
+                                               g_assert (result);
+                                               out_args = mono_array_new (domain, mono_defaults.object_class, 1);
+                                               *outArgs = out_args;
+                                               mono_array_set (out_args, gpointer, 0, result);
+                                               g_free (str);
+                                               return NULL;
+                                       }
                                }
-                       }
+                               k = k->parent;
+                       } 
+                       while (k != NULL);
 
                        g_free (str);
                        g_assert_not_reached ();
@@ -2228,25 +2247,29 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
 
                        str = mono_string_to_utf8 (name);
                
-                       for (i = 0; i < k->field.count; i++) {
-                               if (!strcmp (k->fields [i].name, str)) {
-                                       MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
-                                       MonoObject *val = mono_array_get (params, gpointer, 2);
-
-                                       if (field_klass->valuetype) {
-                                               size = mono_type_size (k->fields [i].type, &align);
-                                               memcpy ((char *)this + k->fields [i].offset, 
-                                                       ((char *)val) + sizeof (MonoObject), size);
-                                       } else 
-                                               *(MonoObject**)((char *)this + k->fields [i].offset) = val;
-                               
-                                       out_args = mono_array_new (domain, mono_defaults.object_class, 0);
-                                       *outArgs = out_args;
-
-                                       g_free (str);
-                                       return NULL;
+                       do {
+                               for (i = 0; i < k->field.count; i++) {
+                                       if (!strcmp (k->fields [i].name, str)) {
+                                               MonoClass *field_klass =  mono_class_from_mono_type (k->fields [i].type);
+                                               MonoObject *val = mono_array_get (params, gpointer, 2);
+       
+                                               if (field_klass->valuetype) {
+                                                       size = mono_type_size (k->fields [i].type, &align);
+                                                       memcpy ((char *)this + k->fields [i].offset, 
+                                                               ((char *)val) + sizeof (MonoObject), size);
+                                               } else 
+                                                       *(MonoObject**)((char *)this + k->fields [i].offset) = val;
+                                       
+                                               out_args = mono_array_new (domain, mono_defaults.object_class, 0);
+                                               *outArgs = out_args;
+       
+                                               g_free (str);
+                                               return NULL;
+                                       }
                                }
-                       }
+                               k = k->parent;
+                       } 
+                       while (k != NULL);
 
                        g_free (str);
                        g_assert_not_reached ();
@@ -2265,6 +2288,8 @@ ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoA
        if (!strcmp (method->method->name, ".ctor"))
                g_assert_not_reached ();
 
+       /* This can be called only on MBR objects, so no need to unbox for valuetypes. */
+       g_assert (!method->method->klass->valuetype);
        result = mono_runtime_invoke_array (method->method, this, params, NULL);
 
        for (i = 0, j = 0; i < mono_array_length (params); i++) {
@@ -2750,10 +2775,15 @@ handle_parent:
                                continue;
                }
                
-               if (method->slot != -1) {
-                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+               if (prop->get && prop->get->slot != -1) {
+                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (prop->get->slot)))
                                continue;
-                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
+                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (prop->get->slot), prop);
+               }
+               if (prop->set && prop->set->slot != -1) {
+                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (prop->set->slot)))
+                               continue;
+                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (prop->set->slot), prop);
                }
 
                l = g_slist_prepend (l, mono_property_get_object (domain, startklass, prop));
@@ -2803,14 +2833,20 @@ handle_parent:
                method = event->add;
                if (!method)
                        method = event->remove;
-
-               if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
-                       if (!(bflags & BFLAGS_Public))
-                               continue;
-               } else {
+               if (!method)
+                       method = event->raise;
+               if (method) {
+                       if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
+                               if (!(bflags & BFLAGS_Public))
+                                       continue;
+                       } else {
+                               if (!(bflags & BFLAGS_NonPublic))
+                                       continue;
+                       }
+               }
+               else
                        if (!(bflags & BFLAGS_NonPublic))
                                continue;
-               }
 
                g_free (event_name);
                return mono_event_get_object (domain, startklass, event);
@@ -2847,25 +2883,36 @@ handle_parent:
                method = event->add;
                if (!method)
                        method = event->remove;
-               if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
-                       if (bflags & BFLAGS_Public)
-                               match++;
-               } else {
-                       if (bflags & BFLAGS_NonPublic)
-                               match++;
+               if (!method)
+                       method = event->raise;
+               if (method) {
+                       if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
+                               if (bflags & BFLAGS_Public)
+                                       match++;
+                       } else {
+                               if (bflags & BFLAGS_NonPublic)
+                                       match++;
+                       }
                }
+               else
+                       if (bflags & BFLAGS_NonPublic)
+                               match ++;
                if (!match)
                        continue;
                match = 0;
-               if (method->flags & METHOD_ATTRIBUTE_STATIC) {
-                       if (bflags & BFLAGS_Static)
-                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+               if (method) {
+                       if (method->flags & METHOD_ATTRIBUTE_STATIC) {
+                               if (bflags & BFLAGS_Static)
+                                       if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                               match++;
+                       } else {
+                               if (bflags & BFLAGS_Instance)
                                        match++;
-               } else {
-                       if (bflags & BFLAGS_Instance)
-                               match++;
+                       }
                }
-
+               else
+                       if (bflags & BFLAGS_Instance)
+                               match ++;
                if (!match)
                        continue;
                match = 0;
@@ -3056,6 +3103,35 @@ ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *asse
        return res;
 }
 
+static MonoBoolean
+ves_icall_System_Reflection_Assembly_get_global_assembly_cache (MonoReflectionAssembly *assembly)
+{
+       MonoAssembly *mass = assembly->assembly;
+
+       MONO_ARCH_SAVE_REGS;
+
+       return mass->in_gac;
+}
+
+static MonoReflectionAssembly*
+ves_icall_System_Reflection_Assembly_load_with_partial_name (MonoString *mname, MonoObject *evidence)
+{
+       gchar *name;
+       MonoAssembly *res;
+       MonoImageOpenStatus status;
+       
+       MONO_ARCH_SAVE_REGS;
+
+       name = mono_string_to_utf8 (mname);
+       res = mono_assembly_load_with_partial_name (name, &status);
+
+       g_free (name);
+
+       if (res == NULL)
+               return NULL;
+       return mono_assembly_get_object (mono_domain_get (), res);
+}
+
 static MonoString *
 ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assembly)
 {
@@ -3119,6 +3195,7 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
        MonoAssembly **ptr;
        MonoDomain *domain = mono_object_domain (assembly);
        int i, count = 0;
+       static MonoMethod *create_culture = NULL;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -3129,7 +3206,15 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
        for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
                count++;
 
-       result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
+       result = mono_array_new (domain, System_Reflection_AssemblyName, count);
+
+       if (count > 0) {
+               MonoMethodDesc *desc = mono_method_desc_new (
+                       "System.Globalization.CultureInfo:CreateSpecificCulture(string)", TRUE);
+               create_culture = mono_method_desc_search_in_image (desc, mono_defaults.corlib);
+               g_assert (create_culture);
+               mono_method_desc_free (desc);
+       }
 
        for (i = 0; i < count; i++) {
                MonoAssembly *assem = assembly->assembly->image->references [i];
@@ -3139,11 +3224,33 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse
                aname = (MonoReflectionAssemblyName *) mono_object_new (
                        domain, System_Reflection_AssemblyName);
 
-               if (strcmp (assem->aname.name, "corlib") == 0)
-                       aname->name = mono_string_new (domain, "mscorlib");
-               else
-                       aname->name = mono_string_new (domain, assem->aname.name);
+               aname->name = mono_string_new (domain, assem->aname.name);
+
                aname->major = assem->aname.major;
+               aname->minor = assem->aname.minor;
+               aname->build = assem->aname.build;
+               aname->revision = assem->aname.revision;
+               aname->revision = assem->aname.revision;
+               aname->hashalg = assem->aname.hash_alg;
+               aname->flags = assem->aname.flags;
+
+               if (create_culture) {
+                       gpointer args [1];
+                       args [0] = mono_string_new (domain, assem->aname.culture);
+                       aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
+               }
+
+               if (assem->aname.public_key) {
+                       guint32 pkey_len;
+                       const char *pkey_ptr = assem->aname.public_key;
+                       pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
+
+                       aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
+                       memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+               }
+
+               /* public key token isn't copied - the class library will 
+                  automatically generate it from the public key if required */
 
                absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
                codebase = g_filename_to_uri (absolute, NULL, NULL);
@@ -3260,8 +3367,8 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
                 * this code should only be called after obtaining the 
                 * ResourceInfo and handling the other cases.
                 */
-               g_assert ((impl & IMPLEMENTATION_MASK) == IMPLEMENTATION_FILE);
-               file_idx = impl >> IMPLEMENTATION_BITS;
+               g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE);
+               file_idx = impl >> MONO_IMPLEMENTATION_BITS;
 
                module = mono_image_load_file_for_image (assembly->assembly->image, file_idx);
                if (!module)
@@ -3302,9 +3409,9 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflec
                info->location = RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST;
        }
        else {
-               switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
-               case IMPLEMENTATION_FILE:
-                       i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
+               switch (cols [MONO_MANIFEST_IMPLEMENTATION] & MONO_IMPLEMENTATION_MASK) {
+               case MONO_IMPLEMENTATION_FILE:
+                       i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
                        table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
                        mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
                        val = mono_metadata_string_heap (assembly->assembly->image, file_cols [MONO_FILE_NAME]);
@@ -3315,16 +3422,16 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflec
                                info->location = RESOURCE_LOCATION_EMBEDDED;
                        break;
 
-               case IMPLEMENTATION_ASSEMBLYREF:
-                       i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
+               case MONO_IMPLEMENTATION_ASSEMBLYREF:
+                       i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
                        info->assembly = mono_assembly_get_object (mono_domain_get (), assembly->assembly->image->references [i - 1]);
 
-                       // Obtain info recursively
+                       /* Obtain info recursively */
                        ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (info->assembly, name, info);
                        info->location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
                        break;
 
-               case IMPLEMENTATION_EXP_TYPE:
+               case MONO_IMPLEMENTATION_EXP_TYPE:
                        g_assert_not_reached ();
                        break;
                }
@@ -3455,7 +3562,7 @@ ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
        MONO_ARCH_SAVE_REGS;
 
        if (!domain->entry_assembly)
-               domain = mono_root_domain;
+               domain = mono_get_root_domain ();
 
        return mono_assembly_get_object (domain, domain->entry_assembly);
 }
@@ -3502,11 +3609,7 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a
 
        MONO_ARCH_SAVE_REGS;
 
-       if (strcmp (name->name, "corlib") == 0)
-               aname->name = mono_string_new (domain, "mscorlib");
-       else
-               aname->name = mono_string_new (domain, name->name);
-
+       aname->name = mono_string_new (domain, name->name);
        aname->major = name->major;
        aname->minor = name->minor;
        aname->build = name->build;
@@ -3853,7 +3956,7 @@ ves_icall_System_DateTime_GetNow (void)
        SYSTEMTIME st;
        FILETIME ft;
        
-       GetLocalTime (&st);
+       GetSystemTime (&st);
        SystemTimeToFileTime (&st, &ft);
        return (gint64) FILETIME_ADJUST + ((((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime);
 #else
@@ -4102,20 +4205,14 @@ ves_icall_System_Object_obj_address (MonoObject *this)
 
 /* System.Buffer */
 
-static gint32 
-ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) 
+static inline gint32 
+mono_array_get_byte_length (MonoArray *array)
 {
        MonoClass *klass;
-       MonoTypeEnum etype;
-       int length, esize;
+       int length;
        int i;
 
-       MONO_ARCH_SAVE_REGS;
-
        klass = array->obj.vtable->klass;
-       etype = klass->element_class->byval_arg.type;
-       if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
-               return -1;
 
        if (array->bounds == NULL)
                length = array->max_length;
@@ -4125,8 +4222,37 @@ ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array)
                        length *= array->bounds [i].length;
        }
 
-       esize = mono_array_element_size (klass);
-       return length * esize;
+       switch (klass->element_class->byval_arg.type) {
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+       case MONO_TYPE_BOOLEAN:
+               return length;
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR:
+               return length << 1;
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+       case MONO_TYPE_R4:
+               return length << 2;
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+               return length * sizeof (gpointer);
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+       case MONO_TYPE_R8:
+               return length << 3;
+       default:
+               return -1;
+       }
+}
+
+static gint32 
+ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) 
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return mono_array_get_byte_length (array);
 }
 
 static gint8 
@@ -4145,17 +4271,23 @@ ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 val
        mono_array_set (array, gint8, idx, value);
 }
 
-static void 
+static MonoBoolean
 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) 
 {
        char *src_buf, *dest_buf;
 
        MONO_ARCH_SAVE_REGS;
 
+       /* watch out for integer overflow */
+       if ((src_offset > mono_array_get_byte_length (src) - count) || (dest_offset > mono_array_get_byte_length (dest) - count))
+               return FALSE;
+
        src_buf = (gint8 *)src->vector + src_offset;
        dest_buf = (gint8 *)dest->vector + dest_offset;
 
        memcpy (dest_buf, src_buf, count);
+
+       return TRUE;
 }
 
 static MonoObject *
@@ -4355,26 +4487,165 @@ ves_icall_System_Environment_Exit (int result)
 static MonoString*
 ves_icall_System_Environment_GetGacPath (void)
 {
-       return mono_string_new (mono_domain_get (), MONO_ASSEMBLIES);
+       return mono_string_new (mono_domain_get (), mono_assembly_getrootdir ());
 }
 
 static MonoString*
-ves_icall_System_Text_Encoding_InternalCodePage (void) 
+ves_icall_System_Environment_GetWindowsFolderPath (int folder)
 {
-       const char *cset;
+#if defined (PLATFORM_WIN32)
+       #ifndef CSIDL_FLAG_CREATE
+               #define CSIDL_FLAG_CREATE       0x8000
+       #endif
+
+       WCHAR path [MAX_PATH];
+       /* Create directory if no existing */
+       if (SUCCEEDED (SHGetFolderPathW (NULL, folder | CSIDL_FLAG_CREATE, NULL, 0, path))) {
+               int len = 0;
+               while (path [len])
+                       ++ len;
+               return mono_string_new_utf16 (mono_domain_get (), path, len);
+       }
+#else
+       g_warning ("ves_icall_System_Environment_GetWindowsFolderPath should only be called on Windows!");
+#endif
+       return mono_string_new (mono_domain_get (), "");
+}
+
+static MonoArray *
+ves_icall_System_Environment_GetLogicalDrives (void)
+{
+        gunichar2 buf [128], *ptr, *dname;
+       gchar *u8;
+       gint initial_size = 127, size = 128;
+       gint ndrives;
+       MonoArray *result;
+       MonoString *drivestr;
+       MonoDomain *domain = mono_domain_get ();
 
        MONO_ARCH_SAVE_REGS;
 
+        buf [0] = '\0';
+       ptr = buf;
+
+       while (size > initial_size) {
+               size = GetLogicalDriveStrings (initial_size, ptr);
+               if (size > initial_size) {
+                       if (ptr != buf)
+                               g_free (ptr);
+                       ptr = g_malloc0 ((size + 1) * sizeof (gunichar2));
+                       initial_size = size;
+                       size++;
+               }
+       }
+
+       /* Count strings */
+       dname = ptr;
+       ndrives = 0;
+       do {
+               while (*dname++);
+               ndrives++;
+       } while (*dname);
+
+       dname = ptr;
+       result = mono_array_new (domain, mono_defaults.string_class, ndrives);
+       ndrives = 0;
+       do {
+               u8 = g_utf16_to_utf8 (dname, -1, NULL, NULL, NULL);
+               drivestr = mono_string_new (domain, u8);
+               g_free (u8);
+               mono_array_set (result, gpointer, ndrives++, drivestr);
+               while (*dname++);
+       } while (*dname);
+
+       if (ptr != buf)
+               g_free (ptr);
+
+       return result;
+}
+
+static MonoString *
+ves_icall_System_Environment_InternalGetHome (void)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       return mono_string_new (mono_domain_get (), g_get_home_dir ());
+}
+
+static const char *encodings [] = {
+       (char *) 1,
+               "ascii", "us_ascii", "us", "ansi_x3.4_1968",
+               "ansi_x3.4_1986", "cp367", "csascii", "ibm367",
+               "iso_ir_6", "iso646_us", "iso_646.irv:1991",
+       (char *) 2,
+               "utf_7", "csunicode11utf7", "unicode_1_1_utf_7",
+               "unicode_2_0_utf_7", "x_unicode_1_1_utf_7",
+               "x_unicode_2_0_utf_7",
+       (char *) 3,
+               "utf_8", "unicode_1_1_utf_8", "unicode_2_0_utf_8",
+               "x_unicode_1_1_utf_8", "x_unicode_2_0_utf_8",
+       (char *) 4,
+               "utf_16", "UTF_16LE", "ucs_2", "unicode",
+               "iso_10646_ucs2",
+       (char *) 5,
+               "unicodefffe", "utf_16be",
+       (char *) 6,
+               "iso_8859_1",
+       (char *) 0
+};
+
+/*
+ * Returns the internal codepage, if the value of "int_code_page" is
+ * 1 at entry, and we can not compute a suitable code page number,
+ * returns the code page as a string
+ */
+static MonoString*
+ves_icall_System_Text_Encoding_InternalCodePage (gint32 *int_code_page) 
+{
+       const char *cset;
+       char *p;
+       char *codepage = NULL;
+       int code;
+       int want_name = *int_code_page;
+       int i;
+       
+       *int_code_page = -1;
+       MONO_ARCH_SAVE_REGS;
+
        g_get_charset (&cset);
+       p = codepage = strdup (cset);
+       for (p = codepage; *p; p++){
+               if (isascii (*p) && isalpha (*p))
+                       *p = tolower (*p);
+               if (*p == '-')
+                       *p = '_';
+       }
        /* g_print ("charset: %s\n", cset); */
+       
        /* handle some common aliases */
-       switch (*cset) {
-       case 'A':
-               if (strcmp (cset, "ANSI_X3.4-1968") == 0)
-                       cset = "us-ascii";
-               break;
+       p = encodings [0];
+       code = 0;
+       for (i = 0; p != 0; ){
+               if ((int) p < 7){
+                       code = (int) p;
+                       p = encodings [++i];
+                       continue;
+               }
+               if (strcmp (p, codepage) == 0){
+                       *int_code_page = code;
+                       break;
+               }
+               p = encodings [++i];
        }
-       return mono_string_new (mono_domain_get (), cset);
+       
+       if (strstr (codepage, "utf_8") != NULL)
+               *int_code_page |= 0x10000000;
+       free (codepage);
+       
+       if (want_name && *int_code_page == -1)
+               return mono_string_new (mono_domain_get (), cset);
+       else
+               return NULL;
 }
 
 static MonoBoolean
@@ -4443,7 +4714,7 @@ ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClas
                g_assert (klass->rank == 1);
                return (MonoObject *) mono_array_new (domain, klass->element_class, 0);
        } else {
-               // Bypass remoting object creation check
+               /* Bypass remoting object creation check */
                return mono_object_new_alloc_specific (mono_class_vtable (domain, klass));
        }
 }
@@ -4464,31 +4735,6 @@ ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
        return mono_compile_method (method);
 }
 
-char const * mono_cfg_dir = "";
-
-void    
-mono_install_get_config_dir (void)
-{
-#ifdef PLATFORM_WIN32
-  int i;
-#endif
-
-  mono_cfg_dir = getenv ("MONO_CFG_DIR");
-
-  if (!mono_cfg_dir) {
-#ifndef PLATFORM_WIN32
-    mono_cfg_dir = MONO_CFG_DIR;
-#else
-    mono_cfg_dir = g_strdup (MONO_CFG_DIR);
-    for (i = strlen (mono_cfg_dir) - 1; i >= 0; i--) {
-        if (mono_cfg_dir [i] == '/')
-            ((char*) mono_cfg_dir) [i] = '\\';
-    }
-#endif
-  }
-}
-
-
 static MonoString *
 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
 {
@@ -4497,7 +4743,7 @@ ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
 
        MONO_ARCH_SAVE_REGS;
 
-       path = g_build_path (G_DIR_SEPARATOR_S, mono_cfg_dir, "mono", "machine.config", NULL);
+       path = g_build_path (G_DIR_SEPARATOR_S, mono_get_config_dir (), "mono", "machine.config", NULL);
 
 #if defined (PLATFORM_WIN32)
        /* Avoid mixing '/' and '\\' */
@@ -4522,7 +4768,7 @@ ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void)
 
        MONO_ARCH_SAVE_REGS;
 
-       path = g_path_get_dirname (mono_cfg_dir);
+       path = g_path_get_dirname (mono_get_config_dir ());
 
 #if defined (PLATFORM_WIN32)
        /* Avoid mixing '/' and '\\' */
@@ -4603,8 +4849,8 @@ ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
        MONO_ARCH_SAVE_REGS;
 
        if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
-            method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ||
-            method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
+           MONO_CLASS_IS_INTERFACE (method->klass) ||
+           method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
                return m;
 
        if (method->klass == NULL || (klass = method->klass->parent) == NULL)
@@ -4647,10 +4893,19 @@ mono_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start)
 
        iter->next_arg = 0;
        /* FIXME: it's not documented what start is exactly... */
-       iter->args = start? start: argsp + sizeof (gpointer);
+       if (start) {
+               iter->args = start;
+       } else {
+               int i, align, arg_size;
+               iter->args = argsp + sizeof (gpointer);
+               for (i = 0; i < iter->sig->sentinelpos; ++i) {
+                       arg_size = mono_type_stack_size (iter->sig->params [i], &align);
+                       iter->args = (char*)iter->args + arg_size;
+               }
+       }
        iter->num_args = iter->sig->param_count - iter->sig->sentinelpos;
 
-       // g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos);
+       /* g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos); */
 }
 
 static MonoTypedRef
@@ -4672,7 +4927,7 @@ mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter)
        iter->args = (char*)iter->args + arg_size;
        iter->next_arg++;
 
-       //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
+       /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
 
        return res;
 }
@@ -4698,10 +4953,10 @@ mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type)
                arg_size = mono_type_stack_size (res.type, &align);
                iter->args = (char*)iter->args + arg_size;
                iter->next_arg++;
-               //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
+               /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
                return res;
        }
-       //g_print ("arg type 0x%02x not found\n", res.type->type);
+       /* g_print ("arg type 0x%02x not found\n", res.type->type); */
 
        res.type = NULL;
        res.value = NULL;
@@ -4783,12 +5038,6 @@ ves_icall_System_Char_GetDataTablePointers (guint8 **category_data, guint8 **num
        *to_upper_data_high = ToUpperDataHigh;
 }
 
-static void
-ves_icall_System_Reflection_Emit_LocalBuilder_MakePinned (MonoReflectionLocalBuilder* this)
-{
-       this->type->type->pinned = TRUE;
-}
-
 /* icall map */
 typedef struct {
        const char *method;
@@ -4828,10 +5077,6 @@ static const IcallEntry appdomain_icalls [] = {
        {"getSetup", ves_icall_System_AppDomain_getSetup}
 };
 
-static const IcallEntry appdomainsetup_icalls [] = {
-       {"InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup}
-};
-
 static const IcallEntry argiterator_icalls [] = {
        {"IntGetNextArg()",                  mono_ArgIterator_IntGetNextArg},
        {"IntGetNextArg(intptr)", mono_ArgIterator_IntGetNextArgT},
@@ -4861,6 +5106,8 @@ static const IcallEntry buffer_icalls [] = {
 
 static const IcallEntry char_icalls [] = {
        {"GetDataTablePointers", ves_icall_System_Char_GetDataTablePointers},
+       {"InternalToLower(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToLower_Comp},
+       {"InternalToUpper(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToUpper_Comp}
 };
 
 static const IcallEntry defaultconf_icalls [] = {
@@ -4917,7 +5164,7 @@ static const IcallEntry process_icalls [] = {
        {"Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal},
        {"SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal},
        {"StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal},
-       {"Start_internal(string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal},
+       {"Start_internal(string,string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal},
        {"WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal}
 };
 
@@ -4936,20 +5183,33 @@ static const IcallEntry environment_icalls [] = {
        {"GetCommandLineArgs", mono_runtime_get_main_args},
        {"GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable},
        {"GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames},
-       {"GetMachineConfigPath",        ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+       {"GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives },
+       {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+       {"GetOSVersionString", ves_icall_System_Environment_GetOSVersionString},
+       {"GetWindowsFolderPath", ves_icall_System_Environment_GetWindowsFolderPath},
        {"get_ExitCode", mono_environment_exitcode_get},
        {"get_HasShutdownStarted", ves_icall_System_Environment_get_HasShutdownStarted},
        {"get_MachineName", ves_icall_System_Environment_get_MachineName},
        {"get_NewLine", ves_icall_System_Environment_get_NewLine},
        {"get_Platform", ves_icall_System_Environment_get_Platform},
        {"get_TickCount", ves_icall_System_Environment_get_TickCount},
+       {"get_UserName", ves_icall_System_Environment_get_UserName},
        {"internalGetGacPath", ves_icall_System_Environment_GetGacPath},
+       {"internalGetHome", ves_icall_System_Environment_InternalGetHome},
        {"set_ExitCode", mono_environment_exitcode_set}
 };
 
 static const IcallEntry cultureinfo_icalls [] = {
        {"construct_compareinfo(object,string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo},
-       {"construct_internal_locale(string)", ves_icall_System_Globalization_CultureInfo_construct_internal_locale}
+       {"construct_datetime_format", ves_icall_System_Globalization_CultureInfo_construct_datetime_format},
+       {"construct_internal_locale(string)", ves_icall_System_Globalization_CultureInfo_construct_internal_locale},
+       {"construct_internal_locale_from_current_locale", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_current_locale},
+       {"construct_internal_locale_from_lcid", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid},
+       {"construct_internal_locale_from_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name},
+       {"construct_internal_locale_from_specific_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name},
+       {"construct_number_format", ves_icall_System_Globalization_CultureInfo_construct_number_format},
+       {"internal_get_cultures", ves_icall_System_Globalization_CultureInfo_internal_get_cultures},
+       {"internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral}
 };
 
 static const IcallEntry compareinfo_icalls [] = {
@@ -5004,6 +5264,7 @@ static const IcallEntry monoio_icalls [] = {
        {"GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength},
        {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync},
        {"GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath},
+       {"Lock(intptr,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Lock},
        {"MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile},
        {"Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open},
        {"Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read},
@@ -5013,6 +5274,7 @@ static const IcallEntry monoio_icalls [] = {
        {"SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes},
        {"SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime},
        {"SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength},
+       {"Unlock(intptr,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Unlock},
        {"Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write},
        {"get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar},
        {"get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError},
@@ -5065,6 +5327,7 @@ static const IcallEntry monotype_icalls [] = {
        {"GetEvents_internal", ves_icall_Type_GetEvents_internal},
        {"GetField", ves_icall_Type_GetField},
        {"GetFields_internal", ves_icall_Type_GetFields_internal},
+       {"GetGenericArguments", ves_icall_MonoType_GetGenericArguments},
        {"GetInterfaces", ves_icall_Type_GetInterfaces},
        {"GetMethodsByName", ves_icall_Type_GetMethodsByName},
        {"GetNestedType", ves_icall_Type_GetNestedType},
@@ -5116,7 +5379,9 @@ static const IcallEntry assembly_icalls [] = {
        /* normal icalls again */
        {"get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint},
        {"get_code_base", ves_icall_System_Reflection_Assembly_get_code_base},
-       {"get_location", ves_icall_System_Reflection_Assembly_get_location}
+       {"get_global_assembly_cache", ves_icall_System_Reflection_Assembly_get_global_assembly_cache},
+       {"get_location", ves_icall_System_Reflection_Assembly_get_location},
+       {"load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name}
 };
 
 static const IcallEntry methodbase_icalls [] = {
@@ -5143,6 +5408,7 @@ static const IcallEntry monoeventinfo_icalls [] = {
 static const IcallEntry monofield_icalls [] = {
        {"GetParentType", ves_icall_MonoField_GetParentType},
        {"GetValueInternal", ves_icall_MonoField_GetValueInternal},
+       {"Mono_GetGenericFieldDefinition", ves_icall_MonoField_Mono_GetGenericFieldDefinition},
        {"SetValueInternal", ves_icall_FieldInfo_SetValueInternal}
 };
 
@@ -5152,20 +5418,19 @@ static const IcallEntry monogenericinst_icalls [] = {
        {"GetFields_internal", ves_icall_MonoGenericInst_GetFields},
        {"GetInterfaces_internal", ves_icall_MonoGenericInst_GetInterfaces},
        {"GetMethods_internal", ves_icall_MonoGenericInst_GetMethods},
-       {"GetNestedTypes_internal", ves_icall_MonoGenericInst_GetNestedTypes},
        {"GetParentType", ves_icall_MonoGenericInst_GetParentType},
        {"GetProperties_internal", ves_icall_MonoGenericInst_GetProperties},
        {"initialize", mono_reflection_generic_inst_initialize}
 };
 
-static const IcallEntry monogenericparam_icalls [] = {
-       {"initialize", ves_icall_MonoGenericParam_initialize}
+static const IcallEntry generictypeparambuilder_icalls [] = {
+       {"initialize", mono_reflection_initialize_generic_parameter}
 };
 
 static const IcallEntry monomethod_icalls [] = {
        {"BindGenericParameters", mono_reflection_bind_generic_method_parameters},
+       {"GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments},
        {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition},
-       {"GetGenericParameters", ves_icall_MonoMethod_GetGenericParameters},
        {"InternalInvoke", ves_icall_InternalInvoke},
        {"get_HasGenericParameters", ves_icall_MonoMethod_get_HasGenericParameters},
        {"get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition},
@@ -5189,26 +5454,30 @@ static const IcallEntry dns_icalls [] = {
 };
 
 static const IcallEntry socket_icalls [] = {
-       {"Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal},
-       {"Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal},
-       {"Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal},
-       {"Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal},
-       {"Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal},
-       {"Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal},
-       {"GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal},
-       {"GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal},
-       {"Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal},
-       {"LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal},
-       {"Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal},
-       {"RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal},
-       {"RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal},
-       {"Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal},
-       {"SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal},
-       {"Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal},
-       {"SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal},
-       {"Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal},
-       {"Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal},
-       {"WSAIoctl", ves_icall_System_Net_Sockets_Socket_WSAIoctl}
+       {"Accept_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Accept_internal},
+       {"AsyncReceiveInternal", ves_icall_System_Net_Sockets_Socket_AsyncReceive},
+       {"AsyncSendInternal", ves_icall_System_Net_Sockets_Socket_AsyncSend},
+       {"Available_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Available_internal},
+       {"Bind_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Bind_internal},
+       {"Blocking_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Blocking_internal},
+       {"Close_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Close_internal},
+       {"Connect_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Connect_internal},
+       {"GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal},
+       {"GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal},
+       {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync},
+       {"Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal},
+       {"LocalEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal},
+       {"Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal},
+       {"Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Receive_internal},
+       {"RecvFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&)", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal},
+       {"RemoteEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal},
+       {"Select_internal(System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal},
+       {"SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_SendTo_internal},
+       {"Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Send_internal},
+       {"SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal},
+       {"Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal},
+       {"Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal},
+       {"WSAIoctl(intptr,int,byte[],byte[],int&)", ves_icall_System_Net_Sockets_Socket_WSAIoctl}
 };
 
 static const IcallEntry socketex_icalls [] = {
@@ -5236,8 +5505,7 @@ static const IcallEntry dynamicmethod_icalls [] = {
 };
 
 static const IcallEntry methodbuilder_icalls [] = {
-       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters},
-       {"define_generic_parameter", ves_icall_MethodBuilder_define_generic_parameter}
+       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters}
 };
 
 static const IcallEntry modulebuilder_icalls [] = {
@@ -5245,6 +5513,7 @@ static const IcallEntry modulebuilder_icalls [] = {
        {"build_metadata", ves_icall_ModuleBuilder_build_metadata},
        {"create_modified_type", ves_icall_ModuleBuilder_create_modified_type},
        {"getDataChunk", ves_icall_ModuleBuilder_getDataChunk},
+       {"getMethodToken", ves_icall_ModuleBuilder_getMethodToken},
        {"getToken", ves_icall_ModuleBuilder_getToken},
        {"getUSIndex", mono_image_insert_string}
 };
@@ -5257,7 +5526,6 @@ static const IcallEntry signaturehelper_icalls [] = {
 static const IcallEntry typebuilder_icalls [] = {
        {"create_internal_class", mono_reflection_create_internal_class},
        {"create_runtime_class", mono_reflection_create_runtime_class},
-       {"define_generic_parameter", ves_icall_TypeBuilder_define_generic_parameter},
        {"get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter},
        {"get_event_info", mono_reflection_event_builder_get_event_info},
        {"setup_generic_class", mono_reflection_setup_generic_class},
@@ -5308,6 +5576,7 @@ static const IcallEntry marshal_icalls [] = {
        {"StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi},
        {"StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni},
        {"StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr},
+       {"UnsafeAddrOfPinnedArrayElement", ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement},
        {"WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte},
        {"WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16},
        {"WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32},
@@ -5337,7 +5606,9 @@ static const IcallEntry remotingservices_icalls [] = {
 };
 
 static const IcallEntry rng_icalls [] = {
-       {"InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes}
+       {"RngClose", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose},
+       {"RngGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes},
+       {"RngInitialize", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize}
 };
 
 static const IcallEntry methodhandle_icalls [] = {
@@ -5355,30 +5626,24 @@ static const IcallEntry string_icalls [] = {
        {".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding},
        {"GetHashCode", ves_icall_System_String_GetHashCode},
        {"InternalAllocateStr", ves_icall_System_String_InternalAllocateStr},
-       {"InternalCompare(string,int,string,int,int,int)", ves_icall_System_String_InternalCompareStr_N},
+       {"InternalCharCopy", ves_icall_System_String_InternalCharCopy},
        {"InternalCopyTo", ves_icall_System_String_InternalCopyTo},
-       {"InternalEquals", ves_icall_System_String_InternalEquals},
-       {"InternalIndexOf(char,int,int)", ves_icall_System_String_InternalIndexOf_Char},
-       {"InternalIndexOf(string,int,int)", ves_icall_System_String_InternalIndexOf_Str},
        {"InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny},
        {"InternalInsert", ves_icall_System_String_InternalInsert},
        {"InternalIntern", ves_icall_System_String_InternalIntern},
        {"InternalIsInterned", ves_icall_System_String_InternalIsInterned},
        {"InternalJoin", ves_icall_System_String_InternalJoin},
-       {"InternalLastIndexOf(char,int,int)", ves_icall_System_String_InternalLastIndexOf_Char},
-       {"InternalLastIndexOf(string,int,int)", ves_icall_System_String_InternalLastIndexOf_Str},
        {"InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny},
        {"InternalPad", ves_icall_System_String_InternalPad},
        {"InternalRemove", ves_icall_System_String_InternalRemove},
        {"InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char},
-       {"InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str},
        {"InternalReplace(string,string,System.Globalization.CompareInfo)", ves_icall_System_String_InternalReplace_Str_Comp},
        {"InternalSplit", ves_icall_System_String_InternalSplit},
+       {"InternalStrcpy(string,int,char[])", ves_icall_System_String_InternalStrcpy_Chars},
+       {"InternalStrcpy(string,int,char[],int,int)", ves_icall_System_String_InternalStrcpy_CharsN},
        {"InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str},
        {"InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN},
-       {"InternalToLower", ves_icall_System_String_InternalToLower},
        {"InternalToLower(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToLower_Comp},
-       {"InternalToUpper", ves_icall_System_String_InternalToUpper},
        {"InternalToUpper(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToUpper_Comp},
        {"InternalTrim", ves_icall_System_String_InternalTrim},
        {"get_Chars", ves_icall_System_String_get_Chars}
@@ -5412,8 +5677,8 @@ static const IcallEntry interlocked_icalls [] = {
 };
 
 static const IcallEntry mutex_icalls [] = {
-       {"CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal},
-       {"ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal}
+       {"CreateMutex_internal(bool,string,bool&)", ves_icall_System_Threading_Mutex_CreateMutex_internal},
+       {"ReleaseMutex_internal(intptr)", ves_icall_System_Threading_Mutex_ReleaseMutex_internal}
 };
 
 static const IcallEntry nativeevents_icalls [] = {
@@ -5430,46 +5695,50 @@ static const IcallEntry thread_icalls [] = {
        {"GetName_internal", ves_icall_System_Threading_Thread_GetName_internal},
        {"Join_internal", ves_icall_System_Threading_Thread_Join_internal},
        {"ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort},
+       {"Resume_internal()", ves_icall_System_Threading_Thread_Resume},
        {"SetName_internal", ves_icall_System_Threading_Thread_SetName_internal},
        {"Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal},
        {"SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup},
        {"SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store},
        {"Start_internal", ves_icall_System_Threading_Thread_Start_internal},
+       {"Suspend_internal", ves_icall_System_Threading_Thread_Suspend},
        {"Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal},
        {"Thread_internal", ves_icall_System_Threading_Thread_Thread_internal},
-       {"VolatileRead(IntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
-       {"VolatileRead(UIntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
        {"VolatileRead(byte&)", ves_icall_System_Threading_Thread_VolatileRead1},
        {"VolatileRead(double&)", ves_icall_System_Threading_Thread_VolatileRead8},
-       {"VolatileRead(float&)", ves_icall_System_Threading_Thread_VolatileRead4},
        {"VolatileRead(int&)", ves_icall_System_Threading_Thread_VolatileRead4},
+       {"VolatileRead(int16&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(intptr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
        {"VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8},
        {"VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
        {"VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1},
-       {"VolatileRead(short&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(single&)", ves_icall_System_Threading_Thread_VolatileRead4},
        {"VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(uint16&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(uintptr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
        {"VolatileRead(ulong&)", ves_icall_System_Threading_Thread_VolatileRead8},
-       {"VolatileRead(ushort&)", ves_icall_System_Threading_Thread_VolatileRead2},
-       {"VolatileWrite(IntPtr&,IntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
-       {"VolatileWrite(UIntPtr&,UIntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
        {"VolatileWrite(byte&,byte)", ves_icall_System_Threading_Thread_VolatileWrite1},
        {"VolatileWrite(double&,double)", ves_icall_System_Threading_Thread_VolatileWrite8},
-       {"VolatileWrite(float&,float)", ves_icall_System_Threading_Thread_VolatileWrite4},
        {"VolatileWrite(int&,int)", ves_icall_System_Threading_Thread_VolatileWrite4},
+       {"VolatileWrite(int16&,int16)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(intptr&,intptr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
        {"VolatileWrite(long&,long)", ves_icall_System_Threading_Thread_VolatileWrite8},
        {"VolatileWrite(object&,object)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
        {"VolatileWrite(sbyte&,sbyte)", ves_icall_System_Threading_Thread_VolatileWrite1},
-       {"VolatileWrite(short&,short)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(single&,single)", ves_icall_System_Threading_Thread_VolatileWrite4},
        {"VolatileWrite(uint&,uint)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(uint16&,uint16)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(uintptr&,uintptr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
        {"VolatileWrite(ulong&,ulong)", ves_icall_System_Threading_Thread_VolatileWrite8},
-       {"VolatileWrite(ushort&,ushort)", ves_icall_System_Threading_Thread_VolatileWrite2},
        {"current_lcid()", ves_icall_System_Threading_Thread_current_lcid}
 };
 
 static const IcallEntry threadpool_icalls [] = {
        {"BindHandleInternal", ves_icall_System_Threading_ThreadPool_BindHandle},
        {"GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads},
-       {"GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads}
+       {"GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads},
+       {"GetMinThreads", ves_icall_System_Threading_ThreadPool_GetMinThreads},
+       {"SetMinThreads", ves_icall_System_Threading_ThreadPool_SetMinThreads}
 };
 
 static const IcallEntry waithandle_icalls [] = {
@@ -5481,7 +5750,6 @@ static const IcallEntry waithandle_icalls [] = {
 static const IcallEntry type_icalls [] = {
        {"BindGenericParameters", ves_icall_Type_BindGenericParameters},
        {"Equals", ves_icall_type_Equals},
-       {"GetGenericArguments", ves_icall_Type_GetGenericArguments},
        {"GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition},
        {"GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl},
        {"GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData},
@@ -5512,8 +5780,31 @@ static const IcallEntry web_icalls [] = {
        {"GetMachineInstallDirectory", ves_icall_System_Web_Util_ICalls_get_machine_install_dir}
 };
 
-static const IcallEntry localbuilder_icalls [] = {
-       {"MakePinned", ves_icall_System_Reflection_Emit_LocalBuilder_MakePinned },
+static const IcallEntry identity_icalls [] = {
+       {"GetCurrentToken", ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken},
+       {"GetTokenName", ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName},
+       {"GetUserToken", ves_icall_System_Security_Principal_WindowsIdentity_GetUserToken},
+       {"_GetRoles", ves_icall_System_Security_Principal_WindowsIdentity_GetRoles}
+};
+
+static const IcallEntry impersonation_icalls [] = {
+       {"CloseToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_CloseToken},
+       {"DuplicateToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken},
+       {"RevertToSelf", ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf},
+       {"SetCurrentToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken}
+};
+
+static const IcallEntry principal_icalls [] = {
+       {"IsMemberOfGroupId", ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupId},
+       {"IsMemberOfGroupName", ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupName}
+};
+
+static const IcallEntry keypair_icalls [] = {
+       {"_CanSecure", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_CanSecure},
+       {"_IsMachineProtected", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_IsMachineProtected},
+       {"_IsUserProtected", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_IsUserProtected},
+       {"_ProtectMachine", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_ProtectMachine},
+       {"_ProtectUser", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_ProtectUser}
 };
 
 /* proto
@@ -5524,9 +5815,9 @@ static const IcallEntry array_icalls [] = {
 
 /* keep the entries all sorted */
 static const IcallMap icall_entries [] = {
-       {"System.Activation", activator_icalls, G_N_ELEMENTS (activator_icalls)},
+       {"Mono.Security.Cryptography.KeyPairPersistence", keypair_icalls, G_N_ELEMENTS (keypair_icalls)},
+       {"System.Activator", activator_icalls, G_N_ELEMENTS (activator_icalls)},
        {"System.AppDomain", appdomain_icalls, G_N_ELEMENTS (appdomain_icalls)},
-       {"System.AppDomainSetup", appdomainsetup_icalls, G_N_ELEMENTS (appdomainsetup_icalls)},
        {"System.ArgIterator", argiterator_icalls, G_N_ELEMENTS (argiterator_icalls)},
        {"System.Array", array_icalls, G_N_ELEMENTS (array_icalls)},
        {"System.Buffer", buffer_icalls, G_N_ELEMENTS (buffer_icalls)},
@@ -5561,7 +5852,7 @@ static const IcallMap icall_entries [] = {
        {"System.Reflection.Emit.AssemblyBuilder", assemblybuilder_icalls, G_N_ELEMENTS (assemblybuilder_icalls)},
        {"System.Reflection.Emit.CustomAttributeBuilder", customattrbuilder_icalls, G_N_ELEMENTS (customattrbuilder_icalls)},
        {"System.Reflection.Emit.DynamicMethod", dynamicmethod_icalls, G_N_ELEMENTS (dynamicmethod_icalls)},
-       {"System.Reflection.Emit.LocalBuilder", localbuilder_icalls, G_N_ELEMENTS (localbuilder_icalls)},
+       {"System.Reflection.Emit.GenericTypeParameterBuilder", generictypeparambuilder_icalls, G_N_ELEMENTS (generictypeparambuilder_icalls)},
        {"System.Reflection.Emit.MethodBuilder", methodbuilder_icalls, G_N_ELEMENTS (methodbuilder_icalls)},
        {"System.Reflection.Emit.ModuleBuilder", modulebuilder_icalls, G_N_ELEMENTS (modulebuilder_icalls)},
        {"System.Reflection.Emit.SignatureHelper", signaturehelper_icalls, G_N_ELEMENTS (signaturehelper_icalls)},
@@ -5573,7 +5864,6 @@ static const IcallMap icall_entries [] = {
        {"System.Reflection.MonoEventInfo", monoeventinfo_icalls, G_N_ELEMENTS (monoeventinfo_icalls)},
        {"System.Reflection.MonoField", monofield_icalls, G_N_ELEMENTS (monofield_icalls)},
        {"System.Reflection.MonoGenericInst", monogenericinst_icalls, G_N_ELEMENTS (monogenericinst_icalls)},
-       {"System.Reflection.MonoGenericParam", monogenericparam_icalls, G_N_ELEMENTS (monogenericparam_icalls)},
        {"System.Reflection.MonoMethod", monomethod_icalls, G_N_ELEMENTS (monomethod_icalls)},
        {"System.Reflection.MonoMethodInfo", monomethodinfo_icalls, G_N_ELEMENTS (monomethodinfo_icalls)},
        {"System.Reflection.MonoPropertyInfo", monopropertyinfo_icalls, G_N_ELEMENTS (monopropertyinfo_icalls)},
@@ -5586,6 +5876,9 @@ static const IcallMap icall_entries [] = {
        {"System.Runtime.Remoting.RemotingServices", remotingservices_icalls, G_N_ELEMENTS (remotingservices_icalls)},
        {"System.RuntimeMethodHandle", methodhandle_icalls, G_N_ELEMENTS (methodhandle_icalls)},
        {"System.Security.Cryptography.RNGCryptoServiceProvider", rng_icalls, G_N_ELEMENTS (rng_icalls)},
+       {"System.Security.Principal.WindowsIdentity", identity_icalls, G_N_ELEMENTS (identity_icalls)},
+       {"System.Security.Principal.WindowsImpersonationContext", impersonation_icalls, G_N_ELEMENTS (impersonation_icalls)},
+       {"System.Security.Principal.WindowsPrincipal", principal_icalls, G_N_ELEMENTS (principal_icalls)},
        {"System.String", string_icalls, G_N_ELEMENTS (string_icalls)},
        {"System.Text.Encoding", encoding_icalls, G_N_ELEMENTS (encoding_icalls)},
        {"System.Threading.Interlocked", interlocked_icalls, G_N_ELEMENTS (interlocked_icalls)},
@@ -5764,8 +6057,8 @@ mono_lookup_internal_call (MonoMethod *method)
        }
        
        g_warning ("cant resolve internal call to \"%s\" (tested without signature also)", mname);
-       g_print ("\nYour mono runtime and corlib are out of sync.\n");
-       g_print ("Corlib is: %s\n", method->klass->image->name);
+       g_print ("\nYour mono runtime and class libraries are out of sync.\n");
+       g_print ("The out of sync library is: %s\n", method->klass->image->name);
        g_print ("\nWhen you update one from cvs you need to update, compile and install\nthe other too.\n");
        g_print ("Do not report this as a bug unless you're sure you have updated correctly:\nyou probably have a broken mono install.\n");
        g_print ("If you see other errors or faults after this message they are probably related\n");