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 #include <stdarg.h> 24 25 #define WIN32_NO_STATUS 26 #define _INC_WINDOWS 27 #define COM_NO_WINDOWS_H 28 29 #define COBJMACROS 30 31 #include <windef.h> 32 #include <winbase.h> 33 #include <winreg.h> 34 #include <objbase.h> 35 #include <cor.h> 36 #include <cordebug.h> 37 #include <metahost.h> 38 39 #include <wine/list.h> 40 #include <wine/unicode.h> 41 42 #include <wine/debug.h> 43 WINE_DEFAULT_DEBUG_CHANNEL( mscoree ); 44 45 extern char *WtoA(LPCWSTR wstr) DECLSPEC_HIDDEN; 46 47 extern HRESULT CLRMetaHost_CreateInstance(REFIID riid, void **ppobj) DECLSPEC_HIDDEN; 48 49 extern HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost* iface, 50 LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer) DECLSPEC_HIDDEN; 51 52 typedef struct _VTableFixup { 53 DWORD rva; 54 WORD count; 55 WORD type; 56 } VTableFixup; 57 58 typedef struct tagASSEMBLY ASSEMBLY; 59 60 extern HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN; 61 extern HRESULT assembly_from_hmodule(ASSEMBLY **out, HMODULE hmodule) DECLSPEC_HIDDEN; 62 extern HRESULT assembly_release(ASSEMBLY *assembly) DECLSPEC_HIDDEN; 63 extern HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN; 64 extern HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWORD *count) DECLSPEC_HIDDEN; 65 66 /* Mono embedding */ 67 typedef struct _MonoDomain MonoDomain; 68 typedef struct _MonoAssembly MonoAssembly; 69 typedef struct _MonoAssemblyName MonoAssemblyName; 70 typedef struct _MonoType MonoType; 71 typedef struct _MonoImage MonoImage; 72 typedef struct _MonoClass MonoClass; 73 typedef struct _MonoObject MonoObject; 74 typedef struct _MonoString MonoString; 75 typedef struct _MonoMethod MonoMethod; 76 typedef struct _MonoProfiler MonoProfiler; 77 typedef struct _MonoThread MonoThread; 78 79 typedef struct loaded_mono loaded_mono; 80 typedef struct RuntimeHost RuntimeHost; 81 82 typedef struct CLRRuntimeInfo 83 { 84 ICLRRuntimeInfo ICLRRuntimeInfo_iface; 85 LPCWSTR mono_libdir; 86 DWORD major; 87 DWORD minor; 88 DWORD build; 89 int mono_abi_version; 90 WCHAR mono_path[MAX_PATH]; 91 WCHAR mscorlib_path[MAX_PATH]; 92 struct RuntimeHost *loaded_runtime; 93 } CLRRuntimeInfo; 94 95 struct RuntimeHost 96 { 97 ICorRuntimeHost ICorRuntimeHost_iface; 98 ICLRRuntimeHost ICLRRuntimeHost_iface; 99 const CLRRuntimeInfo *version; 100 loaded_mono *mono; 101 struct list domains; 102 MonoDomain *default_domain; 103 CRITICAL_SECTION lock; 104 LONG ref; 105 }; 106 107 typedef struct CorProcess 108 { 109 struct list entry; 110 ICorDebugProcess *pProcess; 111 } CorProcess; 112 113 typedef struct CorDebug 114 { 115 ICorDebug ICorDebug_iface; 116 ICorDebugProcessEnum ICorDebugProcessEnum_iface; 117 LONG ref; 118 119 ICLRRuntimeHost *runtimehost; 120 121 /* ICorDebug Callback */ 122 ICorDebugManagedCallback *pCallback; 123 ICorDebugManagedCallback2 *pCallback2; 124 125 /* Debug Processes */ 126 struct list processes; 127 } CorDebug; 128 129 extern HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, 130 DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) DECLSPEC_HIDDEN; 131 132 extern HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result) DECLSPEC_HIDDEN; 133 134 extern HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk) DECLSPEC_HIDDEN; 135 136 typedef struct parsed_config_file 137 { 138 struct list supported_runtimes; 139 } parsed_config_file; 140 141 typedef struct supported_runtime 142 { 143 struct list entry; 144 LPWSTR version; 145 } supported_runtime; 146 147 extern HRESULT parse_config_file(LPCWSTR filename, parsed_config_file *result) DECLSPEC_HIDDEN; 148 149 extern void free_parsed_config_file(parsed_config_file *file) DECLSPEC_HIDDEN; 150 151 typedef enum { 152 MONO_IMAGE_OK, 153 MONO_IMAGE_ERROR_ERRNO, 154 MONO_IMAGE_MISSING_ASSEMBLYREF, 155 MONO_IMAGE_IMAGE_INVALID 156 } MonoImageOpenStatus; 157 158 typedef MonoAssembly* (*MonoAssemblyPreLoadFunc)(MonoAssemblyName *aname, char **assemblies_path, void *user_data); 159 160 typedef void (*MonoProfileFunc)(MonoProfiler *prof); 161 162 struct loaded_mono 163 { 164 HMODULE mono_handle; 165 HMODULE glib_handle; 166 167 BOOL is_started; 168 BOOL is_shutdown; 169 170 MonoImage* (CDECL *mono_assembly_get_image)(MonoAssembly *assembly); 171 MonoAssembly* (CDECL *mono_assembly_load_from)(MonoImage *image, const char *fname, MonoImageOpenStatus *status); 172 MonoAssembly* (CDECL *mono_assembly_open)(const char *filename, MonoImageOpenStatus *status); 173 MonoClass* (CDECL *mono_class_from_mono_type)(MonoType *type); 174 MonoClass* (CDECL *mono_class_from_name)(MonoImage *image, const char* name_space, const char *name); 175 MonoMethod* (CDECL *mono_class_get_method_from_name)(MonoClass *klass, const char *name, int param_count); 176 void (CDECL *mono_config_parse)(const char *filename); 177 MonoAssembly* (CDECL *mono_domain_assembly_open) (MonoDomain *domain, const char *name); 178 void (CDECL *mono_free)(void *); 179 MonoImage* (CDECL *mono_image_open_from_module_handle)(HMODULE module_handle, char* fname, UINT has_entry_point, MonoImageOpenStatus* status); 180 void (CDECL *mono_install_assembly_preload_hook)(MonoAssemblyPreLoadFunc func, void *user_data); 181 int (CDECL *mono_jit_exec)(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]); 182 MonoDomain* (CDECL *mono_jit_init)(const char *file); 183 int (CDECL *mono_jit_set_trace_options)(const char* options); 184 void* (CDECL *mono_marshal_get_vtfixup_ftnptr)(MonoImage *image, DWORD token, WORD type); 185 MonoDomain* (CDECL *mono_object_get_domain)(MonoObject *obj); 186 MonoObject* (CDECL *mono_object_new)(MonoDomain *domain, MonoClass *klass); 187 void* (CDECL *mono_object_unbox)(MonoObject *obj); 188 void (CDECL *mono_profiler_install)(MonoProfiler *prof, MonoProfileFunc shutdown_callback); 189 MonoType* (CDECL *mono_reflection_type_from_name)(char *name, MonoImage *image); 190 MonoObject* (CDECL *mono_runtime_invoke)(MonoMethod *method, void *obj, void **params, MonoObject **exc); 191 void (CDECL *mono_runtime_object_init)(MonoObject *this_obj); 192 void (CDECL *mono_runtime_quit)(void); 193 void (CDECL *mono_runtime_set_shutting_down)(void); 194 void (CDECL *mono_set_dirs)(const char *assembly_dir, const char *config_dir); 195 char* (CDECL *mono_stringify_assembly_name)(MonoAssemblyName *aname); 196 void (CDECL *mono_thread_pool_cleanup)(void); 197 void (CDECL *mono_thread_suspend_all_other_threads)(void); 198 void (CDECL *mono_threads_set_shutting_down)(void); 199 MonoString* (CDECL *mono_string_new)(MonoDomain *domain, const char *str); 200 MonoThread* (CDECL *mono_thread_attach)(MonoDomain *domain); 201 }; 202 203 /* loaded runtime interfaces */ 204 extern void unload_all_runtimes(void) DECLSPEC_HIDDEN; 205 206 extern void expect_no_runtimes(void) DECLSPEC_HIDDEN; 207 208 extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version, 209 loaded_mono *loaded_mono, RuntimeHost** result) DECLSPEC_HIDDEN; 210 211 extern HRESULT RuntimeHost_GetInterface(RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN; 212 213 extern HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk) DECLSPEC_HIDDEN; 214 215 extern HRESULT RuntimeHost_CreateManagedInstance(RuntimeHost *This, LPCWSTR name, 216 MonoDomain *domain, MonoObject **result) DECLSPEC_HIDDEN; 217 218 extern HRESULT RuntimeHost_Destroy(RuntimeHost *This) DECLSPEC_HIDDEN; 219 220 HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost* iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime) DECLSPEC_HIDDEN; 221 222 extern HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown** ppUnk) DECLSPEC_HIDDEN; 223 224 extern HRESULT create_monodata(REFIID riid, LPVOID *ppObj) DECLSPEC_HIDDEN; 225 226 extern void runtimehost_init(void); 227 extern void runtimehost_uninit(void); 228 229 #endif /* __MSCOREE_PRIVATE__ */ 230