// ==++==
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--==
/**************************************************************************************
 **                                                                                  **
 ** Mscoree.idl - interface definitions for mscoree.dll                              **
 **                                                                                  **
 **************************************************************************************/

//
// Interface descriptions
//
import "unknwn.idl";
import "gchost.idl";
import "ivalidator.idl";

#include "product_version.h"

const char* CLR_MAJOR_VERSION = VER_MAJORVERSION;
const char* CLR_MINOR_VERSION = VER_MINORVERSION;
const char* CLR_BUILD_VERSION = VER_PRODUCTBUILD;

const char* CLR_ASSEMBLY_MAJOR_VERSION = VER_ASSEMBLYMAJORVERSION;
const char* CLR_ASSEMBLY_MINOR_VERSION = VER_ASSEMBLYMINORVERSION;
const char* CLR_ASSEMBLY_BUILD_VERSION = VER_ASSEMBLYBUILD;

// LIBID mscoree
cpp_quote("EXTERN_GUID(LIBID_mscoree, 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa0,0xc9,0xb7,0xc9,0xc4);")

// CLSID CorRuntimeHost : uuid(CB2F6723-AB3A-11d2-9C40-00C04FA30A3E)
cpp_quote("EXTERN_GUID(CLSID_CorRuntimeHost, 0xcb2f6723, 0xab3a, 0x11d2, 0x9c, 0x40, 0x00, 0xc0, 0x4f, 0xa3, 0x0a, 0x3e);")

// CLSID TypeNameFactory : uuid{B81FF171-20F3-11d2-8DCC-00A0C9B00525}
cpp_quote("EXTERN_GUID(CLSID_TypeNameFactory, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x25);")

// CLSID CLRRuntimeHost : uuid(90F1A06E-7712-4762-86B5-7A5EBA6BDB02)
cpp_quote("EXTERN_GUID(CLSID_CLRRuntimeHost, 0x90F1A06E, 0x7712, 0x4762, 0x86, 0xB5, 0x7A, 0x5E, 0xBA, 0x6B, 0xDB, 0x02);")

// CLSID ComCallUnmarshall
cpp_quote("EXTERN_GUID(CLSID_ComCallUnmarshal, 0x3F281000,0xE95A,0x11d2,0x88,0x6B,0x00,0xC0,0x4F,0x86,0x9F,0x04);")

// IID IObjectHandle : uuid(C460E2B4-E199-412a-8456-84DC3E4838C3)
cpp_quote("EXTERN_GUID(IID_IObjectHandle, 0xc460e2b4, 0xe199, 0x412a, 0x84, 0x56, 0x84, 0xdc, 0x3e, 0x48, 0x38, 0xc3);")

// IID IManagedObject : uuid(C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4)
cpp_quote("EXTERN_GUID(IID_IManagedObject, 0xc3fcc19e, 0xa970, 0x11d2, 0x8b, 0x5a, 0x00, 0xa0, 0xc9, 0xb7, 0xc9, 0xc4);")

// IID IApartmentCallback : uuid(178E5337-1528-4591-B1C9-1C6E484686D8)
cpp_quote("EXTERN_GUID(IID_IApartmentCallback, 0x178e5337, 0x1528, 0x4591, 0xb1, 0xc9, 0x1c, 0x6e, 0x48, 0x46, 0x86, 0xd8);")

// IID ICatalogServices : uuid(04C6BE1E-1DB1-4058-AB7A-700CCCFBF254)
cpp_quote("EXTERN_GUID(IID_ICatalogServices, 0x04c6be1e, 0x1db1, 0x4058, 0xab, 0x7a, 0x70, 0x0c, 0xcc, 0xfb, 0xf2, 0x54);")

// IID ICorRuntimeHost : uuid(CB2F6722-AB3A-11d2-9C40-00C04FA30A3E)
cpp_quote("EXTERN_GUID(IID_ICorRuntimeHost, 0xcb2f6722, 0xab3a, 0x11d2, 0x9c, 0x40, 0x00, 0xc0, 0x4f, 0xa3, 0x0a, 0x3e);")

// IID ICorThreadpool : uuid(84680D3A-B2C1-46e8-ACC2-DBC0A359159A)
cpp_quote("EXTERN_GUID(IID_ICorThreadpool, 0x84680D3A, 0xB2C1, 0x46e8, 0xAC, 0xC2, 0xDB, 0xC0, 0xA3, 0x59, 0x15, 0x9A);")

// IID_ICLRDebugManager : uuid(00DCAEC6-2AC0-43a9-ACF9-1E36C139B10D)
cpp_quote("EXTERN_GUID(IID_ICLRDebugManager, 0xdcaec6, 0x2ac0, 0x43a9, 0xac, 0xf9, 0x1e, 0x36, 0xc1, 0x39, 0xb1, 0xd);")

// IID_ICLRErrorReportingManager : uuid(980D2F1A-BF79-4c08-812A-BB9778928F78)
cpp_quote("EXTERN_GUID(IID_ICLRErrorReportingManager, 0x980d2f1a, 0xbf79, 0x4c08, 0x81, 0x2a, 0xbb, 0x97, 0x78, 0x92, 0x8f, 0x78);")

// IID IHostMemoryNeededCallback : uuid(47EB8E57-0846-4546-AF76-6F42FCFC2649)
cpp_quote("EXTERN_GUID(IID_IHostMemoryNeededCallback, 0x47EB8E57, 0x0846, 0x4546, 0xAF, 0x76, 0x6F, 0x42, 0xFC, 0xFC, 0x26, 0x49);")

// IID IHostMalloc : uuid(1831991C-CC53-4A31-B218-04E910446479)
cpp_quote("EXTERN_GUID(IID_IHostMalloc, 0x1831991C, 0xCC53, 0x4A31, 0xB2, 0x18, 0x04, 0xE9, 0x10, 0x44, 0x64, 0x79);")

// IID IHostMemoryManager : uuid(7BC698D1-F9E3-4460-9CDE-D04248E9FA25)
cpp_quote("EXTERN_GUID(IID_IHostMemoryManager, 0x7BC698D1, 0xF9E3, 0x4460, 0x9C, 0xDE, 0xD0, 0x42, 0x48, 0xE9, 0xFA, 0x25);")

// IID ICLRTask : uuid(28E66A4A-9906-4225-B231-9187C3EB8611)
cpp_quote("EXTERN_GUID(IID_ICLRTask, 0x28E66A4A, 0x9906, 0x4225, 0xB2, 0x31, 0x91, 0x87, 0xc3, 0xeb, 0x86, 0x11);")

// IID IHostTask : uuid(C2275828-C4B1-4B55-82C9-92135F74DF1A)
cpp_quote("EXTERN_GUID(IID_IHostTask, 0xC2275828, 0xC4B1, 0x4B55, 0x82, 0xC9, 0x92, 0x13, 0x5F, 0x74, 0xDF, 0x1A);")

// IID ICLRTaskManager : uuid(4862efbe-3ae5-44f8-8feb-346190ee8a34)
cpp_quote("EXTERN_GUID(IID_ICLRTaskManager, 0x4862efbe, 0x3ae5, 0x44f8, 0x8F, 0xEB, 0x34, 0x61, 0x90, 0xeE, 0x8A, 0x34);")

// IID IHostTaskManager : uuid(997FF24C-43B7-4352-8667-0DC04FAFD354)
cpp_quote("EXTERN_GUID(IID_IHostTaskManager, 0x997FF24C, 0x43B7, 0x4352, 0x86, 0x67, 0x0D, 0xC0, 0x4F, 0xAF, 0xD3, 0x54);")

// IID IHostThreadpoolManager : uuid(983D50E2-CB15-466B-80FC-845DC6E8C5FD)
cpp_quote("EXTERN_GUID(IID_IHostThreadpoolManager, 0x983D50E2, 0xCB15, 0x466B, 0x80, 0xFC, 0x84, 0x5D, 0xC6, 0xE8, 0xC5, 0xFD);")

// IID_ICLRIOCompletionManager : uuid(2D74CE86-B8D6-4C84-B3A7-9768933B3C12)
cpp_quote("EXTERN_GUID(IID_ICLRIoCompletionManager, 0x2D74CE86, 0xB8D6, 0x4C84, 0xB3, 0xA7, 0x97, 0x68, 0x93, 0x3B, 0x3C, 0x12);")

// IID_ICLRGCManager : uuid(54D9007E-A8E2-4885-B7BF-F998DEEE4F2A)
cpp_quote("EXTERN_GUID(IID_ICLRGCManager, 0x54D9007E, 0xA8E2, 0x4885, 0xB7, 0xBF, 0xF9, 0x98, 0xDE, 0xEE, 0x4F, 0x2A);")

// IID_IHostIOCompletionManager : uuid(8BDE9D80-EC06-41D6-83E6-22580EFFCC20)
cpp_quote("EXTERN_GUID(IID_IHostIoCompletionManager, 0x8BDE9D80, 0xEC06, 0x41D6, 0x83, 0xE6, 0x22, 0x58, 0x0E, 0xFF, 0xCC, 0x20);")

// IID IHostSyncManager : uuid(234330c7-5f10-4f20-9615-5122dab7a0ac)
cpp_quote("EXTERN_GUID(IID_IHostSyncManager, 0x234330c7, 0x5f10, 0x4f20, 0x96, 0x15, 0x51, 0x22, 0xda, 0xb7, 0xa0, 0xac);")

// IID IHostCrst : uuid(6DF710A6-26A4-4a65-8CD5-7237B8BDA8DC)
cpp_quote("EXTERN_GUID(IID_IHostCrst, 0x6DF710A6, 0x26A4, 0x4a65, 0x8c, 0xd5, 0x72, 0x37, 0xb8, 0xbd, 0xa8, 0xdc);")

// IID IHostAutoEvent : uuid(50B0CFCE-4063-4278-9673-E5CB4ED0BDB8)
cpp_quote("EXTERN_GUID(IID_IHostAutoEvent, 0x50B0CFCE, 0x4063, 0x4278, 0x96, 0x73, 0xe5, 0xcb, 0x4e, 0xd0, 0xbd, 0xb8);")

// IID IHostManualEvent : uuid(1BF4EC38-AFFE-4fb9-85A6-525268F15B54)
cpp_quote("EXTERN_GUID(IID_IHostManualEvent, 0x1BF4EC38, 0xAFFE, 0x4fb9, 0x85, 0xa6, 0x52, 0x52, 0x68, 0xf1, 0x5b, 0x54);")

