Date: Tue, 12 Oct 1999 10:10:20 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Johnny Chan cc: djgpp AT delorie DOT com Subject: Re: Q: Want to know the starting address and size of my program In-Reply-To: <000401bf1432$f7656180$ae3d7a86@phoenix.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 11 Oct 1999, Johnny Chan wrote: > Question: I would like to know the starting address and the size of my own > program. Anyway I can find this piece of information out? Please define ``starting address'' and ``size''. A program consists of several sections: there's code, there's data, there's the heap, and a few others. What exactly do you want to know, and for what purpose? A helpful answer depends on this information. > Does the format of COFF (format used in DJGPP) includes these pieces of > info? In general, some info is recorded in the COFF image, other pieces are determined at run time by the loader and the run-time environment. > If yes, how and where I can find the location of the file header? What file header do you refer to? > Also, how can I find out the starting address of the program loader? Again, please define ``starting address'' in this context. Are you looking for the address of the entry point into the loader's code? If so, it is recorded in the normal DOS .exe header of the program, since the loader is just a 16-bit real-mode DOS program. > I assume this loader is located in DOS memory, isn't it? If you want to reach the loader from within a running DJGPP program, then you can't: its space is reused for the transfer buffer, after the loader has done its job. > Can my program > (resided in extended memory) read this piece of DOS memory? You can read this memory with dosmemget, but since it is used for the transfer buffer, you will get garbage: the startup code begins using the transfer buffer quite early, so by the time you get there, it's overwritten many times. > What will happen > if my program modify this loader? Does this affects the behavior of my own > program's execution? Nothing will happen. But why do you need something like that? > I am developing a system diagnostic program in protected mode for a > motherboard. That's why the program has such 'unique' requirement. It might help if you explain some more. The above sounds as if you have already settled on some solution(s) to your problems, but you based the solution on incorrect assumptions. It might be a good idea to post a description of your original problems. Then someone might come up with ideas about how to solve them.