1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5// ==++==
6//
7
8//
9//
10
11//
12// ==--==
13
14#ifndef __HOSTIMPL_H__
15#define __HOSTIMPL_H__
16
17#ifdef SELF_NO_HOST
18extern HANDLE g_ExecutableHeapHandle;
19#endif
20
21// We have an internal class that is used to make sure the hosting api
22// is forwarded to the os. This is a must for the shim because mscorwks
23// which normally contains the implementation of the hosting api has not
24// been loaded yet. In fact the shim is the one component responsible
25// for that loading
26class UtilExecutionEngine : public IExecutionEngine, public IEEMemoryManager
27{
28private:
29
30 //***************************************************************************
31 // IUnknown methods
32 //***************************************************************************
33
34 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID id, void **pInterface);
35 ULONG STDMETHODCALLTYPE AddRef();
36 ULONG STDMETHODCALLTYPE Release();
37
38 //***************************************************************************
39 // IExecutionEngine methods for TLS
40 //***************************************************************************
41
42 // Associate a callback for cleanup with a TLS slot
43 VOID STDMETHODCALLTYPE TLS_AssociateCallback(DWORD slot, PTLS_CALLBACK_FUNCTION callback);
44 // Get the master TLS slot index
45 LPVOID* STDMETHODCALLTYPE TLS_GetDataBlock();
46
47 // Get the value at a slot
48 LPVOID STDMETHODCALLTYPE TLS_GetValue(DWORD slot);
49
50 // Get the value at a slot, return FALSE if TLS info block doesn't exist
51 BOOL STDMETHODCALLTYPE TLS_CheckValue(DWORD slot, LPVOID * pValue);
52 // Set the value at a slot
53 VOID STDMETHODCALLTYPE TLS_SetValue(DWORD slot, LPVOID pData);
54 // Free TLS memory block and make callback
55 VOID STDMETHODCALLTYPE TLS_ThreadDetaching();
56
57 //***************************************************************************
58 // IExecutionEngine methods for locking
59 //***************************************************************************
60
61 CRITSEC_COOKIE STDMETHODCALLTYPE CreateLock(LPCSTR szTag, LPCSTR level, CrstFlags flags);
62 void STDMETHODCALLTYPE DestroyLock(CRITSEC_COOKIE lock);
63 void STDMETHODCALLTYPE AcquireLock(CRITSEC_COOKIE lock);
64 void STDMETHODCALLTYPE ReleaseLock(CRITSEC_COOKIE lock);
65
66 EVENT_COOKIE STDMETHODCALLTYPE CreateAutoEvent(BOOL bInitialState);
67 EVENT_COOKIE STDMETHODCALLTYPE CreateManualEvent(BOOL bInitialState);
68 void STDMETHODCALLTYPE CloseEvent(EVENT_COOKIE event);
69 BOOL STDMETHODCALLTYPE ClrSetEvent(EVENT_COOKIE event);
70 BOOL STDMETHODCALLTYPE ClrResetEvent(EVENT_COOKIE event);
71 DWORD STDMETHODCALLTYPE WaitForEvent(EVENT_COOKIE event, DWORD dwMilliseconds, BOOL bAlertable);
72 DWORD STDMETHODCALLTYPE WaitForSingleObject(HANDLE handle, DWORD dwMilliseconds);
73
74 SEMAPHORE_COOKIE STDMETHODCALLTYPE ClrCreateSemaphore(DWORD dwInitial, DWORD dwMax);
75 void STDMETHODCALLTYPE ClrCloseSemaphore(SEMAPHORE_COOKIE semaphore);
76 DWORD STDMETHODCALLTYPE ClrWaitForSemaphore(SEMAPHORE_COOKIE semaphore, DWORD dwMilliseconds, BOOL bAlertable);
77 BOOL STDMETHODCALLTYPE ClrReleaseSemaphore(SEMAPHORE_COOKIE semaphore, LONG lReleaseCount, LONG *lpPreviousCount);
78
79 MUTEX_COOKIE STDMETHODCALLTYPE ClrCreateMutex(LPSECURITY_ATTRIBUTES lpMutexAttributes,
80 BOOL bInitialOwner,
81 LPCTSTR lpName);
82 void STDMETHODCALLTYPE ClrCloseMutex(MUTEX_COOKIE mutex);
83 BOOL STDMETHODCALLTYPE ClrReleaseMutex(MUTEX_COOKIE mutex);
84 DWORD STDMETHODCALLTYPE ClrWaitForMutex(MUTEX_COOKIE mutex,
85 DWORD dwMilliseconds,
86 BOOL bAlertable);
87
88 DWORD STDMETHODCALLTYPE ClrSleepEx(DWORD dwMilliseconds, BOOL bAlertable);
89
90 BOOL STDMETHODCALLTYPE ClrAllocationDisallowed();
91
92 void STDMETHODCALLTYPE GetLastThrownObjectExceptionFromThread(void **ppvException);
93
94 //***************************************************************************
95 // IEEMemoryManager methods for locking
96 //***************************************************************************
97 LPVOID STDMETHODCALLTYPE ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
98 BOOL STDMETHODCALLTYPE ClrVirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
99 SIZE_T STDMETHODCALLTYPE ClrVirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE_T dwLength);
100 BOOL STDMETHODCALLTYPE ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
101 HANDLE STDMETHODCALLTYPE ClrGetProcessHeap();
102 HANDLE STDMETHODCALLTYPE ClrHeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize);
103 BOOL STDMETHODCALLTYPE ClrHeapDestroy(HANDLE hHeap);
104 LPVOID STDMETHODCALLTYPE ClrHeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
105 BOOL STDMETHODCALLTYPE ClrHeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem);
106 BOOL STDMETHODCALLTYPE ClrHeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem);
107 HANDLE STDMETHODCALLTYPE ClrGetProcessExecutableHeap();
108
109}; // class UtilExecutionEngine
110
111#endif //__HOSTIMPL_H__
112