We have successfully managed to use SVC screening to intercept a SVC call. The only problem is we can only specify one routine to receive control for the intercepted SVC(s). What if we want to intercept more than one and execute specific code for each unique SVC call? We have to add some logic to determine what SVC number was called. Fortunately this information is saved in a Request Block. When our SVC intercept routine is entered register 5 contains the address of the Supervisor Request Block (SVRB) that was created by the SVC interrupt handler. This SVRB does not contain information about the SVC call but does point to the previous RB that does contain the system status that was saved when the SVC instruction caused an interrupt. By examining the previous RB we can determine the SVC number assoicated with the call to our intercept routine.
USING RBBASIC,R5 MAP THE SVRB * L R9,RBLINK LINK TO PREVIOUS RB LA R9,0(,R9) CLEAN UP ADDRESS BCTR R9,0 BACK UP TO LAST BYTE OF RB PREFIX
Since register 5 contains the address of the SVRB we can use it to find the previous RB. First we map it against the RBBASIC section of the Request Block. We use the RBLINK field to get the address of the previous RB. I use the LA instruction to “clean up” the address, that is to clear the high order bits of the address. We then subtract one from that address so register 9 will point to the last byte of the prefix section of the RB that is located right before the beginning of the RBBASIC section. The last byte of the RB prefix contains the SVC interruption code or SVC number.
CLI 0(R9),230 BE SVC230 * CLI 0(R9),231 BE SVC231 * WTO '*** NOT SVC 230 OR SVC 231 ***',ROUTCDE=(1,11)
Now we can simply use a CLI instruction to check the SVC number and branch to the appropriate processing routine. We should have some type of error code in place in the event the SVC number fails to match (because we made some type of coding error). Here we simply issue a WTO and then exit.
SVC230 DS 0H WTO '++++++++ SVC 230 ++++++++',ROUTCDE=(1,11) * LR R14,R11 RESTORE RETURN ADDRESS BR R14 EXIT SVC ROUTINE * SVC231 DS 0H WTO '++++++++ SVC 231 ++++++++',ROUTCDE=(1,11) * LR R14,R11 RESTORE RETURN ADDRESS BR R14 EXIT SVC ROUTINE
Our SVC routines aren’t much more interesting but they will reveal which SVC number was called.
SVC 230 SHOULD BE CAPTURED BY SVC SCREENING SVC 231 SHOULD BE CAPTURED BY SVC SCREENING SVC 231 SHOULD BE CAPTURED BY SVC SCREENING SVC 230 SHOULD BE CAPTURED BY SVC SCREENING
Now we can issue some SVC calls and see what happens.
JOB 6840 $HASP373 SVC03 STARTED - INIT 12 - CLASS A - SYS TCS3 JOB 6840 ++++++++ SVC 230 ++++++++ JOB 6840 ++++++++ SVC 231 ++++++++ JOB 6840 ++++++++ SVC 231 ++++++++ JOB 6840 ++++++++ SVC 230 ++++++++ JOB 6840 8.55.05 0.00.00 0.00.00 0000 SVC03 MVSSP JOB 6840 8.55.05 0.00.00 0.00.00 0000 SVC03 ######## JOB 6840 $HASP395 SVC03 ENDED
And when we execute the results are just we would have expected.