// IID IHostSemaphore : uuid(855efd47-cc09-463a-a97d-16acab882661)
cpp_quote("EXTERN_GUID(IID_IHostSemaphore, 0x855efd47, 0xcc09, 0x463a, 0xa9, 0x7d, 0x16, 0xac, 0xab, 0x88, 0x26, 0x61);")

// IID ICLRSyncManager : uuid(55FF199D-AD21-48f9-A16C-F24EBBB8727D)
cpp_quote("EXTERN_GUID(IID_ICLRSyncManager, 0x55FF199D, 0xAD21, 0x48f9, 0xa1, 0x6c, 0xf2, 0x4e, 0xbb, 0xb8, 0x72, 0x7d);")

// {7D290010-D781-45da-A6F8-AA5D711A730E}
cpp_quote("EXTERN_GUID(IID_ICLRPolicyManager, 0x7D290010, 0xD781, 0x45da, 0xA6, 0xF8, 0xAA, 0x5D, 0x71, 0x1A, 0x73, 0x0E);")

// {7AE49844-B1E3-4683-BA7C-1E8212EA3B79}
cpp_quote("EXTERN_GUID(IID_IHostPolicyManager, 0x7AE49844, 0xB1E3, 0x4683, 0xBA, 0x7C, 0x1E, 0x82, 0x12, 0xEA, 0x3B, 0x79);")

// IID IHostGCManager : uuid(5D4EC34E-F248-457B-B603-255FAABA0D21)
cpp_quote("EXTERN_GUID(IID_IHostGCManager, 0x5D4EC34E, 0xF248, 0x457B, 0xB6, 0x03, 0x25, 0x5F, 0xAA, 0xBA, 0x0D, 0x21);")

// {607BE24B-D91B-4E28-A242-61871CE56E35}
cpp_quote("EXTERN_GUID(IID_IActionOnCLREvent, 0x607BE24B, 0xD91B, 0x4E28, 0xA2, 0x42, 0x61, 0x87, 0x1C, 0xE5, 0x6E, 0x35);")

// {1D0E0132-E64F-493D-9260-025C0E32C175}
cpp_quote("EXTERN_GUID(IID_ICLROnEventManager, 0x1D0E0132, 0xE64F, 0x493D, 0x92, 0x60, 0x02, 0x5C, 0x0E, 0x32, 0xC1, 0x75);")

// IID ICLRRuntimeHost: uuid(90F1A06C-7712-4762-86B5-7A5EBA6BDB02)
cpp_quote("EXTERN_GUID(IID_ICLRRuntimeHost, 0x90F1A06C, 0x7712, 0x4762, 0x86, 0xB5, 0x7A, 0x5E, 0xBA, 0x6B, 0xDB, 0x02);")

// IID ICLRHostProtectionManager :     uuid{89F25F5C-CEEF-43e1-9CFA-A68CE863AAAC}
cpp_quote("EXTERN_GUID(IID_ICLRHostProtectionManager, 0x89f25f5c, 0xceef, 0x43e1, 0x9c, 0xfa, 0xa6, 0x8c, 0xe8, 0x63, 0xaa, 0xac);")

// IID IHostAssemblyStore   :      uuid(7B102A88-3F7F-496D-8FA2-C35374E01AF3)
cpp_quote("EXTERN_GUID(IID_IHostAssemblyStore, 0x7b102a88, 0x3f7f, 0x496d, 0x8f, 0xa2, 0xc3, 0x53, 0x74, 0xe0, 0x1a, 0xf3);")

// IID IHostAssemblyManager :      uuid(613dabd7-62b2-493e-9e65-c1e32a1e0c5e)
cpp_quote("EXTERN_GUID(IID_IHostAssemblyManager, 0x613dabd7, 0x62b2, 0x493e, 0x9e, 0x65, 0xc1, 0xe3, 0x2a, 0x1e, 0x0c, 0x5e);")

// IID IHostSecurityManager :     uuid{75AD2468-A349-4D02-A764-76A68AEE0C4F}
cpp_quote("EXTERN_GUID(IID_IHostSecurityManager, 0x75ad2468, 0xa349, 0x4d02, 0xa7, 0x64, 0x76, 0xa6, 0x8a, 0xee, 0x0c, 0x4f);")

// IID IHostSecurityManager :     uuid{7E573CE4-0343-4423-98D7-6318348A1D3C}
cpp_quote("EXTERN_GUID(IID_IHostSecurityContext, 0x7e573ce4, 0x343, 0x4423, 0x98, 0xd7, 0x63, 0x18, 0x34, 0x8a, 0x1d, 0x3c);")

// IID ICLRAssemblyIdentityManager: uuid(15f0a9da-3ff6-4393-9da9-fdfd284e6972)
cpp_quote("EXTERN_GUID(IID_ICLRAssemblyIdentityManager, 0x15f0a9da, 0x3ff6, 0x4393, 0x9d, 0xa9, 0xfd, 0xfd, 0x28, 0x4e, 0x69, 0x72);")

// IID ITypeName : uuid{B81FF171-20F3-11d2-8DCC-00A0C9B00522}
cpp_quote("EXTERN_GUID(IID_ITypeName, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x22);")

// IID ICLRAssemblyReferenceList: uuid(1b2c9750-2e66-4bda-8b44-0a642c5cd733)
cpp_quote("EXTERN_GUID(IID_ICLRAssemblyReferenceList, 0x1b2c9750, 0x2e66, 0x4bda, 0x8b, 0x44, 0x0a, 0x64, 0x2c, 0x5c, 0xd7, 0x33);")

// IID ICLRReferenceAssemblyEnum: uuid(d509cb5d-cf32-4876-ae61-67770cf91973)
cpp_quote("EXTERN_GUID(IID_ICLRReferenceAssemblyEnum, 0xd509cb5d, 0xcf32, 0x4876, 0xae, 0x61, 0x67, 0x77, 0x0c, 0xf9, 0x19, 0x73);")

// IID ICLRProbingAssemblyEnum: uuid(d0c5fb1f-416b-4f97-81f4-7ac7dc24dd5d)
cpp_quote("EXTERN_GUID(IID_ICLRProbingAssemblyEnum, 0xd0c5fb1f, 0x416b, 0x4f97, 0x81, 0xf4, 0x7a, 0xc7, 0xdc, 0x24, 0xdd, 0x5d);")

// IID ICLRHostBindingPolicyManager: uuid(4b3545e7-1856-48c9-a8ba-24b21a753c09)
cpp_quote("EXTERN_GUID(IID_ICLRHostBindingPolicyManager, 0x4b3545e7, 0x1856, 0x48c9, 0xa8, 0xba, 0x24, 0xb2, 0x1a, 0x75, 0x3c, 0x09);")

// IID ITypeNameBuilder : uuid{B81FF171-20F3-11d2-8DCC-00A0C9B00523}
cpp_quote("EXTERN_GUID(IID_ITypeNameBuilder, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x23);")

// IID ITypeNameFactory : uuid{B81FF171-20F3-11d2-8DCC-00A0C9B00521}
cpp_quote("EXTERN_GUID(IID_ITypeNameFactory, 0xB81FF171, 0x20F3, 0x11d2, 0x8d, 0xcc, 0x00, 0xa0, 0xc9, 0xb0, 0x05, 0x21);")

#pragma midl_echo("STDAPI GetCORSystemDirectory(LPWSTR pbuffer, DWORD  cchBuffer, DWORD* dwLength);")
#pragma midl_echo("STDAPI GetCORVersion(LPWSTR pbBuffer, DWORD cchBuffer, DWORD* dwLength);")
#pragma midl_echo("STDAPI GetFileVersion(LPCWSTR szFilename, LPWSTR szBuffer, DWORD cchBuffer, DWORD* dwLength);")
#pragma midl_echo("STDAPI GetCORRequiredVersion(LPWSTR pbuffer, DWORD cchBuffer, DWORD* dwLength);")
#pragma midl_echo("STDAPI GetRequestedRuntimeInfo(LPCWSTR pExe, LPCWSTR pwszVersion, LPCWSTR pConfigurationFile, DWORD startupFlags, DWORD runtimeInfoFlags, LPWSTR pDirectory, DWORD dwDirectory, DWORD *dwDirectoryLength, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwlength);")
#pragma midl_echo("STDAPI GetRequestedRuntimeVersion(LPWSTR pExe, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwLength);")
#pragma midl_echo("STDAPI CorBindToRuntimeHost(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, LPCWSTR pwszHostConfigFile, VOID* pReserved, DWORD startupFlags, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);")
#pragma midl_echo("STDAPI CorBindToRuntimeEx(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, DWORD startupFlags, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);")
#pragma midl_echo("STDAPI CorBindToRuntimeByCfg(IStream* pCfgStream, DWORD reserved, DWORD startupFlags, REFCLSID rclsid,REFIID riid, LPVOID FAR* ppv);")
#pragma midl_echo("STDAPI CorBindToRuntime(LPCWSTR pwszVersion, LPCWSTR pwszBuildFlavor, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);")
#pragma midl_echo("STDAPI CorBindToCurrentRuntime(LPCWSTR pwszFileName, REFCLSID rclsid, REFIID riid, LPVOID FAR *ppv);")
#pragma midl_echo("STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void **ppObject);")
#pragma midl_echo("void STDMETHODCALLTYPE CorMarkThreadInThreadPool();")
#pragma midl_echo("STDAPI RunDll32ShimW(HWND hwnd, HINSTANCE hinst, LPCWSTR lpszCmdLine, int nCmdShow);")
#pragma midl_echo("STDAPI LoadLibraryShim(LPCWSTR szDllName, LPCWSTR szVersion, LPVOID pvReserved, HMODULE *phModDll);")
#pragma midl_echo("STDAPI CallFunctionShim(LPCWSTR szDllName, LPCSTR szFunctionName, LPVOID lpvArgument1, LPVOID lpvArgument2, LPCWSTR szVersion, LPVOID pvReserved);")
#pragma midl_echo("STDAPI GetRealProcAddress(LPCSTR pwszProcName, VOID** ppv);")
#pragma midl_echo("void STDMETHODCALLTYPE CorExitProcess(int exitCode);")
#pragma midl_echo("STDAPI LoadStringRC(UINT iResouceID, LPWSTR szBuffer, int iMax, int bQuiet);")
#pragma midl_echo("STDAPI LoadStringRCEx(LCID lcid, UINT iResouceID, LPWSTR szBuffer, int iMax, int bQuiet, int *pcwchUsed);")
#pragma midl_echo("typedef HRESULT (__stdcall *FLockClrVersionCallback) ();")
#pragma midl_echo("STDAPI LockClrVersion(FLockClrVersionCallback hostCallback,FLockClrVersionCallback *pBeginHostSetup,FLockClrVersionCallback *pEndHostSetup);")
#pragma midl_echo("STDAPI CreateDebuggingInterfaceFromVersion(int iDebuggerVersion, LPCWSTR szDebuggeeVersion, IUnknown ** ppCordb);")
#pragma midl_echo("STDAPI GetVersionFromProcess(HANDLE hProcess, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwLength);")

