home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!olivea!bu.edu!wang!news
- From: s2212530@techst02.technion.ac.il (Oded Malky)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Convert DOS addres to WINDOWS protected mode address
- Message-ID: <1992Sep9.161258.29430@discus.technion.ac.il>
- Date: 9 Sep 92 16:12:58 GMT
- Sender: news@wang.com
- Organization: Technion, Israel Inst. of Technology
- Lines: 40
-
- Hi programmers.
-
- I'm trying to convert DOS address to WINDOWS address in protected mode.
- I got the following routine and it should do the job, but while running it
- yells for error (in the line marked in arrow). The routine was originaly
- written for MS/C, and I'm trying to make it work under BC++ 3.0.
-
- 1. Can anybody help me to make this routine work under BC++ 3.0 ?
- 2. If not, dose anybody know how to convert DOS addres (segment+offset) to
- WINDOWS protected mode addres ?
- 3. Could someone point me to some documentation on SetSelectorBase() and
- SetSelectorLimit() functions ?
-
- Thanks
-
- Oded.
-
- The routine in question:
- ==============================================================================
- HANDLE PASCAL AllocateSelector(unsigned segment, unsigned offset, DWORD length)
- {
- DWORD physicalAddress, linearAddress; /* This function allocs & maps */
- HANDLE selector; /* a protected mode selector */
- struct SREGS sregs; /* for a real mode address */
-
- segread(&sregs); /* Copy DS selector */
-
- if ((selector = AllocSelector(sregs.ds))) /* Successful Allocate? */
- { /* Phys = Lin In 1st Megabyte */
- linearAddress = physicalAddress = ((DWORD) segment << 4L) + offset;
- ---> SetSelectorBase(selector, linearAddress); /* Set New Base Address */
- SetSelectorLimit(selector, length); /* Set New Segment Range */
- }
- return(selector);
- }
- +---------------------------------------------------------------------------+
- | Oded Malky - Computer Engineering phone: 972-4-230158 |
- | Internet: s2212530@techst02.technion.ac.il fax/phone: 972-4-324780 |
- | Address: Zalman Shneor 36 ap. 23, Haifa 32545 ISRAEL |
- +---------------------------------------------------------------------------+
-