I need to enumerate all methods in a .NET module and check if they have tiny or fat header. I decided to use the powerful dnlib .NET modules handling library.
There is a dnlib.DotNet.Writer.MethodBody
class that indicates the tiny/fat method header (see IsTiny()
and IsFat()
). However, I have no idea how to access this class.
The class is located in the Writer namespace - let's use the Writer Listener:
public void OnWriterEvent(ModuleWriterBase writer, ModuleWriterEvent evt)
{
Note that it's easy to enumerate all methods and get the other MethodBody
, the one in Emit
namespace:
foreach (TypeDef type in module.GetTypes())
{
foreach (MethodDef method in type.Methods)
{
dnlib.DotNet.Emit.MethodBody body = method.MethodBody;
}
}
}
Unfortunately this class doesn't reveal anything useful. I believe something similar to the following pseudocode should work:
public void OnWriterEvent(ModuleWriterBase writer, ModuleWriterEvent evt)
{
foreach (TypeDef type in module.?)
{
foreach (? method in type.?)
{
dnlib.DotNet.Writer.MethodBody body = method.?;
}
}
}