typedef enum {
    HOST_TYPE_DEFAULT     = 0x0,
    HOST_TYPE_APPLAUNCH   = 0x1,
    HOST_TYPE_CORFLAG     = 0x2
} HOST_TYPE;

#pragma midl_echo("STDAPI CorLaunchApplication(HOST_TYPE dwClickOnceHost, LPCWSTR pwzAppFullName, DWORD dwManifestPaths, LPCWSTR* ppwzManifestPaths, DWORD dwActivationData, LPCWSTR* ppwzActivationData, LPPROCESS_INFORMATION lpProcessInformation);")

typedef HRESULT (__stdcall *FExecuteInAppDomainCallback) (void* cookie);

// By default GC is non-concurrent and only the base system library is loaded into the domain-neutral area.
typedef enum {
  STARTUP_CONCURRENT_GC         = 0x1,

  STARTUP_LOADER_OPTIMIZATION_MASK = 0x3<<1,                    // loader optimization mask
  STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN = 0x1<<1,           // no domain neutral loading
  STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN = 0x2<<1,            // all domain neutral loading
  STARTUP_LOADER_OPTIMIZATION_MULTI_DOMAIN_HOST = 0x3<<1,       // strong name domain neutral loading


  STARTUP_LOADER_SAFEMODE = 0x10,                               // Do not apply runtime version policy to the version passed in
  STARTUP_LOADER_SETPREFERENCE = 0x100,                         // Set preferred runtime. Do not actally start it

  STARTUP_SERVER_GC             = 0x1000,                       // Use server GC
  STARTUP_HOARD_GC_VM           = 0x2000,                       // GC keeps virtual address used
  STARTUP_SINGLE_VERSION_HOSTING_INTERFACE = 0x4000,                    // Disallow mixing hosting interface
  STARTUP_LEGACY_IMPERSONATION             = 0x10000,                        // Do not flow impersonation across async points by default
  STARTUP_DISABLE_COMMITTHREADSTACK        = 0x20000,           // Don't eagerly commit thread stack
  STARTUP_ALWAYSFLOW_IMPERSONATION             = 0x40000,                        // Force flow impersonation across async points 
  																// (impersonations achieved thru p/invoke and managed will flow. 
  																// default is to flow only managed impersonation)
  STARTUP_TRIM_GC_COMMIT        = 0x80000,                      // GC uses less committed space when system memory low
} STARTUP_FLAGS;

typedef enum {
  CLSID_RESOLUTION_DEFAULT         = 0x0,     // Standard behavior that interop uses
  CLSID_RESOLUTION_REGISTERED   = 0x1,     // Searches the registry and applies shim policy
} CLSID_RESOLUTION_FLAGS;

typedef enum

{
    RUNTIME_INFO_UPGRADE_VERSION = 0x1,       // apply upgrades - i.e RTM->Everett
    RUNTIME_INFO_REQUEST_IA64 = 0x2,         // requesting a CLR for ia64
    RUNTIME_INFO_REQUEST_AMD64 = 0x4,        // requesting a CLR for amd64
    RUNTIME_INFO_REQUEST_X86 = 0x8,          // requesting a CLR for x86
    RUNTIME_INFO_DONT_RETURN_DIRECTORY = 0x10, // don’t return directory information
    RUNTIME_INFO_DONT_RETURN_VERSION = 0x20,   // don’t return version information
    RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG = 0x40,   // don’t pop up an error dialog on failure
} RUNTIME_INFO_FLAGS;




#pragma midl_echo("STDAPI GetRequestedRuntimeVersionForCLSID(REFCLSID rclsid, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwLength, CLSID_RESOLUTION_FLAGS dwResolutionFlags);")

//*****************************************************************************
// Interface for Object Handles
//*****************************************************************************
[
    object,
    oleautomation,
    uuid(C460E2B4-E199-412a-8456-84DC3E4838C3),
    helpstring("Object Handle Interface"),
    pointer_default(unique)
]
interface IObjectHandle : IUnknown
{
    HRESULT Unwrap([out, retval] VARIANT *ppv);
};


//*****************************************************************************
// Interface for Setting runtime configuration
//*****************************************************************************
[
    uuid(5C2B07A7-1E98-11d3-872F-00C04F79ED0D),
    version(1.0),
    helpstring("Application Domain call back"),
    pointer_default(unique),
    local
]
interface IAppDomainBinding : IUnknown
{
    // <TODO>TODO: this should return an AppDomain interface
    // The event is invoked everytime a domain is created </TODO>
    HRESULT OnAppDomain([in] IUnknown* pAppdomain);
}


//*****************************************************************************
// Interface for participating in the scheduling of threads that would
// otherwise be blocked for a GC
//*****************************************************************************
[
    uuid(F31D1788-C397-4725-87A5-6AF3472C2791),
    version(1.0),
    helpstring("Control over threads blocked in GC"),
    pointer_default(unique),
    local
]
interface IGCThreadControl : IUnknown
{
    // Notification that the thread making the call is about to block, perhaps for
    // a GC or other suspension.  This gives the host an opportunity to re-schedule
    // the thread for unmanaged tasks.
    HRESULT ThreadIsBlockingForSuspension();

    // Notification that the runtime is beginning a thread suspension for a GC or
    // other suspension.  Do not reschedule this thread!
    HRESULT SuspensionStarting();

    // Notification that the runtime is resuming threads after a GC or other
    // suspension.      Do not reschedule this thread!
    HRESULT SuspensionEnding(DWORD Generation);
}

//*****************************************************************************
// Interface for GC to request change in virtual memory limit
//*****************************************************************************
[
    uuid(5513D564-8374-4cb9-AED9-0083F4160A1D),
    version(1.1),
    helpstring("Request change in virtual memory for GC"),
    pointer_default(unique),
    local
]
interface IGCHostControl : IUnknown
{
    // Request to increase the virtual memeory limit of the runtime (GC heap)
    HRESULT RequestVirtualMemLimit([in] SIZE_T sztMaxVirtualMemMB,
                                   [in, out] SIZE_T* psztNewMaxVirtualMemMB);
}

//*****************************************************************************
// Interface for accessing threadpool
//*****************************************************************************
cpp_quote("#if (_MSC_VER < 1300 || _WIN32_WINNT < 0x0500)")
typedef VOID (__stdcall *WAITORTIMERCALLBACK)(PVOID, BOOL);
cpp_quote("#endif // (_MSC_VER < 1300 || _WIN32_WINNT < 0x0500)")

