예제 #1
0
	HRESULT InjectedType::GetRVAFromKnownDefaultCtor(ATL::CComPtr<IMetaDataImport>& metaDataImport,
		const LPCWSTR knownTypeDefName,
		mdTypeDef* pKnownTypeDef,
		mdMethodDef* pKnownTypeDefaultCtorDef,
		ULONG* pCodeRVA)
	{
		GUARD_FAILURE_HRESULT(metaDataImport->FindTypeDefByName(knownTypeDefName, mdTokenNil, pKnownTypeDef));
		GUARD_FAILURE_HRESULT(metaDataImport->FindMethod(*pKnownTypeDef, L".ctor", ctorSignature, sizeof(ctorSignature), pKnownTypeDefaultCtorDef));
		GUARD_FAILURE_HRESULT(metaDataImport->GetMethodProps(*pKnownTypeDefaultCtorDef, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, pCodeRVA, nullptr));

		return S_OK;
	}
예제 #2
0
	bool InjectedType::HasTypeDef(const ModuleID moduleId, const LPCWSTR typeDefName) const
	{
		ATL::CComPtr<IMetaDataImport> metaDataImport;
		auto result = GetMetaDataImport(moduleId, metaDataImport);
		if (result != S_OK)
		{
			return false;
		}

		mdTypeDef systemObject = mdTokenNil;
		result = metaDataImport->FindTypeDefByName(typeDefName, mdTokenNil, &systemObject);
		return result == S_OK;
	}