(05-14-2023, 05:18 PM)Steffan-68 Wrote: My only question is, can the actual program also write itself, or is that only possible with a separate program?
If a program is running, you can still open it for reading, but writing is denied.
So the system, with me Windows denied the write access when a program is running.
Here's the question, is there a way to bypass the system lock?
It might be possible to write to an EXE file on disk, by using some other program.
Otherwise what you want to discuss is a touchy subject and it's what some malware are made of. Not just self-modifying code, but any type that changes the executable file that was when it was executed. If you don't want Windows Defender or any other anti-virus thing deleting your EXE's where you don't expect, please don't insist further into this subject. What Steve suggested could work but it's going to be a hassle.
It is not permitted on MacOS nor Linux neither because there has to be a high emphasis on security and on integrity of files.
The thing is, if anything is going to be added to the end of an EXE created by a programming system, the header has to be adjusted, or some other place in the file, so it doesn't "ring a bell" with an anti-virus scanner. Because some Internet security software are known to look for "magic numbers" and have "heuristics" in case something is not done right. More or less it's known how "g++" creates executable files. Tacking on something at the end of an executable file then could be detected by the experts on the industry.
Sadly plagiarists abound and many people aren't interested in being original in their content. One has to deal with it, when supplying MP4, OGG, PNG and other such files. Attaching one of those files to an EXE file is going to make it even less attractive, since enough people are suspicious of downloading installers that come in EXE files. Even self-extracting 7-Zip or RAR. I would never download an EXE file anyhow. Long ago I used to offer EXE files for download because I was reluctant to show source code, because it was rather simple text-parsing stuff. This was before I discovered that things could get even worse with executable files being infected, and half the users trusting too much about it and the other half don't care.