static void mono_invoke_protected_memory_method (MonoArrayHandle data, MonoObjectHandle scope, const char *method_name, MonoMethod **method, MonoError *error) { if (!*method) { if (system_security_assembly == NULL) { system_security_assembly = mono_image_loaded_internal ("System.Security", FALSE); if (!system_security_assembly) { MonoAssemblyOpenRequest req; mono_assembly_request_prepare (&req.request, sizeof (req), MONO_ASMCTX_DEFAULT); MonoAssembly *sa = mono_assembly_request_open ("System.Security.dll", &req, NULL); g_assert (sa); system_security_assembly = mono_assembly_get_image_internal (sa); } } MonoClass *klass = mono_class_load_from_name (system_security_assembly, "System.Security.Cryptography", "ProtectedMemory"); *method = mono_class_get_method_from_name_checked (klass, method_name, 2, 0, error); mono_error_assert_ok (error); g_assert (*method); } void *params [ ] = { MONO_HANDLE_RAW (data), MONO_HANDLE_RAW (scope) // MemoryProtectionScope.SameProcess }; mono_runtime_invoke_handle_void (*method, NULL_HANDLE, params, error); }
static void mono_debug_add_assembly (MonoAssembly *assembly, gpointer user_data) { MonoDebugHandle *handle; MonoImage *image; mono_debugger_lock (); image = mono_assembly_get_image_internal (assembly); handle = open_symfile_from_bundle (image); if (!handle) mono_debug_open_image (image, NULL, 0); mono_debugger_unlock (); }
int test_mono_callspec_main (void) { int res = 0; MonoDomain *domain = NULL; MonoAssembly *assembly = NULL; MonoImage *prog_image = NULL; MonoImage *corlib = NULL; MonoClass *prog_klass, *console_klass; MonoMethod *meth; MonoImageOpenStatus status; //FIXME This is a fugly hack due to embedding simply not working from the tree mono_set_assemblies_path ("../../mcs/class/lib/net_4_x"); test_methods = g_array_new (FALSE, TRUE, sizeof (MonoMethod *)); if (!test_methods) { res = 1; printf ("FAILED INITIALIZING METHODS ARRAY\n"); goto out; } domain = mono_jit_init_version ("TEST RUNNER", "mobile"); assembly = mono_assembly_open (TESTPROG, &status); if (!domain || !assembly) { res = 1; printf("FAILED LOADING TEST PROGRAM\n"); goto out; } mono_callspec_set_assembly(assembly); prog_image = mono_assembly_get_image_internal (assembly); prog_klass = test_mono_class_from_name (prog_image, "Baz", "Foo"); if (!prog_klass) { res = 1; printf ("FAILED FINDING Baz.Foo\n"); goto out; } meth = mono_class_get_method_from_name (prog_klass, "Bar", 0); if (!meth) { res = 1; printf ("FAILED FINDING Baz.Foo:Bar ()\n"); goto out; } g_array_append_val (test_methods, meth); meth = mono_class_get_method_from_name (prog_klass, "Bar", 1); if (!meth) { res = 1; printf ("FAILED FINDING Baz.Foo:Bar (string)\n"); goto out; } g_array_append_val (test_methods, meth); prog_klass = test_mono_class_from_name (prog_image, "Baz", "Goo"); if (!prog_klass) { res = 1; printf ("FAILED FINDING Baz.Goo\n"); goto out; } meth = mono_class_get_method_from_name (prog_klass, "Bar", 1); if (!meth) { res = 1; printf ("FAILED FINDING Baz.Goo:Bar (string)\n"); goto out; } g_array_append_val (test_methods, meth); prog_klass = test_mono_class_from_name (prog_image, "Baz", "Foo2"); if (!prog_klass) { res = 1; printf ("FAILED FINDING Baz.Foo2\n"); goto out; } meth = mono_class_get_method_from_name (prog_klass, "Bar", 1); if (!meth) { res = 1; printf ("FAILED FINDING Baz.Foo2:Bar (string)\n"); goto out; } g_array_append_val (test_methods, meth); corlib = mono_get_corlib (); console_klass = test_mono_class_from_name (corlib, "System", "Console"); if (!console_klass) { res = 1; printf ("FAILED FINDING System.Console\n"); goto out; } meth = mono_class_get_method_from_name (console_klass, "WriteLine", 1); if (!meth) { res = 1; printf ("FAILED FINDING System.Console:WriteLine\n"); goto out; } g_array_append_val (test_methods, meth); res = test_all_callspecs (); out: return res; }