ReactOS  0.4.13-dev-259-g5ca9c9c
mscoree_private.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winreg.h>
#include <objbase.h>
#include <cor.h>
#include <cordebug.h>
#include <metahost.h>
#include <wine/list.h>
#include <wine/unicode.h>
#include <wine/debug.h>
Include dependency graph for mscoree_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _VTableFixup
 
struct  CLRRuntimeInfo
 
struct  RuntimeHost
 
struct  CorProcess
 
struct  CorDebug
 
struct  parsed_config_file
 
struct  supported_runtime
 
struct  loaded_mono
 

Macros

#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define COBJMACROS
 

Typedefs

typedef struct _VTableFixup VTableFixup
 
typedef struct tagASSEMBLY ASSEMBLY
 
typedef struct _MonoDomain MonoDomain
 
typedef struct _MonoAssembly MonoAssembly
 
typedef struct _MonoAssemblyName MonoAssemblyName
 
typedef struct _MonoType MonoType
 
typedef struct _MonoImage MonoImage
 
typedef struct _MonoClass MonoClass
 
typedef struct _MonoObject MonoObject
 
typedef struct _MonoString MonoString
 
typedef struct _MonoMethod MonoMethod
 
typedef struct _MonoProfiler MonoProfiler
 
typedef struct _MonoThread MonoThread
 
typedef struct loaded_mono loaded_mono
 
typedef struct RuntimeHost RuntimeHost
 
typedef struct CLRRuntimeInfo CLRRuntimeInfo
 
typedef struct CorProcess CorProcess
 
typedef struct CorDebug CorDebug
 
typedef struct parsed_config_file parsed_config_file
 
typedef struct supported_runtime supported_runtime
 
typedef MonoAssembly *(* MonoAssemblyPreLoadFunc) (MonoAssemblyName *aname, char **assemblies_path, void *user_data)
 
typedef void(* MonoProfileFunc) (MonoProfiler *prof)
 

Enumerations

enum  MonoImageOpenStatus { MONO_IMAGE_OK, MONO_IMAGE_ERROR_ERRNO, MONO_IMAGE_MISSING_ASSEMBLYREF, MONO_IMAGE_IMAGE_INVALID }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (mscoree)
 
charWtoA (LPCWSTR wstr) DECLSPEC_HIDDEN
 
HRESULT CLRMetaHost_CreateInstance (REFIID riid, void **ppobj) DECLSPEC_HIDDEN
 
HRESULT WINAPI CLRMetaHost_GetVersionFromFile (ICLRMetaHost *iface, LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer) DECLSPEC_HIDDEN
 
HRESULT assembly_create (ASSEMBLY **out, LPCWSTR file) DECLSPEC_HIDDEN
 
HRESULT assembly_from_hmodule (ASSEMBLY **out, HMODULE hmodule) DECLSPEC_HIDDEN
 
HRESULT assembly_release (ASSEMBLY *assembly) DECLSPEC_HIDDEN
 
HRESULT assembly_get_runtime_version (ASSEMBLY *assembly, LPSTR *version) DECLSPEC_HIDDEN
 
HRESULT assembly_get_vtable_fixups (ASSEMBLY *assembly, VTableFixup **fixups, DWORD *count) DECLSPEC_HIDDEN
 
HRESULT get_runtime_info (LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result) DECLSPEC_HIDDEN
 
HRESULT ICLRRuntimeInfo_GetRuntimeHost (ICLRRuntimeInfo *iface, RuntimeHost **result) DECLSPEC_HIDDEN
 
HRESULT MetaDataDispenser_CreateInstance (IUnknown **ppUnk) DECLSPEC_HIDDEN
 
HRESULT parse_config_file (LPCWSTR filename, parsed_config_file *result) DECLSPEC_HIDDEN
 
void free_parsed_config_file (parsed_config_file *file) DECLSPEC_HIDDEN
 
void unload_all_runtimes (void) DECLSPEC_HIDDEN
 
void expect_no_runtimes (void) DECLSPEC_HIDDEN
 
HRESULT RuntimeHost_Construct (const CLRRuntimeInfo *runtime_version, loaded_mono *loaded_mono, RuntimeHost **result) DECLSPEC_HIDDEN
 
HRESULT RuntimeHost_GetInterface (RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv) DECLSPEC_HIDDEN
 
HRESULT RuntimeHost_GetIUnknownForObject (RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk) DECLSPEC_HIDDEN
 
HRESULT RuntimeHost_CreateManagedInstance (RuntimeHost *This, LPCWSTR name, MonoDomain *domain, MonoObject **result) DECLSPEC_HIDDEN
 
HRESULT RuntimeHost_Destroy (RuntimeHost *This) DECLSPEC_HIDDEN
 
HRESULT WINAPI CLRMetaHost_GetRuntime (ICLRMetaHost *iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime) DECLSPEC_HIDDEN
 
HRESULT CorDebug_Create (ICLRRuntimeHost *runtimehost, IUnknown **ppUnk) DECLSPEC_HIDDEN
 
HRESULT create_monodata (REFIID riid, LPVOID *ppObj) DECLSPEC_HIDDEN
 
void runtimehost_init (void)
 
void runtimehost_uninit (void)
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 26 of file mscoree_private.h.

◆ COBJMACROS

#define COBJMACROS

Definition at line 29 of file mscoree_private.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 27 of file mscoree_private.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 25 of file mscoree_private.h.

Typedef Documentation

◆ ASSEMBLY

Definition at line 58 of file mscoree_private.h.

◆ CLRRuntimeInfo

◆ CorDebug

◆ CorProcess

◆ loaded_mono

Definition at line 79 of file mscoree_private.h.

◆ MonoAssembly

typedef struct _MonoAssembly MonoAssembly

Definition at line 68 of file mscoree_private.h.

◆ MonoAssemblyName

typedef struct _MonoAssemblyName MonoAssemblyName

Definition at line 69 of file mscoree_private.h.

◆ MonoAssemblyPreLoadFunc

typedef MonoAssembly*(* MonoAssemblyPreLoadFunc) (MonoAssemblyName *aname, char **assemblies_path, void *user_data)

