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);
-typedef LPVOID(STDMETHODCALLTYPE* pfnEEHeapAllocInProcessHeap)(DWORD dwFlags, SIZE_T dwBytes);
-typedef BOOL(STDMETHODCALLTYPE* pfnEEHeapFreeInProcessHeap)(DWORD dwFlags, LPVOID lpMem);
-
#endif
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
return iee;
}
-/*#pragma warning( suppress :4996 ) //deprecated
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength)
-{
- DebugBreakorAV(131);
- return 0;
-}
-*/
-
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (original_EEHeapAllocInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- if (original_EEHeapFreeInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
}
*/
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (original_EEHeapAllocInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- if (original_EEHeapFreeInProcessHeap == nullptr)
- __debugbreak();
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
#include "iexecutionengine.h"
CoreClrCallbacks* original_CoreClrCallbacks = nullptr;
-pfnEEHeapAllocInProcessHeap original_EEHeapAllocInProcessHeap = nullptr;
-pfnEEHeapFreeInProcessHeap original_EEHeapFreeInProcessHeap = nullptr;
IExecutionEngine* STDMETHODCALLTYPE IEE_t()
{
return iee;
}
-/*#pragma warning( suppress :4996 ) //deprecated
-HRESULT STDMETHODCALLTYPE GetCORSystemDirectory(LPWSTR pbuffer, DWORD cchBuffer, DWORD* pdwlength)
-{
- DebugBreakorAV(131);
- return 0;
-}
-*/
-
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- return original_EEHeapAllocInProcessHeap(dwFlags, dwBytes);
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- return original_EEHeapFreeInProcessHeap(dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- {
- original_EEHeapAllocInProcessHeap =
- (pfnEEHeapAllocInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- return (void*)EEHeapAllocInProcessHeap;
- }
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- {
- original_EEHeapFreeInProcessHeap =
- (pfnEEHeapFreeInProcessHeap)original_CoreClrCallbacks->m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- return (void*)EEHeapFreeInProcessHeap;
- }
return original_CoreClrCallbacks->m_pfnGetCLRFunction(functionName);
}
HANDLE ourHeap = nullptr;
-LPVOID STDMETHODCALLTYPE EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes)
-{
- if (ourHeap == nullptr)
- ourHeap = HeapCreate(0, 4096, 0);
- if (ourHeap == nullptr)
- {
- LogError("HeapCreate Failed");
- __debugbreak();
- return nullptr;
- }
- LPVOID result = HeapAlloc(ourHeap, dwFlags, dwBytes);
- // LogDebug("EEHeapAllocInProcessHeap %p %u %u", result, dwFlags, dwBytes);
- return result;
-}
-
-BOOL STDMETHODCALLTYPE EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
-{
- // return true;
- return HeapFree(ourHeap, dwFlags, lpMem);
-}
-
void* STDMETHODCALLTYPE GetCLRFunction(LPCSTR functionName)
{
- if (strcmp(functionName, "EEHeapAllocInProcessHeap") == 0)
- return (void*)EEHeapAllocInProcessHeap;
- if (strcmp(functionName, "EEHeapFreeInProcessHeap") == 0)
- return (void*)EEHeapFreeInProcessHeap;
DebugBreakorAV(132);
return nullptr;
}
}
}
-typedef LPVOID (*FastAllocInProcessHeapFunc)(DWORD dwFlags, SIZE_T dwBytes);
-extern FastAllocInProcessHeapFunc __ClrAllocInProcessHeap;
+#ifndef SELF_NO_HOST
+LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
+BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
+#endif
+
inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes)
{
STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY;
}
#ifndef SELF_NO_HOST
- return __ClrAllocInProcessHeap(dwFlags, dwBytes.Value());
+ return EEHeapAllocInProcessHeap(dwFlags, dwBytes.Value());
#else
#undef HeapAlloc
#undef GetProcessHeap
#endif
}
-typedef BOOL (*FastFreeInProcessHeapFunc)(DWORD dwFlags, LPVOID lpMem);
-extern FastFreeInProcessHeapFunc __ClrFreeInProcessHeap;
inline BOOL ClrFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem)
{
STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY;
#ifndef SELF_NO_HOST
- return __ClrFreeInProcessHeap(dwFlags, lpMem);
+ return EEHeapFreeInProcessHeap(dwFlags, lpMem);
#else
#undef HeapFree
#undef GetProcessHeap
return hr;
}
+
+//*****************************************************************************
+// Return a pointer to a null terminated string given an offset previously
+// handed out by AddString or FindString. Only valid for use if the Storage pool is actuall ReadOnly, and not derived
+//*****************************************************************************
+ __checkReturn
+ inline HRESULT GetStringReadOnly(
+ UINT32 nIndex,
+ __deref_out LPCSTR *pszString)
+ {
+ HRESULT hr;
+
+ // Size of the data in the heap will be ignored, because we have verified during creation of the string
+ // heap (code:Initialize) and when adding new strings (e.g. code:AddString,
+ // code:AddTemporaryStringBuffer), that the heap is null-terminated, therefore we don't have to check it
+ // for each string in the heap
+ MetaData::DataBlob stringData;
+
+ // Get data from the heap (clears stringData on error)
+ IfFailGo(GetDataReadOnly(
+ nIndex,
+ &stringData));
+ _ASSERTE(hr == S_OK);
+ // Raw data are always at least 1 byte long, otherwise it would be invalid offset and hr != S_OK
+ PREFAST_ASSUME(stringData.GetDataPointer() != NULL);
+ // Fills output string
+ *pszString = reinterpret_cast<LPSTR>(stringData.GetDataPointer());
+ //_ASSERTE(stringData.GetSize() > strlen(*pszString));
+
+ return hr;
+ ErrExit:
+ // Clears output string on error
+ *pszString = NULL;
+
+ return hr;
+ }
#ifdef _PREFAST_
#pragma warning(pop)
#endif
UINT32 nIndex,
__deref_out_z LPCSTR *pszString) const
{
- return const_cast<StgPoolReadOnly &>(m_StringPool).GetString(
+ return const_cast<StgPoolReadOnly &>(m_StringPool).GetStringReadOnly(
nIndex,
pszString);
}
virtual int CommonIsRo() = 0;
__checkReturn
- virtual HRESULT CommonGetCustomAttributeByName( // S_OK or error.
+ HRESULT CommonGetCustomAttributeByName( // S_OK or error.
mdToken tkObj, // [IN] Object with Custom Attribute.
LPCUTF8 szName, // [IN] Name of desired Custom Attribute.
const void **ppData, // [OUT] Put pointer to data here.
ULONG ulTarget, // target for search
RID *pRid) = 0;
- // Search a table for multiple (adjacent) rows containing the given
- // key value. EG, InterfaceImpls all point back to the implementing class.
- __checkReturn
- HRESULT SearchTableForMultipleRows( // First RID found, or 0.
- ULONG ixTbl, // Table to search.
- CMiniColDef sColumn, // Sorted key column, containing search value.
- ULONG ulTarget, // Target for search.
- RID *pEnd, // [OPTIONAL, OUT]
- RID *pFoundRid);
-
// Search for a custom value with a given type.
__checkReturn
HRESULT FindCustomAttributeFor(// RID of custom value, or 0.
}
//*****************************************************************************
+ // Search a table for multiple (adjacent) rows containing the given
+ // key value. EG, InterfaceImpls all point back to the implementing class.
+ //*****************************************************************************
+ __checkReturn
+ HRESULT SearchTableForMultipleRows(
+ ULONG ixTbl, // Table to search.
+ CMiniColDef sColumn, // Sorted key column, containing search value.
+ ULONG ulTarget, // Target for search.
+ RID *pEnd, // [OPTIONAL, OUT]
+ RID *pFoundRid) // First RID found, or 0.
+ {
+ HRESULT hr;
+ ULONG ridBegin; // RID of first entry.
+ ULONG ridEnd; // RID of first entry past last entry.
+
+ // Search for any entry in the table.
+ IfFailRet(static_cast<Impl*>(this)->vSearchTable(ixTbl, sColumn, ulTarget, &ridBegin));
+
+ // If nothing found, return invalid RID.
+ if (ridBegin == 0)
+ {
+ if (pEnd != NULL)
+ {
+ *pEnd = 0;
+ }
+ *pFoundRid = 0;
+ return S_OK;
+ }
+
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // If you change the rows touched while searching, please update
+ // CMiniMdRW::GetHotMetadataTokensSearchAware
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+ // End will be at least one larger than found record.
+ ridEnd = ridBegin + 1;
+
+ // Search back to start of group.
+ for (;;)
+ {
+ void *pRow;
+ if (ridBegin <= 1)
+ {
+ break;
+ }
+ IfFailRet(static_cast<Impl*>(this)->vGetRow(ixTbl, ridBegin-1, &pRow));
+ if (getIX(pRow, sColumn) != ulTarget)
+ {
+ break;
+ }
+ --ridBegin;
+ }
+
+ // If desired, search forward to end of group.
+ if (pEnd != NULL)
+ {
+ for (;;)
+ {
+ void *pRow;
+ if (ridEnd > GetCountRecs(ixTbl))
+ {
+ break;
+ }
+ IfFailRet(static_cast<Impl*>(this)->vGetRow(ixTbl, ridEnd, &pRow));
+ if (getIX(pRow, sColumn) != ulTarget)
+ {
+ break;
+ }
+ ++ridEnd;
+ }
+ *pEnd = ridEnd;
+ }
+
+ *pFoundRid = ridBegin;
+ return S_OK;
+ } // SearchTableForMultipleRows
+
+ //*****************************************************************************
// Get name and sig of a methodDef
//*****************************************************************************
HRESULT CommonGetMethodDefProps(
template <class MiniMd> class CLiteWeightStgdb;
class CMiniMdRW;
class MDInternalRO;
-class CMiniMd : public CMiniMdTemplate<CMiniMd>
+class CMiniMd final: public CMiniMdTemplate<CMiniMd>
{
public:
friend class CLiteWeightStgdb<CMiniMd>;
__deref_out_bcount(*pcbData) const void **ppData, // [OUT] Put pointer to data here.
__out ULONG *pcbData) // [OUT] Put size of data here.
{
- return m_LiteWeightStgdb.m_MiniMd.CommonGetCustomAttributeByName(tkObj, szName, ppData, pcbData);
+ return m_LiteWeightStgdb.m_MiniMd.CommonGetCustomAttributeByNameEx(tkObj, szName, NULL, ppData, pcbData);
} // MDInternalRO::GetCustomAttributeByName
return m_Schema.m_cRecs[ixTbl];
} // CMiniMdBase::GetCountRecs
-//*****************************************************************************
-// Search a table for multiple (adjacent) rows containing the given
-// key value. EG, InterfaceImpls all point back to the implementing class.
-//*****************************************************************************
-__checkReturn
-HRESULT
-CMiniMdBase::SearchTableForMultipleRows(
- ULONG ixTbl, // Table to search.
- CMiniColDef sColumn, // Sorted key column, containing search value.
- ULONG ulTarget, // Target for search.
- RID *pEnd, // [OPTIONAL, OUT]
- RID *pFoundRid) // First RID found, or 0.
-{
- HRESULT hr;
- ULONG ridBegin; // RID of first entry.
- ULONG ridEnd; // RID of first entry past last entry.
-
- // Search for any entry in the table.
- IfFailRet(vSearchTable(ixTbl, sColumn, ulTarget, &ridBegin));
-
- // If nothing found, return invalid RID.
- if (ridBegin == 0)
- {
- if (pEnd != NULL)
- {
- *pEnd = 0;
- }
- *pFoundRid = 0;
- return S_OK;
- }
-
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // If you change the rows touched while searching, please update
- // CMiniMdRW::GetHotMetadataTokensSearchAware
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
- // End will be at least one larger than found record.
- ridEnd = ridBegin + 1;
-
- // Search back to start of group.
- for (;;)
- {
- void *pRow;
- if (ridBegin <= 1)
- {
- break;
- }
- IfFailRet(vGetRow(ixTbl, ridBegin-1, &pRow));
- if (getIX(pRow, sColumn) != ulTarget)
- {
- break;
- }
- --ridBegin;
- }
-
- // If desired, search forward to end of group.
- if (pEnd != NULL)
- {
- for (;;)
- {
- void *pRow;
- if (ridEnd > GetCountRecs(ixTbl))
- {
- break;
- }
- IfFailRet(vGetRow(ixTbl, ridEnd, &pRow));
- if (getIX(pRow, sColumn) != ulTarget)
- {
- break;
- }
- ++ridEnd;
- }
- *pEnd = ridEnd;
- }
-
- *pFoundRid = ridBegin;
- return S_OK;
-} // CMiniMdBase::SearchTableForMultipleRows
-
#if BIGENDIAN
// Endian Swaps the passed in blob representing a constant into the passed in StgPool
#endif //defined(_DEBUG_IMPL) && defined(ENABLE_CONTRACTS_IMPL)
-
-LPVOID ClrAllocInProcessHeapBootstrap (DWORD dwFlags, SIZE_T dwBytes)
-{
-#if defined(SELF_NO_HOST)
- static HANDLE hHeap = NULL;
-
- // This could race, but the result would be that this
- // variable gets double initialized.
- if (hHeap == NULL)
- hHeap = ClrGetProcessHeap();
-
- return ClrHeapAlloc(hHeap, dwFlags, S_SIZE_T(dwBytes));
-#else //!defined(SELF_NO_HOST)
- FastAllocInProcessHeapFunc pfnHeapAlloc = (FastAllocInProcessHeapFunc)
- GetClrCallbacks().m_pfnGetCLRFunction("EEHeapAllocInProcessHeap");
- if (pfnHeapAlloc != NULL)
- {
- __ClrAllocInProcessHeap = pfnHeapAlloc;
- return pfnHeapAlloc(dwFlags, dwBytes);
- }
- return ClrHeapAlloc(ClrGetProcessHeap(), dwFlags, S_SIZE_T(dwBytes));
-#endif // !defined(SELF_NO_HOST)
-}
-FastAllocInProcessHeapFunc __ClrAllocInProcessHeap = (FastAllocInProcessHeapFunc) ClrAllocInProcessHeapBootstrap;
-
-BOOL ClrFreeInProcessHeapBootstrap (DWORD dwFlags, LPVOID lpMem)
-{
-#if defined(SELF_NO_HOST)
- static HANDLE hHeap = NULL;
-
- // This could race, but the result would be that this
- // variable gets double initialized.
- if (hHeap == NULL)
- hHeap = ClrGetProcessHeap();
-
- return ClrHeapFree(hHeap, dwFlags,lpMem);
-#else //!defined(SELF_NO_HOST)
- FastFreeInProcessHeapFunc pfnHeapFree = (FastFreeInProcessHeapFunc)
- GetClrCallbacks().m_pfnGetCLRFunction("EEHeapFreeInProcessHeap");
- if (pfnHeapFree)
- {
- __ClrFreeInProcessHeap = pfnHeapFree;
- return (*pfnHeapFree)(dwFlags,lpMem);
- }
- return ClrHeapFree(ClrGetProcessHeap(),dwFlags,lpMem);
-#endif //!defined(SELF_NO_HOST)
-}
-FastFreeInProcessHeapFunc __ClrFreeInProcessHeap = (FastFreeInProcessHeapFunc) ClrFreeInProcessHeapBootstrap;
-
const NoThrow nothrow = { 0 };
#ifdef HAS_ADDRESS_SANITIZER
EEPolicy::HandleExitProcess(sca);
}
-//---------------------------------------------------------------------------
-// %%Function: IsRuntimeStarted
-//
-// Parameters:
-// pdwStartupFlags: out parameter that is set to the startup flags if the
-// runtime is started.
-//
-// Returns:
-// TRUE if the runtime has been started, FALSE otherwise.
-//
-// Description:
-// This is a helper used only by the v4+ Shim to determine if this runtime
-// has ever been started. It is exposed ot the Shim via GetCLRFunction.
-// ---------------------------------------------------------------------------
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags)
-{
- LIMITED_METHOD_CONTRACT;
-
- if (pdwStartupFlags != NULL) // this parameter is optional
- {
- *pdwStartupFlags = 0;
- }
- return g_fEEStarted;
-}
-
static bool WaitForEndOfShutdown_OneIteration()
{
CONTRACTL{
// Wrapper around EnsureEEStarted which also sets startup mode.
HRESULT InitializeEE(COINITIEE flags);
-// Has the EE been started up?
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
-
// Enum to control what happens at the end of EE shutdown. There are two options:
// 1. Call ::ExitProcess to cause the process to terminate gracefully. This is how
// shutdown normally ends. "Shutdown" methods that take this action as an argument
{
WRAPPER_NO_CONTRACT;
-#ifdef _DEBUG
- // Check whether (indispensable) implicit casting in ClrAllocInProcessHeapBootstrap is safe.
- static FastAllocInProcessHeapFunc pFunc = EEHeapAllocInProcessHeap;
-#endif
-
static HANDLE ProcessHeap = NULL;
if (ProcessHeap == NULL)
}
CONTRACTL_END;
-#ifdef _DEBUG
- // Check whether (indispensable) implicit casting in ClrFreeInProcessHeapBootstrap is safe.
- static FastFreeInProcessHeapFunc pFunc = EEHeapFreeInProcessHeap;
-#endif
-
static HANDLE ProcessHeap = NULL;
if (ProcessHeap == NULL)
//==========================================================================================
// This will fill in all the MethodEntry slots present in the current MethodTable
-void MethodTable::MethodDataObject::Init(MethodTable *pMT, MethodData *pParentData)
+void MethodTable::MethodDataObject::Init(MethodData *pParentData)
{
CONTRACTL {
THROWS;
WRAPPER(GC_TRIGGERS);
- PRECONDITION(CheckPointer(pMT));
+ PRECONDITION(CheckPointer(m_pDeclMT));
PRECONDITION(CheckPointer(pParentData, NULL_OK));
- PRECONDITION(!pMT->IsInterface());
+ PRECONDITION(!m_pDeclMT->IsInterface());
PRECONDITION(pParentData == NULL ||
- (pMT->ParentEquals(pParentData->GetDeclMethodTable()) &&
- pMT->ParentEquals(pParentData->GetImplMethodTable())));
+ (m_pDeclMT->ParentEquals(pParentData->GetDeclMethodTable()) &&
+ m_pDeclMT->ParentEquals(pParentData->GetImplMethodTable())));
} CONTRACTL_END;
- m_pMT = pMT;
m_iNextChainDepth = 0;
m_containsMethodImpl = FALSE;
return FALSE;
}
// Now move up the chain to the target.
- MethodTable *pMTCur = m_pMT;
+ MethodTable *pMTCur = m_pDeclMT;
for (UINT32 i = 0; pMTCur != NULL && i < iChainDepth; i++) {
pMTCur = pMTCur->GetParentMethodTable();
}
if (pMT->GetClass()->ContainsMethodImpls())
m_containsMethodImpl = TRUE;
- if (m_containsMethodImpl && pMT != m_pMT)
+ if (m_containsMethodImpl && pMT != m_pDeclMT)
return;
unsigned nVirtuals = pMT->GetNumVirtuals();
// We want to fill all methods introduced by the actual type we're gathering
// data for, and the virtual methods of the parent and above
- if (pMT == m_pMT)
+ if (pMT == m_pDeclMT)
{
if (m_containsMethodImpl && slot < nVirtuals)
continue;
{
WRAPPER_NO_CONTRACT;
_ASSERTE(slotNumber < GetNumMethods());
- return DispatchSlot(m_pMT->GetRestoredSlot(slotNumber));
+ return DispatchSlot(m_pDeclMT->GetRestoredSlot(slotNumber));
}
//==========================================================================================
if (pMDRet == NULL)
{
_ASSERTE(slotNumber < GetNumVirtuals());
- pMDRet = m_pMT->GetMethodDescForSlot(slotNumber);
+ pMDRet = m_pDeclMT->GetMethodDescForSlot(slotNumber);
_ASSERTE(CheckPointer(pMDRet));
pEntry->SetImplMethodDesc(pMDRet);
}
else
{
- _ASSERTE(slotNumber >= GetNumVirtuals() || pMDRet == m_pMT->GetMethodDescForSlot(slotNumber));
+ _ASSERTE(slotNumber >= GetNumVirtuals() || pMDRet == m_pDeclMT->GetMethodDescForSlot(slotNumber));
}
return pMDRet;
MethodDesc *MethodTable::MethodDataInterface::GetDeclMethodDesc(UINT32 slotNumber)
{
WRAPPER_NO_CONTRACT;
- return m_pMT->GetMethodDescForSlot(slotNumber);
+ return m_pDeclMT->GetMethodDescForSlot(slotNumber);
}
//==========================================================================================
const DispatchMapTypeID * rgDeclTypeIDs,
UINT32 cDeclTypeIDs,
MethodData * pDecl,
- MethodData * pImpl)
+ MethodData * pImpl) :
+ MethodData(pImpl->GetDeclMethodTable(), pDecl->GetDeclMethodTable())
{
WRAPPER_NO_CONTRACT;
Init(rgDeclTypeIDs, cDeclTypeIDs, pDecl, pImpl);
protected:
ULONG m_cRef;
+ MethodTable *const m_pImplMT;
+ MethodTable *const m_pDeclMT;
public:
- MethodData() : m_cRef(1) { LIMITED_METHOD_CONTRACT; }
+ MethodData(MethodTable *implMT, MethodTable *declMT) : m_cRef(1), m_pImplMT(implMT), m_pDeclMT(declMT) { LIMITED_METHOD_CONTRACT; }
virtual ~MethodData() { LIMITED_METHOD_CONTRACT; }
virtual MethodData *GetDeclMethodData() = 0;
- virtual MethodTable *GetDeclMethodTable() = 0;
+ MethodTable *GetDeclMethodTable() { return m_pDeclMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber) = 0;
virtual MethodData *GetImplMethodData() = 0;
- virtual MethodTable *GetImplMethodTable() = 0;
+ MethodTable *GetImplMethodTable() { return m_pImplMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber) = 0;
// Returns INVALID_SLOT_NUMBER if no implementation exists.
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber) = 0;
static UINT32 GetObjectSize(MethodTable *pMT);
// Constructor. Make sure you have allocated enough memory using GetObjectSize.
- inline MethodDataObject(MethodTable *pMT)
- { WRAPPER_NO_CONTRACT; Init(pMT, NULL); }
+ inline MethodDataObject(MethodTable *pMT) : MethodData(pMT, pMT)
+ { WRAPPER_NO_CONTRACT; Init(NULL); }
- inline MethodDataObject(MethodTable *pMT, MethodData *pParentData)
- { WRAPPER_NO_CONTRACT; Init(pMT, pParentData); }
+ inline MethodDataObject(MethodTable *pMT, MethodData *pParentData) : MethodData(pMT, pMT)
+ { WRAPPER_NO_CONTRACT; Init(pParentData); }
virtual ~MethodDataObject() { LIMITED_METHOD_CONTRACT; }
virtual MethodData *GetDeclMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetDeclMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber);
virtual MethodData *GetImplMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetImplMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber);
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber);
virtual MethodDesc *GetImplMethodDesc(UINT32 slotNumber);
virtual void InvalidateCachedVirtualSlot(UINT32 slotNumber);
virtual UINT32 GetNumVirtuals()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumVirtuals(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumVirtuals(); }
virtual UINT32 GetNumMethods()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetCanonicalMethodTable()->GetNumMethods(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetCanonicalMethodTable()->GetNumMethods(); }
protected:
- void Init(MethodTable *pMT, MethodData *pParentData);
+ void Init(MethodData *pParentData);
BOOL PopulateNextLevel();
- // This is the method table for the actual type we're gathering the data for
- MethodTable *m_pMT;
-
// This is used in staged map decoding - it indicates which type we will next decode.
UINT32 m_iNextChainDepth;
static const UINT32 MAX_CHAIN_DEPTH = UINT32_MAX;
{ LIMITED_METHOD_CONTRACT; return sizeof(MethodDataInterface); }
// Constructor. Make sure you have allocated enough memory using GetObjectSize.
- MethodDataInterface(MethodTable *pMT)
+ MethodDataInterface(MethodTable *pMT) : MethodData(pMT, pMT)
{
LIMITED_METHOD_CONTRACT;
CONSISTENCY_CHECK(CheckPointer(pMT));
CONSISTENCY_CHECK(pMT->IsInterface());
- m_pMT = pMT;
}
virtual ~MethodDataInterface()
{ LIMITED_METHOD_CONTRACT; }
//
virtual MethodData *GetDeclMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetDeclMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual MethodDesc *GetDeclMethodDesc(UINT32 slotNumber);
//
//
virtual MethodData *GetImplMethodData()
{ LIMITED_METHOD_CONTRACT; return this; }
- virtual MethodTable *GetImplMethodTable()
- { LIMITED_METHOD_CONTRACT; return m_pMT; }
virtual DispatchSlot GetImplSlot(UINT32 slotNumber)
- { WRAPPER_NO_CONTRACT; return DispatchSlot(m_pMT->GetRestoredSlot(slotNumber)); }
+ { WRAPPER_NO_CONTRACT; return DispatchSlot(m_pDeclMT->GetRestoredSlot(slotNumber)); }
virtual UINT32 GetImplSlotNumber(UINT32 slotNumber)
{ LIMITED_METHOD_CONTRACT; return slotNumber; }
virtual MethodDesc *GetImplMethodDesc(UINT32 slotNumber);
// Slot count data
//
virtual UINT32 GetNumVirtuals()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumVirtuals(); }
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumVirtuals(); }
virtual UINT32 GetNumMethods()
- { LIMITED_METHOD_CONTRACT; return m_pMT->GetNumMethods(); }
-
- protected:
- // This is the method table for the actual type we're gathering the data for
- MethodTable *m_pMT;
+ { LIMITED_METHOD_CONTRACT; return m_pDeclMT->GetNumMethods(); }
}; // class MethodDataInterface
//--------------------------------------------------------------------------------------
}
#endif // !FEATURE_PAL
-LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes);
-BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem);
-BOOL IsRuntimeStarted(DWORD *pdwStartupFlags);
-
void *GetCLRFunction(LPCSTR FunctionName)
{
LIMITED_METHOD_CONTRACT;
- if (strcmp(FunctionName, "EEHeapAllocInProcessHeap") == 0)
- {
- func = (void*)EEHeapAllocInProcessHeap;
- }
- else if (strcmp(FunctionName, "EEHeapFreeInProcessHeap") == 0)
{
- func = (void*)EEHeapFreeInProcessHeap;
- }
- else if (strcmp(FunctionName, "IsRuntimeStarted") == 0)
- {
- func = (void*)IsRuntimeStarted;
- }
- else {
_ASSERTE ("Unknown function name");
func = NULL;
}