cpp_quote("#ifdef __midl")
typedef DWORD (__stdcall *LPTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef VOID (*LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD dwErrorCode,
                                                DWORD dwNumberOfBytesTransfered,
                                                LPVOID lpOverlapped);
cpp_quote("#endif // __midl")

// Callback function for cleaning up TLS
typedef VOID (__stdcall *PTLS_CALLBACK_FUNCTION)(PVOID);


[
    uuid(84680D3A-B2C1-46e8-ACC2-DBC0A359159A),
    version(1.0),
    helpstring("Threadpool interface"),
    pointer_default(unique),
    local
]
interface ICorThreadpool : IUnknown
{
    HRESULT CorRegisterWaitForSingleObject([in] HANDLE* phNewWaitObject,
                                           [in] HANDLE hWaitObject,
                                           [in] WAITORTIMERCALLBACK Callback,
                                           [in] PVOID Context,
                                           [in] ULONG timeout,
                                           [in] BOOL  executeOnlyOnce,
                                           [out] BOOL* result  );

    HRESULT CorUnregisterWait([in] HANDLE hWaitObject,[in] HANDLE CompletionEvent,[out] BOOL* result);

    HRESULT CorQueueUserWorkItem([in] LPTHREAD_START_ROUTINE Function,
                                 [in] PVOID Context,
                                 [in] BOOL executeOnlyOnce,
                                 [out] BOOL* result );


    HRESULT CorCreateTimer([in] HANDLE* phNewTimer,
                           [in] WAITORTIMERCALLBACK Callback,
                           [in] PVOID Parameter,
                           [in] DWORD DueTime,
                           [in] DWORD Period,
                           [out] BOOL* result);

    HRESULT CorChangeTimer([in] HANDLE Timer, [in] ULONG DueTime, [in] ULONG Period, [out] BOOL* result);

    HRESULT CorDeleteTimer([in] HANDLE Timer, [in] HANDLE CompletionEvent, [out] BOOL* result);

    HRESULT CorBindIoCompletionCallback([in] HANDLE fileHandle, [in] LPOVERLAPPED_COMPLETION_ROUTINE callback);

    HRESULT CorCallOrQueueUserWorkItem([in] LPTHREAD_START_ROUTINE Function,
                                       [in] PVOID Context,
                                       [out] BOOL* result );
        HRESULT CorSetMaxThreads([in] DWORD MaxWorkerThreads,
                                 [in] DWORD MaxIOCompletionThreads);

        HRESULT CorGetMaxThreads([out] DWORD *MaxWorkerThreads,
                                 [out] DWORD *MaxIOCompletionThreads);

        HRESULT CorGetAvailableThreads([out] DWORD *AvailableWorkerThreads,
                                       [out] DWORD *AvailableIOCompletionThreads);


}

cpp_quote("EXTERN_GUID(IID_IDebuggerThreadControl, 0x23d86786, 0x0bb5, 0x4774, 0x8f, 0xb5, 0xe3, 0x52, 0x2a, 0xdd, 0x62, 0x46);")
[
    uuid(23D86786-0BB5-4774-8FB5-E3522ADD6246),
    version(1.0),
    helpstring("Control over threads blocked in debugging services"),
    pointer_default(unique),
    local
]
interface IDebuggerThreadControl : IUnknown
{
    // Notification that the thread making the call is about to
    // block within the debugging services.      This gives the host
    // an opportunity to perform another action while the thread
    // blocks. This will always be called on a Runtime thread.
    HRESULT ThreadIsBlockingForDebugger();

    // Notification that the debugging services is about to
    // release all threads it has blocked. This will never be
    // called on a Runtime thread. If the host has a Runtime
    // thread blocked in ThreadIsBlockingForDebugger() then it
    // should release it now.
    HRESULT ReleaseAllRuntimeThreads();

    // Notification that the debugging services are about to
    // start blocking all threads. This could be called on a
    // Runtime thread. This is the signal to the host to
    // start blocking threads in ThreadIsBlockingForDebugger().
    HRESULT StartBlockingForDebugger(DWORD dwUnused);
}

cpp_quote("EXTERN_GUID(IID_IDebuggerInfo, 0xbf24142d, 0xa47d, 0x4d24, 0xa6, 0x6d, 0x8c, 0x21, 0x41, 0x94, 0x4e, 0x44);")
[
    uuid(BF24142D-A47D-4d24-A66D-8C2141944E44),
    version(1.0),
    helpstring("Information on the state of the debugging services"),
    pointer_default(unique),
    local
]
interface IDebuggerInfo : IUnknown
{
    // Indicates whether or not a managed debugger is attached to this process.
    HRESULT IsDebuggerAttached([out] BOOL *pbAttached);
}

// {5C2B07A5-1E98-11d3-872F-00C04F79ED0D}
cpp_quote("EXTERN_GUID(IID_ICorConfiguration, 0x5c2b07a5, 0x1e98, 0x11d3, 0x87, 0x2f, 0x00, 0xc0, 0x4f, 0x79, 0xed, 0x0d);")
[
    uuid(5C2B07A5-1E98-11d3-872F-00C04F79ED0D),
    version(1.0),
    helpstring("Common Language Runtime Configuration Interface"),
    pointer_default(unique),
    local
]
interface ICorConfiguration : IUnknown
{
    // Set the callback for scheduling threads for non-runtime tasks when they
    // would otherwise be blocked for a GC.
    HRESULT SetGCThreadControl([in] IGCThreadControl* pGCThreadControl);

    // Set the callback for gc to request a change in virtual memmory limit
    HRESULT SetGCHostControl([in] IGCHostControl* pGCHostControl);

    // Set the callback interface that the debugging services will
    // call as Runtime threads are blocked and un-blocked for
    // debugging.
    HRESULT SetDebuggerThreadControl([in] IDebuggerThreadControl* pDebuggerThreadControl);

    // The host may indicate to the debugging services that a
    // particular thread should be allowed to continue to execute
    // while the debugger has an application stopped during
    // managed/unmanaged debugging scenarios. The specified thread
    // will not be allowed to run managed code, or to enter the
    // Runtime in any way. An example of such a thread would be an
    // in-process thread to support legacy script debuggers.
    HRESULT AddDebuggerSpecialThread([in] DWORD dwSpecialThreadId);
}

//*****************************************************************************
// Interface for hosting mscoree
//*****************************************************************************
typedef void* HDOMAINENUM;

[
    uuid(CB2F6722-AB3A-11d2-9C40-00C04FA30A3E),
    version(1.0),
    helpstring("Common Language Runtime Hosting Interface"),
    pointer_default(unique),
    local
]
interface ICorRuntimeHost : IUnknown
{
    HRESULT CreateLogicalThreadState();
    HRESULT DeleteLogicalThreadState();
    HRESULT SwitchInLogicalThreadState(
     [in] DWORD *pFiberCookie);                 // [in] Cookie that indicates the fiber to use.

    HRESULT SwitchOutLogicalThreadState(
     [out] DWORD **pFiberCookie);               // [out] Cookie that indicates the fiber being switched out.

    HRESULT LocksHeldByLogicalThread(           // Return code.
     [out] DWORD *pCount                        // [out] Number of locks that the current thread holds.
        );

    HRESULT MapFile(
     [in]       HANDLE          hFile,          // [in]  HANDLE for file
     [out]      HMODULE*        hMapAddress);   // [out] HINSTANCE for mapped file

    //=================================================================
    //
    // New hosting methods
    //
    // Returns an object for configuring the runtime prior to
    // it starting. If the runtime has been initialized this
    // routine returns an error. See ICorConfiguration.
    HRESULT GetConfiguration([out] ICorConfiguration** pConfiguration);

    // Starts the runtime. This is equivalent to CoInitializeCor();
    HRESULT Start();

    // Terminates the runtime, This is equivalent CoUninitializeCor();
    HRESULT Stop();

    // Creates a domain in the runtime. The identity array is
    // a pointer to an array TYPE containing IIdentity objects defining
    // the security identity.
    HRESULT CreateDomain([in] LPCWSTR pwzFriendlyName,
                         [in] IUnknown* pIdentityArray, // Optional
                         [out] IUnknown** pAppDomain);

    // Returns the default domain.
    HRESULT GetDefaultDomain([out] IUnknown** pAppDomain);


    // Enumerate currently existing domains.
    HRESULT EnumDomains([out] HDOMAINENUM *hEnum);

    // Returns S_FALSE when there are no more domains. A domain
    // is passed out only when S_OK is returned.
    HRESULT NextDomain([in] HDOMAINENUM hEnum,
                       [out] IUnknown** pAppDomain);

    // Close the enumeration, releasing resources
    HRESULT CloseEnum([in] HDOMAINENUM hEnum);

    HRESULT CreateDomainEx([in] LPCWSTR pwzFriendlyName, // Optional
                           [in] IUnknown* pSetup,        // Optional
                           [in] IUnknown* pEvidence,     // Optional
                           [out] IUnknown** pAppDomain);

    HRESULT CreateDomainSetup([out] IUnknown** pAppDomainSetup);

    HRESULT CreateEvidence([out] IUnknown** pEvidence);

    HRESULT UnloadDomain([in] IUnknown* pAppDomain);

    // Returns the thread's domain.
    HRESULT CurrentDomain([out] IUnknown** pAppDomain);
};

typedef enum
{
    eMemoryAvailableLow = 1,
    eMemoryAvailableNeutral = 2,
    eMemoryAvailableHigh = 3
} EMemoryAvailable;

typedef enum
{
    eTaskCritical = 0,
    eAppDomainCritical = 1,
    eProcessCritical = 2
} EMemoryCriticalLevel;

typedef enum {
    WAIT_MSGPUMP = 0x1,
    WAIT_ALERTABLE = 0x2,
    WAIT_NOTINDEADLOCK = 0x4
}WAIT_OPTION;

cpp_quote("EXTERN_GUID(IID_ICLRMemoryNotificationCallback, 0x47EB8E57, 0x0846, 0x4546, 0xAF, 0x76, 0x6F, 0x42, 0xFC, 0xFC, 0x26, 0x49);")
[
    uuid(47EB8E57-0846-4546-AF76-6F42FCFC2649),
    version(1.0),
    helpstring("Callback by Host to notify runtime short of memory"),
    pointer_default(unique),
    local
]
interface ICLRMemoryNotificationCallback : IUnknown
{
    // Callback by Host on out of memory to request runtime to free memory.
    // Runtime will do a GC and Wait for PendingFinalizer.
    HRESULT OnMemoryNotification([in] EMemoryAvailable eMemoryAvailable);
}

[
    uuid(1831991C-CC53-4A31-B218-04E910446479),
    version(1.0),
    helpstring("Host Malloc"),
    pointer_default(unique),
    local
]
interface IHostMalloc : IUnknown
{
    HRESULT Alloc([in] SIZE_T  cbSize,
                  [in] EMemoryCriticalLevel eCriticalLevel,
                  [out] void** ppMem);

    HRESULT DebugAlloc([in] SIZE_T      cbSize,
                      [in] EMemoryCriticalLevel       eCriticalLevel,
                      [in] char*       pszFileName,
                      [in] int         iLineNo,
                      [out] void**     ppMem);

    HRESULT Free([in] void* pMem);
}

typedef enum
{
    MALLOC_THREADSAFE = 0x1,
    MALLOC_EXECUTABLE = 0x2,
} MALLOC_TYPE;

[
    uuid(7BC698D1-F9E3-4460-9CDE-D04248E9FA25),
    version(1.0),
    helpstring("Host memory manager"),
    pointer_default(unique),
    local
]
interface IHostMemoryManager : IUnknown
{
    HRESULT CreateMalloc([in] DWORD dwMallocType,
                         [out] IHostMalloc **ppMalloc);

    HRESULT VirtualAlloc([in] void*       pAddress,
                         [in] SIZE_T      dwSize,
                         [in] DWORD       flAllocationType,
                         [in] DWORD       flProtect,
                         [in] EMemoryCriticalLevel eCriticalLevel,
                         [out] void**     ppMem);

    HRESULT VirtualFree([in] LPVOID      lpAddress,
                        [in] SIZE_T      dwSize,
                        [in] DWORD       dwFreeType);

    HRESULT VirtualQuery([in] void *     lpAddress,
                         [out] void*     lpBuffer,
                         [in] SIZE_T     dwLength,
                         [out] SIZE_T *  pResult);

    HRESULT VirtualProtect([in] void *       lpAddress,
                           [in] SIZE_T       dwSize,
                           [in] DWORD        flNewProtect,
                           [out] DWORD *     pflOldProtect);

    HRESULT GetMemoryLoad([out] DWORD* pMemoryLoad,
                          [out] SIZE_T *pAvailableBytes);

    HRESULT RegisterMemoryNotificationCallback([in] ICLRMemoryNotificationCallback * pCallback);

    HRESULT NeedsVirtualAddressSpace(
        [in] LPVOID startAddress,
        [in] SIZE_T size
        );

    HRESULT AcquiredVirtualAddressSpace(
        [in] LPVOID startAddress,
        [in] SIZE_T size
        );

    HRESULT ReleasedVirtualAddressSpace(
        [in] LPVOID startAddress
        );
}

typedef UINT64 TASKID;
typedef DWORD CONNID;

[
    uuid(28E66A4A-9906-4225-B231-9187C3EB8611),
    version(1.0),
    helpstring("Callback by Host to collaborate with CLR on HostTask"),
    pointer_default(unique),
    local
]
interface ICLRTask: IUnknown
{
    HRESULT SwitchIn([in] HANDLE threadHandle);
    HRESULT SwitchOut();
    HRESULT GetMemStats([out] COR_GC_THREAD_STATS *memUsage);
    HRESULT Reset(BOOL fFull);
    HRESULT ExitTask();
    HRESULT Abort();
    HRESULT RudeAbort();
    HRESULT NeedsPriorityScheduling([out] BOOL * pbNeedsPriorityScheduling);
    HRESULT YieldTask();
    HRESULT LocksHeld([out] SIZE_T *pLockCount);
    HRESULT SetTaskIdentifier([in] TASKID asked);
}

[
    uuid(C2275828-C4B1-4B55-82C9-92135F74DF1A),
    version(1.0),
    helpstring("Called by CLR to operate on a HostTask"),
    pointer_default(unique),
    local
]
interface IHostTask : IUnknown
{
    HRESULT Start();
    HRESULT Alert();
    HRESULT Join([in] DWORD dwMilliseconds,
                             [in] DWORD option);
    HRESULT SetPriority([in] int newPriority);
    HRESULT GetPriority([out] int *pPriority);
    HRESULT SetCLRTask([in] ICLRTask *pCLRTask);
}

typedef enum ETaskType
{
    TT_DEBUGGERHELPER = 0x1,
    TT_GC = 0x2,
    TT_FINALIZER = 0x4,
    TT_THREADPOOL_TIMER = 0x8,
    TT_THREADPOOL_GATE = 0x10,
    TT_THREADPOOL_WORKER = 0x20,
    TT_THREADPOOL_IOCOMPLETION = 0x40,
    TT_ADUNLOAD = 0x80,
    TT_USER = 0x100,
    TT_THREADPOOL_WAIT = 0x200,

    TT_UNKNOWN = 0x80000000,
} ETaskType;

[
    uuid(4862efbe-3ae5-44f8-8feb-346190ee8a34),
    version(1.0),
    helpstring("Functions provided by CLR to handle a CLRTask"),
    pointer_default(unique),
    local
]
interface ICLRTaskManager : IUnknown
{
    HRESULT CreateTask ([out] ICLRTask **pTask);
    HRESULT GetCurrentTask ([out] ICLRTask **pTask);
    HRESULT SetUILocale([in] LCID lcid);
    HRESULT SetLocale([in] LCID lcid);
    HRESULT GetCurrentTaskType([out] ETaskType *pTaskType);
}


[
    uuid(997FF24C-43B7-4352-8667-0DC04FAFD354),
    version(1.0),
    helpstring("Functions provided by host to handle a HostTask"),
    pointer_default(unique),
    local
]
interface IHostTaskManager : IUnknown
{
    HRESULT GetCurrentTask ([out] IHostTask **pTask);
    HRESULT CreateTask ([in] DWORD dwStackSize,
                        [in] LPTHREAD_START_ROUTINE pStartAddress,
                        [in] PVOID pParameter,
                        [out] IHostTask **ppTask);
    HRESULT Sleep([in] DWORD dwMilliseconds,
                  [in] DWORD option);
    HRESULT SwitchToTask([in] DWORD option);

    HRESULT SetUILocale([in] LCID lcid);
    HRESULT SetLocale([in] LCID lcid);

    HRESULT CallNeedsHostHook([in] SIZE_T target,
                              [out] BOOL *pbCallNeedsHostHook);

    HRESULT LeaveRuntime([in] SIZE_T target);
    HRESULT EnterRuntime();

    HRESULT ReverseLeaveRuntime();
    HRESULT ReverseEnterRuntime();

    HRESULT BeginDelayAbort();
    HRESULT EndDelayAbort();
    HRESULT BeginThreadAffinity();
    HRESULT EndThreadAffinity();

    HRESULT SetStackGuarantee([in] ULONG guarantee);
    HRESULT GetStackGuarantee([out] ULONG *pGuarantee);

    HRESULT SetCLRTaskManager(
        [in] ICLRTaskManager *ppManager);
}

[
    uuid(983D50E2-CB15-466B-80FC-845DC6E8C5FD),
    version(1.0),
    helpstring("Threadpool Functions provided by host"),
    pointer_default(unique),
    local
]
interface IHostThreadpoolManager : IUnknown
{
    HRESULT QueueUserWorkItem(
        [in] LPTHREAD_START_ROUTINE Function,
        [in] PVOID Context,
        [in] ULONG Flags);
    HRESULT SetMaxThreads(
        [in] DWORD dwMaxWorkerThreads);
    HRESULT GetMaxThreads(
        [out] DWORD *pdwMaxWorkerThreads);
    HRESULT GetAvailableThreads(
        [out] DWORD *pdwAvailableWorkerThreads);
    HRESULT SetMinThreads(
        [in] DWORD dwMinIOCompletionThreads);
    HRESULT GetMinThreads(
        [out] DWORD *pdwMinIOCompletionThreads);
}

[
    uuid(2d74ce86-b8d6-4c84-b3a7-9768933b3c12),
    version(1.0),
    helpstring("Asynchronous IO support callback"),
    pointer_default(unique),
    local
]
interface ICLRIoCompletionManager : IUnknown
{
    HRESULT OnComplete(
        [in] DWORD dwErrorCode,
        [in] DWORD NumberOfBytesTransferred,
        [in] void* pvOverlapped);
}

[
    uuid(8bde9d80-ec06-41d6-83e6-22580effcc20),
    version(1.0),
    helpstring("Asynchronous IO support provided by host"),
    pointer_default(unique),
    local
]
interface IHostIoCompletionManager : IUnknown
{
    HRESULT CreateIoCompletionPort(
        [out] HANDLE *phPort);
    HRESULT CloseIoCompletionPort(
        [in] HANDLE hPort);
    HRESULT SetMaxThreads(
        [in] DWORD dwMaxIOCompletionThreads);
    HRESULT GetMaxThreads(
        [out] DWORD *pdwMaxIOCompletionThreads);
    HRESULT GetAvailableThreads(
        [out] DWORD *pdwAvailableIOCompletionThreads);
    HRESULT GetHostOverlappedSize(
        [out] DWORD * pcbSize);
    HRESULT SetCLRIoCompletionManager(
        [in] ICLRIoCompletionManager * pManager);
    HRESULT InitializeHostOverlapped(
        [in] void * pvOverlapped);
    HRESULT Bind(
        [in] HANDLE hPort,
        [in] HANDLE hHandle);
    HRESULT SetMinThreads(
        [in] DWORD dwMinIOCompletionThreads);
    HRESULT GetMinThreads(
        [out] DWORD *pdwMinIOCompletionThreads);
}

typedef enum { 
    eSymbolReadingNever = 0,        // Never read PDBs
    eSymbolReadingAlways = 1,       // Always read PDBs
    eSymbolReadingFullTrustOnly = 2 // Only read PDBs that correspond to full-trust assemblies
} ESymbolReadingPolicy;

[
    uuid(00DCAEC6-2AC0-43a9-ACF9-1E36C139B10D),
    version(1.0),
    helpstring("CLR debugger manager"),
    pointer_default(unique),
    local
]
interface ICLRDebugManager : IUnknown
{
    HRESULT BeginConnection(
        [in] CONNID dwConnectionId,
        [in, string] wchar_t *szConnectionName);
    HRESULT SetConnectionTasks(
        [in] CONNID id,
        [in] DWORD dwCount,
        [in, size_is(dwCount)] ICLRTask **ppCLRTask);
    HRESULT EndConnection(
        [in] CONNID dwConnectionId);
    // Set ACL on shared section, events, and process
    HRESULT SetDacl([in] PACL pacl);

    // Returning the current ACL that CLR is using
    // The memory is allocated by runtime using CoTaskmemAlloc. Caller must
    // free the memory pointed to by pacl using CoTaskMemFree.
    HRESULT GetDacl([out] PACL *pacl);

    // Indicates whether or not a managed debugger is attached to this process.
    HRESULT IsDebuggerAttached([out] BOOL *pbAttached);

    // Specify whether the symbol reader should be used.  Affects whether file and line 
    // info can be included when the CLR captures a call stack.
    HRESULT SetSymbolReadingPolicy([in] ESymbolReadingPolicy policy);
}


typedef enum {
    // Default to minidump
        DUMP_FLAVOR_Mini = 0,
        
        // Include critical CLR state
        DUMP_FLAVOR_CriticalCLRState = 1,
        
        // Include critical CLR state and ngen images without including hosted heap
        // It is host's responsibility to report hosted heap.
        DUMP_FLAVOR_NonHeapCLRState = 2,

    DUMP_FLAVOR_Default = DUMP_FLAVOR_Mini
        
} ECustomDumpFlavor;

// reserved for future extension
typedef enum
{           
        DUMP_ITEM_None = 0
} ECustomDumpItemKind;

//
// The CustomDumpItem structure describes an item to be added to a dump. 
// It is defined for future expansion and is not presently used.
//
typedef struct
{
    ECustomDumpItemKind itemKind; //this affects how next fields are interpreted.
    union
    {
                  // Union to be expanded later if need be
             UINT_PTR pReserved;
    };    
} CustomDumpItem;


typedef struct _BucketParameters
{
    BOOL  fInited;                  // Set to TRUE if the rest of this structure is valid.
    WCHAR pszEventTypeName[255];    // Name of the event type.
    WCHAR pszParams[10][255];       // Parameter strings.
} BucketParameters;

[
    uuid(980D2F1A-BF79-4c08-812A-BB9778928F78),
    version(1.0),
    helpstring("CLR error reporting manager"),
    pointer_default(unique),
    local
]
interface ICLRErrorReportingManager : IUnknown
{
    // Get Watson bucket parameters for "current" exception (on calling thread).
    HRESULT GetBucketParametersForCurrentException([out] BucketParameters *pParams);
    
    // The BeginCustomDump function configures the custom dump support
        HRESULT BeginCustomDump(        [in] ECustomDumpFlavor dwFlavor,
                                    [in] DWORD dwNumItems,
                                    [in, size_is(dwNumItems), length_is(dwNumItems)] CustomDumpItem *items,
                                    DWORD dwReserved);
    
    // EndCustomDump clears the custom dump configuration 
        HRESULT EndCustomDump();                             

}


[
    uuid(6DF710A6-26A4-4a65-8CD5-7237B8BDA8DC),
    version(1.0),
    helpstring("CriticalSection provided by host"),
    pointer_default(unique),
    local
]
interface IHostCrst : IUnknown
{
    HRESULT Enter([in] DWORD option);
    HRESULT Leave();
    HRESULT TryEnter([in] DWORD option,
                     [out] BOOL *pbSucceeded);
    HRESULT SetSpinCount([in] DWORD dwSpinCount);
}


[
    uuid(50B0CFCE-4063-4278-9673-E5CB4ED0BDB8),
    version(1.0),
    helpstring("AutoEvent provided by host"),
    pointer_default(unique),
    local
]
interface IHostAutoEvent : IUnknown
{
    HRESULT Wait([in] DWORD dwMilliseconds,
                 [in] DWORD option);
    HRESULT Set();
}


[
    uuid(1BF4EC38-AFFE-4fb9-85A6-525268F15B54),
    version(1.0),
    helpstring("ManualEvent provided by host"),
    pointer_default(unique),
    local
]
interface IHostManualEvent : IUnknown
{
    HRESULT Wait([in] DWORD dwMilliseconds,
                 [in] DWORD option);
    HRESULT Reset();
    HRESULT Set();
}


[
    uuid(855efd47-cc09-463a-a97d-16acab882661),
    version(1.0),
    helpstring("Semaphore provided by host"),
    pointer_default(unique),
    local
]
interface IHostSemaphore : IUnknown
{
    HRESULT Wait([in] DWORD dwMilliseconds,
                 [in] DWORD option);
    HRESULT ReleaseSemaphore([in] LONG lReleaseCount,
                             [out] LONG *lpPreviousCount);
}

[
    uuid(55FF199D-AD21-48f9-A16C-F24EBBB8727D),
    version(1.0),
    helpstring("Functions provided by CLR to provide infomation on synchronization objects"),
    pointer_default(unique),
    local
]
interface ICLRSyncManager : IUnknown
{
    HRESULT GetMonitorOwner ([in] SIZE_T Cookie,
                             [out] IHostTask **ppOwnerHostTask);

    HRESULT CreateRWLockOwnerIterator([in] SIZE_T Cookie, [out] SIZE_T *pIterator);
    HRESULT GetRWLockOwnerNext([in] SIZE_T Iterator, [out] IHostTask **ppOwnerHostTask);
    HRESULT DeleteRWLockOwnerIterator([in] SIZE_T Iterator);
}


[
    uuid(234330c7-5f10-4f20-9615-5122dab7a0ac),
    version(1.0),
    helpstring("Functions provided by host to create synchronization objects"),
    pointer_default(unique),
    local
]
interface IHostSyncManager : IUnknown
{
    HRESULT SetCLRSyncManager([in] ICLRSyncManager *pManager);

    HRESULT CreateCrst([out] IHostCrst** ppCrst);
    HRESULT CreateCrstWithSpinCount ([in] DWORD dwSpinCount,
                                     [out] IHostCrst** ppCrst);

    HRESULT CreateAutoEvent([out] IHostAutoEvent **ppEvent);
    HRESULT CreateManualEvent([in] BOOL bInitialState,
                              [out] IHostManualEvent **ppEvent);

    HRESULT CreateMonitorEvent([in] SIZE_T Cookie,
                               [out] IHostAutoEvent **ppEvent);

    HRESULT CreateRWLockWriterEvent([in] SIZE_T Cookie,
                                    [out] IHostAutoEvent **ppEvent);
    HRESULT CreateRWLockReaderEvent([in] BOOL bInitialState,
                                    [in] SIZE_T Cookie,
                                    [out] IHostManualEvent **ppEvent);

    HRESULT CreateSemaphore([in] DWORD dwInitial,
                            [in] DWORD dwMax,
                            [out] IHostSemaphore ** ppSemaphore);
}

typedef enum
{
    OPR_ThreadAbort,
    OPR_ThreadRudeAbortInNonCriticalRegion,
    OPR_ThreadRudeAbortInCriticalRegion,
    OPR_AppDomainUnload,
    OPR_AppDomainRudeUnload,
    OPR_ProcessExit,
    OPR_FinalizerRun,
    MaxClrOperation
    // Do not add anything after this
} EClrOperation;

typedef enum
{
    FAIL_NonCriticalResource,
    FAIL_CriticalResource,
    FAIL_FatalRuntime,
    FAIL_OrphanedLock,
    FAIL_StackOverflow,
    MaxClrFailure
    // Do not add anything after this
} EClrFailure;

typedef enum
{
        eRuntimeDeterminedPolicy,       // default
        eHostDeterminedPolicy,          // revert back to Everett behavior, i.e. swallow all exception
} EClrUnhandledException;

typedef enum
{
    // !!! Please keep these ordered by severity
    // !!! If you don't, you need to change EEPolicy::IsValidActionForOperation
    // !!! and EEPolicy::IsValidActionForFailure
    eNoAction,
    eThrowException,
    eAbortThread,
    eRudeAbortThread,
    eUnloadAppDomain,
    eRudeUnloadAppDomain,
    eExitProcess,
        // Look at CorHost2::Stop.  For eFastExitProcess, eRudeExitProcess, eDisableRuntime,
        // Stop bypasses finalizer run.
    eFastExitProcess,
    eRudeExitProcess,
    eDisableRuntime,
    MaxPolicyAction
} EPolicyAction;

[
    uuid(7D290010-D781-45da-A6F8-AA5D711A730E),
    version(1.0),
    helpstring("Allow host to specify policy for CLR to follow in abnormal condition"),
    pointer_default(unique),
    local
]
interface ICLRPolicyManager: IUnknown
{
    HRESULT SetDefaultAction(
        [in] EClrOperation operation,
        [in] EPolicyAction action);

    HRESULT SetTimeout(
        [in] EClrOperation operation,
        [in] DWORD dwMilliseconds);

    HRESULT SetActionOnTimeout(
        [in] EClrOperation operation,
        [in] EPolicyAction action);

    HRESULT SetTimeoutAndAction(
        [in] EClrOperation operation,
        [in] DWORD dwMilliseconds,
        [in] EPolicyAction action);

    HRESULT SetActionOnFailure(
        [in] EClrFailure failure,
        [in] EPolicyAction action);

    HRESULT SetUnhandledExceptionPolicy(
        [in] EClrUnhandledException policy);
}

[
    uuid(7AE49844-B1E3-4683-BA7C-1E8212EA3B79),
    version(1.0),
    helpstring("Notify host about how CLR handles abnormal condition"),
    pointer_default(unique),
    local
]
interface IHostPolicyManager: IUnknown
{
    HRESULT OnDefaultAction(
        [in] EClrOperation operation,
        [in] EPolicyAction action);

    HRESULT OnTimeout(
        [in] EClrOperation operation,
        [in] EPolicyAction action);

    HRESULT OnFailure(
        [in] EClrFailure failure,
        [in] EPolicyAction action);
}

typedef enum
{
    Event_DomainUnload,
    Event_ClrDisabled,
    Event_MDAFired,
    Event_StackOverflow,
    MaxClrEvent
    // Do not add anything after this
} EClrEvent;

// An MDAInfo is passed via OnEvent for Event_MDAFired events.
typedef struct _MDAInfo
{
    LPCWSTR lpMDACaption;
    LPCWSTR lpMDAMessage;
    LPCWSTR lpStackTrace;
} MDAInfo;

// An StackOverflowInfo is passed via OnEvent for Event_StackOverflow events.
typedef enum
{
    SO_Managed,
    SO_ClrEngine,
    SO_Other,
} StackOverflowType;

cpp_quote("typedef struct _StackOverflowInfo")
cpp_quote("{")
cpp_quote("    StackOverflowType soType;")
cpp_quote("    EXCEPTION_POINTERS *pExceptionInfo;")
cpp_quote("} StackOverflowInfo;")

[
    uuid(607BE24B-D91B-4E28-A242-61871CE56E35),
    version(1.0),
    helpstring("Allow host to register action on domain unload"),
    pointer_default(unique),
    local
]
interface IActionOnCLREvent: IUnknown
{
    HRESULT OnEvent(
        [in] EClrEvent   event,
        [in] PVOID       data
        );
}

[
    uuid(1D0E0132-E64F-493D-9260-025C0E32C175),
    version(1.0),
    helpstring("Allow host to register action on event"),
    pointer_default(unique),
    local
]
interface ICLROnEventManager: IUnknown
{
    HRESULT RegisterActionOnEvent(
        [in] EClrEvent          event,
        [in] IActionOnCLREvent  *pAction
        );
    HRESULT UnregisterActionOnEvent(
        [in] EClrEvent          event,
        [in] IActionOnCLREvent  *pAction
        );
}

[
    uuid(5D4EC34E-F248-457B-B603-255FAABA0D21),
    version(1.0),
    helpstring("Control over threads blocked in GC"),
    pointer_default(unique),
    local
]
interface IHostGCManager : IUnknown
{
    // Notification that the thread making the call is about to block, perhaps for
    // a GC or other suspension.  This gives the host an opportunity to re-schedule
    // the thread for unmanaged tasks.
    HRESULT ThreadIsBlockingForSuspension();

    // Notification that the runtime is beginning a thread suspension for a GC or
    // other suspension.  Do not reschedule this thread!
    HRESULT SuspensionStarting();

    // Notification that the runtime is resuming threads after a GC or other
    // suspension.      Do not reschedule this thread!
    HRESULT SuspensionEnding(DWORD Generation);
}

/*
 * This interface is used to get information about the GC system and
 * control some aspects of the GC.  This interface is for expert usage
 * only, and can severely impact the performance of an application if
 * used improperly!!
 */
[
        uuid(54D9007E-A8E2-4885-B7BF-F998DEEE4F2A),
    version(1.0),
        pointer_default(unique),
        local
]
interface ICLRGCManager : IUnknown
{
    /*
     * Forces a collection to occur for the given generation, regardless of
     * current GC statistics.  A value of -1 means collect all generations.
     */
    HRESULT Collect([in] LONG Generation);

    /*
     * Returns a set of current statistics about the state of the GC system.
     * These values can then be used by a smart allocation system to help the
     * GC run, by say adding more memory or forcing a collection.
     */
    HRESULT GetStats([in][out] COR_GC_STATS *pStats);

    /*
     * Sets the segment size and gen 0 maximum size.  This value may only be
     * specified once and will not change if called later.
     */
    HRESULT SetGCStartupLimits([in] DWORD SegmentSize, [in] DWORD MaxGen0Size);
}

///////////////////////////////////////////////////////////////////////////////
//
// ICLRAssemblyReferenceList
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(1b2c9750-2e66-4bda-8b44-0a642c5cd733),
        helpstring("Generic Assembly Reference List, created by CLR."),
        pointer_default(unique),
        local
]
interface ICLRAssemblyReferenceList : IUnknown
{
    HRESULT    IsStringAssemblyReferenceInList(
        [in]    LPCWSTR    pwzAssemblyName
    );

