delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2008/03/30/18:45:54

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Rod Pemberton" <do_not_have AT nohavenot DOT cmm>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Segfault reading memory address > 0xFFFFF000
Date: Sun, 30 Mar 2008 19:45:23 -0400
Organization: Aioe.org NNTP Server
Lines: 45
Message-ID: <fsp8j6$poc$1@aioe.org>
References: <c76e39a6-8268-4d92-9ed7-f4a8eaf568f6 AT m36g2000hse DOT googlegroups DOT com>
NNTP-Posting-Host: IVw7K97ih4IohxRqyKkqFw.user.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse AT aioe DOT org
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-Priority: 3
X-MSMail-Priority: Normal
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"James" <countingtoten AT gmail DOT com> wrote in message
news:c76e39a6-8268-4d92-9ed7-f4a8eaf568f6 AT m36g2000hse DOT googlegroups DOT com...
> When I try to read a memory address higher than 0xFFFFF000 directly
> using DJGPP in DOS the program seg faults, but if I step up to that
> address by reading the addresses before it, the program works fine.
> Why does stepping up to the address work but not reading the address
> directly and is there a fix to just read the address directly?
>

Have you found the problem or a solution?

After adding includes, a main(), and the declaration for selector:
  unsigned short selector;

I was able to get it to compile.  I wasn't seeing the SIGSEGV in MS-DOS.  I
was able to get it to fault in a Windows 98 SE dos console.  I also changed
x to an unsigned long and checked all the dpmi calls for -1 error...

Of course, when the app is run in Windows it's not using CWSDPMI, but
Windows' internal DPMI...  Unfortunately, my machine seems to SIGSEGV for
any address over 1Mb + 144k (wierd...), not just those around 0xFFFFF000.  I
don't have time to look at it further for a while.  I'm assuming it's some
other protection related mechanism to prevent access to Windows code or non
existant memory.  Maybe the memory just needs to be mapped into Windows
paging tables somehow...

However, I did come across something else that was interesting.  When I
added a call to __dpmi_set_descriptor_access_rights(), and it didn't fix the
problem, I decided to see what values where actually being set for the
selector (my own trusted assembly, not DJGPP).  It turns out the way you
have the dpmi calls ordered, that Windows doesn't set the requested base
address.  It kept setting the upper three nybbles of the base address to
0xC4_ (forget the third) instead 0xfff.  The only way I could get Windows 98
SE to set the base address of the selector to the value passed to
__dpmi_set_segment_base_address(), was to reorder the dpmi calls like so:

__dpmi_allocate_ldt_descriptors()
__dpmi_set_descriptor_access_rights()
__dpmi_set_segment_base_address()
__dpmi_set_segment_limit()
__dpmi_physical_address_mapping()


Rod Pemberton

- Raw text -


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