Definition at line 158 of file mscoree_private.h.

◆ MonoClass

typedef struct _MonoClass MonoClass

Definition at line 72 of file mscoree_private.h.

◆ MonoDomain

typedef struct _MonoDomain MonoDomain

Definition at line 67 of file mscoree_private.h.

◆ MonoImage

typedef struct _MonoImage MonoImage

Definition at line 71 of file mscoree_private.h.

◆ MonoMethod

typedef struct _MonoMethod MonoMethod

Definition at line 75 of file mscoree_private.h.

◆ MonoObject

typedef struct _MonoObject MonoObject

Definition at line 73 of file mscoree_private.h.

◆ MonoProfileFunc

typedef void(* MonoProfileFunc) (MonoProfiler *prof)

Definition at line 160 of file mscoree_private.h.

◆ MonoProfiler

typedef struct _MonoProfiler MonoProfiler

Definition at line 76 of file mscoree_private.h.

◆ MonoString

typedef struct _MonoString MonoString

Definition at line 74 of file mscoree_private.h.

◆ MonoThread

typedef struct _MonoThread MonoThread

Definition at line 77 of file mscoree_private.h.

◆ MonoType

typedef struct _MonoType MonoType

Definition at line 70 of file mscoree_private.h.

◆ parsed_config_file

◆ RuntimeHost

Definition at line 80 of file mscoree_private.h.

◆ supported_runtime

◆ VTableFixup

Enumeration Type Documentation

◆ MonoImageOpenStatus

Enumerator
MONO_IMAGE_OK 
MONO_IMAGE_ERROR_ERRNO 
MONO_IMAGE_MISSING_ASSEMBLYREF 
MONO_IMAGE_IMAGE_INVALID 

Definition at line 151 of file mscoree_private.h.

Function Documentation

◆ assembly_create()

HRESULT assembly_create ( ASSEMBLY **  out,
LPCWSTR  file 
)

Definition at line 640 of file assembly.c.

641 {
643  HRESULT hr;
644 
645  *out = NULL;
646 
647  if (!(assembly = heap_alloc_zero(sizeof(*assembly)))) return E_OUTOFMEMORY;
648 
649  assembly->path = strdupW(file);
650  if (!assembly->path)
651  {
652  hr = E_OUTOFMEMORY;
653  goto failed;
654  }
655 
658  if (assembly->hfile == INVALID_HANDLE_VALUE)
659  {
661  goto failed;
662  }
663 
665  0, 0, NULL);
666  if (!assembly->hmap)
667  {
669  goto failed;
670  }
671 
672  assembly->data = MapViewOfFile(assembly->hmap, FILE_MAP_READ, 0, 0, 0);
673  if (!assembly->data)
674  {
676  goto failed;
677  }
678 
680  if (FAILED(hr)) goto failed;
681 
683  if (FAILED(hr)) goto failed;
684 
685  *out = assembly;
686  return S_OK;
687 
688 failed:
690  return hr;
691 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define MapViewOfFile
Definition: compat.h:402
HRESULT hr
Definition: shlfolder.c:183
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static struct _tagASSEMBLY assembly
#define FILE_SHARE_READ
Definition: compat.h:125
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define FILE_MAP_READ
Definition: compat.h:427
#define OPEN_EXISTING
Definition: compat.h:426
LONG HRESULT
Definition: typedefs.h:77
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
static FILE * out
Definition: regtests2xml.c:44
static HRESULT parse_clr_metadata(ASSEMBLY *assembly)
Definition: assembly.c:559
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
HRESULT assembly_release(ASSEMBLY *assembly)
Definition: assembly.c:693
#define S_OK
Definition: intsafe.h:59
#define PAGE_READONLY
Definition: compat.h:127
static HRESULT parse_pe_header(ASSEMBLY *assembly)
Definition: assembly.c:602
#define CreateFileW
Definition: compat.h:400
static LPWSTR strdupW(LPCWSTR src)
Definition: assembly.c:67
Definition: fci.c:126

Referenced by CLRMetaHost_GetVersionFromFile(), and IAssemblyCacheImpl_InstallAssembly().

◆ assembly_from_hmodule()

HRESULT assembly_from_hmodule ( ASSEMBLY **  out,
HMODULE  hmodule 
)

Definition at line 245 of file assembly.c.

246 {
248  HRESULT hr;
249 
250  *out = NULL;
251 
253  if (!assembly)
254  return E_OUTOFMEMORY;
255 
256  assembly->is_mapped_file = 0;
257 
258  assembly->data = (BYTE*)hmodule;
259 
261  if (SUCCEEDED(hr))
262  *out = assembly;
263  else
265 
266  return hr;
267 }
HRESULT hr
Definition: shlfolder.c:183
static struct _tagASSEMBLY assembly
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static HMODULE hmodule
Definition: rasapi.c:29
smooth NULL
Definition: ftsmooth.c:416
static HRESULT parse_headers(ASSEMBLY *assembly)
Definition: assembly.c:179
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:77
static FILE * out
Definition: regtests2xml.c:44
unsigned char BYTE
Definition: mem.h:68
HRESULT assembly_release(ASSEMBLY *assembly)
Definition: assembly.c:693
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by FixupVTable().

◆ assembly_get_runtime_version()

HRESULT assembly_get_runtime_version ( ASSEMBLY assembly,
LPSTR version 
)

Definition at line 881 of file assembly.c.

882 {
883  *version = assembly->metadatahdr->Version;
884  return S_OK;
885 }
static const WCHAR version[]
Definition: asmname.c:64
#define S_OK
Definition: intsafe.h:59

Referenced by CLRMetaHost_GetVersionFromFile(), and IAssemblyCacheImpl_InstallAssembly().

◆ assembly_get_vtable_fixups()

HRESULT assembly_get_vtable_fixups ( ASSEMBLY assembly,
VTableFixup **  fixups,
DWORD count 
)

Definition at line 294 of file assembly.c.

