2 * appdomain.h: AppDomain functions
5 * Dietmar Maurer (dietmar@ximian.com)
7 * (C) 2001 Ximian, Inc.
10 #ifndef _MONO_METADATA_APPDOMAIN_H_
11 #define _MONO_METADATA_APPDOMAIN_H_
15 #include <mono/metadata/object.h>
16 #include <mono/metadata/reflection.h>
17 #include <mono/metadata/mempool.h>
18 #include <mono/utils/mono-hash.h>
19 #include <mono/utils/mono-codeman.h>
20 #include <mono/io-layer/io-layer.h>
22 typedef void (*MonoThreadStartCB) (guint32 tid, gpointer stack_start,
24 typedef void (*MonoThreadAttachCB) (guint32 tid, gpointer stack_start);
26 /* This is a copy of System.AppDomainSetup */
29 MonoString *application_base;
30 MonoString *application_name;
31 MonoString *cache_path;
32 MonoString *configuration_file;
33 MonoString *dynamic_base;
34 MonoString *license_file;
35 MonoString *private_bin_path;
36 MonoString *private_bin_path_probe;
37 MonoString *shadow_copy_directories;
38 MonoString *shadow_copy_files;
39 MonoBoolean publisher_policy;
40 MonoBoolean path_changed;
41 int loader_optimization;
42 MonoBoolean disallow_binding_redirects;
43 MonoBoolean disallow_code_downloads;
46 typedef GArray MonoJitInfoTable;
52 gpointer handler_start;
57 } MonoJitExceptionInfo;
66 /* Whenever the code is domain neutral or 'shared' */
67 gboolean domain_neutral:1;
68 MonoJitExceptionInfo *clauses;
75 gpointer *static_data;
79 MONO_APPDOMAIN_CREATED,
80 MONO_APPDOMAIN_UNLOADING,
81 MONO_APPDOMAIN_UNLOADED
84 typedef struct _MonoAppDomain MonoAppDomain;
87 MonoAppDomain *domain;
88 CRITICAL_SECTION lock;
90 MonoCodeManager *code_mp;
92 GHashTable *assemblies;
93 MonoAssembly *entry_assembly;
94 MonoAppDomainSetup *setup;
97 MonoGHashTable *ldstr_table;
98 MonoGHashTable *class_vtable_hash;
99 MonoGHashTable *proxy_vtable_hash;
100 MonoGHashTable *static_data_hash;
101 GHashTable *jit_code_hash;
102 MonoJitInfoTable *jit_info_table;
103 /* hashtables for Reflection handles */
104 MonoGHashTable *type_hash;
105 MonoGHashTable *refobject_hash;
106 /* Needed by Thread:GetDomainID() */
108 /* Used when loading assemblies */
110 /* Used by remoting proxies */
111 MonoMethod *create_proxy_for_type_method;
112 MonoMethod *private_invoke_method;
113 MonoAppContext *default_context;
114 MonoException *out_of_memory_ex;
115 MonoException *null_reference_ex;
116 MonoException *stack_overflow_ex;
117 /* Used to store offsets of thread and context static fields */
118 GHashTable *special_static_fields;
119 GHashTable *jump_target_hash;
120 MonoGHashTable *class_init_trampoline_hash;
122 * This must be a GHashTable, since these objects can't be finalized
123 * if the hashtable contains a GC visible reference to them.
125 GHashTable *finalizable_objects_hash;
128 /* This is a copy of System.AppDomain */
129 struct _MonoAppDomain {
130 MonoMarshalByRefObject mbr;
134 extern MonoDomain *mono_root_domain;
136 extern HANDLE mono_delegate_semaphore;
137 extern CRITICAL_SECTION mono_delegate_section;
139 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
140 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
142 typedef void (*MonoDomainFunc) (MonoDomain *domain, gpointer user_data);
145 mono_init (const char *filename);
148 mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
149 MonoThreadAttachCB attach_cb);
152 mono_runtime_cleanup (MonoDomain *domain);
155 mono_runtime_install_cleanup (MonoDomainFunc func);
158 mono_runtime_quit (void);
161 mono_runtime_is_shutting_down (void);
164 mono_check_corlib_version (void);
167 mono_domain_create (void);
170 mono_domain_get (void);
173 mono_domain_get_by_id (gint32 domainid);
176 mono_domain_set (MonoDomain *domain, gboolean force);
179 mono_domain_set_internal (MonoDomain *domain);
182 mono_domain_is_unloading (MonoDomain *domain);
185 mono_domain_foreach (MonoDomainFunc func, gpointer user_data);
188 mono_domain_assembly_open (MonoDomain *domain, const char *name);
191 mono_domain_finalize (MonoDomain *domain, guint32 timeout);
194 mono_domain_free (MonoDomain *domain, gboolean force);
197 mono_domain_has_type_resolve (MonoDomain *domain);
199 MonoReflectionAssembly *
200 mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb);
203 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
206 mono_jit_info_table_find (MonoDomain *domain, char *addr);
209 ves_icall_System_AppDomain_getCurDomain (void);
212 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
213 MonoAppDomainSetup *setup);
216 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
219 MonoReflectionAssembly *
220 ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
221 MonoArray *raw_assembly,
222 MonoArray *raw_symbol_store,
223 MonoObject *evidence);
226 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
231 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad);
234 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad);
237 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad);
239 MonoReflectionAssembly *
240 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname);
242 MonoReflectionAssembly *
243 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
245 MonoObject *evidence);
248 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id);
251 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id);
254 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
256 MonoObject *evidence,
260 mono_context_init (MonoDomain *domain);
263 mono_context_set (MonoAppContext *new_context);
265 inline MonoAppContext *
266 mono_context_get (void);
269 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad);
272 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid);
275 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad);
278 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id);
281 ves_icall_System_AppDomain_InternalPopDomainRef (void);
284 ves_icall_System_AppDomain_InternalGetContext (void);
287 ves_icall_System_AppDomain_InternalGetDefaultContext (void);
290 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc);
293 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad);
296 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid);
299 #endif /* _MONO_METADATA_APPDOMAIN_H_ */