コード例 #1
0
		public UnusedMethodsFinder(ModuleDef module, IEnumerable<MethodDef> possiblyUnusedMethods, MethodCollection removedMethods) {
			this.module = module;
			this.removedMethods = removedMethods;
			foreach (var method in possiblyUnusedMethods) {
				if (method != module.ManagedEntryPoint && !removedMethods.Exists(method))
					this.possiblyUnusedMethods[method] = true;
			}
		}
コード例 #2
0
        protected MethodCollection getRemovedMethods()
        {
            var removedMethods = new MethodCollection();

            removedMethods.add(getMethodsToRemove());
            removedMethods.addAndNested(getTypesToRemove());
            return(removedMethods);
        }
コード例 #3
0
        protected bool isTypeCalled(TypeDef decrypterType)
        {
            if (decrypterType == null)
            {
                return(false);
            }

            var decrypterMethods = new MethodCollection();

            decrypterMethods.addAndNested(decrypterType);

            var removedMethods = getRemovedMethods();

            foreach (var type in module.GetTypes())
            {
                foreach (var method in type.Methods)
                {
                    if (method.Body == null)
                    {
                        continue;
                    }
                    if (decrypterMethods.exists(method))
                    {
                        break;                          // decrypter type / nested type method
                    }
                    if (removedMethods.exists(method))
                    {
                        continue;
                    }

                    foreach (var instr in method.Body.Instructions)
                    {
                        switch (instr.OpCode.Code)
                        {
                        case Code.Call:
                        case Code.Callvirt:
                        case Code.Newobj:
                            var calledMethod = instr.Operand as IMethod;
                            if (calledMethod == null)
                            {
                                break;
                            }
                            if (decrypterMethods.exists(calledMethod))
                            {
                                return(true);
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            return(false);
        }
コード例 #4
0
ファイル: UnusedMethodsFinder.cs プロジェクト: haise0/de5dot
 public UnusedMethodsFinder(ModuleDef module, IEnumerable <MethodDef> possiblyUnusedMethods, MethodCollection removedMethods)
 {
     this.module         = module;
     this.removedMethods = removedMethods;
     foreach (var method in possiblyUnusedMethods)
     {
         if (method != module.ManagedEntryPoint && !removedMethods.Exists(method))
         {
             this.possiblyUnusedMethods[method] = true;
         }
     }
 }