ReactOS 0.4.15-dev-8241-g63935f8
corruntimehost.c File Reference
#include "mscoree_private.h"
#include <assert.h>
#include <shellapi.h>
#include <initguid.h>
Include dependency graph for corruntimehost.c:

Go to the source code of this file.

Classes

struct  DomainEntry
 
struct  dll_fixup
 
struct  vtable_fixup_thunk
 

Macros

#define CAN_FIXUP_VTABLE   0
 
#define CHARS_IN_GUID   39
 
#define ARRAYSIZE(array)   (sizeof(array)/sizeof((array)[0]))
 

Functions

 DEFINE_GUID (IID__AppDomain, 0x05f696dc, 0x2b29, 0x3663, 0xad, 0x8b, 0xc4, 0x38, 0x9c, 0xf2, 0xa7, 0x13)
 
static HRESULT RuntimeHost_AddDomain (RuntimeHost *This, MonoDomain **result)
 
static HRESULT RuntimeHost_GetDefaultDomain (RuntimeHost *This, MonoDomain **result)
 
static void RuntimeHost_DeleteDomain (RuntimeHost *This, MonoDomain *domain)
 
static HRESULT RuntimeHost_GetIUnknownForDomain (RuntimeHost *This, MonoDomain *domain, IUnknown **punk)
 
static RuntimeHostimpl_from_ICLRRuntimeHost (ICLRRuntimeHost *iface)
 
