ioncodes / dnpatch

.NET Patcher library using dnlib
MIT License
313 stars 48 forks source link

GetEntryPointTarget() #12

Closed SlowLogicBoy closed 7 years ago

SlowLogicBoy commented 7 years ago

returns target for _module.EntryPoint null if doesn't have

ioncodes commented 7 years ago

Can you add an example?

SlowLogicBoy commented 7 years ago
var target = patcher.GetEntryPointTarget();
target.Instructions = {
    Instruction.Create(OpCodes.Ldstr, "Hello Sir 1"),
    Instruction.Create(OpCodes.Ldstr, "Hello Sir 2")
};
target.Indexes = {
    0, // index of Instruction
    2
};

If assembly is obfuscated entry point isnt Program.Main and it changes everytime :).

Possible implementation:

    new Target()
    {
        Namespace = module.EntryPoint.DeclaringType.Namespace,
        Class = module.EntryPoint.DeclaringType.Name,
        Method = module.EntryPoint.Name
    }

If I didn't mix what DeclaringType is

or just return new Target(module.EntryPoint)

ioncodes commented 7 years ago

Like this?

SlowLogicBoy commented 7 years ago

Yes thanks

ioncodes commented 7 years ago

This has been implemented for v1 aswell. The EP is loaded into AssemblyData.Entrypoint