Posted July 30, 201510 yr Hello Guys I am gonna to make a simple renamer for .Net Apps .. the problem is : after rename the (modules, types,methods .. etc) the file is not working this is the code which i am using private void button1_Click(object sender, EventArgs e) { Rename(AssemblyDef.Load("C:\\MyApp.exe")); } public void Rename(AssemblyDef AsmDef) { int xMod = 0; int xType = 0; int xMethod = 0; int xParameter = 0; int xField = 0; int xProperty = 0; foreach (ModuleDef ModDef in AsmDef.Modules) { ModDef.Name = "Mod_" + xMod; xMod += 1; foreach (TypeDef TypDef in ModDef.Types) { TypDef.Name = "Type_" + xType; xType += 1; foreach (MethodDef MthdDef in TypDef.Methods) { if (!MthdDef.IsConstructor && !MthdDef.IsRuntimeSpecialName) { MthdDef.Name = "Method_" + xMethod; xMethod += 1; foreach (ParamDef PrmDef in MthdDef.ParamDefs) { PrmDef.Name = "Parameter_" + xParameter; xParameter += 1; } } } foreach (FieldDef FldDef in TypDef.Fields) { FldDef.Name = "Field_" + xField; xField += 1; } foreach (PropertyDef PropDef in TypDef.Properties) { PropDef.Name = "Property_" + xProperty; xProperty += 1; } } } AsmDef.Write("C:\\MyApp11.exe"); } and this is the problem shown by dotNet Tracer v20.0 Thanks for you
July 30, 201510 yr private void button1_Click(object sender, EventArgs e) { Rename(AssemblyDef.Load("C:\\MyApp.exe")); } public void Rename(AssemblyDef AsmDef) { int xMod = 0; int xType = 0; int xMethod = 0; int xParameter = 0; int xField = 0; int xProperty = 0; foreach (ModuleDef ModDef in AsmDef.Modules) { ModDef.Name = "Mod_" + xMod.Tostring(); xMod += 1; foreach (TypeDef TypDef in ModDef.Types) { TypDef.Name = "Type_" + xType.Tostring(); xType += 1; foreach (MethodDef MthdDef in TypDef.Methods) { if (!MthdDef.IsSpecialName && !MthdDef.IsRuntimeSpecialName) { MthdDef.Name = "Method_" + xMethod.Tostring(); xMethod += 1; foreach (ParamDef PrmDef in MthdDef.ParamDefs) { PrmDef.Name = "Parameter_" + xParameter.Tostring(); xParameter += 1; } } } foreach (FieldDef FldDef in TypDef.Fields) { FldDef.Name = "Field_" + xField.Tostring(); xField += 1; } foreach (PropertyDef PropDef in TypDef.Properties) { PropDef.Name = "Property_" + xProperty.Tostring(); xProperty += 1; } } } AsmDef.Write("D:\\MyApp11.exe"); }Test.............
July 30, 201510 yr Author Thank you hakouabs brother .. unfortunately it does not work .. so temporarily i add this condition in "ModDef.Types" loop to ignore the Namespace shown in figure below .. because the problem come from it .. and its work fine if(TypDef.Namespace.EndsWith(".My")) { continue; } i need some solution to rename it also like in "Phoenix Protector" for example like this Edited July 30, 201510 yr by Sniper.ps
July 30, 201510 yr there is a reason why de4dot's renaming code is a bit longer than these couple lines. If you don't want to use it, which would be the easiest solution, i'd recommend to check the source tho
July 31, 201510 yr You need to exclude some things, certain symbols can't be renamed, or at least require further modification.For example resourcemanager, p/invokes etc..
July 31, 201510 yr Author Thank you li0nsar3c00l .. I'll read the de4dot code and learn from it You need to exclude some things, certain symbols can't be renamed, or at least require further modification.For example resourcemanager, p/invokes etc.. Thank you yq8 .. that's what I'll do .. and I'll study some of Obfuscators to know what should i modify .. Thank you again.
Create an account or sign in to comment