Apply changes from https://github.com/dotnet/runtime/commit/eb1756e97d23df13bc6fe798e...
[mono-project.git] / mono / mini / main-core.c
blob29f575fcf5d15f93577422ea8f6468c75a41aeae
1 #include <config.h>
2 #include <mono/utils/mono-compiler.h>
4 #if ENABLE_NETCORE
6 #include "mini.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
17 #endif
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")
25 #undef MONO_API
26 #define MONO_API MONO_EXTERN_C
27 #endif
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,
41 void** delegate);
44 // Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain
46 // Parameters:
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
55 // Returns:
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
68 // Parameters:
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
76 // Returns:
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.
89 // Parameters:
90 // hostHandle - Handle of the host
91 // domainId - Id of the domain
92 // latchedExitCode - Latched exit code after domain unloaded
94 // Returns:
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.
105 // Parameters:
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
113 // Returns:
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,
118 void** delegate)
120 g_error ("Not implemented");
121 return 0;
123 #else
125 MONO_EMPTY_SOURCE_FILE (main_core);
126 #endif // ENABLE_NETCORE