295 {
296  ULONG size;
297 
298  size = assembly_datadir_get_data(assembly, &assembly->corhdr->VTableFixups, (void**)fixups);
299  *count = size / sizeof(VTableFixup);
300 
301  return S_OK;
302 }
struct _VTableFixup VTableFixup
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define S_OK
Definition: intsafe.h:59
static ULONG assembly_datadir_get_data(ASSEMBLY *assembly, IMAGE_DATA_DIRECTORY *datadir, void **data)
Definition: assembly.c:89
unsigned int ULONG
Definition: retypes.h:1

Referenced by FixupVTable().

◆ assembly_release()

HRESULT assembly_release ( ASSEMBLY assembly)

Definition at line 693 of file assembly.c.

694 {
695  if (!assembly)
696  return S_OK;
697 
698  heap_free(assembly->metadatahdr);
699  heap_free(assembly->path);
700  UnmapViewOfFile(assembly->data);
701  CloseHandle(assembly->hmap);
702  CloseHandle(assembly->hfile);
704 
705  return S_OK;
706 }
#define CloseHandle
Definition: compat.h:398
#define S_OK
Definition: intsafe.h:59
#define UnmapViewOfFile
Definition: compat.h:403
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by assembly_create(), assembly_from_hmodule(), CLRMetaHost_GetVersionFromFile(), FixupVTable(), and IAssemblyCacheImpl_InstallAssembly().

◆ CLRMetaHost_CreateInstance()

HRESULT CLRMetaHost_CreateInstance ( REFIID  riid,
void **  ppobj 
)

Definition at line 1155 of file metahost.c.

1156 {
1157  return ICLRMetaHost_QueryInterface(&GlobalCLRMetaHost.ICLRMetaHost_iface, riid, ppobj);
1158 }
REFIID riid
Definition: precomp.h:44
static struct CLRMetaHost GlobalCLRMetaHost
Definition: metahost.c:937

Referenced by CLRCreateInstance().

◆ CLRMetaHost_GetRuntime()

HRESULT WINAPI CLRMetaHost_GetRuntime ( ICLRMetaHost iface,
LPCWSTR  pwzVersion,
REFIID  iid,
LPVOID ppRuntime 
)

Definition at line 1010 of file metahost.c.

1012 {
1013  int i;
1014  DWORD major, minor, build;
1015 
1016  TRACE("%s %s %p\n", debugstr_w(pwzVersion), debugstr_guid(iid), ppRuntime);
1017 
1018  if (!pwzVersion)
1019  return E_POINTER;
1020 
1021  if (!parse_runtime_version(pwzVersion, &major, &minor, &build))
1022  {
1023  ERR("Cannot parse %s\n", debugstr_w(pwzVersion));
1024  return CLR_E_SHIM_RUNTIME;
1025  }
1026 
1027  find_runtimes();
1028 
1029  for (i=0; i<NUM_RUNTIMES; i++)
1030  {
1031  if (runtimes[i].major == major && runtimes[i].minor == minor &&
1032  runtimes[i].build == build)
1033  {
1034  if (runtimes[i].mono_abi_version)
1035  return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface, iid,
1036  ppRuntime);
1037  else
1038  {
1040  return CLR_E_SHIM_RUNTIME;
1041  }
1042  }
1043  }
1044 
1045  FIXME("Unrecognized version %s\n", debugstr_w(pwzVersion));
1046  return CLR_E_SHIM_RUNTIME;
1047 }
#define NUM_RUNTIMES
Definition: metahost.c:36
static void find_runtimes(void)
Definition: metahost.c:718
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES]
Definition: metahost.c:38
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_guid
Definition: kernel32.h:35
#define CLR_E_SHIM_RUNTIME
Definition: corerror.h:127
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static void missing_runtime_message(const CLRRuntimeInfo *This)
Definition: metahost.c:85
#define ERR(fmt,...)
Definition: debug.h:109
#define major(rdev)
Definition: propsheet.cpp:879
#define minor(rdev)
Definition: propsheet.cpp:880
#define E_POINTER
Definition: winerror.h:2365
static BOOL parse_runtime_version(LPCWSTR version, DWORD *major, DWORD *minor, DWORD *build)
Definition: metahost.c:971

Referenced by CreateDebuggingInterfaceFromVersion(), and get_runtime_info().

◆ CLRMetaHost_GetVersionFromFile()

HRESULT WINAPI CLRMetaHost_GetVersionFromFile ( ICLRMetaHost iface,
LPCWSTR  pwzFilePath,
LPWSTR  pwzBuffer,
DWORD pcchBuffer 
)

Definition at line 1049 of file metahost.c.

