home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name iscurprc -- Return or set PSP address of currently
- * executing process.
- *
- * Synopsis oldproc = iscurprc(option,newproc);
- *
- * unsigned oldproc Segment address of PSP of currently
- * executing process beforehand.
- * int option IS_SETPROC to change the currently
- * executing process, or
- * IS_RETPROC to merely report it.
- * unsigned newproc If option is IS_SETPROC, newproc
- * is the PSP address of the new
- * currently executing process.
- *
- * Description This function returns (and possibly changes) DOS's
- * record of the program segment prefix (PSP) of the
- * currently executing process.
- *
- * Returns oldproc Segment address of PSP of currently
- * executing process before the call.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987,1989
- *
- **/
-
- #include <dos.h>
-
- #include <bintrupt.h>
-
- unsigned iscurprc(option,newproc)
- int option;
- unsigned newproc;
- {
- unsigned result;
- union REGS regs;
-
- /* DOS function 0x62 (Return PSP) is available (and documented) */
- /* for DOS versions 3.00 and later. Function 0x51 is available, */
- /* but not documented, for all versions of DOS, so prefer */
- /* function 0x62 when it is available. */
-
- regs.h.ah = (unsigned char) ((utdosmajor < 3) ? 0x51 : 0x62);
- intdos(®s,®s);
-
- result = regs.x.bx;
-
- if (option == IS_SETPROC)
- {
- regs.h.ah = 0x50; /* DOS function 0x50: Set current PSP */
- regs.x.bx = newproc; /* (an undocumented function). */
- intdos(®s,®s);
- }
-
- return result;
- }