Date: Fri, 19 Aug 94 17:12:45 -0400 From: dj AT ctron DOT com (DJ Delorie) To: leisner AT sdsp DOT mc DOT xerox DOT com Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: reading dos memory > I'm somewhat confused about dosmemget and linear addresses in go32... > > dosmemget is defined as: > #include > > void dosmemget(int offset, int length, void *buffer); > > Description > ----------- > > This function transfers data from MS-DOS's conventional memory space to > the program's virtual address space. The OFFSET is a physical address, > which can be computed from a real-mode segment/offset pair as follows: > > > But go32_info_block has a number with begins with 0xe0000000 and there > is an example: > dosmemget(_go32_info_block.linear_address_of_primary_screen, 80*25*2, buf); dosmemget and dosmemput automatically strip the top four bits off the linear address you give it to compensate for those values. They're set that way as an indication to go32 that the libc routines have already transferred data into the transfer buffer; when go32 sees the magic number as a pointer, and the magic number corresponds to the address of the transfer buffer, it doesn't need to transfer any memory. That speeds things up a lot as there are fewer mode switches required. > Wouldn't it be easier (and possible) to map in the 1Mbyte of dos memory > readonly? You have to go through a function to read *and* write at the moment, unless you use farptr and/or movedata, but then you have to know to strip off the top four bytes yourself.