1051 {
1052  ASSEMBLY *assembly;
1053  HRESULT hr;
1054  LPSTR version;
1055  ULONG buffer_size=*pcchBuffer;
1056 
1057  TRACE("%s %p %p\n", debugstr_w(pwzFilePath), pwzBuffer, pcchBuffer);
1058 
1059  hr = assembly_create(&assembly, pwzFilePath);
1060 
1061  if (SUCCEEDED(hr))
1062  {
1064 
1065  if (SUCCEEDED(hr))
1066  {
1067  *pcchBuffer = MultiByteToWideChar(CP_UTF8, 0, version, -1, NULL, 0);
1068 
1069  if (pwzBuffer)
1070  {
1071  if (buffer_size >= *pcchBuffer)
1072  MultiByteToWideChar(CP_UTF8, 0, version, -1, pwzBuffer, buffer_size);
1073  else
1075  }
1076  }
1077 
1079  }
1080 
1081  return hr;
1082 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
HRESULT hr
Definition: shlfolder.c:183
HRESULT assembly_get_runtime_version(ASSEMBLY *assembly, LPSTR *version)
Definition: assembly.c:881
char * LPSTR
Definition: xmlstorage.h:182
static struct _tagASSEMBLY assembly
#define CP_UTF8
Definition: nls.h:20
#define debugstr_w
Definition: kernel32.h:32
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
Definition: assembly.c:640
HRESULT assembly_release(ASSEMBLY *assembly)
Definition: assembly.c:693
#define MultiByteToWideChar
Definition: compat.h:100
unsigned int ULONG
Definition: retypes.h:1
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by get_runtime_info(), and GetFileVersion().

◆ CorDebug_Create()

HRESULT CorDebug_Create ( ICLRRuntimeHost runtimehost,
IUnknown **  ppUnk 
)

Definition at line 742 of file cordebug.c.

743 {
744  CorDebug *This;
745 
746  This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
747  if ( !This )
748  return E_OUTOFMEMORY;
749 
750  This->ICorDebug_iface.lpVtbl = &cordebug_vtbl;
751  This->ICorDebugProcessEnum_iface.lpVtbl = &processenum_vtbl;
752  This->ref = 1;
753  This->pCallback = NULL;
754  This->pCallback2 = NULL;
755  This->runtimehost = runtimehost;
756 
757  list_init(&This->processes);
758 
759  if(This->runtimehost)
760  ICLRRuntimeHost_AddRef(This->runtimehost);
761 
762  *ppUnk = (IUnknown*)&This->ICorDebug_iface;
763 
764  return S_OK;
765 }
static const struct ICorDebugVtbl cordebug_vtbl
Definition: cordebug.c:726
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const struct ICorDebugProcessEnumVtbl processenum_vtbl
Definition: cordebug.c:503
#define S_OK
Definition: intsafe.h:59
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by RuntimeHost_GetInterface().

◆ create_monodata()

HRESULT create_monodata ( REFIID  riid,
LPVOID ppObj 
)

Definition at line 1211 of file corruntimehost.c.

1212 {
1213  static const WCHAR wszCodebase[] = {'C','o','d','e','B','a','s','e',0};
1214  static const WCHAR wszClass[] = {'C','l','a','s','s',0};
1215  static const WCHAR wszFileSlash[] = {'f','i','l','e',':','/','/','/',0};
1216  static const WCHAR wszCLSIDSlash[] = {'C','L','S','I','D','\\',0};
1217  static const WCHAR wszInprocServer32[] = {'\\','I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
1218  WCHAR path[CHARS_IN_GUID + ARRAYSIZE(wszCLSIDSlash) + ARRAYSIZE(wszInprocServer32) - 1];
1219  MonoDomain *domain;
1222  RuntimeHost *host;
1223  HRESULT hr;
1224  HKEY key;
1225  LONG res;
1226  int offset = 0;
1227  WCHAR codebase[MAX_PATH + 8];
1228  WCHAR classname[350];
1230 
1231  DWORD dwBufLen = 350;
1232 
1233  lstrcpyW(path, wszCLSIDSlash);
1234  StringFromGUID2(riid, path + lstrlenW(wszCLSIDSlash), CHARS_IN_GUID);
1235  lstrcatW(path, wszInprocServer32);
1236 
1237  TRACE("Registry key: %s\n", debugstr_w(path));
1238 
1240  if (res == ERROR_FILE_NOT_FOUND)
1242 
1244  if(res != ERROR_SUCCESS)
1245  {
1246  WARN("Class value cannot be found.\n");
1248  goto cleanup;
1249  }
1250 
1251  TRACE("classname (%s)\n", debugstr_w(classname));
1252 
1253  dwBufLen = MAX_PATH + 8;
1254  res = RegGetValueW( key, NULL, wszCodebase, RRF_RT_REG_SZ, NULL, codebase, &dwBufLen);
1255  if(res != ERROR_SUCCESS)
1256  {
1257  WARN("CodeBase value cannot be found.\n");
1259  goto cleanup;
1260  }
1261 
1262  /* Strip file:/// */
1263  if(strncmpW(codebase, wszFileSlash, strlenW(wszFileSlash)) == 0)
1264  offset = strlenW(wszFileSlash);
1265 
1266  strcpyW(filename, codebase + offset);
1267 
1268  TRACE("codebase (%s)\n", debugstr_w(filename));
1269 
1270  *ppObj = NULL;
1271 
1272 
1273  hr = get_runtime_info(filename, NULL, NULL, 0, 0, FALSE, &info);
1274  if (SUCCEEDED(hr))
1275  {
1277 
1278  if (SUCCEEDED(hr))
1279  hr = RuntimeHost_GetDefaultDomain(host, &domain);
1280 
1281  if (SUCCEEDED(hr))
1282  {
1283  MonoImage *image;
1284  MonoClass *klass;
1285  MonoObject *result;
1286  IUnknown *unk = NULL;
1287  char *filenameA, *ns;
1288  char *classA;
1289 
1291 
1292  host->mono->mono_thread_attach(domain);
1293 
1294  filenameA = WtoA(filename);
1295  assembly = host->mono->mono_domain_assembly_open(domain, filenameA);
1297  if (!assembly)
1298  {
1299  ERR("Cannot open assembly %s\n", filenameA);
1300  goto cleanup;
1301  }
1302 
1303  image = host->mono->mono_assembly_get_image(assembly);
1304  if (!image)
1305  {
1306  ERR("Couldn't get assembly image\n");
1307  goto cleanup;
1308  }
1309 
1310  classA = WtoA(classname);
1311  ns = strrchr(classA, '.');
1312  *ns = '\0';
1313 
1314  klass = host->mono->mono_class_from_name(image, classA, ns+1);
1315  HeapFree(GetProcessHeap(), 0, classA);
1316  if (!klass)
1317  {
1318  ERR("Couldn't get class from image\n");
1319  goto cleanup;
1320  }
1321 
1322  /*
1323  * Use the default constructor for the .NET class.
1324  */
1325  result = host->mono->mono_object_new(domain, klass);
1326  host->mono->mono_runtime_object_init(result);
1327 
1329  if (SUCCEEDED(hr))
1330  {
1331  hr = IUnknown_QueryInterface(unk, &IID_IUnknown, ppObj);
1332 
1333  IUnknown_Release(unk);
1334  }
1335  else
1337  }
1338  else
1340  }
1341  else
1343 
1344 cleanup:
1345  if(info)
1346  ICLRRuntimeInfo_Release(info);
1347 
1348  RegCloseKey(key);
1349 
1350  return hr;
1351 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1975
GLeglImageOES image
Definition: gl.h:2204
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result)
Definition: metahost.c:544
#define KEY_READ
Definition: nt_native.h:1023
REFIID riid
Definition: precomp.h:44
#define WARN(fmt,...)
Definition: debug.h:111
char * host
Definition: whois.c:55
#define CHARS_IN_GUID
GLintptr offset
Definition: glext.h:5920
#define RRF_RT_REG_SZ
Definition: driver.c:575
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
WCHAR classname[128]
Definition: startup.c:15
const char * filename
Definition: ioapi.h:135
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4245
#define lstrlenW
Definition: compat.h:407
static struct _tagASSEMBLY assembly
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
WINE_UNICODE_INLINE int strncmpW(const WCHAR *str1, const WCHAR *str2, int n)
Definition: unicode.h:235
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **result)
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define MAX_PATH
Definition: compat.h:26
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2343
unsigned long DWORD
Definition: ntddk_ex.h:95
static CHAR filenameA[MAX_PATH]
Definition: storage32.c:42
struct _MonoClass MonoClass
struct _MonoImage MonoImage
Definition: mxnamespace.c:44
HKEY key
Definition: reg.c:42
struct _MonoObject MonoObject
#define ARRAYSIZE(array)
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define lstrcpyW
Definition: compat.h:406
char * WtoA(LPCWSTR wstr)
Definition: mscoree_main.c:30
Definition: services.c:325
HRESULT get_runtime_info(LPCWSTR exefile, LPCWSTR version, LPCWSTR config_file, DWORD startup_flags, DWORD runtimeinfo_flags, BOOL legacy, ICLRRuntimeInfo **result)
Definition: metahost.c:1247
GLuint res
Definition: glext.h:9613
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
char * cleanup(char *str)
Definition: wpickclick.c:99
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
struct _MonoDomain MonoDomain
struct _MonoAssembly MonoAssembly
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57
Definition: path.c:42

Referenced by DllGetClassObject().

◆ expect_no_runtimes()

void expect_no_runtimes ( void  )

Definition at line 289 of file metahost.c.

290 {
291  int i;
292 
293  for (i=0; i<NUM_ABI_VERSIONS; i++)
294  {
295  loaded_mono *mono = &loaded_monos[i];
296  if (mono->mono_handle && mono->is_started && !mono->is_shutdown)
297  {
298  ERR("Process exited with a Mono runtime loaded.\n");
299  return;
300  }
301  }
302 }
HMODULE mono_handle
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static loaded_mono loaded_monos[NUM_ABI_VERSIONS]
Definition: metahost.c:58
#define ERR(fmt,...)
Definition: debug.h:109
#define NUM_ABI_VERSIONS
Definition: metahost.c:56

Referenced by DllMain().

◆ free_parsed_config_file()

void free_parsed_config_file ( parsed_config_file file)

Definition at line 448 of file config.c.

449 {
450  supported_runtime *cursor, *cursor2;
451 
452  LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &file->supported_runtimes, supported_runtime, entry)
453  {
454  HeapFree(GetProcessHeap(), 0, cursor->version);
455  list_remove(&cursor->entry);
457  }
458 }
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define GetProcessHeap()
Definition: compat.h:395
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
const char cursor[]
Definition: icontest.c:13
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

