getting or setting value on injecteed application

Sep 20, 2013 at 3:48 PM
Hello,
I have trouble with injectted application values. I am trying to get or set text value on injected application textbox field. Can you give me simple example i will be very appreciated.
Best regards.
Coordinator
Sep 21, 2013 at 3:09 AM
Hi erdemalkan,

I would require your sample code to be able to help you. Without the code, it is difficult to understand the issue you are facing.

Can you please paste your injector code and one method of your application in which you are trying to inject?

You go through set of tutorials on http://www.ganshani.com/tag/cinject/
Sep 21, 2013 at 10:41 AM
Ok I just add 2 line under Oninvoke Dont sure it is the right place. But this is not working

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CInject.Injections.Interfaces;
using CInject.Injections.Library;
using System.Windows.Forms;
using System.Reflection;
namespace MyApplication
{
public class MyLogInjector : ICInject
{
    #region ICInject Members


    public void OnInvoke(CInjection injection)
    {

        PropertyInfo propertyInfo = injection.Arguments.GetType().GetProperty("Form1.set_TextBox1");
        propertyInfo.SetValue(injection, Convert.ChangeType("HELLO World", propertyInfo.PropertyType), null);



        try
        {


            Console.WriteLine("Hey, I am called with following values-");
            for (int i = 0; i < injection.Arguments.Length; i++)
            {
                Console.WriteLine(String.Format("    [{0}]: {1}", i, injection.Arguments[i].ToString()));


            }
        }
        catch
        {
            throw;
        }
    }

    public void OnComplete()
    {
        Console.WriteLine("Hey, I have finished working! Good Bye!");
    }

    #endregion
}
}
Coordinator
Sep 21, 2013 at 12:50 PM
PropertyInfo propertyInfo = injection.Arguments.GetType().GetProperty("Form1.set_TextBox1");
injection.Arguments.GetType() will give you type of object[]

You need to check for the Argument index and then probably its DeclaringType that will give you the Windows Form object.

Then you can search for TextBox1
Sep 21, 2013 at 1:10 PM
I just want to try get or set value the application that i injected my dll. And i dont know how i can do this properly. i realy stucked here. My situation so simple . injected application have textbox and that textbox have a value "TEST". I would read that value then replace it with dllinject method. . I dont have any code except your injection class. because i dont know how i can set or get value from the other application with your injector. Could you do me a favor with sample code i will be realy appreciated

Best regards.
Erdem
Oct 1, 2013 at 3:32 PM
For example i injected your dll on ChatEditBox and i open chat editbox log file and it only show the properties. Cant read the values what editbox contains.
Can you give me an example or show me the road how i can do that?
Best regards


nvoked ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,620 [1] INFO MTGO_NET Completed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,620 [1] INFO MTGO_NET Clone executed in 0 mSec
2013-10-01 18:25:23,620 [1] INFO MTGO_NET Invoked ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,620 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,671 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,671 [1] INFO MTGO_NET Completed ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,671 [1] INFO MTGO_NET CopyFrom executed in 51.043399810791 mSec
2013-10-01 18:25:23,671 [1] INFO MTGO_NET Invoked ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,671 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,700 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Completed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Copy executed in 29.0214004516602 mSec
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Invoked ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Completed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Clone executed in 0 mSec
2013-10-01 18:25:23,700 [1] INFO MTGO_NET Invoked ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,700 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,700 [2] DEBUG MTGO_NET Destroyed ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,700 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,732 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,732 [1] INFO MTGO_NET Completed ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,732 [1] INFO MTGO_NET CopyFrom executed in 32.0265007019043 mSec
2013-10-01 18:25:23,732 [1] INFO MTGO_NET Invoked ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,732 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,750 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Completed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Copy executed in 18.0144996643066 mSec
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Invoked ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Completed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Clone executed in 0 mSec
2013-10-01 18:25:23,750 [1] INFO MTGO_NET Invoked ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,750 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,769 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,769 [1] INFO MTGO_NET Completed ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:23,769 [1] INFO MTGO_NET CopyFrom executed in 19.0153999328613 mSec
2013-10-01 18:25:23,769 [1] INFO MTGO_NET Invoked ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,769 [1] DEBUG MTGO_NET >> Paramerters: 1
2013-10-01 18:25:23,787 [1] DEBUG MTGO_NET [source]: WotC.MTGO.Client.CustomUI.ChatEditBox
2013-10-01 18:25:23,787 [1] INFO MTGO_NET Completed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:23,787 [1] INFO MTGO_NET Copy executed in 18.0149993896484 mSec
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.CopyFrom, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Clone, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.Copy, MTGO_NET
2013-10-01 18:25:25,624 [2] DEBUG MTGO_NET Destroyed ChatEditBox.CopyFrom, MTGO_NET
Coordinator
Oct 1, 2013 at 10:15 PM
You haven't provided the code yet so can't figure out what exactly you are doing.
public static object GetPropValue(object src, string propName)
 {
     return src.GetType().GetProperty(propName).GetValue(src, null);
 }
This should help you get the value of a property in any object. Make sure you are passing an argument object (not the list of arguments) to this method and required property.
Oct 2, 2013 at 10:12 AM
I just tried this code but couldn’t get any information
I tried to call GetProbValue with this line
MessageBox.Show(String.Format(GetPropValue(injection.Arguments[i], "get_txt1").ToString()));
This doesn’t work,
I know you warn me, I should pass argument object to method but forgive me I don’t know how to do that with my lack of c# knowledge.
I sent you where I inject the code.
This job is realy important for me and CInject looks great tool to do this.
Hope you help me about this problem
Best regards
Erdem
Coordinator
Dec 21, 2013 at 1:28 PM
Hi,

I've added ObjectValueInjector in the new release 1.4 with Sample Winform example.
That should be doing exactly what you want

Punit
Dec 23, 2013 at 12:05 PM

Great master.

Thank you for respond i will check immediately. J

Regards

Erdem..