    HRESULT    IsAssemblyReferenceInList(
        [in]    IUnknown *pName
    );
};

///////////////////////////////////////////////////////////////////////////////
//
// ICLRReferenceAssemblyEnum
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(d509cb5d-cf32-4876-ae61-67770cf91973),
        helpstring("Reference Enum of an Assembly."),
        pointer_default(unique),
        local
]
interface ICLRReferenceAssemblyEnum : IUnknown
{
    HRESULT Get(
        [in]        DWORD   dwIndex,
        [out, size_is(*pcchBufferSize)]    LPWSTR  pwzBuffer,
        [in, out]   DWORD   *pcchBufferSize
    );
};

///////////////////////////////////////////////////////////////////////////////
//
// ICLRProbingAssemblyEnum
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(d0c5fb1f-416b-4f97-81f4-7ac7dc24dd5d),
        helpstring("The assemblies CLR will probe for given assembly"),
        pointer_default(unique),
        local
]
interface ICLRProbingAssemblyEnum:IUnknown
{
    HRESULT Get(
        [in]        DWORD   dwIndex,
        [out, size_is(*pcchBufferSize)]    LPWSTR  pwzBuffer,
        [in, out]   DWORD   *pcchBufferSize
    );
};

typedef enum _CLRAssemblyIdentityFlags
{
    CLR_ASSEMBLY_IDENTITY_FLAGS_DEFAULT = 0
}ECLRAssemblyIdentityFlags;