Referenced by get_runtime_info().

◆ get_runtime_info()

HRESULT get_runtime_info ( LPCWSTR  exefile,
LPCWSTR  version,
LPCWSTR  config_file,
DWORD  startup_flags,
DWORD  runtimeinfo_flags,
BOOL  legacy,
ICLRRuntimeInfo **  result 
)

Definition at line 1247 of file metahost.c.

1249 {
1250  static const WCHAR dotconfig[] = {'.','c','o','n','f','i','g',0};
1251  static const DWORD supported_startup_flags = 0;
1252  static const DWORD supported_runtime_flags = RUNTIME_INFO_UPGRADE_VERSION;
1253  int i;
1254  WCHAR local_version[MAX_PATH];
1255  ULONG local_version_size = MAX_PATH;
1256  WCHAR local_config_file[MAX_PATH];
1257  HRESULT hr;
1258  parsed_config_file parsed_config;
1259 
1260  if (startup_flags & ~supported_startup_flags)
1261  FIXME("unsupported startup flags %x\n", startup_flags & ~supported_startup_flags);
1262 
1263  if (runtimeinfo_flags & ~supported_runtime_flags)
1264  FIXME("unsupported runtimeinfo flags %x\n", runtimeinfo_flags & ~supported_runtime_flags);
1265 
1266  if (exefile && !config_file)
1267  {
1268  strcpyW(local_config_file, exefile);
1269  strcatW(local_config_file, dotconfig);
1270 
1271  config_file = local_config_file;
1272  }
1273 
1274  if (config_file)
1275  {
1276  int found=0;
1277  hr = parse_config_file(config_file, &parsed_config);
1278 
1279  if (SUCCEEDED(hr))
1280  {
1283  {
1284  hr = CLRMetaHost_GetRuntime(0, entry->version, &IID_ICLRRuntimeInfo, (void**)result);
1285  if (SUCCEEDED(hr))
1286  {
1287  found = 1;
1288  break;
1289  }
1290  }
1291  }
1292  else
1293  {
1294  WARN("failed to parse config file %s, hr=%x\n", debugstr_w(config_file), hr);
1295  }
1296 
1297  free_parsed_config_file(&parsed_config);
1298 
1299  if (found)
1300  return S_OK;
1301  }
1302 
1303  if (exefile && !version)
1304  {
1305  hr = CLRMetaHost_GetVersionFromFile(0, exefile, local_version, &local_version_size);
1306 
1307  version = local_version;
1308 
1309  if (FAILED(hr)) return hr;
1310  }
1311 
1312  if (version)
1313  {
1314  hr = CLRMetaHost_GetRuntime(0, version, &IID_ICLRRuntimeInfo, (void**)result);
1315  if(SUCCEEDED(hr))
1316  return hr;
1317  }
1318 
1319  if (runtimeinfo_flags & RUNTIME_INFO_UPGRADE_VERSION)
1320  {
1321  DWORD major, minor, build;
1322 
1323  if (version && !parse_runtime_version(version, &major, &minor, &build))
1324  {
1325  ERR("Cannot parse %s\n", debugstr_w(version));
1326  return CLR_E_SHIM_RUNTIME;
1327  }
1328 
1329  find_runtimes();
1330 
1331  if (legacy)
1332  i = 2;
1333  else
1334  i = NUM_RUNTIMES;
1335 
1336  while (i--)
1337  {
1338  if (runtimes[i].mono_abi_version)
1339  {
1340  /* Must be greater or equal to the version passed in. */
1341  if (!version || ((runtimes[i].major >= major && runtimes[i].minor >= minor && runtimes[i].build >= build) ||
1342  (runtimes[i].major >= major && runtimes[i].minor > minor) ||
1343  (runtimes[i].major > major)))
1344  {
1345  return ICLRRuntimeInfo_QueryInterface(&runtimes[i].ICLRRuntimeInfo_iface,
1346  &IID_ICLRRuntimeInfo, (void **)result);
1347  }
1348  }
1349  }
1350 
1351  if (legacy)
1353  else
1355 
1356  return CLR_E_SHIM_RUNTIME;
1357  }
1358 
1359  return CLR_E_SHIM_RUNTIME;
1360 }
#define NUM_RUNTIMES
Definition: metahost.c:36
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI CLRMetaHost_GetVersionFromFile(ICLRMetaHost *iface, LPCWSTR pwzFilePath, LPWSTR pwzBuffer, DWORD *pcchBuffer)
Definition: metahost.c:1049
static void find_runtimes(void)
Definition: metahost.c:718
#define WARN(fmt,...)
Definition: debug.h:111
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES]
Definition: metahost.c:38
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
static const WCHAR version[]
Definition: asmname.c:64
#define CLR_E_SHIM_RUNTIME
Definition: corerror.h:127
void free_parsed_config_file(parsed_config_file *file)
Definition: config.c:448
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
struct list supported_runtimes
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT parse_config_file(LPCWSTR filename, parsed_config_file *result)
Definition: config.c:419
uint32_t entry
Definition: isohybrid.c:63
static void missing_runtime_message(const CLRRuntimeInfo *This)
Definition: metahost.c:85
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define major(rdev)
Definition: propsheet.cpp:879
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
HRESULT WINAPI CLRMetaHost_GetRuntime(ICLRMetaHost *iface, LPCWSTR pwzVersion, REFIID iid, LPVOID *ppRuntime)
Definition: metahost.c:1010
unsigned int ULONG
Definition: retypes.h:1
#define minor(rdev)
Definition: propsheet.cpp:880
static BOOL parse_runtime_version(LPCWSTR version, DWORD *major, DWORD *minor, DWORD *build)
Definition: metahost.c:971
GLuint64EXT * result
Definition: glext.h:11304
BOOL legacy
Definition: mkisofs.c:131
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by _CorExeMain(), ClrCreateManagedInstance(), CorBindToRuntimeEx(), CorBindToRuntimeHost(), create_monodata(), GetCORSystemDirectory(), GetCORVersion(), GetRequestedRuntimeInfo(), and ReallyFixupVTable().

