Article View: comp.os.ms-windows.programmer.tools
Article #255Convert DOS addres to WINDOWS protected mode address
From: Oded Malky
Date: Wed, 09 Sep 1992 16:10
Date: Wed, 09 Sep 1992 16:10
38 lines
2367 bytes
2367 bytes
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 ?
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 |
+---------------------------------------------------------------------------+
Technical Details
Message-ID:
<1992Sep9.161024.29360@discus.technion.ac.il>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!wang!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!wang!news From: s2212530@techst02.technion.ac.il (Oded Malky) Newsgroups: comp.os.ms-windows.programmer.tools Subject: Convert DOS addres to WINDOWS protected mode address Message-ID: <1992Sep9.161024.29360@discus.technion.ac.il> Date: 9 Sep 92 16:10:24 GMT Sender: news@wang.com Organization: Technion, Israel Inst. of Technology Lines: 38