2 #include <mono/utils/mono-compiler.h>
7 #include "mini-runtime.h"
8 #include <mono/metadata/assembly.h>
9 #include <mono/metadata/assembly-internals.h>
10 #include <mono/metadata/environment.h>
11 #include <mono/metadata/loader-internals.h>
12 #include <mono/mini/monovm.h>
13 #include <mono/utils/mono-logger-internals.h>
15 #ifndef STDAPICALLTYPE
16 #define STDAPICALLTYPE
19 #if defined(_MSC_VER) && defined(HOST_WIN32) && defined(HOST_X86)
20 // Ensure that the exported symbols are not decorated and that only one set is exported
21 #pragma comment(linker, "/export:coreclr_initialize=_coreclr_initialize@28")
22 #pragma comment(linker, "/export:coreclr_execute_assembly=_coreclr_execute_assembly@24")
23 #pragma comment(linker, "/export:coreclr_shutdown_2=_coreclr_shutdown_2@12")
24 #pragma comment(linker, "/export:coreclr_create_delegate=_coreclr_create_delegate@24")
26 #define MONO_API MONO_EXTERN_C
29 MONO_API
int STDAPICALLTYPE
coreclr_initialize (const char* exePath
, const char* appDomainFriendlyName
,
30 int propertyCount
, const char** propertyKeys
, const char** propertyValues
,
31 void** hostHandle
, unsigned int* domainId
);
33 MONO_API
int STDAPICALLTYPE
coreclr_execute_assembly (void* hostHandle
, unsigned int domainId
,
34 int argc
, const char** argv
,
35 const char* managedAssemblyPath
, unsigned int* exitCode
);
37 MONO_API
int STDAPICALLTYPE
coreclr_shutdown_2 (void* hostHandle
, unsigned int domainId
, int* latchedExitCode
);
39 MONO_API
int STDAPICALLTYPE
coreclr_create_delegate (void* hostHandle
, unsigned int domainId
,
40 const char* entryPointAssemblyName
, const char* entryPointTypeName
, const char* entryPointMethodName
,
44 // Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain
47 // exePath - Absolute path of the executable that invoked the ExecuteAssembly
48 // appDomainFriendlyName - Friendly name of the app domain that will be created to execute the assembly
49 // propertyCount - Number of properties (elements of the following two arguments)
50 // propertyKeys - Keys of properties of the app domain
51 // propertyValues - Values of properties of the app domain
52 // hostHandle - Output parameter, handle of the created host
53 // domainId - Output parameter, id of the created app domain
56 // HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
58 int STDAPICALLTYPE
coreclr_initialize (const char* exePath
, const char* appDomainFriendlyName
,
59 int propertyCount
, const char** propertyKeys
, const char** propertyValues
,
60 void** hostHandle
, unsigned int* domainId
)
62 return monovm_initialize (propertyCount
, propertyKeys
, propertyValues
);
66 // Execute a managed assembly with given arguments
69 // hostHandle - Handle of the host
70 // domainId - Id of the domain
71 // argc - Number of arguments passed to the executed assembly
72 // argv - Array of arguments passed to the executed assembly
73 // managedAssemblyPath - Path of the managed assembly to execute (or NULL if using a custom entrypoint).
74 // exitCode - Exit code returned by the executed assembly
77 // HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
79 int STDAPICALLTYPE
coreclr_execute_assembly (void* hostHandle
, unsigned int domainId
,
80 int argc
, const char** argv
,
81 const char* managedAssemblyPath
, unsigned int* exitCode
)
83 return monovm_execute_assembly (argc
, argv
, managedAssemblyPath
, exitCode
);
87 // Shutdown CoreCLR. It unloads the app domain and stops the CoreCLR host.
90 // hostHandle - Handle of the host
91 // domainId - Id of the domain
92 // latchedExitCode - Latched exit code after domain unloaded
95 // HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
97 int STDAPICALLTYPE
coreclr_shutdown_2 (void* hostHandle
, unsigned int domainId
, int* latchedExitCode
)
99 return monovm_shutdown (latchedExitCode
);
103 // Create a native callable delegate for a managed method.
106 // hostHandle - Handle of the host
107 // domainId - Id of the domain
108 // entryPointAssemblyName - Name of the assembly which holds the custom entry point
109 // entryPointTypeName - Name of the type which holds the custom entry point
110 // entryPointMethodName - Name of the method which is the custom entry point
111 // delegate - Output parameter, the function stores a pointer to the delegate at the specified address
114 // HRESULT indicating status of the operation. S_OK if the assembly was successfully executed
116 int STDAPICALLTYPE
coreclr_create_delegate (void* hostHandle
, unsigned int domainId
,
117 const char* entryPointAssemblyName
, const char* entryPointTypeName
, const char* entryPointMethodName
,
120 g_error ("Not implemented");
125 MONO_EMPTY_SOURCE_FILE (main_core
);
126 #endif // ENABLE_NETCORE