modify exe file in runtime RRS feed

  • Question

  • hi everybody,i have a .net exe file and i want to modify this file in runtime(.net exe file modify itself),how can i does it?

    please help me it is very important and urgent for me

    Sunday, April 24, 2011 5:57 AM

All replies

  • Hi,

    Take a look at the following post which discusses the same issue. To be short, dynamic runtime code generation is possible but self modification of .NET code after being translated by the JIT compiler is impossible : http://social.msdn.microsoft.com/Forums/en-US/clr/thread/d3ac6b68-1257-4f7c-946c-85d5da4c1b48/

    Mounir IDRASSI

    Mounir IDRASSI IDRIX http://www.idrix.fr
    Sunday, April 24, 2011 7:35 AM
  • I could be wrong, but I believe Windows won't run files opened for write (i.e. doesn't specify FILE_SHARE_WRITE when loading).  You can copy yourself to a temp file, execute the temp file, and then modify the original .exe after the parent process quits, though.
    Friday, May 6, 2011 9:10 PM