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

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

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

            field.IsPublic = true;
        }