示例#1
0
        public void InjectBefore(
            string sourceTypeName,
            string sourceMethodName,
            string targetTypeName,
            string targetMethodName,
            int instructionIndex,
            bool includeCallingObject = false,
            int includeArgumentCount  = 0,
            bool passArgumentsByRef   = false,
            bool useFullName          = false)
        {
            MethodBody targetMethodBody = CecilHelper
                                          .GetMethodDefinition(
                this._targetModule,
                targetTypeName,
                targetMethodName,
                useFullName).Body;
            Instruction instruction = targetMethodBody.Instructions[instructionIndex];

            this.InjectBefore(
                sourceTypeName,
                sourceMethodName,
                targetMethodBody,
                instruction,
                includeCallingObject,
                includeArgumentCount,
                passArgumentsByRef,
                useFullName);
        }
示例#2
0
        public void ReplaceByNopAt(string typeName, string methodName, int instructionIndex)
        {
            MethodDefinition method     = CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName);
            MethodBody       methodBody = method.Body;

            this.ReplaceByNop(methodBody, methodBody.Instructions[instructionIndex]);
        }
示例#3
0
        public void ClearAllButLast(string typeName, string methodName)
        {
            MethodDefinition method     = CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName);
            MethodBody       methodBody = method.Body;

            this.ClearAllButLast(methodBody);
        }
示例#4
0
        public void InjectBefore(
            string sourceTypeName,
            string sourceMethodName,
            MethodBody targetMethodBody,
            Instruction targetInstruction,
            bool includeCallingObject = false,
            int includeArgumentCount  = 0,
            bool passArgumentsByRef   = false,
            bool useFullName          = false)
        {
            MethodDefinition sourceMethod =
                CecilHelper.GetMethodDefinition(this._sourceModule, sourceTypeName, sourceMethodName, useFullName);
            MethodReference sourceMethodReference = CecilHelper.GetMethodReference(this._targetModule, sourceMethod);

            this.InjectBefore(
                sourceMethodReference,
                targetMethodBody,
                targetInstruction,
                includeCallingObject,
                includeArgumentCount,
                passArgumentsByRef);
        }
示例#5
0
 private MethodBody GetMethodBody(string typeName, string methodName) =>
 CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName).Body;
示例#6
0
        public void MakeMethodPublic(string typeName, string methodName)
        {
            MethodDefinition method = CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName);

            method.IsPublic = true;
        }
示例#7
0
        public void MakeFieldPublic(string typeName, string fieldName)
        {
            FieldDefinition field = CecilHelper.GetFieldDefinition(this._targetModule, typeName, fieldName);

            field.IsPublic = true;
        }