///////////////////////////////////////////////////////////////////////////////
//
// ICLRAssemblyIdentityManager
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(15f0a9da-3ff6-4393-9da9-fdfd284e6972),
        helpstring("CLR Assembly Identity Manager"),
        pointer_default(unique),
        local
]
interface ICLRAssemblyIdentityManager : IUnknown
{
    HRESULT  GetCLRAssemblyReferenceList(
        [in]    LPCWSTR  *ppwzAssemblyReferences,
        [in]    DWORD    dwNumOfReferences,
        [out]   ICLRAssemblyReferenceList    **ppReferenceList
    );

    HRESULT GetBindingIdentityFromFile(
        [in]    LPCWSTR     pwzFilePath,
        [in]    DWORD       dwFlags,
        [out, size_is(*pcchBufferSize)]    LPWSTR  pwzBuffer,
        [in, out]   DWORD   *pcchBufferSize
    );

    HRESULT GetBindingIdentityFromStream(
        [in]        IStream         *pStream,
        [in]        DWORD           dwFlags,
        [out, size_is(*pcchBufferSize)]    LPWSTR  pwzBuffer,
        [in, out]   DWORD           *pcchBufferSize
    );

    HRESULT GetReferencedAssembliesFromFile(
        [in]    LPCWSTR                     pwzFilePath,
        [in]    DWORD                       dwFlags,
        [in]    ICLRAssemblyReferenceList   *pExcludeAssembliesList,
        [out]   ICLRReferenceAssemblyEnum   **ppReferenceEnum
    );

