コード例 #1
0
        public static void ObfuscateMethodCalls(MethodDef target, int callLayers, List <ModuleDefMD> modules)
        {
            var callers = target.FindAllCallsToThisMethod(modules); // THIS HAS TO STAY AT THE TOP OF THE METHOD BECAUSE OTHERWISE IT WILL GRAB OBFUSCATOR GENERATED METHODS AND CAUSE A STACK OVERFLOW

            MethodDef lastTarget = target;

            for (int i = 0; i < callLayers; i++)
            {
                var callerMethod = CreateMethodCaller(lastTarget, "CALLERLAYER" + i.ToString());
                lastTarget = callerMethod;
            }

            ReplaceCallsToMethod(target, lastTarget, callers, modules);
        }