Posted March 30, 20178 yr Hello I have some issue with dnlib when I want to get variables and their values in C# I can get variable count for example in Form1_Load and other methods but variable's name have null values. https://j00i.imgup.net/17563.pnghttps://m07i.imgup.net/20e1a.png What can I do ?
March 30, 20178 yr Follow the code so let's say the variable id is 0 and type is string so in the ilcode it will look like ldstr "string value" stloc.0
March 30, 20178 yr Author Thanks for reply. I think the problem is not about target's ilcodehttps://l72i.imgup.net/38055.png maybe I have mistake in my code for example I use this code in foreach loop foreach (TypeDef type in mod.GetTypes()) { if (type.BaseType != null) if (type.BaseType.ToString() == "System.Windows.Forms.Form") { Console.WriteLine(" Name: {0}", type.FullName); Console.WriteLine(" Methods: {0}", type.Methods.Count); Console.WriteLine(" Fields: {0}", type.Fields.Count); Console.WriteLine(); foreach (MethodDef method in type.Methods) { Console.WriteLine(method.Body.Variables); } } } Edited March 30, 20178 yr by Mahmoudnia
April 1, 20178 yr Author So, there is no solution at all ? I changed code to this but vr.Name has still null value . foreach (MethodDef method in type.Methods) { //my commands if (method.HasBody && method.Body.HasVariables) { foreach (var vr in method.Body.Variables) { vr.Name = GenerateName(); } } }
Create an account or sign in to comment