B From:	MERC::"uunet!WKUVX1.BITNET!MacroMan" 18-MAR-1993 09:04:23.36# To:	MACRO32 <MACRO32@WKUVX1.BITNET>  CC:	8 Subj:	Re: Sys. Serv. Hook (Was RE: Imp terminates Qio !)  C >I'm not sure that's necessary.  On the rare occasions where system   I Yeah! When it's well behaved VMS code/ASTs, etc.  It's the 'foreign' (NOT 2 supplied with VMS) code that I was concerned with.  I >services call other system services, they call the EXE$xxx entry points, F >since the main purpose of the system service vectors is to provide anH >entry point for outer access mode callers to come in thru a change modeI >handler to run inner mode code.  An AST delivered from somewhere else is D >going to already be in an inner mode and not need to go through the >change mode handler.   I Oh Yeah! And how to you propose the AST will find these EXE$xxx points of F the system services?  (eg: EXE$QIO)  Actually, EXE$QIO is the S0 tableH vector.  It contains the same MASK, CHMK #<?> and RET as the P1 SYS$QIO.H Hence, you will still be going thru the Change mode dispatch! The actualE QIO routine (dispatched by EXE$CMODKRNL)  is loaded _somewhere_ in S0 & space.  Try finding it! It AIN'T easy.  J 1) EXE$CMODKRNL (EXE$CMODEXEC) aren't fixed in S0. They're loadable imagesJ    and can NOT be guaranteed to be in the same location from boot to boot.?    However, you can locate them from SCB+40(16) and SCB+44(16).   J 2) The entry points of the service routines are located in the change modeH    dispatch tables pointed to by CMOD$AR_<mode>_DISPATCH_VECTOR.  Here's%    another one for you to track down!   I 3) IF you know the Loadable Exec. Image that the routine is found in, you J    CAN find its loaded address by walking the LDRIMG blocks.  Then, IF youI    know IMAGE VALUE of the routine, you CAN calculated the loaded address J    of its entry point.  AND... How do you get the IMAGE VALUE?  Still more    gyrations...   J A lot of work to directly call the service routine directly, especially if you're in an AST!   H Brevity here.  On account of I have a train-stopping headache this morn.  H >One thing that pulls the same grubby trick is DEBUG, and doesn't botherG >raising IPL or locking the vectors down after creating the new vector. H >Note also that DEBUG remaps the _whole_ vector table, not just parts ofF >it.  It's done by copying the vector table into a local save area andF >restoring it after the $CRETVA.  The page protection is left at URKW.  ' AHHHH... You let the cat outta the bag.   I >Also, the $DELTVA call is superfluous, since $CRETVA always discards the  >pages that are being remapped.   I I wanted to break down the steps of remapping the table vector so that it . was more apparent what was actually happenin'. --- K Actually, I'm surprised that a cut-and-paste faux pax in a pseudoSDA output I (used to comment the code) went 'unpunished'!  I specified one PFN in the J EVAL/PFN command but displayed (formatted) another.  Oops!  It should alsoF have L under the bits field since it is now locked in the working set. --- I The real challenge of that ditty was to devise a mechanism to execute the I "set prompt" code in exec mode and keep the functions of the hook routine G process specific.  The WRTATTN AST on the mailbox worked out real nice.   C Got any other ideas on how to do it?  It may prove to be a bit more B interesting than the discussion ensuing about RMSing with the UAF!  H BJS- /Brian Schenkenberger/Schenkenberg@Eisner.DECUS.Org/Space for Rent/G     /VMS Software Support/Vitronics, Inc./Eatontown, NJ/(908) 542-0600/ F    /Independent Consult./Tmesis Consulting/Jackson, NJ/(908) 363-7551/E   /<VAXman or Schenkenberger>@Monmouth-ETDL1.Army.Mil/CIS: 70253,114/ 