コード例 #1
0
ファイル: Jump.cs プロジェクト: dotnet-toolset/Netfuser
        public override void Mangle(ICFMangleContext context, Block.Regular block)
        {
            var fragments = context.SplitFragments(block);

            if (fragments.Count < 4)
            {
                return;
            }
            var current = fragments.First;

            while (current.Next != null)
            {
                var newFragment = new CilFragment(current.Value);
                context.AddJump(newFragment, current.Next.Value.First, true);
                current.Value = newFragment;
                current       = current.Next;
            }

            var first = fragments.First.Value;

            fragments.RemoveFirst();
            var last = fragments.Last.Value;

            fragments.RemoveLast();

            var newFragments = fragments.ToList();

            newFragments.Shuffle(Mangler.Rng);

            block.Fragment.Reset(first
                                 .Concat(newFragments.SelectMany(fragment => fragment))
                                 .Concat(last));
        }
コード例 #2
0
            public Expr(ICFMangleContext ctx)
                : base(ctx)
            {
                _invCompiled = new CilFragment();
                _stateVar    = new Local(ctx.Method.Module.CorLibTypes.Int32);
                var body = ctx.Method.Body;

                body.Variables.Add(_stateVar);
                body.InitLocals = true;
                var nm    = new IntGenerator(ctx.Mangler.Rng, ctx.Mangler.Options.MaxMangleIterations);
                var codec = nm.Generate();

                codec.ParameterResolver = p => p == nm.Argument ? _stateVar : null;
                _codec = codec;
                var emitter = DnextFactory.NewILEmitter(ctx.Method.Module, ctx.Importer, _invCompiled);

                codec.EmitDemangler(emitter);
            }
コード例 #3
0
            public Impl(Switch @switch, ICFMangleContext context)
            {
                _switch  = @switch;
                _context = context;
                _local   = new Local(_context.Method.Module.CorLibTypes.UInt32);
                _context.MethodBody.Variables.Add(_local);
                _context.MethodBody.InitLocals = true;

                var rng = _switch.Mangler.Rng;

                switch (rng.NextUInt32(2)) // case 2 is null predicate, which is OK
                {
                case 0:
                    _predicate = new SwitchPredicate.Xor(_context);
                    break;

                case 1:
                    _predicate = new SwitchPredicate.Expr(_context);
                    break;
                }
            }
コード例 #4
0
 public abstract void Mangle(ICFMangleContext context, Block.Regular block);
コード例 #5
0
 public Xor(ICFMangleContext ctx)
     : base(ctx)
 {
     _xorKey = ctx.Mangler.Rng.NextInt32();
 }
コード例 #6
0
 protected SwitchPredicate(ICFMangleContext technique)
 {
     _context = technique;
 }
コード例 #7
0
 public override void Mangle(ICFMangleContext context, Block.Regular block)
 {
     PropImpl.GetOrAdd(context, () => new Impl(this, context)).Mangle(block);
 }