Date: Wed, 1 Oct 1997 11:18:30 +0200 (IST) From: Eli Zaretskii To: Gustav Roder cc: djgpp AT delorie DOT com Subject: Re: Segment & Offset In-Reply-To: <342FC820.DB745851@vip.cybercity.dk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 29 Sep 1997, Gustav Roder wrote: > I'm writing a mouse-handler in DJGPP. I need to get the segment and > offset of my handler-function. > > How can I estimate the segment and offset of a function in DJGPP? You cannot ``estimate'' the segment and an offset of a DJGPP function, because they live in protected-mode memory, almost always above the 1MB mark, and real-mode seg:off addresses cannot address more than 1MB. In addition, you cannot pass the address of your handler directly to the mouse driver, because your function will then be called in real mode (the driver itself is a real-mode software), and it won't work at all. What you need is to allocate a real-mode callback that will switch into protected mode befoe calling your function, and pass the address of that callback to the mouse driver. The DJGPP FAQ list (available as v2/faq210b.zip from the same place you get DJGPP) explains how to do that in section 18.8; in fact, it actually uses the mouse handler as example, so you even have some code there.