#include <mono/metadata/mono-config.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/security-manager.h>
+#include <mono/metadata/security-core-clr.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/strtod.h>
#include <mono/utils/monobitset.h>
*result = strtod (ptr, &endptr);
#else
if (*ptr)
- *result = bsd_strtod (ptr, &endptr);
+ *result = mono_strtod (ptr, &endptr);
#endif
if (!*ptr || (endptr && *endptr))
if ((req_info & PInfo_GetMethod) != 0)
info->get = property->property->get ?
- mono_method_get_object (domain, property->property->get, NULL): NULL;
+ mono_method_get_object (domain, property->property->get, property->klass): NULL;
if ((req_info & PInfo_SetMethod) != 0)
info->set = property->property->set ?
- mono_method_get_object (domain, property->property->set, NULL): NULL;
+ mono_method_get_object (domain, property->property->set, property->klass): NULL;
/*
* There may be other methods defined for properties, though, it seems they are not exposed
* in the reflection API
if (klass->generic_container) {
MonoGenericContainer *container = klass->generic_container;
- res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, container->type_argc);
+ res = mono_array_new (mono_object_domain (type), mono_defaults.systemtype_class, container->type_argc);
for (i = 0; i < container->type_argc; ++i) {
pklass = mono_class_from_generic_parameter (&container->type_params [i], klass->image, FALSE);
mono_array_setref (res, i, mono_type_get_object (mono_object_domain (type), &pklass->byval_arg));
}
} else if (klass->generic_class) {
MonoGenericInst *inst = klass->generic_class->context.class_inst;
- res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, inst->type_argc);
+ res = mono_array_new (mono_object_domain (type), mono_defaults.systemtype_class, inst->type_argc);
for (i = 0; i < inst->type_argc; ++i)
mono_array_setref (res, i, mono_type_get_object (mono_object_domain (type), inst->type_argv [i]));
} else {
- res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, 0);
+ res = mono_array_new (mono_object_domain (type), mono_defaults.systemtype_class, 0);
}
return res;
}
return res;
}
+static void
+ensure_reflection_security (void)
+{
+ MonoMethod *m = mono_method_get_last_managed ();
+
+ while (m) {
+ /*
+ g_print ("method %s.%s.%s in image %s\n",
+ m->klass->name_space, m->klass->name, m->name, m->klass->image->name);
+ */
+
+ /* We stop at the first method which is not in
+ System.Reflection or which is not in a platform
+ image. */
+ if (strcmp (m->klass->name_space, "System.Reflection") != 0 ||
+ !mono_security_core_clr_is_platform_image (m->klass->image)) {
+ /* If the method is transparent we throw an exception. */
+ if (mono_security_core_clr_method_level (m, TRUE) == MONO_SECURITY_CORE_CLR_TRANSPARENT ) {
+ MonoException *ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MethodAccessException", "Reflection called from transparent code");
+
+ mono_raise_exception (ex);
+ }
+ return;
+ }
+
+ mono_stack_walk_no_il (get_caller, &m);
+ }
+}
+
static MonoObject *
ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
{
MONO_ARCH_SAVE_REGS;
+ if (mono_security_get_mode () == MONO_SECURITY_MODE_CORE_CLR &&
+ mono_security_core_clr_method_level (m, TRUE) == MONO_SECURITY_CORE_CLR_CRITICAL)
+ ensure_reflection_security ();
+
if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
if (this) {
if (!mono_object_isinst (this, m->klass))
}
static MonoReflectionModule*
-ves_icall_System_Reflection_Assembly_get_ManifestModule (MonoReflectionAssembly *assembly)
+ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoReflectionAssembly *assembly)
{
return mono_module_get_object (mono_object_domain (assembly), assembly->assembly->image);
}
if (image->dynamic) {
if (type_args || method_args)
mono_raise_exception (mono_get_exception_not_implemented (NULL));
- return mono_lookup_dynamic_token (image, token);
+ return mono_lookup_dynamic_token (image, token, NULL);
}
if ((index <= 0) || (index > image->tables [table].rows)) {
if (type_args || method_args)
mono_raise_exception (mono_get_exception_not_implemented (NULL));
/* FIXME: validate memberref token type */
- return mono_lookup_dynamic_token (image, token);
+ return mono_lookup_dynamic_token (image, token, NULL);
}
if ((index <= 0) || (index > image->tables [table].rows)) {
}
if (image->dynamic)
- return mono_lookup_dynamic_token (image, token);
+ return mono_lookup_dynamic_token (image, token, NULL);
if ((index <= 0) || (index >= image->heap_us.size)) {
*error = ResolveTokenError_OutOfRange;
if (type_args || method_args)
mono_raise_exception (mono_get_exception_not_implemented (NULL));
/* FIXME: validate memberref token type */
- return mono_lookup_dynamic_token (image, token);
+ return mono_lookup_dynamic_token (image, token, NULL);
}
if ((index <= 0) || (index > image->tables [table].rows)) {
}
static MonoString *
-ves_icall_System_Configuration_DefaultConfig_get_bundled_machine_config (void)
+get_bundled_machine_config (void)
{
const gchar *machine_config;