--- /dev/null
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+#ifndef _CoreClrCommonCallbacks
+#define _CoreClrCommonCallbacks
+
+#include "runtimedetails.h"
+
+IExecutionEngine* IEE_t();
+HRESULT GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+void* GetCLRFunction(LPCSTR functionName);
+
+typedef LPVOID (*pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
+typedef BOOL (*pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
+
+#endif
#include "coreclrcallbacks.h"
#include "iexecutionengine.h"
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
{
interceptor_IEE* iee = new interceptor_IEE();
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
}
*/
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
{
if (original_EEHeapAllocInProcessHeap == nullptr)
__debugbreak();
return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
}
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
if (original_EEHeapFreeInProcessHeap == nullptr)
__debugbreak();
return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
}
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
{
if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
{
#ifndef _CoreClrCallbacks
#define _CoreClrCallbacks
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
extern CoreClrCallbacks* original_CoreClrCallbacks;
-#endif
\ No newline at end of file
+#endif
#include "coreclrcallbacks.h"
#include "iexecutionengine.h"
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
{
interceptor_IEE* iee = new interceptor_IEE();
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
}
*/
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
{
if (original_EEHeapAllocInProcessHeap == nullptr)
__debugbreak();
return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
}
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
if (original_EEHeapFreeInProcessHeap == nullptr)
__debugbreak();
return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
}
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
{
if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
{
#ifndef _CoreClrCallbacks
#define _CoreClrCallbacks
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
extern CoreClrCallbacks* original_CoreClrCallbacks;
-#endif
\ No newline at end of file
+#endif
#include "coreclrcallbacks.h"
#include "iexecutionengine.h"
-typedef LPVOID(__stdcall* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(__stdcall* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
{
interceptor_IEE* iee = new interceptor_IEE();
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
}
*/
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
{
return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
}
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
}
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
{
if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
{
#ifndef _CoreClrCallbacks
#define _CoreClrCallbacks
-#include "runtimedetails.h"
-
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
+#include "coreclrcommoncallbacks.h"
// Added to allow us to persist a copy of the original callbacks
extern CoreClrCallbacks* original_CoreClrCallbacks;
-#endif
\ No newline at end of file
+#endif
#include "coreclrcallbacks.h"
#include "iexecutionengine.h"
-IExecutionEngine* STDMETHODCALLTYPE IEE_t()
+IExecutionEngine* IEE_t()
{
MyIEE* iee = InitIExecutionEngine();
return iee;
HANDLE ourHeap = nullptr;
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
{
if (ourHeap == nullptr)
ourHeap = HeapCreate(0, 4096, 0);
return result;
}
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
// return true;
return HeapFree(ourHeap, dwFlags, lpMem);
}
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
+void* GetCLRFunction(LPCSTR functionName)
{
if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
return (void*)EEHeapAllocInProcessHeap;
#ifndef _CoreClrCallbacks
#define _CoreClrCallbacks
-#include "runtimedetails.h"
+#include "coreclrcommoncallbacks.h"
-IExecutionEngine* STDMETHODCALLTYPE IEE_t();
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
CoreClrCallbacks* InitCoreClrCallbacks();
-#endif
\ No newline at end of file
+#endif
#include <process.h> // for __security_init_cookie()
-extern "C" IExecutionEngine* __stdcall IEE();
+extern "C" IExecutionEngine* IEE();
#ifdef NO_CRT_INIT
#define _CRT_INIT(hInstance, dwReason, lpReserved) (TRUE)
//----------------------------------------------------------------------------------------
struct CoreClrCallbacks
{
- typedef IExecutionEngine* (__stdcall * pfnIEE_t)();
- typedef HRESULT (__stdcall * pfnGetCORSystemDirectory_t)(SString& pbuffer);
- typedef void* (__stdcall * pfnGetCLRFunction_t)(LPCSTR functionName);
+ typedef IExecutionEngine* (* pfnIEE_t)();
+ typedef HRESULT (* pfnGetCORSystemDirectory_t)(SString& pbuffer);
+ typedef void* (* pfnGetCLRFunction_t)(LPCSTR functionName);
HINSTANCE m_hmodCoreCLR;
pfnIEE_t m_pfnIEE;
// ======================================================================================
-void* __stdcall GetCLRFunction(LPCSTR FunctionName);
+void* GetCLRFunction(LPCSTR FunctionName);
#endif // __UtilCode_h__
#define STDMETHODCALLTYPE __stdcall
#define STDMETHODVCALLTYPE __cdecl
-#define STDAPICALLTYPE __stdcall
+#define STDAPICALLTYPE __cdecl
#define STDAPIVCALLTYPE __cdecl
#define STDMETHODIMP HRESULT STDMETHODCALLTYPE
// Shim APIs, passing off into the desktop VM
//
-IExecutionEngine * __stdcall SnIEE()
+IExecutionEngine* SnIEE()
{
- typedef IExecutionEngine * ( __stdcall *IEEFn_t)();
+ typedef IExecutionEngine* (* IEEFn_t)();
return ApiShim<IEEFn_t>("IEE")();
}
-STDAPI SnGetCorSystemDirectory(SString& pbuffer)
+HRESULT SnGetCorSystemDirectory(SString& pbuffer)
{
- typedef HRESULT (__stdcall *GetCorSystemDirectoryFn_t)(SString&);
+ typedef HRESULT (*GetCorSystemDirectoryFn_t)(SString&);
return ApiShim<GetCorSystemDirectoryFn_t>("GetCORSystemDirectory")(pbuffer);
}
// no longer maintains a ref count since the EE doesn't support being
// unloaded and re-loaded. It simply ensures the EE has been started.
// ---------------------------------------------------------------------------
-HRESULT STDMETHODCALLTYPE CoInitializeEE(DWORD fFlags)
+HRESULT STDAPICALLTYPE CoInitializeEE(DWORD fFlags)
{
CONTRACTL
{
// Description:
// Must be called by client on shut down in order to free up the system.
// ---------------------------------------------------------------------------
-void STDMETHODCALLTYPE CoUninitializeEE(BOOL fIsDllUnloading)
+void STDAPICALLTYPE CoUninitializeEE(BOOL fIsDllUnloading)
{
LIMITED_METHOD_CONTRACT;
//BEGIN_ENTRYPOINT_VOIDRET;
#ifndef DACCESS_COMPILE
extern void STDMETHODCALLTYPE EEShutDown(BOOL fIsDllUnloading);
-extern HRESULT STDMETHODCALLTYPE CoInitializeEE(DWORD fFlags);
+extern HRESULT STDAPICALLTYPE CoInitializeEE(DWORD fFlags);
extern void PrintToStdOutA(const char *pszString);
extern void PrintToStdOutW(const WCHAR *pwzString);
extern BOOL g_fEEHostedStartup;
WRAPPER_NO_CONTRACT;
STATIC_CONTRACT_SO_TOLERANT;
+#ifdef _DEBUG
+ // Check whether (indispensable) implicit casting in ClrAllocInProcessHeapBootstrap is safe.
+ static FastAllocInProcessHeapFunc pFunc = EEHeapAllocInProcessHeap;
+#endif
+
static HANDLE ProcessHeap = NULL;
// We need to guarentee a very small stack consumption in allocating. And we can't allow
}
CONTRACTL_END;
+#ifdef _DEBUG
+ // Check whether (indispensable) implicit casting in ClrFreeInProcessHeapBootstrap is safe.
+ static FastFreeInProcessHeapFunc pFunc = EEHeapFreeInProcessHeap;
+#endif
+
// Take a look at comment in EEHeapFree and EEHeapAllocInProcessHeap, obviously someone
// needs to take a little time to think more about this code.
//CONTRACT_VIOLATION(SOToleranceViolation);
#endif // !FEATURE_PAL
-extern LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-extern BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-extern void ShutdownRuntimeWithoutExiting(int exitCode);
-extern BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+void ShutdownRuntimeWithoutExiting(int exitCode);
+BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
-void * __stdcall GetCLRFunction(LPCSTR FunctionName)
+void *GetCLRFunction(LPCSTR FunctionName)
{
void* func = NULL;