Is it possible to extract the header of a DLL? If yes, how?

1

Is it possible to extract header from a dll ? Is this practice possible? If so, how can I do it?

    
asked by anonymous 16.02.2016 / 19:47

1 answer

0

If you are using C #, use the class FileVersionInfo :

myFileVersionInfo = FileVersionInfo.GetVersionInfo("dll-alvo.dll");

Instance properties expose the build details - for example CompanyName , ProductName , and ProductVersion .

To extract the classes of a given assembly , you need to use reflection :

Assembly assembly = Assembly.ReflectionOnlyLoadFrom("dll-alvo.dll");

foreach (Type tc in assembly .GetTypes())
{
    Console.WriteLine(tc.FullName);
}

And finally listing all methods of a given class:

    foreach (Type tc in assembly .GetTypes())
        {
            if (tc.IsAbstract)
            {
                Console.WriteLine("Abstract Class : " + tc.Name);
            }
            else if (tc.IsPublic)
            {
                Console.WriteLine("Public Class : " + tc.Name);
            }
            else if (tc.IsSealed)
            {
                Console.WriteLine("Sealed Class : " + tc.Name);
            }  

            //Obtém lista de nomes de métodos
            MemberInfo[] methodName = tc.GetMethods();

            foreach (MemberInfo method in methodName)
            {
                if (method.ReflectedType.IsPublic)
                {
                    Console.WriteLine("Método público : " + method.Name.ToString());
                }
                else
                {
                    Console.WriteLine("Método não público : " + method.Name.ToString());
                }
            }
        }

Sources: 1 , 2 .

    
16.02.2016 / 19:56