◆ ICLRRuntimeInfo_GetRuntimeHost()

HRESULT ICLRRuntimeInfo_GetRuntimeHost ( ICLRRuntimeInfo iface,
RuntimeHost **  result 
)

Definition at line 544 of file metahost.c.

545 {
547 
548  assert(This->ICLRRuntimeInfo_iface.lpVtbl == &CLRRuntimeInfoVtbl);
549 
551 }
#define assert(x)
Definition: debug.h:53
static const struct ICLRRuntimeInfoVtbl CLRRuntimeInfoVtbl
Definition: metahost.c:34
static CLRRuntimeInfo * impl_from_ICLRRuntimeInfo(ICLRRuntimeInfo *iface)
Definition: metahost.c:304
GLuint64EXT * result
Definition: glext.h:11304
static HRESULT CLRRuntimeInfo_GetRuntimeHost(CLRRuntimeInfo *This, RuntimeHost **result)
Definition: metahost.c:240

Referenced by _CorExeMain(), ClrCreateManagedInstance(), create_monodata(), and ReallyFixupVTable().

◆ MetaDataDispenser_CreateInstance()

HRESULT MetaDataDispenser_CreateInstance ( IUnknown **  ppUnk)

Definition at line 169 of file metadata.c.

170 {
172 
174 
175  if (!This)
176  return E_OUTOFMEMORY;
177 
178  This->IMetaDataDispenserEx_iface.lpVtbl = &MetaDataDispenserVtbl;
179  This->ref = 1;
180 
181  *ppUnk = (IUnknown*)This;
182 
183  return S_OK;
184 }
static const struct IMetaDataDispenserExVtbl MetaDataDispenserVtbl
Definition: metadata.c:153
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59

Referenced by RuntimeHost_GetInterface().

◆ parse_config_file()

HRESULT parse_config_file ( LPCWSTR  filename,
parsed_config_file result 
)

Definition at line 419 of file config.c.

420 {
421  IStream *stream;
422  VARIANT var;
423  HRESULT hr;
424  HRESULT initresult;
425 
427 
429 
431 
432  if (SUCCEEDED(hr))
433  {
434  V_VT(&var) = VT_UNKNOWN;
435  V_UNKNOWN(&var) = (IUnknown*)stream;
436 
437  hr = parse_config(var, result);
438 
439  IStream_Release(stream);
440  }
441 
442  if (SUCCEEDED(initresult))
443  CoUninitialize();
444 
445  return hr;
446 }
static HRESULT parse_config(VARIANT input, parsed_config_file *result)
Definition: config.c:381
HRESULT hr
Definition: shlfolder.c:183
#define STGM_FAILIFTHERE
Definition: objbase.h:927
const char * filename
Definition: ioapi.h:135
smooth NULL
Definition: ftsmooth.c:416
#define STGM_READ
Definition: objbase.h:916
LONG HRESULT
Definition: typedefs.h:77
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define V_VT(A)
Definition: oleauto.h:211
#define V_UNKNOWN(A)
Definition: oleauto.h:281
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:1935
HRESULT WINAPI SHCreateStreamOnFileW(LPCWSTR lpszPath, DWORD dwMode, IStream **lppStream)
Definition: istream.c:484
#define STGM_SHARE_DENY_WRITE
Definition: objbase.h:921
static void init_config(parsed_config_file *config)
Definition: config.c:376
GLuint64EXT * result
Definition: glext.h:11304
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by get_runtime_info().