    HRESULT GetReferencedAssembliesFromStream(
        [in]    IStream                     *pStream,
        [in]    DWORD                       dwFlags,
        [in]    ICLRAssemblyReferenceList   *pExcludeAssembliesList,
        [out]   ICLRReferenceAssemblyEnum   **ppReferenceEnum
    );

    HRESULT GetProbingAssembliesFromReference(
        [in]    DWORD           dwMachineType,
        [in]    DWORD           dwFlags,
        [in]    LPCWSTR         pwzReferenceIdentity,
        [out]   ICLRProbingAssemblyEnum     **ppProbingAssemblyEnum
    );

    HRESULT IsStronglyNamed(
        [in]    LPCWSTR pwzAssemblyIdentity,
        [out]   BOOL    *pbIsStronglyNamed
    );
};

typedef enum _hostBiningPolicyModifyFlags
{
    HOST_BINDING_POLICY_MODIFY_DEFAULT  = 0,
    HOST_BINDING_POLICY_MODIFY_CHAIN    = 1,
    HOST_BINDING_POLICY_MODIFY_REMOVE   = 2,
    HOST_BINDING_POLICY_MODIFY_MAX      = 3
}EHostBindingPolicyModifyFlags;

///////////////////////////////////////////////////////////////////////////////
//
// ICLRHostBindingPolicyManager
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(4b3545e7-1856-48c9-a8ba-24b21a753c09),
        helpstring("CLR Host Binding Policy Manager, managing binding policy for host."),
        pointer_default(unique),
        local
]
interface ICLRHostBindingPolicyManager : IUnknown
{
    HRESULT     ModifyApplicationPolicy(
        [in]    LPCWSTR         pwzSourceAssemblyIdentity,
        [in]    LPCWSTR         pwzTargetAssemblyIdentity,
        [in]    BYTE            *pbApplicationPolicy,
        [in]    DWORD           cbAppPolicySize,
        [in]    DWORD           dwPolicyModifyFlags,
        [out, size_is(*pcbNewAppPolicySize)]BYTE       *pbNewApplicationPolicy,
        [in, out]   DWORD      *pcbNewAppPolicySize
    );

    HRESULT    EvaluatePolicy(
        [in]    LPCWSTR             pwzReferenceIdentity,
        [in]    BYTE                *pbApplicationPolicy,
        [in]    DWORD               cbAppPolicySize,
        [out, size_is(*pcchPostPolicyReferenceIdentity)]    LPWSTR              pwzPostPolicyReferenceIdentity,
        [in, out] DWORD             *pcchPostPolicyReferenceIdentity,
        [out]    DWORD              *pdwPoliciesApplied
    );
};

///////////////////////////////////////////////////////////////////////////////
//
// enum EBindPolicyLevels
//
///////////////////////////////////////////////////////////////////////////////
typedef enum
{
    ePolicyLevelNone = 0x0,
    ePolicyLevelRetargetable = 0x1,
    ePolicyUnifiedToCLR = 0x2,
    ePolicyLevelApp = 0x4,
    ePolicyLevelPublisher = 0x8,
    ePolicyLevelHost = 0x10,
    ePolicyLevelAdmin = 0x20
} EBindPolicyLevels;
///////////////////////////////////////////////////////////////////////////////
//
// struct AssemblyBindInfo
//
///////////////////////////////////////////////////////////////////////////////
typedef struct _AssemblyBindInfo
{
    DWORD                       dwAppDomainId;
    LPCWSTR                     lpReferencedIdentity;
    LPCWSTR                     lpPostPolicyIdentity;
    DWORD                       ePolicyLevel;
}AssemblyBindInfo;
///////////////////////////////////////////////////////////////////////////////
//
// struct ModuleBindInfo
//
///////////////////////////////////////////////////////////////////////////////
typedef struct _ModuleBindInfo
{
    DWORD                         dwAppDomainId;
    LPCWSTR                       lpAssemblyIdentity;
    LPCWSTR                       lpModuleName;
} ModuleBindInfo;


typedef enum _HostApplicationPolicy
{
    HOST_APPLICATION_BINDING_POLICY = 1
}EHostApplicationPolicy;


///////////////////////////////////////////////////////////////////////////////
//
// IHostAssemblyStore
//
///////////////////////////////////////////////////////////////////////////////
[
        local,
        object,
        version(1.0),
        uuid(7b102a88-3f7f-496d-8fa2-c35374e01af3),
        helpstring("Assembly Store provided by host"),
        pointer_default(unique)
]
interface IHostAssemblyStore: IUnknown
{
    HRESULT ProvideAssembly
            (
            [in] AssemblyBindInfo *pBindInfo,
            [out] UINT64          *pAssemblyId,
            [out] UINT64          *pContext,
            [out] IStream        **ppStmAssemblyImage,
            [out] IStream        **ppStmPDB);

    HRESULT ProvideModule
            (
            [in] ModuleBindInfo *pBindInfo,
            [out] DWORD         *pdwModuleId,
            [out] IStream      **ppStmModuleImage,
            [out] IStream      **ppStmPDB);
};

///////////////////////////////////////////////////////////////////////////////
//
// IHostAssemblyManager
//
///////////////////////////////////////////////////////////////////////////////
[
        local,
        object,
        version(1.0),
        uuid(613dabd7-62b2-493e-9e65-c1e32a1e0c5e),
        helpstring("Assembly Manager provided by host"),
        pointer_default(unique)
]
interface IHostAssemblyManager: IUnknown
{
    HRESULT GetNonHostStoreAssemblies
            (
            [out] ICLRAssemblyReferenceList **ppReferenceList
            );

    HRESULT GetAssemblyStore
            (
            [out] IHostAssemblyStore **ppAssemblyStore
            );
};

// Implemented in mscorwks.dll, use mscoree!GetRealProcAddress to get
// a function pointer of this API.
#pragma midl_echo("STDAPI GetCLRIdentityManager(REFIID riid, IUnknown **ppManager);")

// {02CA073D-7079-4860-880A-C2F7A449C991}
cpp_quote("EXTERN_GUID(IID_IHostControl, 0x02CA073C, 0x7079, 0x4860, 0x88, 0x0A, 0xC2, 0xF7, 0xA4, 0x49, 0xC9, 0x91);")
[
    uuid(02CA073C-7079-4860-880A-C2F7A449C991),
    version(1.0),
    helpstring("Common Language Runtime Host Control Interface"),
    pointer_default(unique),
    local
]
interface IHostControl : IUnknown
{
    HRESULT GetHostManager(
        [in] REFIID riid,
        [out] void **ppObject);

    /* Notify Host with IUnknown with the pointer to AppDomainManager */
        HRESULT SetAppDomainManager(
        [in] DWORD dwAppDomainID,
        [in] IUnknown* pUnkAppDomainManager);
}

cpp_quote("EXTERN_GUID(IID_ICLRControl, 0x9065597E, 0xD1A1, 0x4fb2, 0xB6, 0xBA, 0x7E, 0x1F, 0xCE, 0x23, 0x0F, 0x61);")
[
    uuid(9065597E-D1A1-4fb2-B6BA-7E1FCE230F61),
    version(1.0),
    helpstring("Common Language Runtime Control Interface"),
    pointer_default(unique),
    local
]
interface ICLRControl : IUnknown
{
    HRESULT GetCLRManager(
        [in] REFIID riid,
        [out] void **ppObject);

