When you use reflector to browse and analyze various. Net assemblies, especially when you are analyzing EXE files and are overwhelmed by hundreds of classes, we always hope to grasp the main line as soon as possible. Program Step by step. At this time, we usually need to "start from scratch"-find the program's entrypoint, that is, the entry function (usually the main function ).
Needless to say, if the main function has changed its name after obfuscation, even if it has not been obfuscated, it will take dozens of namespaces, finding the main function among hundreds of classes is not easy. We hope to find that the main function is a function provided by reflector! Unfortunately, I haven't found it for a long time (in fact, it does have this function ...... Right-click the menu on the assembly ).
However, I suddenly thought that it would take three minutes to find this function as a plug-in, which is far easier than turning it over.
The following describes how to bake the plug-in.
First, if you are not familiar with the reflector plug-in, you need to know that the reflector plug-in is an assembly that implements the reflector. ipackage interface. First, we add reflector.exe to reference and then use the following statement:
Using reflector;
Using reflector. codemodel;
You can use the various features it provides. Then, use icommandbarmanager to add a menu item "go to entrypoint" under "Tools", set the shortcut key (CTRL + E), and add the corresponding eventhandler for the menu item. (Note: You must select an assembly before you can jump to its entrypoint. If you select the type and members under the Assembly, an error is returned)
CompleteCodeAs follows:
Using System;
Using System. Windows. forms;
UsingReflector;
UsingReflector. codemodel;
Namespace Entrypointlookup
{
Public Class Pluginpackage: ipackage
{
Private Iwindowmanager m_windowsmanager;
Private Icommandbarmanager m_commandbarmanager;
Private Iassemblybrowser m_assemblybrowser;
Private Icommandbarbutton m_gotoentrypointbtn;
Public Void Load (iserviceprovider serviceprovider)
{
M_windowsmanager = (Iwindowmanager) serviceprovider. getservice ( Typeof (Iwindowmanager ));
M_commandbarmanager = (Icommandbarmanager) serviceprovider. getservice ( Typeof (Icommandbarmanager ));
M_assemblybrowser = (Iassemblybrowser) serviceprovider. getservice ( Typeof (Iassemblybrowser ));
Foreach (Icommandbarmenu item In M_commandbarmanager.commandbars [ " Menubar " ]. Items)
{
If (Item. identifier = " Tools " )
{
M_gotoentrypointbtn = Item. Items. addbutton ( " Go to entrypoint " , New Eventhandler (menuentrypoint_click), keys. Control | Keys. E );
}
}
}
Private Void Menuentrypoint_click ( Object Sender, eventargs E)
{
If (M_assemblybrowser ! = Null && M_assemblybrowser.activeitem ! = Null )
{
Iassembly assembly = M_assemblybrowser.activeitem As Iassembly;
If (Assembly ! = Null )
{
If (Assembly. entrypoint ! = Null )
{
M_assemblybrowser.activeitem = Assembly. entrypoint;
}
Else
{
M_windowsmanager.showmessage ( " We cannot find an entrypoint inside the current Assembly. " );
}
}
Else
{
M_windowsmanager.showmessage ( " Please click the top node of the Assembly first. " );
}
}
}
Public Void Unload ()
{
If (M_gotoentrypointbtn ! = Null )
{
Foreach (Icommandbarmenu item In M_commandbarmanager.commandbars [ " Menubar " ]. Items)
{
If (Item. identifier = " Tools " )
{< br> item. items. remove (m_gotoentrypointbtn);
}< BR >}