◆ RuntimeHost_Construct()

HRESULT RuntimeHost_Construct ( const CLRRuntimeInfo runtime_version,
loaded_mono loaded_mono,
RuntimeHost **  result 
)

Definition at line 1120 of file corruntimehost.c.

1122 {
1123  RuntimeHost *This;
1124 
1125  This = HeapAlloc( GetProcessHeap(), 0, sizeof *This );
1126  if ( !This )
1127  return E_OUTOFMEMORY;
1128 
1129  This->ICorRuntimeHost_iface.lpVtbl = &corruntimehost_vtbl;
1130  This->ICLRRuntimeHost_iface.lpVtbl = &CLRHostVtbl;
1131 
1132  This->ref = 1;
1133  This->version = runtime_version;
1134  This->mono = loaded_mono;
1135  list_init(&This->domains);
1136  This->default_domain = NULL;
1138  This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RuntimeHost.lock");
1139 
1140  *result = This;
1141 
1142  return S_OK;
1143 }
static const struct ICorRuntimeHostVtbl corruntimehost_vtbl
#define DWORD_PTR
Definition: treelist.c:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
static const struct ICLRRuntimeHostVtbl CLRHostVtbl
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define S_OK
Definition: intsafe.h:59
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
GLuint64EXT * result
Definition: glext.h:11304
struct loaded_mono loaded_mono

Referenced by CLRRuntimeInfo_GetRuntimeHost().

◆ RuntimeHost_CreateManagedInstance()

HRESULT RuntimeHost_CreateManagedInstance ( RuntimeHost This,
LPCWSTR  name,
MonoDomain domain,
MonoObject **  result 
)

Definition at line 638 of file corruntimehost.c.

640 {
641  HRESULT hr=S_OK;
642  char *nameA=NULL;
643  MonoType *type;
644  MonoClass *klass;
645  MonoObject *obj;
646 
647  if (!domain)
649 
650  if (SUCCEEDED(hr))
651  {
652  nameA = WtoA(name);
653  if (!nameA)
654  hr = E_OUTOFMEMORY;
655  }
656 
657  if (SUCCEEDED(hr))
658  {
659  This->mono->mono_thread_attach(domain);
660 
661  type = This->mono->mono_reflection_type_from_name(nameA, NULL);
662  if (!type)
663  {
664  ERR("Cannot find type %s\n", debugstr_w(name));
665  hr = E_FAIL;
666  }
667  }
668 
669  if (SUCCEEDED(hr))
670  {
671  klass = This->mono->mono_class_from_mono_type(type);
672  if (!klass)
673  {
674  ERR("Cannot convert type %s to a class\n", debugstr_w(name));
675  hr = E_FAIL;
676  }
677  }
678 
679  if (SUCCEEDED(hr))
680  {
681  obj = This->mono->mono_object_new(domain, klass);
682  if (!obj)
683  {
684  ERR("Cannot allocate object of type %s\n", debugstr_w(name));
685  hr = E_FAIL;
686  }
687  }
688 
689  if (SUCCEEDED(hr))
690  {
691  /* FIXME: Detect exceptions from the constructor? */
692  This->mono->mono_runtime_object_init(obj);
693  *result = obj;
694  }
695 
696  HeapFree(GetProcessHeap(), 0, nameA);
697 
698  return hr;
699 }
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define E_FAIL
Definition: ddrawi.h:102
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **result)
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
LONG HRESULT
Definition: typedefs.h:77
struct _MonoClass MonoClass
struct _MonoObject MonoObject
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
char * WtoA(LPCWSTR wstr)
Definition: mscoree_main.c:30
Definition: name.c:36
struct _MonoType MonoType
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by ClrCreateManagedInstance().

◆ RuntimeHost_Destroy()

HRESULT RuntimeHost_Destroy ( RuntimeHost This)

Definition at line 1190 of file corruntimehost.c.

1191 {
1192  struct DomainEntry *cursor, *cursor2;
1193 
1194  This->lock.DebugInfo->Spare[0] = 0;
1195  DeleteCriticalSection(&This->lock);
1196 
1197  LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, &This->domains, struct DomainEntry, entry)
1198  {
1199  list_remove(&cursor->entry);
1201  }
1202 
1203  HeapFree( GetProcessHeap(), 0, This );
1204  return S_OK;
1205 }
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define GetProcessHeap()
Definition: compat.h:395
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
uint32_t entry
Definition: isohybrid.c:63
#define S_OK
Definition: intsafe.h:59
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
const char cursor[]
Definition: icontest.c:13
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by unload_all_runtimes().

◆ RuntimeHost_GetInterface()

HRESULT RuntimeHost_GetInterface ( RuntimeHost This,
REFCLSID  clsid,
REFIID  riid,
void **  ppv 
)

Definition at line 1145 of file corruntimehost.c.

1146 {
1147  IUnknown *unk;
1148  HRESULT hr;
1149 
1150  if (IsEqualGUID(clsid, &CLSID_CorRuntimeHost))
1151  {
1152  unk = (IUnknown*)&This->ICorRuntimeHost_iface;
1153  IUnknown_AddRef(unk);
1154  }
1155  else if (IsEqualGUID(clsid, &CLSID_CLRRuntimeHost))
1156  {
1157  unk = (IUnknown*)&This->ICLRRuntimeHost_iface;
1158  IUnknown_AddRef(unk);
1159  }
1160  else if (IsEqualGUID(clsid, &CLSID_CorMetaDataDispenser) ||
1161  IsEqualGUID(clsid, &CLSID_CorMetaDataDispenserRuntime))
1162  {
1164  if (FAILED(hr))
1165  return hr;
1166  }
1167  else if (IsEqualGUID(clsid, &CLSID_CLRDebuggingLegacy))
1168  {
1169  hr = CorDebug_Create(&This->ICLRRuntimeHost_iface, &unk);
1170  if (FAILED(hr))
1171  return hr;
1172  }
1173  else
1174  unk = NULL;
1175 
1176  if (unk)
1177  {
1178  hr = IUnknown_QueryInterface(unk, riid, ppv);
1179 
1180  IUnknown_Release(unk);
1181 
1182  return hr;
1183  }
1184  else
1185  FIXME("not implemented for class %s\n", debugstr_guid(clsid));
1186 
1188 }
HRESULT CorDebug_Create(ICLRRuntimeHost *runtimehost, IUnknown **ppUnk)
Definition: cordebug.c:742
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
HRESULT MetaDataDispenser_CreateInstance(IUnknown **ppUnk)
Definition: metadata.c:169

