Posted December 26, 20168 yr Hi everybody, that was a long time that i didn't try to code anything. So sorry if there're stupid mistakes in my code. I try to have an assembly that modify itself at runtime For example, all Nop opcode becomes Ret opcode (don't try to find logic ) So i inject a method in the .cctor of the assembly. Here's the code : Assembly currentAssembly = Assembly.GetExecutingAssembly(); Type type = currentAssembly.GetType(); foreach(MethodInfo method in type.GetMethods()) { RuntimeHelpers.PrepareMethod(method.MethodHandle); byte[] iLAsByteArray = method.GetMethodBody().GetILAsByteArray(); for (int i = 0; i < iLAsByteArray.Length; i++) { if ((short)iLAsByteArray == OpCodes.Endfinally.Value) { iLAsByteArray = (byte)OpCodes.Ldarg_0.Value; } } UpdateILCodes(method, iLAsByteArray, -1); } the code is a mess but as i said, i didn't touched a computer for a long time. Thanks for you greatful help Edited December 26, 20168 yr by Legend-Modz-V1
December 29, 20168 yr Author On 26/12/2016 at 9:10 PM, ilya01 said: Seems, that are you using injection library. Try to watch source of exaples, how to use it. But this library is unstable and It does not always work. i looked on examples for a day but impossible to find solution ;/
Create an account or sign in to comment