static RuntimeHostimpl_from_ICorRuntimeHost (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_QueryInterface (ICorRuntimeHost *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI corruntimehost_AddRef (ICorRuntimeHost *iface)
 
static ULONG WINAPI corruntimehost_Release (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_CreateLogicalThreadState (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState (ICorRuntimeHost *iface, DWORD *fiberCookie)
 
static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState (ICorRuntimeHost *iface, DWORD **fiberCookie)
 
static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread (ICorRuntimeHost *iface, DWORD *pCount)
 
static HRESULT WINAPI corruntimehost_MapFile (ICorRuntimeHost *iface, HANDLE hFile, HMODULE *mapAddress)
 
static HRESULT WINAPI corruntimehost_GetConfiguration (ICorRuntimeHost *iface, ICorConfiguration **pConfiguration)
 
static HRESULT WINAPI corruntimehost_Start (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_Stop (ICorRuntimeHost *iface)
 
static HRESULT WINAPI corruntimehost_CreateDomain (ICorRuntimeHost *iface, LPCWSTR friendlyName, IUnknown *identityArray, IUnknown **appDomain)
 
static HRESULT WINAPI corruntimehost_GetDefaultDomain (ICorRuntimeHost *iface, IUnknown **pAppDomain)
 
static HRESULT WINAPI corruntimehost_EnumDomains (ICorRuntimeHost *iface, HDOMAINENUM *hEnum)
 
static HRESULT WINAPI corruntimehost_NextDomain (ICorRuntimeHost *iface, HDOMAINENUM hEnum, IUnknown **appDomain)
 
static HRESULT WINAPI corruntimehost_CloseEnum (ICorRuntimeHost *iface, HDOMAINENUM hEnum)
 
static HRESULT WINAPI corruntimehost_CreateDomainEx (ICorRuntimeHost *iface, LPCWSTR friendlyName, IUnknown *setup, IUnknown *evidence, IUnknown **appDomain)
 
static HRESULT WINAPI corruntimehost_CreateDomainSetup (ICorRuntimeHost *iface, IUnknown **appDomainSetup)
 
static HRESULT WINAPI corruntimehost_CreateEvidence (ICorRuntimeHost *iface, IUnknown **evidence)
 
static HRESULT WINAPI corruntimehost_UnloadDomain (ICorRuntimeHost *iface, IUnknown *appDomain)
 
static HRESULT WINAPI corruntimehost_CurrentDomain (ICorRuntimeHost *iface, IUnknown **appDomain)
 
static HRESULT WINAPI CLRRuntimeHost_QueryInterface (ICLRRuntimeHost *iface, REFIID riid, void **ppvObject)
 
static ULONG WINAPI CLRRuntimeHost_AddRef (ICLRRuntimeHost *iface)
 
static ULONG WINAPI CLRRuntimeHost_Release (ICLRRuntimeHost *iface)
 
static HRESULT WINAPI CLRRuntimeHost_Start (ICLRRuntimeHost *iface)
 
static HRESULT WINAPI CLRRuntimeHost_Stop (ICLRRuntimeHost *iface)
 
static HRESULT WINAPI CLRRuntimeHost_SetHostControl (ICLRRuntimeHost *iface, IHostControl *pHostControl)
 
static HRESULT WINAPI CLRRuntimeHost_GetCLRControl (ICLRRuntimeHost *iface, ICLRControl **pCLRControl)
 
static HRESULT WINAPI CLRRuntimeHost_UnloadAppDomain (ICLRRuntimeHost *iface, DWORD dwAppDomainId, BOOL fWaitUntilDone)
 
static HRESULT WINAPI CLRRuntimeHost_ExecuteInAppDomain (ICLRRuntimeHost *iface, DWORD dwAppDomainId, FExecuteInAppDomainCallback pCallback, void *cookie)
 
static HRESULT WINAPI CLRRuntimeHost_GetCurrentAppDomainId (ICLRRuntimeHost *iface, DWORD *pdwAppDomainId)
 
static HRESULT WINAPI CLRRuntimeHost_ExecuteApplication (ICLRRuntimeHost *iface, LPCWSTR pwzAppFullName, DWORD dwManifestPaths, LPCWSTR *ppwzManifestPaths, DWORD dwActivationData, LPCWSTR *ppwzActivationData, int *pReturnValue)
 
static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain (ICLRRuntimeHost *iface, LPCWSTR pwzAssemblyPath, LPCWSTR pwzTypeName, LPCWSTR pwzMethodName, LPCWSTR pwzArgument, DWORD *pReturnValue)
 
HRESULT RuntimeHost_CreateManagedInstance (RuntimeHost *This, LPCWSTR name, MonoDomain *domain, MonoObject **result)
 
HRESULT RuntimeHost_GetIUnknownForObject (RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk)
 
static void get_utf8_args (int *argc, char ***argv)
 
static void CDECL ReallyFixupVTable (struct dll_fixup *fixup)
 
static void FixupVTableEntry (HMODULE hmodule, VTableFixup *vtable_fixup)
 
static void FixupVTable (HMODULE hmodule)
 
__int32 WINAPI _CorExeMain (void)
 
BOOL WINAPI _CorDllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
void runtimehost_init (void)
 
void runtimehost_uninit (void)
 
HRESULT RuntimeHost_Construct (const CLRRuntimeInfo *runtime_version, loaded_mono *loaded_mono, RuntimeHost **result)
 
HRESULT RuntimeHost_GetInterface (RuntimeHost *This, REFCLSID clsid, REFIID riid, void **ppv)
 
HRESULT RuntimeHost_Destroy (RuntimeHost *This)
 
HRESULT create_monodata (REFIID riid, LPVOID *ppObj)
 

Variables

static HANDLE dll_fixup_heap
 
static struct list dll_fixups
 
static const struct ICorRuntimeHostVtbl corruntimehost_vtbl
 
static const struct ICLRRuntimeHostVtbl CLRHostVtbl
 
static const struct vtable_fixup_thunk thunk_template = {0}
 

Macro Definition Documentation

◆ ARRAYSIZE

#define ARRAYSIZE (   array)    (sizeof(array)/sizeof((array)[0]))

Definition at line 1209 of file corruntimehost.c.

◆ CAN_FIXUP_VTABLE

#define CAN_FIXUP_VTABLE   0

Definition at line 841 of file corruntimehost.c.

◆ CHARS_IN_GUID

#define CHARS_IN_GUID   39

Definition at line 1207 of file corruntimehost.c.

Function Documentation

◆ _CorDllMain()

BOOL WINAPI _CorDllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 1083 of file corruntimehost.c.

1084{
1085 TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
1086
1087 switch (fdwReason)
1088 {
1089 case DLL_PROCESS_ATTACH:
1090 DisableThreadLibraryCalls(hinstDLL);
1091 FixupVTable(hinstDLL);
1092 break;
1093 case DLL_PROCESS_DETACH:
1094 /* FIXME: clean up the vtables */
1095 break;
1096 }
1097 return TRUE;
1098}
static void FixupVTable(HMODULE hmodule)
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static IN DWORD IN LPVOID lpvReserved
#define TRACE(s)
Definition: solgame.cpp:4

◆ _CorExeMain()

__int32 WINAPI _CorExeMain ( void  )

Definition at line 1008 of file corruntimehost.c.

1009{
1010 int exit_code;
1011 int argc;
1012 char **argv;
1018 char *filenameA;
1021 HRESULT hr;
1022 int i;
1023
1025
1027
1028 TRACE("%s", debugstr_w(filename));
1029 for (i=0; i<argc; i++)
1030 TRACE(" %s", debugstr_a(argv[i]));
1031 TRACE("\n");
1032
1034 if (!filenameA)
1035 return -1;
1036
1038
1040
1041 if (SUCCEEDED(hr))
1042 {
1044
1045 if (SUCCEEDED(hr))
1047
1048 if (SUCCEEDED(hr))
1049 {
1050 image = host->mono->mono_image_open_from_module_handle(GetModuleHandleW(NULL),
1051 filenameA, 1, &status);
1052
1053 if (image)
1054 assembly = host->mono->mono_assembly_load_from(image, filenameA, &status);
1055
1056 if (assembly)
1057 {
1058 exit_code = host->mono->mono_jit_exec(domain, assembly, argc, argv);
1059 }
1060 else
1061 {
1062 ERR("couldn't load %s, status=%d\n", debugstr_w(filename), status);
1063 exit_code = -1;
1064 }
1065
1067 }
1068 else
1069 exit_code = -1;
1070
1071 ICLRRuntimeInfo_Release(info);
1072 }
1073 else
1074 exit_code = -1;
1075
1077
1079
1080 return exit_code;
1081}
static int argc
Definition: ServiceArgs.c:12
#define ERR(fmt,...)
Definition: debug.h:113
static void RuntimeHost_DeleteDomain(RuntimeHost *This, MonoDomain *domain)
static void get_utf8_args(int *argc, char ***argv)
static HRESULT RuntimeHost_GetDefaultDomain(RuntimeHost *This, MonoDomain **result)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
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
void unload_all_runtimes(void)
Definition: metahost.c:266
HRESULT ICLRRuntimeInfo_GetRuntimeHost(ICLRRuntimeInfo *iface, RuntimeHost **result)
Definition: metahost.c:544
GLeglImageOES image
Definition: gl.h:2204
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
#define SUCCEEDED(hr)
Definition: intsafe.h:50
const char * filename
Definition: ioapi.h:137
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
static UINT exit_code
Definition: process.c:78
static CHAR filenameA[MAX_PATH]
Definition: storage32.c:42
#define argv
Definition: mplay32.c:18
char * WtoA(LPCWSTR wstr)
Definition: mscoree_main.c:30
struct _MonoAssembly MonoAssembly
struct _MonoImage MonoImage
MonoImageOpenStatus
struct _MonoDomain MonoDomain
HRESULT hr
Definition: shlfolder.c:183
Definition: cookie.c:42
Definition: ps.c:97
char * host
Definition: whois.c:55
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ CLRRuntimeHost_AddRef()

static ULONG WINAPI CLRRuntimeHost_AddRef ( ICLRRuntimeHost iface)
static

Definition at line 463 of file corruntimehost.c.

464{
466 return ICorRuntimeHost_AddRef(&This->ICorRuntimeHost_iface);
467}
static RuntimeHost * impl_from_ICLRRuntimeHost(ICLRRuntimeHost *iface)

◆ CLRRuntimeHost_ExecuteApplication()

static HRESULT WINAPI CLRRuntimeHost_ExecuteApplication ( ICLRRuntimeHost iface,
LPCWSTR  pwzAppFullName,
DWORD  dwManifestPaths,
LPCWSTR ppwzManifestPaths,
DWORD  dwActivationData,
LPCWSTR ppwzActivationData,
int pReturnValue 
)
static

Definition at line 522 of file corruntimehost.c.

525{
526 FIXME("(%p,%s,%u,%u)\n", iface, debugstr_w(pwzAppFullName), dwManifestPaths, dwActivationData);
527 return E_NOTIMPL;
528}
#define FIXME(fmt,...)
Definition: debug.h:114
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CLRRuntimeHost_ExecuteInAppDomain()

static HRESULT WINAPI CLRRuntimeHost_ExecuteInAppDomain ( ICLRRuntimeHost iface,
DWORD  dwAppDomainId,
FExecuteInAppDomainCallback  pCallback,
void cookie 
)
static

Definition at line 508 of file corruntimehost.c.

510{
511 FIXME("(%p,%u,%p,%p)\n", iface, dwAppDomainId, pCallback, cookie);
512 return E_NOTIMPL;
513}
FxPnpStateCallbackInfo * pCallback
Definition: cookie.c:34

◆ CLRRuntimeHost_ExecuteInDefaultAppDomain()

static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain ( ICLRRuntimeHost iface,
LPCWSTR  pwzAssemblyPath,
LPCWSTR  pwzTypeName,
LPCWSTR  pwzMethodName,
LPCWSTR  pwzArgument,
DWORD pReturnValue 
)
static

Definition at line 530 of file corruntimehost.c.

533{
535 HRESULT hr;
539 MonoClass *klass;
543 void *args[2];
544 char *filenameA = NULL, *classA = NULL, *methodA = NULL;
545 char *argsA = NULL, *ns;
546
547 TRACE("(%p,%s,%s,%s,%s)\n", iface, debugstr_w(pwzAssemblyPath),
548 debugstr_w(pwzTypeName), debugstr_w(pwzMethodName), debugstr_w(pwzArgument));
549
551 if(hr != S_OK)
552 {
553 ERR("Couldn't get Default Domain\n");
554 return hr;
555 }
556
557 hr = E_FAIL;
558
559 This->mono->mono_thread_attach(domain);
560
561 filenameA = WtoA(pwzAssemblyPath);
562 assembly = This->mono->mono_domain_assembly_open(domain, filenameA);
563 if (!assembly)
564 {
565 ERR("Cannot open assembly %s\n", filenameA);
566 goto cleanup;
567 }
568
569 image = This->mono->mono_assembly_get_image(assembly);
570 if (!image)
571 {
572 ERR("Couldn't get assembly image\n");
573 goto cleanup;
574 }
575
576 classA = WtoA(pwzTypeName);
577 ns = strrchr(classA, '.');
578 *ns = '\0';
579 klass = This->mono->mono_class_from_name(image, classA, ns+1);
580 if (!klass)
581 {
582 ERR("Couldn't get class from image\n");
583 goto cleanup;
584 }
585
586 methodA = WtoA(pwzMethodName);
587 method = This->mono->mono_class_get_method_from_name(klass, methodA, 1);
588 if (!method)
589 {
590 ERR("Couldn't get method from class\n");
591 goto cleanup;
592 }
593
594 /* The .NET function we are calling has the following declaration
595 * public static int functionName(String param)
596 */
597 argsA = WtoA(pwzArgument);
598 str = This->mono->mono_string_new(domain, argsA);
599 args[0] = str;
600 args[1] = NULL;
601 result = This->mono->mono_runtime_invoke(method, NULL, args, NULL);
602 if (!result)
603 ERR("Couldn't get result pointer\n");
604 else
605 {
606 *pReturnValue = *(DWORD*)This->mono->mono_object_unbox(result);
607 hr = S_OK;
608 }
609
610cleanup:
612 HeapFree(GetProcessHeap(), 0, classA);
613 HeapFree(GetProcessHeap(), 0, argsA);
614 HeapFree(GetProcessHeap(), 0, methodA);
615
616 return hr;
617}
#define E_FAIL
Definition: ddrawi.h:102
static void cleanup(void)
Definition: main.c:1335
method
Definition: dragdrop.c:54
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint64EXT * result
Definition: glext.h:11304
#define S_OK
Definition: intsafe.h:52
struct _MonoObject MonoObject
struct _MonoString MonoString
struct _MonoMethod MonoMethod
struct _MonoClass MonoClass
const WCHAR * str
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Definition: match.c:390
Definition: mxnamespace.c:45

◆ CLRRuntimeHost_GetCLRControl()

static HRESULT WINAPI CLRRuntimeHost_GetCLRControl ( ICLRRuntimeHost iface,
ICLRControl **  pCLRControl 
)
static

Definition at line 494 of file corruntimehost.c.

496{
497 FIXME("(%p,%p)\n", iface, pCLRControl);
498 return E_NOTIMPL;
499}

◆ CLRRuntimeHost_GetCurrentAppDomainId()

static HRESULT WINAPI CLRRuntimeHost_GetCurrentAppDomainId ( ICLRRuntimeHost iface,
DWORD pdwAppDomainId 
)
static

Definition at line 515 of file corruntimehost.c.

517{
518 FIXME("(%p,%p)\n", iface, pdwAppDomainId);
519 return E_NOTIMPL;
520}

◆ CLRRuntimeHost_QueryInterface()

static HRESULT WINAPI CLRRuntimeHost_QueryInterface ( ICLRRuntimeHost iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 440 of file corruntimehost.c.

443{
445 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
446
447 if ( IsEqualGUID( riid, &IID_ICLRRuntimeHost ) ||
449 {
450 *ppvObject = iface;
451 }
452 else
453 {
454 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
455 return E_NOINTERFACE;
456 }
457
458 ICLRRuntimeHost_AddRef( iface );
459
460 return S_OK;
461}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ CLRRuntimeHost_Release()

static ULONG WINAPI CLRRuntimeHost_Release ( ICLRRuntimeHost iface)
static

Definition at line 469 of file corruntimehost.c.

470{
472 return ICorRuntimeHost_Release(&This->ICorRuntimeHost_iface);
473}

◆ CLRRuntimeHost_SetHostControl()

static HRESULT WINAPI CLRRuntimeHost_SetHostControl ( ICLRRuntimeHost iface,
IHostControl pHostControl 
)
static

Definition at line 487 of file corruntimehost.c.

489{
490 FIXME("(%p,%p)\n", iface, pHostControl);
491 return E_NOTIMPL;
492}

◆ CLRRuntimeHost_Start()

static HRESULT WINAPI CLRRuntimeHost_Start ( ICLRRuntimeHost iface)
static

Definition at line 475 of file corruntimehost.c.

476{
477 FIXME("(%p)\n", iface);
478 return E_NOTIMPL;
479}

◆ CLRRuntimeHost_Stop()

static HRESULT WINAPI CLRRuntimeHost_Stop ( ICLRRuntimeHost iface)
static

Definition at line 481 of file corruntimehost.c.

482{
483 FIXME("(%p)\n", iface);
484 return E_NOTIMPL;
485}

◆ CLRRuntimeHost_UnloadAppDomain()

static HRESULT WINAPI CLRRuntimeHost_UnloadAppDomain ( ICLRRuntimeHost iface,
DWORD  dwAppDomainId,
BOOL  fWaitUntilDone 
)
static

Definition at line 501 of file corruntimehost.c.

503{
504 FIXME("(%p,%u,%i)\n", iface, dwAppDomainId, fWaitUntilDone);
505 return E_NOTIMPL;
506}

◆ corruntimehost_AddRef()

static ULONG WINAPI corruntimehost_AddRef ( ICorRuntimeHost iface)
static

Definition at line 229 of file corruntimehost.c.

230{
232
233 return InterlockedIncrement( &This->ref );
234}
#define InterlockedIncrement
Definition: armddk.h:53
static RuntimeHost * impl_from_ICorRuntimeHost(ICorRuntimeHost *iface)

◆ corruntimehost_CloseEnum()

static HRESULT WINAPI corruntimehost_CloseEnum ( ICorRuntimeHost iface,
HDOMAINENUM  hEnum 
)
static

Definition at line 363 of file corruntimehost.c.

366{
367 FIXME("stub %p\n", iface);
368 return E_NOTIMPL;
369}

◆ corruntimehost_CreateDomain()

static HRESULT WINAPI corruntimehost_CreateDomain ( ICorRuntimeHost iface,
LPCWSTR  friendlyName,
IUnknown identityArray,
IUnknown **  appDomain 
)
static

Definition at line 316 of file corruntimehost.c.

321{
322 FIXME("stub %p\n", iface);
323 return E_NOTIMPL;
324}

◆ corruntimehost_CreateDomainEx()

static HRESULT WINAPI corruntimehost_CreateDomainEx ( ICorRuntimeHost iface,
LPCWSTR  friendlyName,
IUnknown setup,
IUnknown evidence,
IUnknown **  appDomain 
)
static

Definition at line 371 of file corruntimehost.c.

377{
378 FIXME("stub %p\n", iface);
379 return E_NOTIMPL;
380}

◆ corruntimehost_CreateDomainSetup()

static HRESULT WINAPI corruntimehost_CreateDomainSetup ( ICorRuntimeHost iface,
IUnknown **  appDomainSetup 
)
static

Definition at line 382 of file corruntimehost.c.

385{
386 FIXME("stub %p\n", iface);
387 return E_NOTIMPL;
388}

◆ corruntimehost_CreateEvidence()

static HRESULT WINAPI corruntimehost_CreateEvidence ( ICorRuntimeHost iface,
IUnknown **  evidence 
)
static

Definition at line 390 of file corruntimehost.c.

393{
394 FIXME("stub %p\n", iface);
395 return E_NOTIMPL;
396}

◆ corruntimehost_CreateLogicalThreadState()

static HRESULT WINAPI corruntimehost_CreateLogicalThreadState ( ICorRuntimeHost iface)
static

Definition at line 247 of file corruntimehost.c.

249{
250 FIXME("stub %p\n", iface);
251 return E_NOTIMPL;
252}

◆ corruntimehost_CurrentDomain()

static HRESULT WINAPI corruntimehost_CurrentDomain ( ICorRuntimeHost iface,
IUnknown **  appDomain 
)
static

Definition at line 406 of file corruntimehost.c.

409{
410 FIXME("stub %p\n", iface);
411 return E_NOTIMPL;
412}

◆ corruntimehost_DeleteLogicalThreadState()

static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState ( ICorRuntimeHost iface)
static

Definition at line 254 of file corruntimehost.c.

256{
257 FIXME("stub %p\n", iface);
258 return E_NOTIMPL;
259}

◆ corruntimehost_EnumDomains()

static HRESULT WINAPI corruntimehost_EnumDomains ( ICorRuntimeHost iface,
HDOMAINENUM hEnum 
)
static

Definition at line 346 of file corruntimehost.c.

349{
350 FIXME("stub %p\n", iface);
351 return E_NOTIMPL;
352}

◆ corruntimehost_GetConfiguration()

static HRESULT WINAPI corruntimehost_GetConfiguration ( ICorRuntimeHost iface,
ICorConfiguration **  pConfiguration 
)
static

Definition at line 294 of file corruntimehost.c.

297{
298 FIXME("stub %p\n", iface);
299 return E_NOTIMPL;
300}

◆ corruntimehost_GetDefaultDomain()

static HRESULT WINAPI corruntimehost_GetDefaultDomain ( ICorRuntimeHost iface,
IUnknown **  pAppDomain 
)
static

Definition at line 326 of file corruntimehost.c.

329{
331 HRESULT hr;
333
334 TRACE("(%p)\n", iface);
335
337
338 if (SUCCEEDED(hr))
339 {
341 }
342
343 return hr;
344}
static HRESULT RuntimeHost_GetIUnknownForDomain(RuntimeHost *This, MonoDomain *domain, IUnknown **punk)

◆ corruntimehost_LocksHeldByLogicalThread()

static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread ( ICorRuntimeHost iface,
DWORD pCount 
)
static

Definition at line 277 of file corruntimehost.c.

280{
281 FIXME("stub %p\n", iface);
282 return E_NOTIMPL;
283}

◆ corruntimehost_MapFile()

static HRESULT WINAPI corruntimehost_MapFile ( ICorRuntimeHost iface,
HANDLE  hFile,
HMODULE mapAddress 
)
static

Definition at line 285 of file corruntimehost.c.

289{
290 FIXME("stub %p\n", iface);
291 return E_NOTIMPL;
292}

◆ corruntimehost_NextDomain()

static HRESULT WINAPI corruntimehost_NextDomain ( ICorRuntimeHost iface,
HDOMAINENUM  hEnum,
IUnknown **  appDomain 
)
static

Definition at line 354 of file corruntimehost.c.

358{
359 FIXME("stub %p\n", iface);
360 return E_NOTIMPL;
361}

◆ corruntimehost_QueryInterface()

static HRESULT WINAPI corruntimehost_QueryInterface ( ICorRuntimeHost iface,
REFIID  riid,
void **  ppvObject 
)
static

Definition at line 206 of file corruntimehost.c.

209{
211 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
212
213 if ( IsEqualGUID( riid, &IID_ICorRuntimeHost ) ||
215 {
216 *ppvObject = iface;
217 }
218 else
219 {
220 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
221 return E_NOINTERFACE;
222 }
223
224 ICorRuntimeHost_AddRef( iface );
225
226 return S_OK;
227}

◆ corruntimehost_Release()

static ULONG WINAPI corruntimehost_Release ( ICorRuntimeHost iface)
static

Definition at line 236 of file corruntimehost.c.

237{
239 ULONG ref;
240
241 ref = InterlockedDecrement( &This->ref );
242
243 return ref;
244}
#define InterlockedDecrement
Definition: armddk.h:52
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ corruntimehost_Start()

static HRESULT WINAPI corruntimehost_Start ( ICorRuntimeHost iface)
static

Definition at line 302 of file corruntimehost.c.

304{
305 FIXME("stub %p\n", iface);
306 return S_OK;
307}

◆ corruntimehost_Stop()

static HRESULT WINAPI corruntimehost_Stop ( ICorRuntimeHost iface)
static

Definition at line 309 of file corruntimehost.c.

311{
312 FIXME("stub %p\n", iface);
313 return E_NOTIMPL;
314}

◆ corruntimehost_SwitchInLogicalThreadState()

static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState ( ICorRuntimeHost iface,
DWORD fiberCookie 
)
static

Definition at line 261 of file corruntimehost.c.

264{
265 FIXME("stub %p\n", iface);
266 return E_NOTIMPL;
267}

◆ corruntimehost_SwitchOutLogicalThreadState()

static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState ( ICorRuntimeHost iface,
DWORD **  fiberCookie 
)
static

Definition at line 269 of file corruntimehost.c.

272{
273 FIXME("stub %p\n", iface);
274 return E_NOTIMPL;
275}

◆ corruntimehost_UnloadDomain()

static HRESULT WINAPI corruntimehost_UnloadDomain ( ICorRuntimeHost iface,
IUnknown appDomain 
)
static

Definition at line 398 of file corruntimehost.c.

401{
402 FIXME("stub %p\n", iface);
403 return E_NOTIMPL;
404}

◆ 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];
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
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
1274 if (SUCCEEDED(hr))
1275 {
1277
1278 if (SUCCEEDED(hr))
1280
1281 if (SUCCEEDED(hr))
1282 {
1284 MonoClass *klass;
1286 IUnknown *unk = NULL;
1287 char *filenameA, *ns;
1288 char *classA;
1289
1291
1292 host->mono->mono_thread_attach(domain);
1293
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
1344cleanup:
1345 if(info)
1346 ICLRRuntimeInfo_Release(info);
1347
1349
1350 return hr;
1351}
#define WARN(fmt,...)
Definition: debug.h:115
#define RegCloseKey(hKey)
Definition: registry.h:49
#define CHARS_IN_GUID
#define ARRAYSIZE(array)
HRESULT RuntimeHost_GetIUnknownForObject(RuntimeHost *This, MonoObject *obj, IUnknown **ppUnk)
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
#define RRF_RT_REG_SZ
Definition: driver.c:575
GLuint res
Definition: glext.h:9613
GLintptr offset
Definition: glext.h:5920
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define KEY_READ
Definition: nt_native.h:1023
long LONG
Definition: pedump.c:60
#define strlenW(s)
Definition: unicode.h:34
#define strncmpW(s1, s2, n)
Definition: unicode.h:42
#define strcpyW(d, s)
Definition: unicode.h:35
WCHAR classname[128]
Definition: startup.c:15
Definition: copy.c:22
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4246
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by DllGetClassObject().

◆ DEFINE_GUID()

DEFINE_GUID ( IID__AppDomain  ,
0x05f696dc  ,
0x2b29  ,
0x3663  ,
0xad  ,
0x8b  ,
0xc4  ,
0x38  ,
0x9c  ,
0xf2  ,
0xa7  ,
0x13   
)

◆ FixupVTable()

static void FixupVTable ( HMODULE  hmodule)
static

Definition at line 985 of file corruntimehost.c.

986{
988 HRESULT hr;
989 VTableFixup *vtable_fixups;
990 ULONG vtable_fixup_count, i;
991
993 if (SUCCEEDED(hr))
994 {
995 hr = assembly_get_vtable_fixups(assembly, &vtable_fixups, &vtable_fixup_count);
997 for (i=0; i<vtable_fixup_count; i++)
998 FixupVTableEntry(hmodule, &vtable_fixups[i]);
999 else if (vtable_fixup_count)
1000 FIXME("cannot fixup vtable; expect a crash\n");
1001
1003 }
1004 else
1005 ERR("failed to read CLR headers, hr=%x\n", hr);
1006}
#define CAN_FIXUP_VTABLE
static void FixupVTableEntry(HMODULE hmodule, VTableFixup *vtable_fixup)
HRESULT assembly_release(ASSEMBLY *assembly)
Definition: assembly.c:694
static HMODULE hmodule
Definition: rasapi.c:29
HRESULT assembly_from_hmodule(ASSEMBLY **out, HMODULE hmodule)
Definition: assembly.c:245
HRESULT assembly_get_vtable_fixups(ASSEMBLY *assembly, VTableFixup **fixups, DWORD *count)
Definition: assembly.c:294

Referenced by _CorDllMain(), and _CorExeMain().

◆ FixupVTableEntry()

static void FixupVTableEntry ( HMODULE  hmodule,
VTableFixup vtable_fixup 
)
static

Definition at line 934 of file corruntimehost.c.

935{
936 /* We can't actually generate code for the functions without loading mono,
937 * and loading mono inside DllMain is a terrible idea. So we make thunks
938 * that call ReallyFixupVTable, which will load the runtime and fill in the
939 * vtable, then do an indirect jump using the (now filled in) vtable. Note
940 * that we have to keep the thunks around forever, as one of them may get
941 * called while we're filling in the table, and we can never be sure all
942 * threads are clear. */
943 struct dll_fixup *fixup;
944
945 fixup = HeapAlloc(GetProcessHeap(), 0, sizeof(*fixup));
946
947 fixup->dll = hmodule;
948 fixup->thunk_code = HeapAlloc(dll_fixup_heap, 0, sizeof(struct vtable_fixup_thunk) * vtable_fixup->count);
949 fixup->fixup = vtable_fixup;
950 fixup->vtable = (BYTE*)hmodule + vtable_fixup->rva;
951 fixup->done = 0;
952
953 if (vtable_fixup->type & COR_VTABLE_32BIT)
954 {
955 DWORD *vtable = fixup->vtable;
956 DWORD *tokens;
957 int i;
958 struct vtable_fixup_thunk *thunks = fixup->thunk_code;
959
960 if (sizeof(void*) > 4)
961 ERR("32-bit fixup in 64-bit mode; broken image?\n");
962
963 tokens = fixup->tokens = HeapAlloc(GetProcessHeap(), 0, sizeof(*tokens) * vtable_fixup->count);
964 memcpy(tokens, vtable, sizeof(*tokens) * vtable_fixup->count);
965 for (i=0; i<vtable_fixup->count; i++)
966 {
967 memcpy(&thunks[i], &thunk_template, sizeof(thunk_template));
968 thunks[i].fixup = fixup;
969 thunks[i].function = ReallyFixupVTable;
970 thunks[i].vtable_entry = &vtable[i];
971 vtable[i] = PtrToUint(&thunks[i]);
972 }
973 }
974 else
975 {
976 ERR("unsupported vtable fixup flags %x\n", vtable_fixup->type);
977 HeapFree(dll_fixup_heap, 0, fixup->thunk_code);
979 return;
980 }
981
982 list_add_tail(&dll_fixups, &fixup->entry);
983}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define PtrToUint(p)
Definition: basetsd.h:85
static HANDLE dll_fixup_heap
static struct list dll_fixups
static void CDECL ReallyFixupVTable(struct dll_fixup *fixup)
static const struct vtable_fixup_thunk thunk_template
#define HeapAlloc
Definition: compat.h:733
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void * vtable[]
Definition: typelib.c:1231
VTableFixup * fixup
void * tokens
struct dll_fixup * fixup
@ COR_VTABLE_32BIT
Definition: winnt_old.h:3279
unsigned char BYTE
Definition: xxhash.c:193

Referenced by FixupVTable().

◆ get_utf8_args()

static void get_utf8_args ( int argc,
char ***  argv 
)
static

Definition at line 771 of file corruntimehost.c.

772{
773 WCHAR **argvw;
774 int size=0, i;
775 char *current_arg;
776
778
779 for (i=0; i<*argc; i++)
780 {
781 size += sizeof(char*);
782 size += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, NULL, 0, NULL, NULL);
783 }
784 size += sizeof(char*);
785
787 current_arg = (char*)(*argv + *argc + 1);
788
789 for (i=0; i<*argc; i++)
790 {
791 (*argv)[i] = current_arg;
792 current_arg += WideCharToMultiByte(CP_UTF8, 0, argvw[i], -1, current_arg, size, NULL, NULL);
793 }
794
795 (*argv)[*argc] = NULL;
796
797 HeapFree(GetProcessHeap(), 0, argvw);
798}
#define WideCharToMultiByte
Definition: compat.h:111
LPWSTR WINAPI GetCommandLineW(VOID)
Definition: proc.c:2013
GLsizeiptr size
Definition: glext.h:5919
#define CP_UTF8
Definition: nls.h:20
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:80

Referenced by _CorExeMain().

◆ impl_from_ICLRRuntimeHost()

static RuntimeHost * impl_from_ICLRRuntimeHost ( ICLRRuntimeHost iface)
inlinestatic

Definition at line 195 of file corruntimehost.c.

196{
197 return CONTAINING_RECORD(iface, RuntimeHost, ICLRRuntimeHost_iface);
198}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by CLRRuntimeHost_AddRef(), CLRRuntimeHost_ExecuteInDefaultAppDomain(), CLRRuntimeHost_QueryInterface(), and CLRRuntimeHost_Release().

◆ impl_from_ICorRuntimeHost()

static RuntimeHost * impl_from_ICorRuntimeHost ( ICorRuntimeHost iface)
inlinestatic

Definition at line 200 of file corruntimehost.c.

201{
202 return CONTAINING_RECORD(iface, RuntimeHost, ICorRuntimeHost_iface);
203}

Referenced by corruntimehost_AddRef(), corruntimehost_GetDefaultDomain(), corruntimehost_QueryInterface(), and corruntimehost_Release().

◆ ReallyFixupVTable()

static void CDECL ReallyFixupVTable ( struct dll_fixup fixup)
static

Definition at line 854 of file corruntimehost.c.

855{
860 char *filenameA;
865
866 if (fixup->done) return;
867
868 /* It's possible we'll have two threads doing this at once. This is
869 * considered preferable to the potential deadlock if we use a mutex. */
870
872
873 TRACE("%p,%p,%s\n", fixup, fixup->dll, debugstr_w(filename));
874
876 if (!filenameA)
878
879 if (SUCCEEDED(hr))
881
882 if (SUCCEEDED(hr))
884
885 if (SUCCEEDED(hr))
887
888 if (SUCCEEDED(hr))
889 {
890 host->mono->mono_thread_attach(domain);
891
892 image = host->mono->mono_image_open_from_module_handle(fixup->dll,
893 filenameA, 1, &status);
894 }
895
896 if (image)
897 assembly = host->mono->mono_assembly_load_from(image, filenameA, &status);
898
899 if (assembly)
900 {
901 int i;
902
903 /* Mono needs an image that belongs to an assembly. */
904 image = host->mono->mono_assembly_get_image(assembly);
905
906 if (fixup->fixup->type & COR_VTABLE_32BIT)
907 {
908 DWORD *vtable = fixup->vtable;
909 DWORD *tokens = fixup->tokens;
910 for (i=0; i<fixup->fixup->count; i++)
911 {
912 TRACE("%x\n", tokens[i]);
913 vtable[i] = PtrToUint(host->mono->mono_marshal_get_vtfixup_ftnptr(
914 image, tokens[i], fixup->fixup->type));
915 }
916 }
917
918 fixup->done = 1;
919 }
920
921 if (info != NULL)
922 ICLRRuntimeInfo_Release(info);
923
925
926 if (!fixup->done)
927 {
928 ERR("unable to fixup vtable, hr=%x, status=%d\n", hr, status);
929 /* If we returned now, we'd get an infinite loop. */
930 assert(0);
931 }
932}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define assert(x)
Definition: debug.h:53
void * vtable
HMODULE dll

Referenced by FixupVTableEntry().

◆ RuntimeHost_AddDomain()

static HRESULT RuntimeHost_AddDomain ( RuntimeHost This,
MonoDomain **  result 
)
static

Definition at line 49 of file corruntimehost.c.

50{
51 struct DomainEntry *entry;
52 char *mscorlib_path;
54
56
57 entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry));
58 if (!entry)
59 {
61 goto end;
62 }
63
64 mscorlib_path = WtoA(This->version->mscorlib_path);
65 if (!mscorlib_path)
66 {
69 goto end;
70 }
71
72 entry->domain = This->mono->mono_jit_init(mscorlib_path);
73
74 HeapFree(GetProcessHeap(), 0, mscorlib_path);
75
76 if (!entry->domain)
77 {
79 res = E_FAIL;
80 goto end;
81 }
82
83 This->mono->is_started = TRUE;
84
85 list_add_tail(&This->domains, &entry->entry);
86
87 *result = entry->domain;
88
89end:
91
92 return res;
93}
GLuint GLuint end
Definition: gl.h:1545
uint32_t entry
Definition: isohybrid.c:63
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by RuntimeHost_GetDefaultDomain().

◆ RuntimeHost_Construct()

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

Definition at line 1120 of file corruntimehost.c.

1122{
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 void list_init(struct list_entry *head)
Definition: list.h:51
static const struct ICorRuntimeHostVtbl corruntimehost_vtbl
static const struct ICLRRuntimeHostVtbl CLRHostVtbl
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76

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{
642 char *nameA=NULL;
643 MonoType *type;
644 MonoClass *klass;
646
647 if (!domain)
649
650 if (SUCCEEDED(hr))
651 {
652 nameA = WtoA(name);
653 if (!nameA)
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}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _MonoType MonoType
Definition: name.c:39

Referenced by ClrCreateManagedInstance().

◆ RuntimeHost_DeleteDomain()

static void RuntimeHost_DeleteDomain ( RuntimeHost This,
MonoDomain domain 
)
static

Definition at line 113 of file corruntimehost.c.

114{
115 struct DomainEntry *entry;
116
118
119 LIST_FOR_EACH_ENTRY(entry, &This->domains, struct DomainEntry, entry)
120 {
121 if (entry->domain == domain)
122 {
123 list_remove(&entry->entry);
124 if (This->default_domain == domain)
125 This->default_domain = NULL;
127 break;
128 }
129 }
130
132}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198

Referenced by _CorExeMain().

◆ 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;
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}
const char cursor[]
Definition: icontest.c:13
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by unload_all_runtimes().

◆ RuntimeHost_GetDefaultDomain()

static HRESULT RuntimeHost_GetDefaultDomain ( RuntimeHost This,
MonoDomain **  result 
)
static

Definition at line 95 of file corruntimehost.c.

96{
98
100
101 if (This->default_domain) goto end;
102
103 res = RuntimeHost_AddDomain(This, &This->default_domain);
104
105end:
106 *result = This->default_domain;
107
109
110 return res;
111}
static HRESULT RuntimeHost_AddDomain(RuntimeHost *This, MonoDomain **result)

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

◆ 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 MetaDataDispenser_CreateInstance(IUnknown **ppUnk)
Definition: metadata.c:169
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define FAILED(hr)
Definition: intsafe.h:51
REFCLSID clsid
Definition: msctf.c:82

Referenced by CLRRuntimeInfo_GetInterface().

◆ RuntimeHost_GetIUnknownForDomain()

static HRESULT RuntimeHost_GetIUnknownForDomain ( RuntimeHost This,
MonoDomain domain,
IUnknown **  punk 
)
static

Definition at line 134 of file corruntimehost.c.

135{
136 HRESULT hr;
137 void *args[1];
140 MonoClass *klass;
142 MonoObject *appdomain_object;
143 IUnknown *unk;
144
145 This->mono->mono_thread_attach(domain);
146
147 assembly = This->mono->mono_domain_assembly_open(domain, "mscorlib");
148 if (!assembly)
149 {
150 ERR("Cannot load mscorlib\n");
151 return E_FAIL;
152 }
153
154 image = This->mono->mono_assembly_get_image(assembly);
155 if (!image)
156 {
157 ERR("Couldn't get assembly image\n");
158 return E_FAIL;
159 }
160
161 klass = This->mono->mono_class_from_name(image, "System", "AppDomain");
162 if (!klass)
163 {
164 ERR("Couldn't get class from image\n");
165 return E_FAIL;
166 }
167
168 method = This->mono->mono_class_get_method_from_name(klass, "get_CurrentDomain", 0);
169 if (!method)
170 {
171 ERR("Couldn't get method from class\n");
172 return E_FAIL;
173 }
174
175 args[0] = NULL;
176 appdomain_object = This->mono->mono_runtime_invoke(method, NULL, args, NULL);
177 if (!appdomain_object)
178 {
179 ERR("Couldn't get result pointer\n");
180 return E_FAIL;
181 }
182
183 hr = RuntimeHost_GetIUnknownForObject(This, appdomain_object, &unk);
184
185 if (SUCCEEDED(hr))
186 {
187 hr = IUnknown_QueryInterface(unk, &IID__AppDomain, (void**)punk);
188
189 IUnknown_Release(unk);
190 }
191
192 return hr;
193}

Referenced by corruntimehost_GetDefaultDomain().

◆ RuntimeHost_GetIUnknownForObject()

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

Definition at line 711 of file corruntimehost.c.

713{
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}

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
#define HEAP_CREATE_ENABLE_EXECUTE
Definition: rtltypes.h:135

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);
1117 }
1118}
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85

Referenced by DllMain().

Variable Documentation

◆ CLRHostVtbl

const struct ICLRRuntimeHostVtbl CLRHostVtbl
static
Initial value:
=
{
}
static HRESULT WINAPI CLRRuntimeHost_ExecuteInAppDomain(ICLRRuntimeHost *iface, DWORD dwAppDomainId, FExecuteInAppDomainCallback pCallback, void *cookie)
static HRESULT WINAPI CLRRuntimeHost_UnloadAppDomain(ICLRRuntimeHost *iface, DWORD dwAppDomainId, BOOL fWaitUntilDone)
static HRESULT WINAPI CLRRuntimeHost_SetHostControl(ICLRRuntimeHost *iface, IHostControl *pHostControl)
static HRESULT WINAPI CLRRuntimeHost_Start(ICLRRuntimeHost *iface)
static ULONG WINAPI CLRRuntimeHost_Release(ICLRRuntimeHost *iface)
static ULONG WINAPI CLRRuntimeHost_AddRef(ICLRRuntimeHost *iface)
static HRESULT WINAPI CLRRuntimeHost_ExecuteInDefaultAppDomain(ICLRRuntimeHost *iface, LPCWSTR pwzAssemblyPath, LPCWSTR pwzTypeName, LPCWSTR pwzMethodName, LPCWSTR pwzArgument, DWORD *pReturnValue)
static HRESULT WINAPI CLRRuntimeHost_GetCLRControl(ICLRRuntimeHost *iface, ICLRControl **pCLRControl)
static HRESULT WINAPI CLRRuntimeHost_GetCurrentAppDomainId(ICLRRuntimeHost *iface, DWORD *pdwAppDomainId)
static HRESULT WINAPI CLRRuntimeHost_QueryInterface(ICLRRuntimeHost *iface, REFIID riid, void **ppvObject)
static HRESULT WINAPI CLRRuntimeHost_Stop(ICLRRuntimeHost *iface)
static HRESULT WINAPI CLRRuntimeHost_ExecuteApplication(ICLRRuntimeHost *iface, LPCWSTR pwzAppFullName, DWORD dwManifestPaths, LPCWSTR *ppwzManifestPaths, DWORD dwActivationData, LPCWSTR *ppwzActivationData, int *pReturnValue)

Definition at line 619 of file corruntimehost.c.

Referenced by RuntimeHost_Construct().

◆ corruntimehost_vtbl

const struct ICorRuntimeHostVtbl corruntimehost_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI corruntimehost_AddRef(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_Start(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_SwitchOutLogicalThreadState(ICorRuntimeHost *iface, DWORD **fiberCookie)
static HRESULT WINAPI corruntimehost_QueryInterface(ICorRuntimeHost *iface, REFIID riid, void **ppvObject)
static HRESULT WINAPI corruntimehost_CurrentDomain(ICorRuntimeHost *iface, IUnknown **appDomain)
static HRESULT WINAPI corruntimehost_GetConfiguration(ICorRuntimeHost *iface, ICorConfiguration **pConfiguration)
static HRESULT WINAPI corruntimehost_UnloadDomain(ICorRuntimeHost *iface, IUnknown *appDomain)
static HRESULT WINAPI corruntimehost_CreateLogicalThreadState(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_GetDefaultDomain(ICorRuntimeHost *iface, IUnknown **pAppDomain)
static HRESULT WINAPI corruntimehost_Stop(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_CreateDomainEx(ICorRuntimeHost *iface, LPCWSTR friendlyName, IUnknown *setup, IUnknown *evidence, IUnknown **appDomain)
static HRESULT WINAPI corruntimehost_SwitchInLogicalThreadState(ICorRuntimeHost *iface, DWORD *fiberCookie)
static HRESULT WINAPI corruntimehost_EnumDomains(ICorRuntimeHost *iface, HDOMAINENUM *hEnum)
static HRESULT WINAPI corruntimehost_CreateDomain(ICorRuntimeHost *iface, LPCWSTR friendlyName, IUnknown *identityArray, IUnknown **appDomain)
static HRESULT WINAPI corruntimehost_MapFile(ICorRuntimeHost *iface, HANDLE hFile, HMODULE *mapAddress)
static HRESULT WINAPI corruntimehost_DeleteLogicalThreadState(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_CloseEnum(ICorRuntimeHost *iface, HDOMAINENUM hEnum)
static ULONG WINAPI corruntimehost_Release(ICorRuntimeHost *iface)
static HRESULT WINAPI corruntimehost_CreateDomainSetup(ICorRuntimeHost *iface, IUnknown **appDomainSetup)
static HRESULT WINAPI corruntimehost_NextDomain(ICorRuntimeHost *iface, HDOMAINENUM hEnum, IUnknown **appDomain)
static HRESULT WINAPI corruntimehost_CreateEvidence(ICorRuntimeHost *iface, IUnknown **evidence)
static HRESULT WINAPI corruntimehost_LocksHeldByLogicalThread(ICorRuntimeHost *iface, DWORD *pCount)

Definition at line 414 of file corruntimehost.c.

Referenced by RuntimeHost_Construct().

◆ dll_fixup_heap

HANDLE dll_fixup_heap
static

Definition at line 34 of file corruntimehost.c.

Referenced by FixupVTableEntry(), runtimehost_init(), and runtimehost_uninit().

◆ dll_fixups

struct list dll_fixups
static

Definition at line 36 of file corruntimehost.c.

Referenced by FixupVTableEntry(), runtimehost_init(), and runtimehost_uninit().

◆ thunk_template

const struct vtable_fixup_thunk thunk_template = {0}
static

Definition at line 850 of file corruntimehost.c.

Referenced by FixupVTableEntry().