{"id":85,"date":"2013-01-27T17:57:38","date_gmt":"2013-01-27T23:57:38","guid":{"rendered":"http:\/\/tommysprinkle.com\/mvssp\/?p=85"},"modified":"2013-06-24T21:07:53","modified_gmt":"2013-06-25T02:07:53","slug":"intercepting-findbldl","status":"publish","type":"post","link":"https:\/\/tommysprinkle.com\/mvssp\/2013\/01\/27\/intercepting-findbldl\/","title":{"rendered":"Intercepting FIND\/BLDL"},"content":{"rendered":"<p>Now that we know how to intercept SVC calls we can try something more interesting.\u00a0 When a program is assembled the various macro contained in the source code have to be read from the macro library.\u00a0 As the assembler reads these macros they are located using SVC 18 (FIND\/BLDL).\u00a0 By intercepting SVC 18 we can list the macros as they are being accessed by the assembler.<\/p>\n<p>First we need to look at the input registers to SVC 18.\u00a0 Register zero points to a parameter list and register one contains a DCB address or zero.\u00a0 If the request is for BLDL then the contents register one will be positive.\u00a0 If the request is for find then contents of register one will be negative.\u00a0 For this excercise we only care about FIND and not BLDL so we can ignore the parameter list for BLDL.\u00a0 For a FIND request register zero points to an eight-byte member name.<\/p>\n<p>Now all we have to do is intercept calls to SVC 18 and print out the member name each time we encounter a FIND request.\u00a0 In order for the assembler to work we will have to reissue the SVC call so the real SVC 18 can locate the member in the PDS.<\/p>\n<pre>         MVI   18(R2),X'00'       INTERCEPT SVC 18  BLDL\/FIND<\/pre>\n<p>First we include SVC 18 in our list of intercepted SVC calls in the screen table.\u00a0 By setting the corresponding byte in the screen table to X&#8217;00&#8217; instead of X&#8217;80&#8217; we will cause SVC 18 to be intercepted.<\/p>\n<pre>         CLI   0(R9),18           BLDL\/FIND\r\n         BE    SVC18<\/pre>\n<p>In our SVC processing routine we need to check for SVC number 18 as the interrupt code in the RB.<\/p>\n<pre>SVC18    DS    0H                          \r\n         LR    R8,R0              SAVE R0  \r\n         LR    R9,R1              SAVE R1  \r\n         LR    R10,R15            SAVE R15<\/pre>\n<p>To process our SVC 18 interrupt we first save the parameter registers passed to the SVC routine.<\/p>\n<pre>          LTR   R1,R1                                 \r\n          BP    SKIP18                  BRANCH IF BLDL<\/pre>\n<p>Now we check to see if the request is for BLDL or for FIND.\u00a0 For now we will ignore BLDL requests.<\/p>\n<pre>         ST    R0,FWORD           SAVE R0 CONTENTS          \r\n         UNPK  WORK(9),FWORD(5)   UNPACK                    \r\n         TR    WORK(8),HEXTAB-C'0'                          \r\n         MVC   WTO18+18(8),WORK                             \r\n*                                                           \r\n         ST    R1,FWORD                                     \r\n         UNPK  WORK(9),FWORD(5)                             \r\n         TR    WORK(8),HEXTAB-C'0'                          \r\n         MVC   WTO18+30(8),WORK                             \r\n*                                                           \r\n         MVC   WTO18+39(8),0(R8)       COPY FIND MEMBER NAME\r\n*                                                           \r\n*               8.10...15...20...25...30...35...40...45...50\r\nWTO18    WTO   'SVC 18 R0=******** R1=******** ********',   \r\n               ROUTCDE=(1,11)<\/pre>\n<p>If it is a FIND request we make the contents of registers zero and one printable.\u00a0 We do this by first storing the contents of the register into a full word.\u00a0 Next we unpack the full word and finally we have to translate it to make it printable.\u00a0 The result is copied into the message area of a WTO along with the member name which is pointed to by register zero (which was copied into register 8 for save keeping).\u00a0 One think to note here is that we are not writing reentrant code.\u00a0 This is not the way a SVC routine should be written but for now we can get away with it.<\/p>\n<pre>SKIP18   DS    0H                                             \r\n         LR    R0,R8                                          \r\n         LR    R1,R9                                          \r\n         LR    R15,R10                                        \r\n         NI    TCBFLGS7,255-(TCBSVCS)  TURN OFF SVC SCREENING \r\n         SVC   18                                             \r\n         OI    TCBFLGS7,TCBSVCS        TURN ON SVC SCREENING  \r\n         LR    R14,R11            RESTORE RETURN ADDRESS      \r\n         BR    R14                RETURN TO CALLER<\/pre>\n<p>Finally we reissue the SVC call.\u00a0 First we restore the parameter registers.\u00a0 In order to allow the SVC call to actually go through instead of being intercepted again, and causing an endless loop, we have to temporarly disable screening by clearing the TCBSVCS bit.\u00a0 Once we issue the SVC we can once again set the bit to resume screening.\u00a0 All that remins is to do is to restore the return address and return to the caller.<\/p>\n<pre>        MODESET MODE=PROB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 GIVE UP SUPERVISOR STATE<\/pre>\n<p>In our previous test of SVC screening we reset the APF Authorization bit in the JSCB using my User SVC 245 after getting into supervisor state using MODESET.\u00a0 Before transfering control to the assembler we need to issue MODESET to restore us to problem state.<\/p>\n<pre>         LR    R1,R9              RESTORE PARM REG             \r\n         LINK  EP=IFOX00          TRANSFER CONTROL TO ASSEMBLER<\/pre>\n<p>Before calling the assember we need to restore the parameter register contents which was saved off in register nine.<\/p>\n<pre>JOB 6911  $HASP373 RUNSVX   STARTED - INIT 12 - CLASS A - SYS TCS3\r\nJOB 6911   6.02.51   0.00.00   0.00.00  0000   RUNSVX    COMPRESS \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IHARB                    \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IKJRB                    \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IEZXRB                   \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IEZBITS                  \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IKJTCB                   \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 TESTAUTH                 \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IHBERMAC                 \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 WTO                      \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IHBINNRA                 \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 DETACH                   \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 WAIT                     \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 ATTACH                   \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 IHBOPLST                 \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 GETMAIN                  \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 MODESET                  \r\nJOB 6911  SVC 18 R0=00096C68 R1=FFF69718 SAVE                     \r\nJOB 6911   6.02.51   0.00.00   0.00.00  0000   RUNSVX    ASM     \r\nJOB 6911   6.02.51   0.00.00   0.00.00  0000   RUNSVX    ########\r\nJOB 6911  $HASP395 RUNSVX   ENDED<\/pre>\n<p>After assembling and link editing I modified my assembler JCL and replaced the assembler program name (EXEC PGM=IFOX00) with my SVC screening program (EXEC PGM=SVCX) and added a STEPLIB.\u00a0 Here are the results of running it.\u00a0 We get a list of all the macros, including the inner macros, that were used in the assembly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that we know how to intercept SVC calls we can try something more interesting.\u00a0 When a program is assembled the various macro contained in the source code have to be read from the macro library.\u00a0 As the assembler reads these macros they are located using SVC 18 (FIND\/BLDL).\u00a0 By intercepting SVC 18 we can &#8230;<\/p>\n<p><a href=\"https:\/\/tommysprinkle.com\/mvssp\/2013\/01\/27\/intercepting-findbldl\/\" class=\"more-link\">Continue reading &lsquo;Intercepting FIND\/BLDL&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12],"tags":[23,22,24,18],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-intercepting-findbldl","tag-bldl","tag-find","tag-link","tag-modeset"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3x7AW-1n","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":7,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/posts\/85\/revisions\/114"}],"wp:attachment":[{"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tommysprinkle.com\/mvssp\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}