- Sync with trunk r58248 to bring the latest changes from Amine (headers) and others...
[reactos.git] / dll / win32 / mscoree / mscoree_private.h
1 /*
2 *
3 * Copyright 2008 Alistair Leslie-Hughes
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #ifndef __MSCOREE_PRIVATE__
21 #define __MSCOREE_PRIVATE__
22
23 extern char *WtoA(LPCWSTR wstr) DECLSPEC_HIDDEN;
24
25 extern HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj) DECLSPEC_HIDDEN;
26
27 extern HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost* iface,
28 LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer) DECLSPEC_HIDDEN;
29
30 typedef struct _VTableFixup {
31 DWORD rva;
32 WORD count;
33 WORD type;
34 } VTableFixup;
35
36 typedef struct tagASSEMBLY ASSEMBLY;
37
38 extern HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN;
39 extern HRESULT assembly_from_hmodule(ASSEMBLY **out, HMODULE hmodule) DECLSPEC_HIDDEN;
40 extern HRESULT assembly_release(ASSEMBLY *assembly) DECLSPEC_HIDDEN;
41 extern HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN;
42 extern HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWORD *count) DECLSPEC_HIDDEN;
43
44 /* Mono embedding */
45 typedef struct _MonoDomain MonoDomain;
46 typedef struct _MonoAssembly MonoAssembly;
47 typedef struct _MonoAssemblyName MonoAssemblyName;
48 typedef struct _MonoType MonoType;
49 typedef struct _MonoImage MonoImage;
50 typedef struct _MonoClass MonoClass;
51 typedef struct _MonoObject MonoObject;
52 typedef struct _MonoString MonoString;
53 typedef struct _MonoMethod MonoMethod;
54 typedef struct _MonoProfiler MonoProfiler;
55 typedef struct _MonoThread MonoThread;
56
57 typedef struct loaded_mono loaded_mono;
58 typedef struct RuntimeHost RuntimeHost;
59
60 typedef struct CLRRuntimeInfo
61 {
62 ICLRRuntimeInfo ICLRRuntimeInfo_iface;
63 LPCWSTR mono_libdir;
64 DWORD major;
65 DWORD minor;
66 DWORD build;
67 int mono_abi_version;
68 WCHAR mono_path[MAX_PATH];
69 WCHAR mscorlib_path[MAX_PATH];
70 struct RuntimeHost *loaded_runtime;
71 } CLRRuntimeInfo;
72
73 struct RuntimeHost
74 {
75 ICorRuntimeHost ICorRuntimeHost_iface;
76 ICLRRuntimeHost ICLRRuntimeHost_iface;
77 const CLRRuntimeInfo *version;
78 loaded_mono *mono;
79 struct list domains;
80 MonoDomain *default_domain;
81 CRITICAL_SECTION lock;
82 LONG ref;
83 };
84
85 typedef struct CorProcess
86 {
87 struct list entry;
88 ICorDebugProcess *pProcess;
89 } CorProcess;
90
91 typedef struct CorDebug
92 {
93 ICorDebug ICorDebug_iface;
94 ICorDebugProcessEnum ICorDebugProcessEnum_iface;
95 LONG ref;
96
97 ICLRRuntimeHost *runtimehost;
98
99 /* ICorDebug Callback */
100 ICorDebugManagedCallback *pCallback;
101 ICorDebugManagedCallback2 *pCallback2;
102
103 /* Debug Processes */
104 struct list processes;
105 } CorDebug;
106
107 extern HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
108 DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) DECLSPEC_HIDDEN;
109
110 extern HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result) DECLSPEC_HIDDEN;
111
112 extern HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk) DECLSPEC_HIDDEN;
113
114 typedef struct parsed_config_file
115 {
116 struct list supported_runtimes;
117 } parsed_config_file;
118
119 typedef struct supported_runtime
120 {
121 struct list entry;
122 LPWSTR version;
123 } supported_runtime;
124
125 extern HRESULT parse_config_file(LPCWSTR filename, parsed_config_file *result) DECLSPEC_HIDDEN;
126
127 extern void free_parsed_config_file(parsed_config_file *file) DECLSPEC_HIDDEN;
128
129 typedef enum {
130 MONO_IMAGE_OK,
131 MONO_IMAGE_ERROR_ERRNO,
132 MONO_IMAGE_MISSING_ASSEMBLYREF,
133 MONO_IMAGE_IMAGE_INVALID
134 } MonoImageOpenStatus;
135
136 typedef MonoAssembly* (*MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname, char **assemblies_path, void *user_data);
137
138 typedef void (*MonoProfileFunc)(MonoProfiler *prof);
139
140 struct loaded_mono
141 {
142 HMODULE mono_handle;
143 HMODULE glib_handle;
144
145 BOOL is_started;
146 BOOL is_shutdown;
147
148 MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly);
149 MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status);
150 MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status);
151 MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type);
152 MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name);
153 MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count);
154 void (CDECL *mono_config_parse)(const char *filename);
155 MonoAssembly* (CDECL *mono_domain_assembly_open) (MonoDomain *domain, const char *name);
156 void (CDECL *mono_free)(void *);
157 MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status);
158 void (CDECL *mono_install_assembly_preload_hook)(MonoAssemblyPreLoadFunc func, void *user_data);
159 int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
160 MonoDomain* (CDECL *mono_jit_init)(const char *file);
161 int (CDECL *mono_jit_set_trace_options)(const char* options);
162 void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type);
163 MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj);
164 MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass);
165 void* (CDECL *mono_object_unbox)(MonoObject *obj);
166 void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
167 MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image);
168 MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
169 void (CDECL *mono_runtime_object_init)(MonoObject *this_obj);
170 void (CDECL *mono_runtime_quit)(void);
171 void (CDECL *mono_runtime_set_shutting_down)(void);
172 void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir);
173 char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname);
174 void (CDECL *mono_thread_pool_cleanup)(void);
175 void (CDECL *mono_thread_suspend_all_other_threads)(void);
176 void (CDECL *mono_threads_set_shutting_down)(void);
177 MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str);
178 MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain);
179 };
180
181 /* loaded runtime interfaces */
182 extern void unload_all_runtimes(void) DECLSPEC_HIDDEN;
183
184 extern void expect_no_runtimes(void) DECLSPEC_HIDDEN;
185
186 extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
187 loaded_mono *loaded_mono, RuntimeHost** result) DECLSPEC_HIDDEN;
188
189 extern HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN;
190
191 extern HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk) DECLSPEC_HIDDEN;
192
193 extern HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name,
194 MonoDomain *domain, MonoObject **result) DECLSPEC_HIDDEN;
195
196 extern HRESULT RuntimeHost_Destroy(RuntimeHost *This) DECLSPEC_HIDDEN;
197
198 HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime) DECLSPEC_HIDDEN;
199
200 extern HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown** ppUnk) DECLSPEC_HIDDEN;
201
202 extern HRESULT create_monodata(REFIID riid, LPVOID *ppObj) DECLSPEC_HIDDEN;
203
204 extern void runtimehost_init(void);
205 extern void runtimehost_uninit(void);
206
207 #endif /* __MSCOREE_PRIVATE__ */