mdMemberRef CCodeCoverage::RegisterSafeCuckooMethod(ModuleID moduleId) { ATLTRACE(_T("Registering %s(%d)"), CUCKOO_SAFE_METHOD_NAME, moduleId); // for modules we are going to instrument add our reference to the method marked // with the SecuritySafeCriticalAttribute CComPtr<IMetaDataEmit> metaDataEmit; COM_FAIL_RETURNMSG(m_profilerInfo->GetModuleMetaData(moduleId, ofRead | ofWrite, IID_IMetaDataEmit, (IUnknown**)&metaDataEmit), _T(" ::ModuleAttachedToAssembly => GetModuleMetaData(0x%x)")); mdModuleRef mscorlibRef; COM_FAIL_RETURNMSG(GetModuleRef(moduleId, MSCORLIB_NAME, mscorlibRef), _T(" ::ModuleAttachedToAssembly => GetModuleRef(0x%x)")); mdTypeDef nestToken; COM_FAIL_RETURNMSG(metaDataEmit->DefineTypeRefByName(mscorlibRef, CUCKOO_NEST_TYPE_NAME, &nestToken), _T(" ::ModuleAttachedToAssembly => DefineTypeRefByName(0x%x)")); mdMemberRef cuckooSafeToken; COM_FAIL_RETURNMSG(metaDataEmit->DefineMemberRef(nestToken, CUCKOO_SAFE_METHOD_NAME, visitedMethodCallSignature, sizeof(visitedMethodCallSignature), &cuckooSafeToken) , _T(" ::ModuleAttachedToAssembly => DefineMemberRef(0x%x)")); return cuckooSafeToken; }
mdMemberRef CCodeCoverage::RegisterSafeCuckooMethod(ModuleID moduleId, const WCHAR* moduleName) { ATLTRACE(_T("::RegisterSafeCuckooMethod(%X) => %s"), moduleId, CUCKOO_SAFE_METHOD_NAME); // for modules we are going to instrument add our reference to the method marked // with the SecuritySafeCriticalAttribute CComPtr<IMetaDataEmit> metaDataEmit; COM_FAIL_MSG_RETURN_ERROR(m_profilerInfo->GetModuleMetaData(moduleId, ofRead | ofWrite, IID_IMetaDataEmit, (IUnknown**)&metaDataEmit), _T(" ::RegisterSafeCuckooMethod(...) => GetModuleMetaData => 0x%X")); mdModuleRef mscorlibRef; COM_FAIL_MSG_RETURN_ERROR(GetModuleRef(moduleId, moduleName, mscorlibRef), _T(" ::RegisterSafeCuckooMethod(...) => GetModuleRef => 0x%X")); mdTypeDef nestToken; COM_FAIL_MSG_RETURN_ERROR(metaDataEmit->DefineTypeRefByName(mscorlibRef, CUCKOO_NEST_TYPE_NAME, &nestToken), _T(" ::RegisterSafeCuckooMethod(...) => DefineTypeRefByName => 0x%X")); mdMemberRef cuckooSafeToken; COM_FAIL_MSG_RETURN_ERROR(metaDataEmit->DefineMemberRef(nestToken, CUCKOO_SAFE_METHOD_NAME, visitedMethodCallSignature, sizeof(visitedMethodCallSignature), &cuckooSafeToken), _T(" ::RegisterSafeCuckooMethod(...) => DefineMemberRef => 0x%X")); return cuckooSafeToken; }