How do I change the OriginalFileName & InternalFileName assembly properties using mono.cecil?

167 views
Skip to first unread message

nauli...@gmail.com

unread,
Aug 3, 2017, 12:06:43 AM8/3/17
to mono-cecil
Hi,

I've used cecil to change a compiled assembly name (had to change both Name & MainModule.Name). after saving the PE to disk I was hoping the OriginalFileName property will get changed as well. 
It is part of the Version Info resource, which can't be accessed using Mono.cecil.

These attributes don't appear in the CustomAttributes collection as well.

Thank you!

Jb Evain

unread,
Aug 9, 2017, 12:05:31 AM8/9/17
to mono-...@googlegroups.com
Hey there,

Currently there's no API to add/modify/remove win32 unmanaged resources.

Jb

--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups "mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mono-cecil+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dataprot...@gmail.com

unread,
Jul 23, 2018, 5:53:31 PM7/23/18
to mono-cecil
AssemblyDefinition a = AssemblyDefinition.ReadAssembly(fileName);

                   foreach (CustomAttribute attribute in a.CustomAttributes)
                    {
                        if (attribute.AttributeType.Name == "AssemblyFileVersionAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, fileversion);
                        }

                        if (attribute.AttributeType.Name == "AssemblyTitleAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, fileDsc);
                        }

                        if (attribute.AttributeType.Name == "AssemblyDescriptionAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, comments);
                        }

                        if (attribute.AttributeType.Name == "AssemblyCompanyAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, compname);
                        }

                        if (attribute.AttributeType.Name == "AssemblyProductAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, prodname);
                        }

                        if (attribute.AttributeType.Name == "AssemblyProductAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, prodname);
                        }

                        if (attribute.AttributeType.Name == "AssemblyCopyrightAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, copyright);
                        }

                        if (attribute.AttributeType.Name == "InternalNameAttribute")
                        {
                            attribute.ConstructorArguments[0] =
                                new CustomAttributeArgument(a.MainModule.TypeSystem.String, a.Name);
Reply all
Reply to author
Forward
0 new messages