• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# blocks.Blocks类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中de4dot.blocks.Blocks的典型用法代码示例。如果您正苦于以下问题:C# Blocks类的具体用法?C# Blocks怎么用?C# Blocks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Blocks类属于de4dot.blocks命名空间,在下文中一共展示了Blocks类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: deobfuscate

        public bool deobfuscate(Blocks blocks)
        {
            if (blocks.Method.Name != ".cctor" && blocks.Method.Name != ".ctor")
                return false;
            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count - 2; i++) {
                    var ldtoken = instrs[i];
                    if (ldtoken.OpCode.Code != Code.Ldtoken)
                        continue;

                    var call1 = instrs[i + 1];
                    if (call1.OpCode.Code != Code.Call && call1.OpCode.Code != Code.Callvirt)
                        continue;
                    if (!DotNetUtils.isMethod(call1.Operand as IMethod, "System.Type", "(System.RuntimeTypeHandle)"))
                        continue;

                    var call2 = instrs[i + 2];
                    if (call2.OpCode.Code != Code.Call && call2.OpCode.Code != Code.Callvirt)
                        continue;
                    if (!MethodEqualityComparer.CompareDeclaringTypes.Equals(call2.Operand as IMethod, strongNameCheckMethod))
                        continue;

                    block.remove(i, 3);
                    return true;
                }
            }
            return false;
        }
开发者ID:n017,项目名称:ConfuserDeobfuscator,代码行数:29,代码来源:StrongNameChecker.cs


示例2: ParseBody

        public void ParseBody()
        {
            var blocks = new Blocks(Method).MethodBlocks.GetAllBlocks();

            foreach (var blockAnalyzer in blocks.Select(block => new BlockAnalyzer(block)))
                Expressions.AddRange(blockAnalyzer.GenerateExpressions());
        }
开发者ID:crajeshbe,项目名称:ILAST,代码行数:7,代码来源:BodyAnalyzer.cs


示例3: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count; i++) {
                    var call = instrs[i];
                    if (call.OpCode.Code != Code.Call)
                        continue;
                    var calledMethod = call.Operand as MethodDefinition;
                    if (calledMethod == null)
                        continue;

                    MethodReference newMethod = null;
                    if (calledMethod == getManifestResourceStream1Method)
                        newMethod = Assembly_GetManifestResourceStream1;
                    else if (calledMethod == getManifestResourceStream2Method)
                        newMethod = Assembly_GetManifestResourceStream2;
                    else if (calledMethod == getManifestResourceNamesMethod)
                        newMethod = Assembly_GetManifestResourceNames;
                    if (newMethod == null)
                        continue;

                    instrs[i] = new Instr(Instruction.Create(OpCodes.Callvirt, newMethod));
                }
            }
        }
开发者ID:ByteCatcher,项目名称:de4dot,代码行数:26,代码来源:GetManifestResourceRestorerBase.cs


示例4: remove

        public bool remove(Blocks blocks)
        {
            if (antiStrongNameMethod == null)
                return false;

            Block antiSnBlock;
            int numInstructions;
            if (!findBlock(blocks, out antiSnBlock, out numInstructions))
                return false;

            if (antiSnBlock.FallThrough == null || antiSnBlock.Targets == null || antiSnBlock.Targets.Count != 1)
                throw new ApplicationException("Invalid state");

            var goodBlock = antiSnBlock.Targets[0];
            var badBlock = antiSnBlock.FallThrough;

            antiSnBlock.replaceLastInstrsWithBranch(numInstructions, goodBlock);

            if (badBlock.FallThrough == badBlock && badBlock.Sources.Count == 1 && badBlock.Targets == null) {
                badBlock.Parent.removeGuaranteedDeadBlock(badBlock);
                return true;
            }
            if (badBlock.Instructions.Count <= 1 && badBlock.LastInstr.OpCode.Code == Code.Nop) {
                if (badBlock.FallThrough != null && badBlock.Targets == null && badBlock.Sources.Count == 0) {
                    var badBlock2 = badBlock.FallThrough;
                    if (badBlock2.FallThrough == badBlock2 && badBlock2.Sources.Count == 2 && badBlock2.Targets == null) {
                        badBlock.Parent.removeGuaranteedDeadBlock(badBlock);
                        badBlock2.Parent.removeGuaranteedDeadBlock(badBlock2);
                        return true;
                    }
                }
            }

            throw new ApplicationException("Invalid state");
        }
