Exemple #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);
        }
        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]);
        }
        public void ClearAllButLast(string typeName, string methodName)
        {
            MethodDefinition method     = CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName);
            MethodBody       methodBody = method.Body;

            this.ClearAllButLast(methodBody);
        }
Exemple #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);
        }
Exemple #5
0
 private MethodBody GetMethodBody(string typeName, string methodName) =>
 CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName).Body;
Exemple #6
0
        public void MakeMethodPublic(string typeName, string methodName)
        {
            MethodDefinition method = CecilHelper.GetMethodDefinition(this._targetModule, typeName, methodName);

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

            field.IsPublic = true;
        }