[comp.lang.c] Changing a data segment to a code segment in OS/2

TAMURA@HLERUL5.BITNET (Tamura Jones) (10/13/88)

> SUBJECT: Changing data segment to code segment in OS/2
> In article <993@tiger.oxy.edu> bagpiper@oxy.edu (Michael Paul Hunter) writes:
> >I thought that I had heard that their was a privileged routine that could
> >convert a section of memory from the 'data' type to the 'code' type?  I
> >think I heard about this in an interview with [forgot his name but he was
> >the chief architect for OS/2 and wrote a book...] in which he talked about
> >this routine...?!
>
> The answer is yes: OS/2 (which is, incidentally, not a compiler) does
> indeed have as part of its design a system call that changes the tag
> associated with a region.  Presumably, when a region is changed from
> data to code, it is made read-only and any caches in the CPU are
> flushed if necessary, and so forth.  Obviously a machine with such a
> system call will have trouble with multiser protection mechanisms that
> are not enforced by hardware.

The routine is NOT priviliged.
The routine does NOT change a data to a code segment.
The routine, DosCreateCSAlias, creates a CS alias, a CS segment
descriptor, that is identical to the DS segment descriptor you
already have. From the point you used the routine onwards you have
two CONCEPTUALLY different ways of accessing the segment in question.
You can execute it as code, using CS, or read/modify it as data,
using DS. Using the wrong segment register for a purpose will result in a
Generel Protection (GP) Fault.

The person reffered to is Ed Iaccobucci and he wrote the book
"Inside OS/2", published by Microsoft Press.
Warning #1: there exist another book with the same title
Warning #2: The book contains no source code, it explains the
concept and ideas behind OS/2, nothing more.
Warning #3: And that can get quite technical at times! If you
are not familiar with OS terminology and concepts, this may
prove a difficult book.
Warning #4: If you want to know about OS/2, you NEED to read this
book one day or another. It may however not be the best to start with...

Just thought people might like to know this, but it is, as Chris Torek
already pointed out, in beyond the bounds of this list. (GP Fault)

/* Tamura "2 C | ! 2 C == ?" Jones  ( quote free after ) */
#include <disclaim.h>           /*  ( W. Shakespeare's ) */
/* INTERNET: TAMURA@HLERUL5.BITNET  ( Hamlet, Act III, ) */
/* imagine  #include on first line  ( scene 1, line 56 ) */

Kevin_P_McCarty@cup.portal.com (10/24/88)

For those who may have been misled by
article <8810211337.AA19395@ucbvax.Berkeley.EDU>
(which was posted over 10 days ago, but just reached this site)
in which TAMURA@HLERUL5.BITNET (Tamura Jones) remarks

>The person reffered to is Ed Iaccobucci and he wrote the book
>"Inside OS/2", published by Microsoft Press.
>Warning #1: there exist another book with the same title
>Warning #2: The book contains no source code, it explains the
>concept and ideas behind OS/2, nothing more.

The book by Ed Iacobucci, the leader of the IBM OS/2 design team,
is called "OS/2 Programmer's Guide", published by Microsoft Press.
The book contains a considerable amount of source code, mostly
assembly language, and explains considerably more than just
concepts and ideas.  There is enough code that a separate diskette
is offered as a companion to the book.

The other book, called "Inside OS/2", is by a senior OS/2 architect
at Microsoft (whose name escapes me).  According to my ever-faulty
memory, Warning #2 is accurate regarding this book.

Ok, back to C.

Kevin McCarty