www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/05/18:03:29

From: lonniem AT cs DOT utexas DOT edu (Lonnie McCullough)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Memory Allocation
Date: Sat, 05 Jul 1997 05:09:45 GMT
Message-ID: <33bdd5ce.1664500@news.nol.net>
References: <5pf4oq$4ds AT lantana DOT singnet DOT com DOT sg>
NNTP-Posting-Host: ip38-18.nol.net
Lines: 22
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>Hello !
>
>I just started using DJGPP and I'm a little confused about memory allocation. There appears to be a few ways to allocate memory : using the new operator,
>using __dpmi_allocate_dos_memory, __dpmi_allocate_linear_memory, __dpmi_allocate_memory, __dpmi_allocate_shared_memory.
>Could someone tell me which one I should use and what is the difference between them ? I need to allocate about 1-2 MB.
Just use malloc.

>I know the following will be painfully obvious to some people, but how is it possible ( In the sense of I know how it is done but I would like to know why it is allowed)
>to be able to just set a descriptor to point to the video ram ? Does this mean that I can just point anywhere and just write anywhere ?
Because protected mode is not for completely prohibiting you from
accessing various place in memory that don't necessarily belong to you
it is just for prohibiting you from doing it accidentally.  If you can
get a valid selector going (meaning a valid physical address and a
valid size) you should be able to write to the area of memory it
"points" to.  It is probably rather hard and unlikely that through a
chain of accidental events and instructions you would get a valid
selector into any of the segment registers so it is a safe system.



Lonnie McCullough
lonniem AT cs DOT utexas DOT edu

- Raw text -


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