コード例 #1
0
        bool CompareMethod(IMethod method, BabelMethodreference babelMethodRef)
        {
            var sig = method.MethodSig;

            if (sig.Params.Count != babelMethodRef.Parameters.Length)
            {
                return(false);
            }
            if (method.Name != babelMethodRef.Name)
            {
                return(false);
            }
            if (sig.HasThis != babelMethodRef.HasThis)
            {
                return(false);
            }
            if (sig.GenParamCount != babelMethodRef.GenericArguments.Length)
            {
                return(false);
            }

            if (!new SigComparer().Equals(sig.RetType, babelMethodRef.ReturnType))
            {
                return(false);
            }

            for (int i = 0; i < babelMethodRef.Parameters.Length; i++)
            {
                if (!new SigComparer().Equals(sig.Params[i], babelMethodRef.Parameters[i].Type))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
 public MethodReferenceReader(ImageReader imageReader, BinaryReader reader, BabelMethodreference bmr)
 {
     this.imageReader = imageReader;
     this.reader      = reader;
     this.bmr         = bmr;
 }
コード例 #3
0
ファイル: ImageReader.cs プロジェクト: Predator75/de4dot
        List<MethodReference> getMethods(TypeDefinition declaringType, BabelMethodreference babelMethodRef)
        {
            var methods = new List<MethodReference>();

            var git = babelMethodRef.DeclaringType as GenericInstanceType;
            IGenericInstance gim = babelMethodRef.IsGenericMethod ? babelMethodRef : null;
            foreach (var method in declaringType.Methods) {
                if (compareMethod(MethodReferenceInstance.make(method, git, gim), babelMethodRef)) {
                    if (!babelMethodRef.IsGenericMethod)
                        methods.Add(memberReferenceConverter.convert(method));
                    else {
                        var gim2 = new GenericInstanceMethod(memberReferenceConverter.convert(method));
                        foreach (var arg in babelMethodRef.GenericArguments)
                            gim2.GenericArguments.Add(arg);
                        methods.Add(gim2);
                    }
                }
            }

            return methods;
        }
コード例 #4
0
ファイル: ImageReader.cs プロジェクト: Predator75/de4dot
        MethodReference getMethodReference(BabelMethodreference babelMethodRef)
        {
            var declaringType = resolve(babelMethodRef.DeclaringType);
            if (declaringType == null)
                return null;

            var methods = getMethods(declaringType, babelMethodRef);
            if (methods.Count != 1) {
                throw new ApplicationException(string.Format("Couldn't find one method named '{0}' in type {1}",
                                babelMethodRef.Name,
                                Utils.removeNewlines(declaringType)));
            }

            return methods[0];
        }
コード例 #5
0
ファイル: ImageReader.cs プロジェクト: Predator75/de4dot
        bool compareMethod(MethodReference method, BabelMethodreference babelMethodRef)
        {
            if (method.Parameters.Count != babelMethodRef.Parameters.Length)
                return false;
            if (method.Name != babelMethodRef.Name)
                return false;
            if (method.HasThis != babelMethodRef.HasThis)
                return false;
            if (method.GenericParameters.Count != babelMethodRef.GenericArguments.Length)
                return false;

            if (!MemberReferenceHelper.compareTypes(method.MethodReturnType.ReturnType, babelMethodRef.ReturnType))
                return false;

            for (int i = 0; i < babelMethodRef.Parameters.Length; i++) {
                if (!MemberReferenceHelper.compareTypes(method.Parameters[i].ParameterType, babelMethodRef.Parameters[i].ParameterType))
                    return false;
            }

            return true;
        }
コード例 #6
0
ファイル: ImageReader.cs プロジェクト: GreenDamTan/de4dot
		bool CompareMethod(IMethod method, BabelMethodreference babelMethodRef) {
			var sig = method.MethodSig;
			if (sig.Params.Count != babelMethodRef.Parameters.Length)
				return false;
			if (method.Name != babelMethodRef.Name)
				return false;
			if (sig.HasThis != babelMethodRef.HasThis)
				return false;
			if (sig.GenParamCount != babelMethodRef.GenericArguments.Length)
				return false;

			if (!new SigComparer().Equals(sig.RetType, babelMethodRef.ReturnType))
				return false;

			for (int i = 0; i < babelMethodRef.Parameters.Length; i++) {
				if (!new SigComparer().Equals(sig.Params[i], babelMethodRef.Parameters[i].Type))
					return false;
			}

			return true;
		}
コード例 #7
0
ファイル: ImageReader.cs プロジェクト: GreenDamTan/de4dot
		List<IMethod> GetMethods(TypeDef declaringType, BabelMethodreference babelMethodRef) {
			var methods = new List<IMethod>();

			var gis = babelMethodRef.DeclaringType as GenericInstSig;
			var gim = babelMethodRef.GenericArguments;
			foreach (var method in declaringType.Methods) {
				if (CompareMethod(GenericArgsSubstitutor.Create(method, gis, gim), babelMethodRef)) {
					if (!babelMethodRef.IsGenericMethod)
						methods.Add(memberRefConverter.Convert(method));
					else {
						var gim2 = new GenericInstMethodSig(babelMethodRef.GenericArguments);
						var ms = module.UpdateRowId(new MethodSpecUser(memberRefConverter.Convert(method), gim2));
						methods.Add(ms);
					}
				}
			}

			return methods;
		}
コード例 #8
0
		public MethodRefReader(ImageReader imageReader, IBinaryReader reader, BabelMethodreference bmr) {
			this.imageReader = imageReader;
			this.reader = reader;
			this.bmr = bmr;
		}