I have a C# program and it has a class:
public class Test
{
internal const string a = "some value";
private DateTime b = new DateTime();
}
How can I use Mono Cecil to change their initial value so that it looks like this:
public class Test
{
internal const string a = "test";
private DateTime b = DateTime.MaxValue;
}
Right now I only have the following skeleton code and I don't know how to modify the fields.
void Main()
{
var input = @"C:\my_projects\a.exe";
var asm = AssemblyDefinition.ReadAssembly(input);
foreach (ModuleDefinition module in asm.Modules)
{
foreach (TypeDefinition type in module.GetTypes())
{
foreach (var field in type.Fields)
{
if (field.Name == "a")
{
}
else if (field.Name == "b")
{
}
}
}
}
asm.Write(@"c:\my_projects\b.exe");
}