3 Replies - 337 Views - Last Post: 07 October 2012 - 10:31 AM Rate Topic: -----

#1 Boosi1  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 29-July 12

Code that change itself

Posted 07 October 2012 - 05:41 AM

Hi i want to make program that can change itself by reading from txt file some people told me that i can learn it from here http://flee.codeplex.com/ but i did'nt understand how to do what i want from there i want to do something like that
the txt file will have this written in it:
process.start("someproecess");
and that what the program will do
how can i do it?

Is This A Good Question/Topic? 0
  • +

Replies To: Code that change itself

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3469
  • View blog
  • Posts: 10,693
  • Joined: 05-May 12

Re: Code that change itself

Posted 07 October 2012 - 06:52 AM

If it is fully compilable text, look at CompileAssemblyFromSource(): http://msdn.microsof...fromsource.aspx

If not, then you'll have to use the rest of the CodeDomProvider methods to put together what you need. An alternative is to use Expression Trees: http://msdn.microsof...y/bb397951.aspx

Of course, none of those will be modifying the currently running code. In general, self modifying code is looked down upon. If you really want self modifying code, then you'll need to take advantage of the CodeDomProvider to read your code in, modify the DOM, regenerate source code based on the modifications, and then schedule your code to be recompiled and re-run.
Was This Post Helpful? 0
  • +
  • -

#3 Boosi1  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 39
  • Joined: 29-July 12

Re: Code that change itself

Posted 07 October 2012 - 07:10 AM

View PostSkydiver, on 07 October 2012 - 06:52 AM, said:

If it is fully compilable text, look at CompileAssemblyFromSource(): http://msdn.microsof...fromsource.aspx

If not, then you'll have to use the rest of the CodeDomProvider methods to put together what you need. An alternative is to use Expression Trees: http://msdn.microsof...y/bb397951.aspx

Of course, none of those will be modifying the currently running code. In general, self modifying code is looked down upon. If you really want self modifying code, then you'll need to take advantage of the CodeDomProvider to read your code in, modify the DOM, regenerate source code based on the modifications, and then schedule your code to be recompiled and re-run.

But how can i do it with the eval function like here http://www.codeproje...e-Eval-Function

i tried the code but it does'nt work at my computer
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,659
  • Joined: 02-June 10

Re: Code that change itself

Posted 07 October 2012 - 10:31 AM

Having a program modify/re-write itself is a fairly advanced topic.
You're obviously not an advanced coder.
So my first thought is "Why?" What is it you are trying to build? Most likely there is a better approach, more in line with your skills. Not to mention this could just as easily be used to bypass anti-virus programs. Your code could be innocent and the text file would contain the virus code to be added latter and we don't help with malicious code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1