当前位置: 首页>>代码示例>>C++>>正文


C++ MethodDesc::GetLoaderModule方法代码示例

本文整理汇总了C++中MethodDesc::GetLoaderModule方法的典型用法代码示例。如果您正苦于以下问题:C++ MethodDesc::GetLoaderModule方法的具体用法?C++ MethodDesc::GetLoaderModule怎么用?C++ MethodDesc::GetLoaderModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MethodDesc的用法示例。


在下文中一共展示了MethodDesc::GetLoaderModule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StartUpdateILCodes

BOOL CInjection::StartUpdateILCodes( MethodTable * pMethodTable
	, CORINFO_METHOD_HANDLE pMethodHandle
	, mdMethodDef md
	, LPBYTE pBuffer
	, DWORD dwSize
	)
{
	if( s_nStatus != Status_Ready || !pMethodHandle )
		return FALSE;

	MethodDesc * pMethodDesc = (MethodDesc*)pMethodHandle;
	pMethodDesc->Reset();

	MethodDesc * pStripMethodDesc = pMethodDesc->StripMethodInstantiation();
	if( pStripMethodDesc )
		pStripMethodDesc->Reset();

	ILCodeBuffer tILCodeBuffer;
	tILCodeBuffer.pBuffer = pBuffer;
	tILCodeBuffer.dwSize = dwSize;
	tILCodeBuffer.bIsGeneric = FALSE;

	// this is a generic method
	if( pMethodDesc->ContainsGenericVariables() || pMethodDesc->HasClassOrMethodInstantiation() )
	{
		tILCodeBuffer.bIsGeneric = TRUE;
		MethodDesc * pWrappedMethodDesc = pMethodDesc->GetWrappedMethodDesc();
		if( pWrappedMethodDesc )
		{
			pWrappedMethodDesc->Reset();
		}

		// find out all the instantiations of this generic method
		Module * pModule = pMethodDesc->GetLoaderModule();
		AppDomain * pAppDomain = pMethodDesc->GetDomain();
		if( pModule )
		{
			LoadedMethodDescIterator * pLoadedMethodDescIter = new LoadedMethodDescIterator( pAppDomain, pModule, md);
			while(pLoadedMethodDescIter->Next())
			{
				MethodDesc * pMD = pLoadedMethodDescIter->Current();
				if( pMD )
					pMD->Reset();
			}
			delete pLoadedMethodDescIter;
		}
	}

	std::map< CORINFO_METHOD_HANDLE, ILCodeBuffer>::iterator iter = s_mpILBuffers.find(pMethodHandle);
	if( iter != s_mpILBuffers.end() )
	{
		LocalFree(iter->second.pBuffer);
		s_mpILBuffers.erase(iter);
	}

	
	s_mpILBuffers.insert( std::pair< CORINFO_METHOD_HANDLE, ILCodeBuffer>( pMethodHandle, tILCodeBuffer) );

	return TRUE;
}
开发者ID:Evit15,项目名称:-NET-Modify-IL-Code-during-Run-time,代码行数:60,代码来源:Injection.cpp


注:本文中的MethodDesc::GetLoaderModule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。