开发者ID:Joelone,项目名称:de4dot,代码行数:35,代码来源:AntiStrongname.cs


示例5: Deobfuscate

		public void Deobfuscate(Blocks blocks) {
			if (type == null)
				return;

			foreach (var block in blocks.MethodBlocks.GetAllBlocks()) {
				var instrs = block.Instructions;
				for (int i = 0; i < instrs.Count - 1; i++) {
					var instr = instrs[i];
					if (instr.OpCode.Code != Code.Ldc_I4)
						continue;
					var call = instrs[i + 1];
					if (call.OpCode.Code != Code.Call)
						continue;
					var method = call.Operand as IMethod;
					if (method == null)
						continue;
					if (!new SigComparer().Equals(type, method.DeclaringType))
						continue;
					var methodDef = DotNetUtils.GetMethod(module, method);
					if (methodDef == null)
						continue;
					if (methodDef != typeMethod && methodDef != fieldMethod)
						continue;

					uint token = (uint)(int)instrs[i].Operand;
					instrs[i] = new Instr(OpCodes.Nop.ToInstruction());
					instrs[i + 1] = new Instr(new Instruction(OpCodes.Ldtoken, module.ResolveToken(token) as ITokenOperand));
				}
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:30,代码来源:MetadataTokenObfuscator.cs


示例6: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count; i++) {
                    var instr = instrs[i];

                    if (instr.OpCode.Code == Code.Call || instr.OpCode.Code == Code.Callvirt) {
                        if (blocks.Method.DeclaringType == decrypterType)
                            continue;
                        var calledMethod = instr.Operand as MethodReference;
                        if (calledMethod != null && calledMethod.DeclaringType == decrypterType)
                            canRemoveType = false;
                    }
                    else if (instr.OpCode.Code == Code.Ldsfld) {
                        if (instr.OpCode.Code != Code.Ldsfld)
                            continue;
                        var field = instr.Operand as FieldReference;
                        if (field == null)
                            continue;
                        var decrypted = fieldToDecryptedString.find(field);
                        if (decrypted == null)
                            continue;

                        instrs[i] = new Instr(Instruction.Create(OpCodes.Ldstr, decrypted));
                        Log.v("Decrypted string: {0}", Utils.toCsharpString(decrypted));
                    }
                }
            }
        }
开发者ID:Predator75,项目名称:de4dot,代码行数:30,代码来源:StringDecrypter.cs


示例7: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            if (type == null)
                return;

            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count - 1; i++) {
                    var instr = instrs[i];
                    if (instr.OpCode.Code != Code.Ldc_I4)
                        continue;
                    var call = instrs[i + 1];
                    if (call.OpCode.Code != Code.Call)
                        continue;
                    var method = call.Operand as MethodReference;
                    if (method == null)
                        continue;
                    if (!MemberReferenceHelper.compareTypes(type, method.DeclaringType))
                        continue;
                    var methodDef = DotNetUtils.getMethod(module, method);
                    if (methodDef == null)
                        continue;
                    if (methodDef != typeMethod && methodDef != fieldMethod)
                        continue;

                    int token = (int)instrs[i].Operand;
                    instrs[i] = new Instr(Instruction.Create(OpCodes.Nop));
                    instrs[i + 1] = new Instr(new Instruction(OpCodes.Ldtoken, module.LookupToken(token) as MemberReference));
                }
            }
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:31,代码来源:MetadataTokenObfuscator.cs


