IExecutionEngine* STDMETHODCALLTYPE IEE_t();
HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength);
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName);
#endif
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
return iee;
}
-
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
-{
- return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
-}
original_CoreClrCallbacks->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
original_CoreClrCallbacks->m_pfnIEE = original_cccallbacks.m_pfnIEE;
original_CoreClrCallbacks->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- original_CoreClrCallbacks->m_pfnGetCLRFunction = original_cccallbacks.m_pfnGetCLRFunction;
CoreClrCallbacks* temp = new CoreClrCallbacks();
temp->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
temp->m_pfnIEE = IEE_t;
temp->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- temp->m_pfnGetCLRFunction = GetCLRFunction;
pnsxsJitStartup(*temp);
}
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
return iee;
}
-
-/*#pragma warning( suppress :4996 ) //deprecated
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength)
-{
- DebugBreakorAV(131);
- return 0;
-}
-*/
-
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
-{
- return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
-}
original_CoreClrCallbacks->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
original_CoreClrCallbacks->m_pfnIEE = original_cccallbacks.m_pfnIEE;
original_CoreClrCallbacks->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- original_CoreClrCallbacks->m_pfnGetCLRFunction = original_cccallbacks.m_pfnGetCLRFunction;
CoreClrCallbacks* temp = new CoreClrCallbacks();
temp->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
temp->m_pfnIEE = IEE_t;
temp->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- temp->m_pfnGetCLRFunction = GetCLRFunction;
pnsxsJitStartup(*temp);
}
iee->original_IEE = original_CoreClrCallbacks->m_pfnIEE();
return iee;
}
-
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
-{
- return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
-}
original_CoreClrCallbacks->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
original_CoreClrCallbacks->m_pfnIEE = original_cccallbacks.m_pfnIEE;
original_CoreClrCallbacks->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- original_CoreClrCallbacks->m_pfnGetCLRFunction = original_cccallbacks.m_pfnGetCLRFunction;
CoreClrCallbacks* temp = new CoreClrCallbacks();
temp->m_hmodCoreCLR = original_cccallbacks.m_hmodCoreCLR;
temp->m_pfnIEE = IEE_t;
temp->m_pfnGetCORSystemDirectory = original_cccallbacks.m_pfnGetCORSystemDirectory;
- temp->m_pfnGetCLRFunction = GetCLRFunction;
pnsxsJitStartup(*temp);
}
HANDLE ourHeap = nullptr;
-void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
-{
- DebugBreakorAV(132);
- return nullptr;
-}
-
CoreClrCallbacks* InitCoreClrCallbacks()
{
CoreClrCallbacks* temp = new CoreClrCallbacks();
temp->m_hmodCoreCLR = (HINSTANCE)(size_t)0xbadbad01; // any non-null value seems okay...
temp->m_pfnIEE = IEE_t;
temp->m_pfnGetCORSystemDirectory = nullptr; // GetCORSystemDirectory;
- temp->m_pfnGetCLRFunction = GetCLRFunction;
return temp;
}
cccallbacks.m_hmodCoreCLR = (HINSTANCE)m_globalBase; // Base address of the runtime in the target process
cccallbacks.m_pfnIEE = NULL;
cccallbacks.m_pfnGetCORSystemDirectory = NULL;
- cccallbacks.m_pfnGetCLRFunction = NULL;
InitUtilcode(cccallbacks);
return S_OK;
cccallbacks.m_hmodCoreCLR = hmodTargetCLR;
cccallbacks.m_pfnIEE = NULL;
cccallbacks.m_pfnGetCORSystemDirectory = NULL;
- cccallbacks.m_pfnGetCLRFunction = NULL;
InitUtilcode(cccallbacks);
return S_OK;
cccallbacks.m_hmodCoreCLR = (HINSTANCE)hInstance;
cccallbacks.m_pfnIEE = IEE;
cccallbacks.m_pfnGetCORSystemDirectory = GetCORSystemDirectoryInternaL;
- cccallbacks.m_pfnGetCLRFunction = GetCLRFunction;
InitUtilcode(cccallbacks);
if (!(result = _CRT_INIT(hInstance, dwReason, lpReserved)))
// which in turn calls InitUtilcode.
//
// This structure collects all of the critical callback info passed in InitUtilcode().
-// Note that one of them is GetCLRFunction() which is itself a gofer for many other
-// callbacks. If a callback fetch be safely deferred until we have TLS and stack probe
-// functionality running, it should be added to that function rather than this structure.
-// Things like IEE are here because that callback has to be set up before GetCLRFunction()
-// can be safely called.
//----------------------------------------------------------------------------------------
struct CoreClrCallbacks
{
typedef IExecutionEngine* (* pfnIEE_t)();
typedef HRESULT (* pfnGetCORSystemDirectory_t)(SString& pbuffer);
- typedef void* (* pfnGetCLRFunction_t)(LPCSTR functionName);
HINSTANCE m_hmodCoreCLR;
pfnIEE_t m_pfnIEE;
pfnGetCORSystemDirectory_t m_pfnGetCORSystemDirectory;
- pfnGetCLRFunction_t m_pfnGetCLRFunction;
};
extern SpinConstants g_SpinConstants;
-// ======================================================================================
-
-void* GetCLRFunction(LPCSTR FunctionName);
-
#endif // __UtilCode_h__
return retVal;
}
-static LONG s_ProcessedExitProcessEventCount = 0;
-
-LONG GetProcessedExitProcessEventCount()
-{
- LIMITED_METHOD_CONTRACT;
- return s_ProcessedExitProcessEventCount;
-}
-
void AppDomain::RaiseExitProcessEvent()
{
if (!g_fEEStarted)
RETURN pAssembly;
} // AppDomain::RaiseAssemblyResolveEvent
-
-ULONGLONG g_ObjFinalizeStartTime = 0;
-Volatile<BOOL> g_FinalizerIsRunning = FALSE;
-Volatile<ULONG> g_FinalizerLoopCount = 0;
-
enum WorkType
{
WT_UnloadDomain = 0x1,
#endif // FEATURE_COMINTEROP
StubHelpers::Init();
- NDirect::Init();
// Before setting up the execution manager initialize the first part
// of the JIT helpers.
if (!pGetLastError)
{
// No need to use a holder here, since no cleanup is necessary.
- HMODULE hMod = CLRGetModuleHandle(WINDOWS_KERNEL32_DLLNAME_W);
+ HMODULE hMod = WszGetModuleHandle(WINDOWS_KERNEL32_DLLNAME_W);
if (hMod)
{
pGetLastError = (LPBYTE)GetProcAddress(hMod, "GetLastError");
#ifndef FEATURE_PAL
- if ((flags & 0xFFFFFF00) != 0
-#ifndef FEATURE_CORESYSTEM
- && NDirect::SecureLoadLibrarySupported()
-#endif // !FEATURE_CORESYSTEM
- )
+ if ((flags & 0xFFFFFF00) != 0)
{
hmod = CLRLoadLibraryEx(name, NULL, flags & 0xFFFFFF00);
if (hmod != NULL)
return hmod;
}
-#if !defined(FEATURE_PAL)
-bool NDirect::s_fSecureLoadLibrarySupported = false;
-#endif
-
#define TOLOWER(a) (((a) >= W('A') && (a) <= W('Z')) ? (W('a') + (a - W('A'))) : (a))
#define TOHEX(a) ((a)>=10 ? W('a')+(a)-10 : W('0')+(a))
}
}
-
-//---------------------------------------------------------
-// One-time init
-//---------------------------------------------------------
-/*static*/ void NDirect::Init()
-{
- CONTRACTL
- {
- THROWS;
- GC_TRIGGERS;
- MODE_ANY;
- INJECT_FAULT(COMPlusThrowOM());
- }
- CONTRACTL_END;
-
-#if !defined(FEATURE_PAL)
- // Check if the OS supports the new secure LoadLibraryEx flags introduced in KB2533623
- HMODULE hMod = CLRGetModuleHandle(WINDOWS_KERNEL32_DLLNAME_W);
- _ASSERTE(hMod != NULL);
-
- if (GetProcAddress(hMod, "AddDllDirectory") != NULL)
- {
- // The AddDllDirectory export was added in KB2533623 together with the new flag support
- s_fSecureLoadLibrarySupported = true;
- }
-#endif // !FEATURE_PAL
-}
-
-
//==========================================================================
// This function is reached only via NDirectImportThunk. It's purpose
// is to ensure that the target DLL is fully loaded and ready to run.
public:
//---------------------------------------------------------
- // One-time init
- //---------------------------------------------------------
- static void Init();
-
- //---------------------------------------------------------
// Does a class or method have a NAT_L CustomAttribute?
//
// S_OK = yes
static NATIVE_LIBRARY_HANDLE LoadLibraryModuleViaCallback(NDirectMethodDesc * pMD, LPCWSTR wszLibName);
static NATIVE_LIBRARY_HANDLE LoadLibraryModuleBySearch(NDirectMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker, LPCWSTR wszLibName);
static NATIVE_LIBRARY_HANDLE LoadLibraryModuleBySearch(Assembly *callingAssembly, BOOL searchAssemblyDirectory, DWORD dllImportSearchPathFlags, LoadLibErrorTracker * pErrorTracker, LPCWSTR wszLibName);
-
-#if !defined(FEATURE_PAL)
- // Indicates if the OS supports the new secure LoadLibraryEx flags introduced in KB2533623
- static bool s_fSecureLoadLibrarySupported;
-
-public:
- static bool SecureLoadLibrarySupported()
- {
- LIMITED_METHOD_CONTRACT;
- return s_fSecureLoadLibrarySupported;
- }
-#endif // !FEATURE_PAL
};
//----------------------------------------------------------------
STATIC_CONTRACT_GC_TRIGGERS;
STATIC_CONTRACT_MODE_COOPERATIVE;
- class ResetFinalizerStartTime
- {
- public:
- ResetFinalizerStartTime()
- {
- if (CLRHosted())
- {
- g_ObjFinalizeStartTime = CLRGetTickCount64();
- }
- }
- ~ResetFinalizerStartTime()
- {
- if (g_ObjFinalizeStartTime)
- {
- g_ObjFinalizeStartTime = 0;
- }
- }
- };
- {
- ResetFinalizerStartTime resetTime;
- CallFinalizer(fobj);
- }
+ CallFinalizer(fobj);
+
pThread->InternalReset();
}
{
GetFinalizerThread()->EEResetAbort(Thread::TAR_ALL);
}
- FastInterlockExchange ((LONG*)&g_FinalizerIsRunning, TRUE);
FinalizeAllObjects(0);
_ASSERTE(GetFinalizerThread()->GetDomain()->IsDefaultDomain());
- FastInterlockExchange ((LONG*)&g_FinalizerIsRunning, FALSE);
// We may still have the finalizer thread for abort. If so the abort request is for previous finalizer method, not for next one.
if (GetFinalizerThread()->IsAbortRequested())
{
GetFinalizerThread()->EEResetAbort(Thread::TAR_ALL);
}
- // Increment the loop count. This is currently used by the AddMemoryPressure heuristic to see
- // if finalizers have run since the last time it triggered GC.
- FastInterlockIncrement((LONG *)&g_FinalizerLoopCount);
-
// Anyone waiting to drain the Q can now wake up. Note that there is a
// race in that another thread starting a drain, as we leave a drain, may
// consider itself satisfied by the drain that just completed. This is
else
return maxSize;
}
-
-//---------------------------------------------------------------------
-
-#ifndef FEATURE_PAL
-HMODULE CLRGetModuleHandle(LPCWSTR lpModuleFileName)
-{
- // Don't use dynamic contract: will override GetLastError value
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_FORBID_FAULT;
-
- HMODULE hMod = WszGetModuleHandle(lpModuleFileName);
- return hMod;
-}
-#endif // !FEATURE_PAL
-
-void *GetCLRFunction(LPCSTR FunctionName)
-{
-
- void* func = NULL;
- BEGIN_ENTRYPOINT_VOIDRET;
-
- LIMITED_METHOD_CONTRACT;
-
- {
- _ASSERTE ("Unknown function name");
- func = NULL;
- }
- END_ENTRYPOINT_VOIDRET;
-
- return func;
-}
-
#endif // CROSSGEN_COMPILE
LPVOID
}
#ifndef FEATURE_PAL
-HMODULE CLRGetModuleHandle(LPCWSTR lpModuleFileName);
-
HMODULE CLRLoadLibraryEx(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
#endif // !FEATURE_PAL
};
EXTERN DWORD g_FinalizerWaiterStatus;
-extern ULONGLONG g_ObjFinalizeStartTime;
-extern Volatile<BOOL> g_FinalizerIsRunning;
-extern Volatile<ULONG> g_FinalizerLoopCount;
#if defined(FEATURE_PAL) && defined(FEATURE_EVENT_TRACE)
extern Volatile<BOOL> g_TriggerHeapDump;
#endif // FEATURE_PAL
-extern LONG GetProcessedExitProcessEventCount();
-
#ifndef DACCESS_COMPILE
//
// Allow use of native images?