home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / 3_1SWTOO.DMS / in.adf / wack.lha / demos / ShowLVO.wack < prev    next >
Encoding:
Text File  |  1993-09-10  |  1.8 KB  |  78 lines

  1. /* ShowLVO.wack
  2.  *
  3.  * (c) Copyright 1992-1993 Commodore-Amiga, Inc.  All rights reserved.
  4.  *
  5.  * This software is provided as-is and is subject to change; no warranties
  6.  * are made.  All use is at your own risk.  No liability or responsibility
  7.  * is assumed.
  8.  *
  9.  * Wack script to show the address that a library's LVO points to.
  10.  * Will set the spare address to this.
  11.  *
  12.  * Syntax:    lvo library[.library] function
  13.  *
  14.  * Example:    lvo intuition OpenWindow
  15.  *    or:    lvo intuition cc
  16.  *    ->    intuition.library OpenWindow(), offset cc, jumps to 00FCD65E
  17.  *
  18.  * Suggested binding:    bindrx lvo showlvo
  19.  */
  20.  
  21. options results
  22. if ( arg() > 0 ) then
  23. DO
  24.     argline = arg(1)
  25.     parse var argline library" "function
  26.     if ( right(library,8) = ".library" ) then
  27.     DO
  28.         library = left(library,length(library)-8)
  29.     END
  30.     findlibrary library".library"
  31.     libaddr = result
  32.     if ( rc ~= 0 ) then
  33.     DO
  34.         Print "Couldn't find "library".library"
  35.         exit
  36.     END
  37.     call open 'pragmafile', "include:pragmas/"library"_pragmas.h"
  38.     done = 0
  39.     line = ""
  40.     DO until (done ~= 0)
  41.         readdata = readln('pragmafile')
  42.         if (eof('pragmafile')) then
  43.             done = 2
  44.         else
  45.         DO
  46.             /* Only check lines beginning with #pragma, and
  47.              * strip off the register descriptor number, since
  48.              * it might just match the offset the caller wanted.
  49.              */
  50.             if ( left(readdata,7) = "#pragma" ) then
  51.             DO
  52.                 readdata = left(readdata,lastpos(' ',readdata))
  53.                 if ( pos(function,readdata,1) > 0 ) then
  54.                 DO
  55.                     parse var readdata "Base" func offset .
  56.                     done = 1
  57.                 END
  58.             END
  59.         END
  60.     END
  61.     if ( done ~= 1 ) then
  62.     DO
  63.         Print "Couldn't find function "function"() in" library".library"
  64.         exit
  65.     END
  66.     
  67.     call close 'pragmafile'
  68.     lvoaddr = d2x(x2d(libaddr)-x2d(offset))
  69.     readlong d2x( x2d(lvoaddr)+2 )
  70.     addr = result
  71.     Print library".library "func"(), offset "offset", jumps to "addr
  72.     spareaddr addr
  73. END
  74. else
  75. DO
  76.     'print Bad syntax'
  77. END
  78.