Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!ucsd!sdcsvax!beowulf!holtz From: holtz@beowulf.ucsd.edu (Fred Holtz) Newsgroups: comp.sys.ibm.pc Subject: Re: Program Loaded Where? from inside another Message-ID: <4872@sdcsvax.UCSD.EDU> Date: 19 Apr 88 18:33:10 GMT References: <39@softart.UUCP> Sender: nobody@sdcsvax.UCSD.EDU Organization: CSE Dept. U.C. San Diego Lines: 36 In article <39@softart.UUCP> riml@softart.UUCP (Research in Motion Limited) writes: >I have a program which invokes another program via an exec-type call >("system()" in C). In mess-dos so far, this means your calling program >goes away until the new program has done its stuff. My calling program >needs to know where the called program got loaded in memory. Does >anyone have any hints on how to do this? An idea that may work for you is to reserve a special memory location in the caller for the called program to patch its address into, and then passing the address of this area as a parameter to the called program, like: Calling program: char *area, **temp, buf[64]; temp = &area; sprintf(buf, "pgmname %lx", temp); system(buf); Called program: char **area, *address; /* ... set up the address */ sscanf(av[1], "%lx", &area); *area = address; Upon return from the called program the caller should now have its "area" set to the called "address", which I am not sure how to set, but if your goal is passing back a data structure or function address it is simple enough to do. This will have to be done using a large memory and data model for both. These code fragments may not work exactly as is (this is off the top of my head), but I think the general idea is workable. My only question is why do you want to do this in the first place? Fred Holtz ARPA: holtz@sdcsvax.UCSD.EDU UUCP: sdcsvax!holtz