Kaidoz Posted March 17, 2019 Posted March 17, 2019 Hey everyone. I try inject Method in TypeDef, but i cant do. Maybe anybody help me? My code: try { ModuleDefMD typeModule = ModuleDefMD.Load(typeof(Encrypt).Module); var mthDef = typeModule.ResolveMethod(MDToken.ToRID(typeof(Encrypt).GetMethods().Where(x => x.Name == "EncryptOrDecrypt").First().MetadataToken)); foreach (var d in module.Types) if (d.HasMethods) { d.Methods.Add(mthDef); } foreach (MethodDef md in module.GlobalType.Methods) { if (md.Name == ".ctor") { module.GlobalType.Remove(md); break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); }
CodeExplorer Posted May 4, 2019 Posted May 4, 2019 I think the problems is that you try to inject same method in multiple types; https://github.com/yck1509/ConfuserEx/blob/master/Confuser.Core/Helpers/InjectHelper.cs http://www.voidcc.com/project/dnpatch
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now