Jump to content
Tuts 4 You

[C#, Dnlib] - How add args to method ?


r3xq1

Recommended Posts

var module = ModuleDefMD.Load(@"C:\Temp\DemoDLL.dll");
            var type = module.GetTypes().FirstOrDefault(t => t.Name == "Demo");

            // Create the Main signature
            var main = new MethodDefUser("Main", MethodSig.CreateStatic(module.CorLibTypes.Void, new SZArraySig(module.CorLibTypes.String)))
            {
                Attributes = MethodAttributes.Static,
                ImplAttributes = MethodImplAttributes.IL | MethodImplAttributes.Managed
            };

            // Add Main param
            main.ParamDefs.Add(new ParamDefUser("args", 1));

            // Create Main body
            var mainBody = new CilBody();
            main.Body = mainBody;

            // Instance of Execute method
            var exec = type.Methods.FirstOrDefault(m => m.Name == "Execute");
var exec = type.Methods.FirstOrDefault(m => m.Name == "Execute"); // - This Line Execute 

How add 2 arguments to the Execute(string line, string key)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...