a45a4052e9d9e9e0335a5c4a2fa3f662688e2483
[reactos.git] / reactos / 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 tagASSEMBLY ASSEMBLY;
31
32 HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN;
33 HRESULT assembly_release(ASSEMBLY *assembly) DECLSPEC_HIDDEN;
34 HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN;
35
36 /* Mono embedding */
37 typedef struct _MonoDomain MonoDomain;
38 typedef struct _MonoAssembly MonoAssembly;
39 typedef struct _MonoAssemblyName MonoAssemblyName;
40 typedef struct _MonoType MonoType;
41 typedef struct _MonoImage MonoImage;
42 typedef struct _MonoClass MonoClass;
43 typedef struct _MonoObject MonoObject;
44 typedef struct _MonoString MonoString;
45 typedef struct _MonoMethod MonoMethod;
46 typedef struct _MonoProfiler MonoProfiler;
47
48 typedef struct loaded_mono loaded_mono;
49 typedef struct RuntimeHost RuntimeHost;
50
51 typedef struct CLRRuntimeInfo
52 {
53 ICLRRuntimeInfo ICLRRuntimeInfo_iface;
54 LPCWSTR mono_libdir;
55 DWORD major;
56 DWORD minor;
57 DWORD build;
58 int mono_abi_version;
59 WCHAR mono_path[MAX_PATH];
60 WCHAR mscorlib_path[MAX_PATH];
61 struct RuntimeHost *loaded_runtime;
62 } CLRRuntimeInfo;
63
64 struct RuntimeHost
65 {
66 ICorRuntimeHost ICorRuntimeHost_iface;
67 ICLRRuntimeHost ICLRRuntimeHost_iface;
68 const CLRRuntimeInfo *version;
69 loaded_mono *mono;
70 struct list domains;
71 MonoDomain *default_domain;
72 CRITICAL_SECTION lock;
73 LONG ref;
74 };
75
76 typedef struct CorProcess
77 {
78 struct list entry;
79 ICorDebugProcess *pProcess;
80 } CorProcess;
81
82 typedef struct CorDebug
83 {
84 ICorDebug ICorDebug_iface;
85 ICorDebugProcessEnum ICorDebugProcessEnum_iface;
86 LONG ref;
87
88 ICLRRuntimeHost *runtimehost;
89
90 /* ICorDebug Callback */
91 ICorDebugManagedCallback *pCallback;
92 ICorDebugManagedCallback2 *pCallback2;
93
94 /* Debug Processes */
95 struct list processes;
96 } CorDebug;
97
98 extern HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file,
99 DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) DECLSPEC_HIDDEN;
100
101 extern HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result) DECLSPEC_HIDDEN;
102
103 extern HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk) DECLSPEC_HIDDEN;
104
105 typedef struct parsed_config_file
106 {
107 struct list supported_runtimes;
108 } parsed_config_file;
109
110 typedef struct supported_runtime
111 {
112 struct list entry;
113 LPWSTR version;
114 } supported_runtime;
115
116 extern HRESULT parse_config_file(LPCWSTR filename, parsed_config_file *result) DECLSPEC_HIDDEN;
117
118 extern void free_parsed_config_file(parsed_config_file *file) DECLSPEC_HIDDEN;
119
120 typedef enum {
121 MONO_IMAGE_OK,
122 MONO_IMAGE_ERROR_ERRNO,
123 MONO_IMAGE_MISSING_ASSEMBLYREF,
124 MONO_IMAGE_IMAGE_INVALID
125 } MonoImageOpenStatus;
126
127 typedef MonoAssembly* (*MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname, char **assemblies_path, void *user_data);
128
129 typedef void (*MonoProfileFunc)(MonoProfiler *prof);
130
131 struct loaded_mono
132 {
133 HMODULE mono_handle;
134 HMODULE glib_handle;
135
136 BOOL is_started;
137 BOOL is_shutdown;
138
139 MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly);
140 MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status);
141 MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type);
142 MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name);
143 MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count);
144 void (CDECL *mono_config_parse)(const char *filename);
145 MonoAssembly* (CDECL *mono_domain_assembly_open) (MonoDomain *domain, const char *name);
146 void (CDECL *mono_free)(void *);
147 void (CDECL *mono_install_assembly_preload_hook)(MonoAssemblyPreLoadFunc func, void *user_data);
148 int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
149 MonoDomain* (CDECL *mono_jit_init)(const char *file);
150 int (CDECL *mono_jit_set_trace_options)(const char* options);
151 MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj);
152 MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass);
153 void* (CDECL *mono_object_unbox)(MonoObject *obj);
154 void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback);
155 MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image);
156 MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc);
157 void (CDECL *mono_runtime_object_init)(MonoObject *this_obj);
158 void (CDECL *mono_runtime_quit)(void);
159 void (CDECL *mono_runtime_set_shutting_down)(void);
160 void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir);
161 char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname);
162 void (CDECL *mono_thread_pool_cleanup)(void);
163 void (CDECL *mono_thread_suspend_all_other_threads)(void);
164 void (CDECL *mono_threads_set_shutting_down)(void);
165 MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str);
166 };
167
168 /* loaded runtime interfaces */
169 extern void unload_all_runtimes(void) DECLSPEC_HIDDEN;
170
171 extern void expect_no_runtimes(void) DECLSPEC_HIDDEN;
172
173 extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
174 loaded_mono *loaded_mono, RuntimeHost** result) DECLSPEC_HIDDEN;
175
176 extern HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN;
177
178 extern HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk) DECLSPEC_HIDDEN;
179
180 extern HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name,
181 MonoDomain *domain, MonoObject **result) DECLSPEC_HIDDEN;
182
183 extern HRESULT RuntimeHost_Destroy(RuntimeHost *This) DECLSPEC_HIDDEN;
184
185 HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime) DECLSPEC_HIDDEN;
186
187 extern HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown** ppUnk) DECLSPEC_HIDDEN;
188
189 #endif /* __MSCOREE_PRIVATE__ */