Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello ,
I was trying to patch a static member (which has a type of custom class I've created) from a static class in an exe file using dnlib. However it was not possible to do that do you have any idea ?
try
{
foreach (TypeDef type in asmDef.Types)
{
asmDef.Assembly.Name = Path.GetFileNameWithoutExtension(AsmName);
asmDef.Name = Path.GetFileName(AsmName);
if (type.Name == "Starting")
{
foreach (MethodDef method in type.Methods)
{
for (int i = 0; i < method.Body.Instructions.Count(); i++)
{
try
{
if (method.Body.Instructions[i].Operand.ToString().Contains("HostsList"))
{
MessageBox.Show(method.Body.Instructions[i].Operand.ToString());
method.Body.Instructions[i].Operand = new List<Host>() { new Host("127.0.0.1", 5900) };
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
}
}
I even tried to check the type with operator "is" like following :
method.Body.Instructions[i].Operand is List<Host>
and
((List<Host>)method.Body.Instructions[i].Operand).Add(new Host("127.0.0.1", 5900));
but it did not work too.
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.