示例8: cleanUp

        public IEnumerable<FieldDef> cleanUp()
        {
            var removedFields = new List<FieldDef>();
            var moduleCctor = DotNetUtils.getModuleTypeCctor(module);
            if (moduleCctor == null)
                return removedFields;
            var moduleCctorBlocks = new Blocks(moduleCctor);

            var keep = findFieldsToKeep();
            foreach (var fieldInfo in fieldToInfo.getValues()) {
                if (keep.ContainsKey(fieldInfo))
                    continue;
                if (removeInitCode(moduleCctorBlocks, fieldInfo)) {
                    removedFields.Add(fieldInfo.field);
                    removedFields.Add(fieldInfo.arrayInitField);
                }
                fieldInfo.arrayInitField.InitialValue = new byte[1];
                fieldInfo.arrayInitField.FieldSig.Type = module.CorLibTypes.Byte;
                fieldInfo.arrayInitField.RVA = 0;
            }

            IList<Instruction> allInstructions;
            IList<ExceptionHandler> allExceptionHandlers;
            moduleCctorBlocks.getCode(out allInstructions, out allExceptionHandlers);
            DotNetUtils.restoreBody(moduleCctorBlocks.Method, allInstructions, allExceptionHandlers);
            return removedFields;
        }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:27,代码来源:ArrayBlockState.cs


示例9: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count - 2; i++) {
                    var ldsfld = instrs[i];
                    if (ldsfld.OpCode.Code != Code.Ldsfld)
                        continue;

                    var ldci4 = instrs[i + 1];
                    if (!ldci4.isLdcI4())
                        continue;

                    var stfld = instrs[i + 2];
                    if (stfld.OpCode.Code != Code.Stfld)
                        continue;

                    var field = stfld.Operand as FieldReference;
                    if (!MemberReferenceHelper.compareFieldReferenceAndDeclaringType(enumField, field))
                        continue;
                    block.remove(i, 3);
                    i--;
                }
            }
        }
开发者ID:Joelone,项目名称:de4dot,代码行数:25,代码来源:EnumClassFinder.cs


示例10: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count - 2; i++) {
                    var ldsfld = instrs[i];
                    if (ldsfld.OpCode.Code != Code.Ldsfld)
                        continue;

                    var ldci4 = instrs[i + 1];
                    if (!ldci4.isLdcI4())
                        continue;

                    var stfld = instrs[i + 2];
                    if (stfld.OpCode.Code != Code.Stfld)
                        continue;

                    var field = stfld.Operand as IField;
                    if (!FieldEqualityComparer.CompareDeclaringTypes.Equals(enumField, field))
                        continue;
                    block.remove(i, 3);
                    i--;
                }
            }
        }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:25,代码来源:EnumClassFinder.cs


