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/io-layer/io-layer.h>
21 typedef void (*MonoThreadStartCB) (guint32 tid, gpointer stack_start,
23 typedef void (*MonoThreadAttachCB) (guint32 tid, gpointer stack_start);
25 /* This is a copy of System.AppDomainSetup */
28 MonoString *application_base;
29 MonoString *application_name;
30 MonoString *cache_path;
31 MonoString *configuration_file;
32 MonoString *dynamic_base;
33 MonoString *license_file;
34 MonoString *private_bin_path;
35 MonoString *private_bin_path_probe;
36 MonoString *shadow_copy_directories;
37 MonoString *shadow_copy_files;
38 MonoBoolean publisher_policy;
39 MonoBoolean path_changed;
40 int loader_optimization;
41 MonoBoolean disallow_binding_redirects;
42 MonoBoolean disallow_code_downloads;
45 typedef GArray MonoJitInfoTable;
51 gpointer handler_start;
56 } MonoJitExceptionInfo;
65 /* Whenever the code is domain neutral or 'shared' */
66 gboolean domain_neutral:1;
67 MonoJitExceptionInfo *clauses;
74 gpointer *static_data;
78 MONO_APPDOMAIN_CREATED,
79 MONO_APPDOMAIN_UNLOADING,
80 MONO_APPDOMAIN_UNLOADED
83 typedef struct _MonoAppDomain MonoAppDomain;
86 MonoAppDomain *domain;
87 CRITICAL_SECTION lock;
91 GHashTable *assemblies;
92 MonoAssembly *entry_assembly;
93 MonoAppDomainSetup *setup;
96 MonoGHashTable *ldstr_table;
97 MonoGHashTable *class_vtable_hash;
98 MonoGHashTable *proxy_vtable_hash;
99 MonoGHashTable *static_data_hash;
100 GHashTable *jit_code_hash;
101 MonoJitInfoTable *jit_info_table;
102 /* hashtables for Reflection handles */
103 MonoGHashTable *type_hash;
104 MonoGHashTable *refobject_hash;
105 /* Needed by Thread:GetDomainID() */
107 /* Used when loading assemblies */
109 /* Used by remoting proxies */
110 MonoMethod *create_proxy_for_type_method;
111 MonoMethod *private_invoke_method;
112 MonoAppContext *default_context;
113 MonoException *out_of_memory_ex;
114 /* Used to store offsets of thread and context static fields */
115 GHashTable *special_static_fields;
116 GHashTable *jump_target_hash;
117 MonoGHashTable *class_init_trampoline_hash;
119 * This must be a GHashTable, since these objects can't be finalized
120 * if the hashtable contains a GC visible reference to them.
122 GHashTable *finalizable_objects_hash;
125 /* This is a copy of System.AppDomain */
126 struct _MonoAppDomain {
127 MonoMarshalByRefObject mbr;
131 extern MonoDomain *mono_root_domain;
133 extern HANDLE mono_delegate_semaphore;
134 extern CRITICAL_SECTION mono_delegate_section;
136 #define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
137 #define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
139 typedef void (*MonoDomainFunc) (MonoDomain *domain, gpointer user_data);
142 mono_init (const char *filename);
145 mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
146 MonoThreadAttachCB attach_cb);
149 mono_runtime_cleanup (MonoDomain *domain);
152 mono_runtime_install_cleanup (MonoDomainFunc func);
155 mono_runtime_quit (void);
158 mono_domain_create (void);
161 mono_domain_get (void);
164 mono_domain_get_by_id (gint32 domainid);
167 mono_domain_set (MonoDomain *domain, gboolean force);
170 mono_domain_set_internal (MonoDomain *domain);
173 mono_domain_is_unloading (MonoDomain *domain);
176 mono_domain_foreach (MonoDomainFunc func, gpointer user_data);
179 mono_domain_assembly_open (MonoDomain *domain, const char *name);
182 mono_domain_finalize (MonoDomain *domain, guint32 timeout);
185 mono_domain_free (MonoDomain *domain, gboolean force);
188 mono_domain_has_type_resolve (MonoDomain *domain);
190 MonoReflectionAssembly *
191 mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *tb);
194 mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
197 mono_jit_info_table_find (MonoDomain *domain, char *addr);
200 ves_icall_System_AppDomainSetup_InitAppDomainSetup (MonoAppDomainSetup *setup);
203 ves_icall_System_AppDomain_getCurDomain (void);
206 ves_icall_System_AppDomain_createDomain (MonoString *friendly_name,
207 MonoAppDomainSetup *setup);
210 ves_icall_System_AppDomain_GetData (MonoAppDomain *ad,
214 ves_icall_System_AppDomain_SetData (MonoAppDomain *ad,
219 ves_icall_System_AppDomain_getSetup (MonoAppDomain *ad);
222 ves_icall_System_AppDomain_getFriendlyName (MonoAppDomain *ad);
225 ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad);
227 MonoReflectionAssembly *
228 ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname);
230 MonoReflectionAssembly *
231 ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad,
232 MonoReflectionAssemblyName *assRef,
233 MonoObject *evidence);
236 ves_icall_System_AppDomain_InternalIsFinalizingForUnload (gint32 domain_id);
239 ves_icall_System_AppDomain_InternalUnload (gint32 domain_id);
242 ves_icall_System_AppDomain_ExecuteAssembly (MonoAppDomain *ad,
244 MonoObject *evidence,
248 mono_context_init (MonoDomain *domain);
251 mono_context_set (MonoAppContext *new_context);
253 inline MonoAppContext *
254 mono_context_get (void);
257 ves_icall_System_AppDomain_InternalSetDomain (MonoAppDomain *ad);
260 ves_icall_System_AppDomain_InternalSetDomainByID (gint32 domainid);
263 ves_icall_System_AppDomain_InternalPushDomainRef (MonoAppDomain *ad);
266 ves_icall_System_AppDomain_InternalPushDomainRefByID (gint32 domain_id);
269 ves_icall_System_AppDomain_InternalPopDomainRef (void);
272 ves_icall_System_AppDomain_InternalGetContext (void);
275 ves_icall_System_AppDomain_InternalGetDefaultContext (void);
278 ves_icall_System_AppDomain_InternalSetContext (MonoAppContext *mc);
281 ves_icall_System_AppDomain_GetIDFromDomain (MonoAppDomain * ad);
284 ves_icall_System_AppDomain_InternalGetProcessGuid (MonoString* newguid);
287 #endif /* _MONO_METADATA_APPDOMAIN_H_ */