www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/13/18:41:20

From: "Johnny Chan" <jchan AT paclink DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: Q: Want to know the starting address and size of my program
Date: Wed, 13 Oct 1999 13:14:49 -0700
Message-ID: <001401bf15b7$9a7635e0$ae3d7a86@phoenix.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Importance: Normal
In-Reply-To: <LOBBLPJELBKBBPKFEHMDAEAFCAAA.jchan@paclink.net>
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

>>If you want safety, your program shall not write to any address below
>>what sbrk(0) returns, because some or all of the addresses in this
>>range are used by the code or the data of your program.

Is it possible to find out exactly where is my data, stack, code area
located. Some of the routine will test the RAM bit by bit. The code
and data will be very small, no heap will be involved here.
I am trying to maximize the test coverage and limited the untouched 
area that code and data area. The stub program should know exactly
where is this "program" located. Is there any way to collect this
piece of information?

>>You *can* read from these addresses, though (except that reading from
>>the null page would ususally crash your program under CWSDPMI and
>>other DPMI v1.0 hosts, unless you set the _CRT0_FLAG_NULLOK bit in the
>>_crt0_startup_flags variable).

my program uses djgpp_map_physical_address() to map the phyiscal address
I wanted, then use DPMI functions to access the memory. It gives me an
impression that this method can let me access all the available physical
memory. (Correct if I am wrong)

I am now trying to find out where my program is located (even in linear 
address) so that I can set up some overwrite protection by myself.

Can I scan the memory downward from the address which is returned from 
sbrk() to find out where is my code area and data area?

>>Note that, in general, you cannot access memory beyond the current DS
>>limit.  You might use the near pointer hack to make all addresses
>>accessible, but if you really want to access all the physical memory,
>>that won't do.  You need in addition to map all the physical memory
>>into your address space.  One way of doing so would be to use the
>>method described in section 18.7 of the DJGPP FAQ list.  If you go
>>that way, you don't need (and don't want) to use the nearptr hack; use
>>either movedata or the farptr functions instead.

I think I am using the 18.7 method. Actually I am using farpeek and 
farpoke to access the physical memory in my program.

--jC

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019