[comp.windows.ms] Useful exported selectors

mojo@netcom.UUCP (Morris Jones) (07/07/90)

This information was provided by Dan Quigley at MS, and I found it to be
very useful for accessing memory in the Real Mode memory (first 1MB):

--quoted--
Windows 3.0 Kernel exports several selectors for just this purpose.  All of
these exports are meant to cover the area below 1 mb (physical). If you need
access to other areas of memory then you will have to synthesize a selector
for that purpose. I will leave the discussion of selector synthesis for
another time. (You should have the DDK for that).

Anyway, these are the selectors that are exported by Kernel:

    __0000h
    __0040h
    __A000h
    __B000h
    __C000h
    __D000h
    __E000h
    __F000h
        
   Each of these selectors has a limit of 64k. This is how you use them.

   // written for your specfic case but easily modified for others

   extern WORD _F000h;       // note the single underscore here
   LPSTR  MySelectorOffset;  // or WORD FAR * or whatever

   MySelectorOffset = (LPSTR) MAKELONG(0xFFFx,&_F000h);
   // note the &

   Make sure that you do not extend beyond the end of a segment or change the
selector (you will GP fault). Remember that you are in protect mode and you
have access to memory that Windows or its drivers assume exclusive control.

   Dan Quigley (MSV)
   
-- 
Mojo     mojo@netcom.UUCP
Morris Jones
Campbell, CA