示例11: deobfuscate

        public void deobfuscate(Blocks blocks)
        {
            var removeInfos = new Dictionary<Block, List<RemoveInfo>>();

            var allBlocks = blocks.MethodBlocks.getAllBlocks();
            foreach (var block in allBlocks) {
                var instrs = block.Instructions;
                for (int i = 0; i < instrs.Count; i++) {
                    var instr = instrs[i];
                    if (instr.OpCode == OpCodes.Ldsfld) {
                        var di = getDelegateInfo(instr.Operand as FieldReference);
                        if (di == null)
                            continue;

                        var visited = new Dictionary<Block, bool>();
                        var callInfo = findProxyCall(di, block, i, visited, 1);
                        if (callInfo != null) {
                            add(removeInfos, block, i, null);
                            add(removeInfos, callInfo.Block, callInfo.Index, di);
                        }
                        else {
                            Log.w("Could not fix proxy call. Method: {0} ({1:X8}), Proxy type: {2} ({3:X8})",
                                blocks.Method, blocks.Method.MetadataToken.ToInt32(),
                                di.field.DeclaringType, di.field.DeclaringType.MetadataToken.ToInt32());
                        }
                    }
                    else if (instr.OpCode == OpCodes.Call) {
                        var method = instr.Operand as MethodDefinition;
                        if (method == null)
                            continue;
                        FieldDefinition field;
                        if (!proxyMethodToField.TryGetValue(method, out field))
                            continue;
                        var di = getDelegateInfo(field);
                        if (di == null)
                            continue;
                        add(removeInfos, block, i, di);
                    }
                }
            }

            foreach (var block in removeInfos.Keys) {
                var list = removeInfos[block];
                var removeIndexes = new List<int>(list.Count);
                foreach (var info in list) {
                    if (info.IsCall) {
                        var opcode = info.DelegateInfo.callOpcode;
                        var newInstr = Instruction.Create(opcode, info.DelegateInfo.methodRef);
                        block.replace(info.Index, 1, newInstr);
                    }
                    else
                        removeIndexes.Add(info.Index);
                }
                block.remove(removeIndexes);
            }

            fixBrokenCalls(blocks.Method, allBlocks);
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:58,代码来源:ProxyDelegateFinderBase.cs


示例12: Remove

		public bool Remove(Blocks blocks) {
			var allBlocks = blocks.MethodBlocks.GetAllBlocks();
			foreach (var block in allBlocks) {
				if (Remove(blocks, block))
					return true;
			}

			return false;
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:9,代码来源:AntiStrongName.cs


示例13: find

        bool find(Blocks blocks, out TryBlock tryBlock)
        {
            tryBlock = null;

            foreach (var bb in blocks.MethodBlocks.BaseBlocks) {
                tryBlock = bb as TryBlock;
                if (tryBlock == null)
                    continue;
                if (tryBlock.TryHandlerBlocks.Count != 1)
                    continue;
                var catchBlock = tryBlock.TryHandlerBlocks[0];
                if (catchBlock.HandlerType != ExceptionHandlerType.Catch ||
                    catchBlock.CatchType.FullName != "System.Exception") {
                    continue;
                }
                if (catchBlock.BaseBlocks.Count != 1)
                    continue;
                var handlerBlock = catchBlock.BaseBlocks[0] as HandlerBlock;
                if (handlerBlock == null)
                    continue;

                int calls = 0;
                Instr callInstr = null;
                bool failed = false;
                foreach (var bb2 in handlerBlock.BaseBlocks) {
                    var block = bb2 as Block;
                    if (block == null) {
                        failed = true;
                        break;
                    }
                    foreach (var instr in block.Instructions) {
                        switch (instr.OpCode.Code) {
                        case Code.Call:
                        case Code.Calli:
                        case Code.Callvirt:
                            calls++;
                            callInstr = instr;
                            break;
                        }
                    }
                }
                if (failed || calls != 1 || callInstr.OpCode.Code != Code.Call)
                    continue;
                var calledMethod = callInstr.Operand as MethodReference;
                if (calledMethod == null)
                    continue;
                if (!isExceptionLogger(calledMethod))
                    continue;

                return true;
            }

            return false;
        }
开发者ID:Joelone,项目名称:de4dot,代码行数:54,代码来源:ExceptionLoggerRemover.cs


示例14: remove

        public bool remove(Blocks blocks)
        {
            if (!HasExceptionLoggers)
                return false;

            TryBlock tryBlock;
            if (!find(blocks, out tryBlock))
                return false;

            blocks.MethodBlocks.removeTryBlock(tryBlock);
            NumRemovedExceptionLoggers++;
            return true;
        }
开发者ID:Joelone,项目名称:de4dot,代码行数:13,代码来源:ExceptionLoggerRemover.cs


示例15: FindTamperBlocks

		TamperBlocks FindTamperBlocks(Blocks blocks, IList<Block> allBlocks) {
			var tamperBlocks = new TamperBlocks();

			if (!FindFirstBlocks(tamperBlocks, allBlocks, blocks.Locals))
				return null;

			var second = tamperBlocks.second;
			var badBlock = second.Block.LastInstr.IsBrfalse() ? second.Block.Targets[0] : second.Block.FallThrough;
			tamperBlocks.bad = FindBadBlock(badBlock);
			if (tamperBlocks.bad == null)
				return null;

			return tamperBlocks;
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:14,代码来源:TamperProtectionRemover.cs


示例16: deobfuscate

 public void deobfuscate(Blocks blocks)
 {
     foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
         var instrs = block.Instructions;
         for (int i = 0; i < instrs.Count; i++) {
             var call = instrs[i];
             if (call.OpCode.Code != Code.Call)
                 continue;
             var realInstanceMethod = classMethods.find(call.Operand as IMethod);
             if (realInstanceMethod == null)
                 continue;
             call.Operand = realInstanceMethod;
         }
     }
 }
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:15,代码来源:SpicesMethodCallInliner.cs


示例17: decrypt

        public int decrypt(Blocks theBlocks)
        {
            try {
                blocks = theBlocks;
                callResults = new List<CallResult>();
                allBlocks = new List<Block>(blocks.MethodBlocks.getAllBlocks());

                findAllCallResults();
                inlineAllCalls();
                inlineReturnValues();
                return callResults.Count;
            }
            finally {
                blocks = null;
                callResults = null;
                allBlocks = null;
                variableValues = null;
            }
        }
开发者ID:ldh0227,项目名称:de4dot,代码行数:19,代码来源:MethodReturnValueInliner.cs


示例18: Deobfuscate

		public void Deobfuscate(Blocks blocks) {
			foreach (var block in blocks.MethodBlocks.GetAllBlocks()) {
				var instrs = block.Instructions;
				for (int i = 0; i < instrs.Count - 1; i++) {
					var first = instrs[i];
					var second = instrs[i + 1];
					if (first.OpCode.Code == Code.Not && second.OpCode.Code == Code.Neg) {
						// It's increment
						instrs[i] = new Instr(OpCodes.Ldc_I4_1.ToInstruction());
						instrs[i + 1] = new Instr(OpCodes.Add.ToInstruction());
					}
					else if (first.OpCode.Code == Code.Neg && second.OpCode.Code == Code.Not) {
						// It's decrement
						instrs[i] = new Instr(OpCodes.Ldc_I4_1.ToInstruction());
						instrs[i + 1] = new Instr(OpCodes.Sub.ToInstruction());
					}
				}
			}
		}
开发者ID:GreenDamTan,项目名称:de4dot,代码行数:19,代码来源:LogicalExpressionFixer.cs


示例19: deobfuscate

 public void deobfuscate(Blocks blocks)
 {
     foreach (var block in blocks.MethodBlocks.getAllBlocks()) {
         var instrs = block.Instructions;
         for (int i = 0; i < instrs.Count; i++) {
             var instr = instrs[i];
             if (instr.OpCode.Code != Code.Newobj)
                 continue;
             var ctor = instr.Operand as MethodReference;
             if (ctor == null)
                 continue;
             var newCtor = resourceManagerCtors.find(ctor);
             if (newCtor == null)
                 newCtor = componentManagerCtors.find(ctor);
             if (newCtor == null)
                 continue;
             instr.Operand = newCtor;
         }
     }
 }
开发者ID:Predator75,项目名称:de4dot,代码行数:20,代码来源:ResourceNamesRestorer.cs


示例20: RemoveResolveHandlerCode

		static bool RemoveResolveHandlerCode(Blocks blocks, MethodDef handler, string installHandlerMethod) {
			bool modified = false;
			foreach (var block in blocks.MethodBlocks.GetAllBlocks()) {
				var instrs = block.Instructions;
				for (int i = 0; i < instrs.Count - 4; i++) {
					var call = instrs[i];
					if (call.OpCode.Code != Code.Call)
						continue;
					var calledMethod = call.Operand as IMethod;
					if (calledMethod == null || calledMethod.FullName != "System.AppDomain System.AppDomain::get_CurrentDomain()")
						continue;

					if (instrs[i + 1].OpCode.Code != Code.Ldnull)
						continue;

					var ldftn = instrs[i + 2];
					if (ldftn.OpCode.Code != Code.Ldftn)
						continue;
					if (ldftn.Operand != handler)
						continue;

					var newobj = instrs[i + 3];
					if (newobj.OpCode.Code != Code.Newobj)
						continue;
					var ctor = newobj.Operand as IMethod;
					if (ctor == null || ctor.FullName != "System.Void System.ResolveEventHandler::.ctor(System.Object,System.IntPtr)")
						continue;

					var callvirt = instrs[i + 4];
					if (callvirt.OpCode.Code != Code.Callvirt)
						continue;
					calledMethod = callvirt.Operand as IMethod;
					if (calledMethod == null || calledMethod.FullName != installHandlerMethod)
						continue;

					block.Remove(i, 5);
					modified = true;
				}
			}
			return modified;
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:41,代码来源:ConfuserUtils.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# cflow.Int32Value类代码示例发布时间:2022-05-26
下一篇:
C# blocks.Block类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap