Have question i hope someone can help me with.
Is there anyway to read an object that you dont know the type of?
Basiclly i have an old application the source has been lost and the code was obfuscated:(
Now we need to get a list of information from an object within this application.
I have injected a DLL that accepts the object as a Object But my question is what do I do next?
How can I export all information in that object without casting it to its original object type (which i can't do)?
Here is the declaration for the class:
public class OurOrders : IEnumerator<>, IEnumerable<>, IEnumerable, IEnumerator, IDisposable |
Thanks for any help!!
VulpesPosted Apr 5, 2011, 7:37 AM
private void simpleButton1_Click(object sender, EventArgs e)
{
Type t = sender.GetType();
PropertyInfo[] pia = t.GetProperties();
string message = "";
foreach (PropertyInfo b in pia)
{
message += String.Format("Name : {0}, Value : {1}\r\n", b.Name, b.GetValue(obj, null));
}
MessageBox.Show(message);
}
james williamsPosted Apr 5, 2011, 8:51 AM
Just also found that there is an object dumper class that comes in:
C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033\CSharpSamples.zip
thanks again for the help!!
james williamsPosted Apr 5, 2011, 7:17 AM
thanks for the reply.
i just tried the below as an example. It does give me the name and type of property but not its value.
What i was more thinking of is a way to pass the object and that object is printed kinda like this:
Object
[0]=>String Value: [0]"Hello World"
[1]=>Method
[2]=>String[] Value: [0] "Val 1"
[1] "Val 2"
[2] "Val 3"
[3]=>Object Value:[0]
So like a snapshot of what the data in the specfic instance of that class.
Thanks again!
VulpesPosted Apr 5, 2011, 6:44 AM
If 'obj' is an instance of the lost class, then you could get the Type object from:
Type t = obj.GetType();
PropertyInfo[] pia = t.GetProperties();
and work from there.