        HRESULT SetAppDomainManagerType(
                [in] LPCWSTR pwzAppDomainManagerAssembly,
        [in] LPCWSTR pwzAppDomainManagerType);
}



//*****************************************************************************
// New interface for hosting mscoree
//*****************************************************************************
[
    uuid(90F1A06C-7712-4762-86B5-7A5EBA6BDB02),
    version(1.0),
    helpstring("Common Language Runtime Hosting Interface"),
    pointer_default(unique),
    local
]
interface ICLRRuntimeHost : IUnknown
{
    // Starts the runtime. This is equivalent to CoInitializeCor().
    HRESULT Start();

    // Terminates the runtime, This is equivalent CoUninitializeCor();
    HRESULT Stop();

    // Returns an object for configuring runtime, e.g. threading, lock
    // prior it starts.  If the runtime has been initialized this
    // routine returns an error.  See IHostControl.
    HRESULT SetHostControl([in] IHostControl* pHostControl);

    HRESULT GetCLRControl([out] ICLRControl** pCLRControl);

    HRESULT UnloadAppDomain([in] DWORD dwAppDomainId,
                            [in] BOOL fWaitUntilDone);

    HRESULT ExecuteInAppDomain([in] DWORD dwAppDomainId,
                               [in] FExecuteInAppDomainCallback pCallback,
                               [in] void* cookie);

    HRESULT GetCurrentAppDomainId([out] DWORD *pdwAppDomainId);

    HRESULT ExecuteApplication([in] LPCWSTR   pwzAppFullName,
                               [in] DWORD     dwManifestPaths,
                               [in] LPCWSTR   *ppwzManifestPaths,   // optional
                               [in] DWORD     dwActivationData,
                               [in] LPCWSTR   *ppwzActivationData,  // optional
                               [out] int      *pReturnValue);

    HRESULT ExecuteInDefaultAppDomain([in] LPCWSTR pwzAssemblyPath,
                                      [in] LPCWSTR pwzTypeName,
                                      [in] LPCWSTR pwzMethodName,
                                      [in] LPCWSTR pwzArgument,
                                      [out] DWORD  *pReturnValue);
};


//*****************************************************************************
// Interface to utilize HostProtection
//*****************************************************************************
typedef enum
{
    eNoChecks                    = 0,
    //---------------------------------
    eSynchronization             = 0x1,
    eSharedState                 = 0x2,
    eExternalProcessMgmt         = 0x4,
    eSelfAffectingProcessMgmt    = 0x8,
    eExternalThreading           = 0x10,
    eSelfAffectingThreading      = 0x20,
    eSecurityInfrastructure      = 0x40,
    eUI                          = 0x80,
    eMayLeakOnAbort              = 0x100,
    //----------------------------------
    eAll                         = 0x1ff
} EApiCategories;

[
    object,
    uuid(89F25F5C-CEEF-43e1-9CFA-A68CE863AAAC),
    helpstring("Host Protection Interface"),
    pointer_default(unique)
]
interface ICLRHostProtectionManager : IUnknown
{
    // These allow the host to specify resources that could cause
    // instability in order to guarantee protection from them.
    HRESULT SetProtectedCategories([in] EApiCategories categories);

    // Call once before starting the runtime to sacrifice a little
    // assembly-loading-performance for a guarantee that a certain
    // rare race condition that can result in a FatalEE error won't
    // happen.
    HRESULT SetEagerSerializeGrantSets();
};

//*****************************************************************************
// mscoree typelib definition
//*****************************************************************************

[
    uuid(5477469e-83b1-11d2-8b49-00a0c9b7c9c4),
    version(2.0),
    helpstring("Common Language Runtime Execution Engine 2.0 Library")
]
library mscoree
{
    importlib("stdole32.tlb");

#ifdef INCLUDE_SVC_IDL
#define IN_MSCOREE
#include "mscorsvc.idl"
#endif

    //*****************************************************************************
    //
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(B81FF171-20F3-11d2-8DCC-00A0C9B00522),
        helpstring("Type name parser"),
        pointer_default(unique)
    ]
    interface ITypeName : IUnknown
    {
        HRESULT GetNameCount([out, retval] DWORD* pCount);
        HRESULT GetNames([in] DWORD count, [out] BSTR* rgbszNames, [out, retval] DWORD* pCount);
        HRESULT GetTypeArgumentCount([out, retval] DWORD* pCount);
        HRESULT GetTypeArguments([in] DWORD count, [out] ITypeName** rgpArguments, [out, retval] DWORD* pCount);
        HRESULT GetModifierLength([out, retval] DWORD* pCount);
        HRESULT GetModifiers([in] DWORD count, [out] DWORD* rgModifiers, [out, retval] DWORD* pCount);
        HRESULT GetAssemblyName([out, retval] BSTR* rgbszAssemblyNames);
    };

    //*****************************************************************************
    //
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(B81FF171-20F3-11d2-8DCC-00A0C9B00523),
        helpstring("Type name builder"),
        pointer_default(unique)
    ]
    interface ITypeNameBuilder : IUnknown
    {
        HRESULT OpenGenericArguments();
        HRESULT CloseGenericArguments();
        HRESULT OpenGenericArgument();
        HRESULT CloseGenericArgument();
        HRESULT AddName([in] LPCWSTR szName);
        HRESULT AddPointer();
        HRESULT AddByRef();
        HRESULT AddSzArray();
        HRESULT AddArray([in] DWORD rank);
        HRESULT AddAssemblySpec([in] LPCWSTR szAssemblySpec);
        HRESULT ToString([out, retval] BSTR* pszStringRepresentation);
        HRESULT Clear();
    };

    //*****************************************************************************
    //
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(B81FF171-20F3-11d2-8DCC-00A0C9B00521),
        helpstring("Type name builder and parser factory"),
        pointer_default(unique)
    ]
    interface ITypeNameFactory : IUnknown
    {
        HRESULT ParseTypeName([in] LPCWSTR szName, [out] DWORD* pError, [out, retval] ITypeName** ppTypeName);
        HRESULT GetTypeNameBuilder([out, retval] ITypeNameBuilder** ppTypeBuilder);
    };

    //*****************************************************************************
    // Interface for apartment callbacks.
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(178E5337-1528-4591-B1C9-1C6E484686D8),
        helpstring("Apartment callback interface"),
        pointer_default(unique)
    ]
    interface IApartmentCallback : IUnknown
    {
        HRESULT _stdcall DoCallback(
                        [in] SIZE_T pFunc,
                        [in] SIZE_T pData);
    };


#ifdef _WIN64
    #define CCW_PTR __int64 *
#else // WIN64
    #define CCW_PTR int *
#endif // WIN64


    //*****************************************************************************
    // Interface for controlling a managed object
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(C3FCC19E-A970-11d2-8B5A-00A0C9B7C9C4),
        helpstring("Managed Object Interface"),
        pointer_default(unique)
    ]
    interface IManagedObject : IUnknown
    {
        // helper to serialize the object and marshal it to the client
        HRESULT GetSerializedBuffer( [out] BSTR *pBSTR);

        // Object identity includes, process guid, appdomain id, ccw
        HRESULT GetObjectIdentity([out] BSTR* pBSTRGUID, [out] int* AppDomainID, [out] CCW_PTR pCCW);
    };

    //*****************************************************************************
    // Interface for controlling a managed object
    //*****************************************************************************
    [
        object,
        oleautomation,
        uuid(04C6BE1E-1DB1-4058-AB7A-700CCCFBF254),
        helpstring("ICatalogServices Interface"),
        pointer_default(unique)
    ]
    interface ICatalogServices : IUnknown
    {
        HRESULT Autodone();

        HRESULT NotAutodone();
    };

    [
        uuid(3F281000-E95A-11d2-886B-00C04F869F04),
        helpstring("Com Call Wrapper Unmarshalling Class")
    ]
    coclass ComCallUnmarshal
    {
        [default] interface IMarshal;
    };

    [
        uuid(CB2F6723-AB3A-11d2-9C40-00C04FA30A3E),
        helpstring("Cor Runtime Hosting Class")
    ]
    coclass CorRuntimeHost
    {
        [default] interface ICorRuntimeHost;
        interface IGCHost;
        interface ICorConfiguration;
        interface IValidator;
        interface IDebuggerInfo;
    };

    [
        uuid(90F1A06E-7712-4762-86B5-7A5EBA6BDB02),
        helpstring("CLR Runtime Hosting Class V2")
    ]
    coclass CLRRuntimeHost
    {
        [default] interface ICLRRuntimeHost;
        interface ICLRValidator;
    };

    [
        uuid(B81FF171-20F3-11d2-8DCC-00A0C9B00525),
        helpstring("TypeName parser and builder")
    ]
    coclass TypeNameFactory
    {
        [default] interface ITypeNameFactory;
    };
};

typedef enum
{
        eCurrentContext=0x00,
        eRestrictedContext=0x01
} EContextType;
///////////////////////////////////////////////////////////////////////////////
//
// IHostSecurityContext
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(7E573CE4-0343-4423-98D7-6318348A1D3C),
        helpstring("Security Context provided by host"),
        pointer_default(unique),
        local
]

interface IHostSecurityContext : IUnknown
{
        HRESULT Capture([out] IHostSecurityContext** ppClonedContext);
}

///////////////////////////////////////////////////////////////////////////////
//
// IHostSecurityManager
//
///////////////////////////////////////////////////////////////////////////////
[
        object,
        version(1.0),
        uuid(75ad2468-a349-4d02-a764-76a68aee0c4f),
        helpstring("Security Manager provided by host"),
        pointer_default(unique),
        local
]
interface IHostSecurityManager: IUnknown
{
    // Impersonation APIs.
    HRESULT ImpersonateLoggedOnUser(
            [in] HANDLE hToken);

    HRESULT RevertToSelf();

    HRESULT OpenThreadToken(
            [in]  DWORD   dwDesiredAccess,
            [in]  BOOL    bOpenAsSelf,
            [out] HANDLE  *phThreadToken
            );

    HRESULT SetThreadToken(
            [in] HANDLE hToken);

      HRESULT GetSecurityContext([in] EContextType eContextType,
                        [out] IHostSecurityContext** ppSecurityContext);
        // May return S_OK, E_FAIL (in what circumstances?)
        HRESULT SetSecurityContext([in] EContextType eContextType,
                        [in] IHostSecurityContext* pSecurityContext);

};
