Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[dnlib] .Net Renamer problem

Featured Replies

Posted

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


 


i_6634cb91081.png


 


 


Thanks for you


 


  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.............

  • 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_2bb8c9de0b1.png


 


 


i need some solution to rename it also like in "Phoenix Protector" for example like this


 


i_d1f9dce2c41.png


Edited by Sniper.ps

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


You need to exclude some things, certain symbols can't be renamed, or at least require further modification.

For example resourcemanager, p/invokes etc..

  • 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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.