Seriously, what's the point of asking these questions if you know nothing about programming yet? Even if you had some source code, you wouldn't understand what it does. Before thinking about running a marathon, it might be advisable to get out of your mother's womb first (then learning how to crawl and how to walk) - for you, that means learning how to program.
I agree the OP has not framed his question in a manner that would invite a serious reply. I hope that I can do better because I am interested in the answer to his/her question. I would like to eventually contribute to anti-virus research/work.
So, say I have a simple program that writes the line "My name is Jack."
1 2 3 4
int main()
cout << "My name is Jack." << endl;
return 0;
How would I write a virus that takes over the code and writes instead "My name is Jill."?
What I have so far is only pseudocode.
1) Read the lines of the target code.
2) Find lines contain cout.
3) In those lines, input strings between the quotation marks.
4) Search for the string "Jack".
5) Replace the target string with the string "Jill".
6) Release the target code to execute itself.
If you're looking to understand how certain pieces of choice software work, you will need to dive very, very, very, very deeply into low level constructs. Areas of interest for you would be: Understanding the C run-time library (or JVM, or whichever you're targeting), (various) PE formats (bytecode files, etc), (various flavors of) assembly level instructions, and how (various) operating systems / virtual machines interact with programs.
If you ever want to make something that won't be instantly detected and removed by even ancient antivirus products, then you will have to do much more research than I think you're aware of...and by the time that you do that, there will probably still be a huge demand for people with that kind of knowledge outside of the 'dark side'.
Hope that was helpful.
@nathan10
"What I have so far is only pseudocode..."
Pseudocode (or any code) doesn't matter in this case. To change the program behavior (in your simplest of cases), you'll have to modify the actual executable file. How this is done "safely" varies for each format that you want to work with. The easiest way would be to use a hex-editor and change the string value (and pray that the strings aren't decrypted at run-time). If the strings aren't available for editing, you'll have to search the PE for the correct assembly region that decrypts the string, find out how it decrypts it, and then change the value at which the decryptor is reading. Hopefully by doing that you didn't mess up any offsets further down in the file that you will also need to fix. Of course, there are tools available that facilitate this, but you won't get links from me.
^^ This can be automated through a C++ program, but the process would be specific to the exact build of the target software. Even if the target source is recompiled using a different optimization (or even perhaps a different seemingly unrelated compiler setting, such as whether the build was done by more than a single core), your program would crash and burn.
^^^ You should also pray that the PE files aren't packed and/or protected...that's another field all in itself.
^^^^ Long story short --- unless you're willing to put a few months / years into it, give up.
@Scorpic
"A lot of them will "attach" themselves to the runtime of another program and will get executed when the regular program is ran. "