Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!unido!laura!heike!klute From: klute@heike.informatik.uni-dortmund.de (Rainer Klute) Newsgroups: comp.sys.atari.st.tech Subject: Re: Location of variables in executable files. Message-ID: <2796@laura.UUCP> Date: 15 Nov 90 07:47:12 GMT References: <1990Nov11.013428.4566@cs.utk.edu> Sender: news@laura.UUCP Reply-To: klute@heike.informatik.uni-dortmund.de (Rainer Klute) Organization: University of Dortmund, Germany Lines: 54 In article <1990Nov11.013428.4566@cs.utk.edu>, andrew@.cs.utk.edu (Andrew Krzywdzinski) writes: |> I want to be able to write setup information directly to a program |> file. I once posted a fundamental (as I think) article against self-modifying code to this newsgroup. Here it is again - slightly generalized and of course open to consideration and discussion: ------------------------------ cut here ------------------------------ No, no, no! Never write self-modifying code! Self-modifying code is very bad style. It is difficult to write and even more difficult to understand. Programs that modify itself tend to be unmaintainable. A lot of machines do not allow you to modify a program file for security aspects. Consider everyone on a multiuser system would be allowed to modify any file. Sure, this is not true for the Atari ST, but one should learn to do it the right way. Spend some time to figure out how to do it on e. g. a Unix system and you can to it equivalently on the ST. (Slight simplification here, but you got the idea, right?) On a related topic: Several systems do not even allow you to modify your executing program while it is located in memory. You will only be allowed to write to the data portion of the program. This is due to the fact that on a multitasking system several tasks can execute one single program simultaneously. Now, if the program code can not be modified by the executing task it is sufficient to load the program into core only once, thus gaining a lot of efficiency. (Of course each program get it's individual data section.) If you are afraid of virusses don't modify your program file. You (the average user) can never tell whether the program has been modified by a virus or not. There are programs on the market (including the PD market) that estimate a certain checksum for each program and alarm you if this number changes. How could such a program tell if the change is due to a virus or not? If you are afraid of virusses write protect your media as far as possible. A program that writes to its program file needs to be run from a not write protected disk. This a unnessary and an avoidable security hole. In most cases it is fully sufficient to maintain a configuration file. Keep an entry for every variable that needs to be modified permanently. Upon startup of the program the whole stuff is read in again and the program's variables are set accordingly. Simple, isn't it? -- Dipl.-Inform. Rainer Klute klute@irb.informatik.uni-dortmund.de Univ. Dortmund, IRB klute@unido.uucp, klute@unido.bitnet Postfach 500500 |)|/ Tel.: +49 231 755-4663 D-4600 Dortmund 50 |\|\ Fax : +49 231 755-2386