questions, my code, and request for help

Nov 25, 2013 at 11:24 PM
Here are my questions:

Can you change the return value of a c# method in a strong-named assembly with cinject while the assembly is running by injecting your own custom .dll which intercepts the call and modifies the return value?

If so, how would you format such a thing?

Here is my sample code, I'm new to programming, but I think cinject is very neat!

filename: test.dll
using System;
using System.Collections.Generic;
using System.Text;

namespace Test.Subtest
    class TestData
        int get_TestValues()
            return default(int);
I want to make all TestValues force return with an integer value of 1 with cinject. Possible?
Dec 11, 2013 at 9:38 AM
Hi lw1990,

Yes that is possible but you will have to write some logic for that.

I'll take an example of LogInjector to explain this to you but you will have to write your own injector for this.

Before the exit of the method, CInject adds a call to
Inside OnComplete method, you can use Reflection to know the calling method. Access a variable of the calling method and change its value.

You can follow instructions in to create your own injector from scratch.