home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / mswindo / programm / tools / 909 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  2.3 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!wang!news
  2. From: s2212530@techst02.technion.ac.il (Oded Malky)
  3. Newsgroups: comp.os.ms-windows.programmer.tools
  4. Subject: Convert DOS addres to WINDOWS protected mode address
  5. Message-ID: <1992Sep9.161024.29360@discus.technion.ac.il>
  6. Date: 9 Sep 92 16:10:24 GMT
  7. Sender: news@wang.com
  8. Organization: Technion, Israel Inst. of Technology
  9. Lines: 38
  10.  
  11. Hi programmers.
  12.  
  13.  I'm trying to convert DOS address to WINDOWS address in protected mode. 
  14. I got the following routine and it should do the job, but while running it
  15. yells for error (in the line marked in arrow). The routine was originaly
  16. written for MS/C, and I'm trying to make it work under BC++ 3.0.
  17.  
  18. 1. Can anybody help me to make this routine work under BC++ 3.0 ?
  19. 2. If not, dose anybody know how to convert DOS addres (segment+offset) to
  20.    WINDOWS protected mode addres ?
  21.  
  22. Thanks
  23.  
  24.   Oded.
  25.  
  26. The routine in question:
  27. ==============================================================================
  28. HANDLE PASCAL AllocateSelector(unsigned segment, unsigned offset, DWORD length)
  29. {                                               
  30.     DWORD physicalAddress, linearAddress;       /* This function allocs & maps */
  31.     HANDLE selector;                            /* a protected mode selector */
  32.     struct SREGS sregs;                         /* for a real mode address */
  33.  
  34.     segread(&sregs);                            /* Copy DS selector */
  35.  
  36.     if ((selector = AllocSelector(sregs.ds)))   /* Successful Allocate? */
  37.     {                                           /* Phys = Lin In 1st Megabyte */
  38.         linearAddress = physicalAddress = ((DWORD) segment << 4L) + offset;
  39. --->    SetSelectorBase(selector, linearAddress);  /* Set New Base Address */
  40.         SetSelectorLimit(selector, length);     /* Set New Segment Range */
  41.     }
  42.     return(selector);
  43. }
  44. +---------------------------------------------------------------------------+
  45. | Oded Malky - Computer Engineering                    phone: 972-4-230158  |
  46. | Internet: s2212530@techst02.technion.ac.il       fax/phone: 972-4-324780  |
  47. | Address: Zalman Shneor 36 ap. 23, Haifa 32545 ISRAEL                      |
  48. +---------------------------------------------------------------------------+
  49.