Referenced by CLRRuntimeInfo_GetInterface().

◆ RuntimeHost_GetIUnknownForObject()

HRESULT RuntimeHost_GetIUnknownForObject ( RuntimeHost This,
MonoObject obj,
IUnknown **  ppUnk 
)

Definition at line 711 of file corruntimehost.c.

713 {
716  MonoImage *image;
717  MonoClass *klass;
720  void *args[2];
721 
722  domain = This->mono->mono_object_get_domain(obj);
723 
724  assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib");
725  if (!assembly)
726  {
727  ERR("Cannot load mscorlib\n");
728  return E_FAIL;
729  }
730 
731  image = This->mono->mono_assembly_get_image(assembly);
732  if (!image)
733  {
734  ERR("Couldn't get assembly image\n");
735  return E_FAIL;
736  }
737 
738  klass = This->mono->mono_class_from_name(image, "System.Runtime.InteropServices", "Marshal");
739  if (!klass)
740  {
741  ERR("Couldn't get class from image\n");
742  return E_FAIL;
743  }
744 
745  method = This->mono->mono_class_get_method_from_name(klass, "GetIUnknownForObject", 1);
746  if (!method)
747  {
748  ERR("Couldn't get method from class\n");
749  return E_FAIL;
750  }
751 
752  args[0] = obj;
753  args[1] = NULL;
754  result = This->mono->mono_runtime_invoke(method, NULL, args, NULL);
755  if (!result)
756  {
757  ERR("Couldn't get result pointer\n");
758  return E_FAIL;
759  }
760 
761  *ppUnk = *(IUnknown**)This->mono->mono_object_unbox(result);
762  if (!*ppUnk)
763  {
764  ERR("GetIUnknownForObject returned 0\n");
765  return E_FAIL;
766  }
767 
768  return S_OK;
769 }
GLeglImageOES image
Definition: gl.h:2204
#define E_FAIL
Definition: ddrawi.h:102
static struct _tagASSEMBLY assembly
Definition: match.c:390
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
MonoDomain * domain
smooth NULL
Definition: ftsmooth.c:416
struct _MonoMethod MonoMethod
struct _MonoClass MonoClass
method
Definition: dragdrop.c:53
struct _MonoImage MonoImage
struct _MonoObject MonoObject
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
struct _MonoDomain MonoDomain
struct _MonoAssembly MonoAssembly
GLuint64EXT * result
Definition: glext.h:11304

Referenced by ClrCreateManagedInstance(), create_monodata(), and RuntimeHost_GetIUnknownForDomain().

◆ runtimehost_init()

void runtimehost_init ( void  )

Definition at line 1101 of file corruntimehost.c.

1102 {
1105 }
HANDLE WINAPI HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
Definition: heapmem.c:45
static struct list dll_fixups
static HANDLE dll_fixup_heap
#define HEAP_CREATE_ENABLE_EXECUTE
Definition: mmtypes.h:217
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by DllMain().

◆ runtimehost_uninit()

void runtimehost_uninit ( void  )

Definition at line 1108 of file corruntimehost.c.

1109 {
1110  struct dll_fixup *fixup, *fixup2;
1111 
1114  {
1115  HeapFree(GetProcessHeap(), 0, fixup->tokens);
1116  HeapFree(GetProcessHeap(), 0, fixup);
1117  }
1118 }
VTableFixup * fixup
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85
static struct list dll_fixups
#define GetProcessHeap()
Definition: compat.h:395
static HANDLE dll_fixup_heap
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DllMain().

◆ unload_all_runtimes()

void unload_all_runtimes ( void  )

Definition at line 266 of file metahost.c.

267 {
268  int i;
269 
270  for (i=0; i<NUM_ABI_VERSIONS; i++)
271  {
272  loaded_mono *mono = &loaded_monos[i];
273  if (mono->mono_handle && mono->is_started && !mono->is_shutdown)
274  {
275  /* Copied from Mono's ves_icall_System_Environment_Exit */
276  mono->mono_threads_set_shutting_down();
277  mono->mono_runtime_set_shutting_down();
278  mono->mono_thread_pool_cleanup();
279  mono->mono_thread_suspend_all_other_threads();
280  mono->mono_runtime_quit();
281  }
282  }
283 
284  for (i=0; i<NUM_RUNTIMES; i++)
285  if (runtimes[i].loaded_runtime)
286  RuntimeHost_Destroy(runtimes[i].loaded_runtime);
287 }
#define NUM_RUNTIMES
Definition: metahost.c:36
HRESULT RuntimeHost_Destroy(RuntimeHost *This)
HMODULE mono_handle
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static struct CLRRuntimeInfo runtimes[NUM_RUNTIMES]
Definition: metahost.c:38
static loaded_mono loaded_monos[NUM_ABI_VERSIONS]
Definition: metahost.c:58
#define NUM_ABI_VERSIONS
Definition: metahost.c:56

Referenced by _CorExeMain(), and CorExitProcess().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( mscoree  )

◆ WtoA()

char* WtoA ( LPCWSTR  wstr)

Definition at line 30 of file mscoree_main.c.

31 {
32  int length;
33  char *result;
34 
35  length = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
36 
38 
39  if (result)
41 
42  return result;
43 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_UTF8
Definition: nls.h:20
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLuint64EXT * result
Definition: glext.h:11304

Referenced by _CorExeMain(), CLRRuntimeHost_ExecuteInDefaultAppDomain(), create_monodata(), mono_assembly_search_hook_fn(), ReallyFixupVTable(), RuntimeHost_AddDomain(), and RuntimeHost_CreateManagedInstance().