home *** CD-ROM | disk | FTP | other *** search
- /* ShowLVO.wack
- *
- * (c) Copyright 1992-1993 Commodore-Amiga, Inc. All rights reserved.
- *
- * This software is provided as-is and is subject to change; no warranties
- * are made. All use is at your own risk. No liability or responsibility
- * is assumed.
- *
- * Wack script to show the address that a library's LVO points to.
- * Will set the spare address to this.
- *
- * Syntax: lvo library[.library] function
- *
- * Example: lvo intuition OpenWindow
- * or: lvo intuition cc
- * -> intuition.library OpenWindow(), offset cc, jumps to 00FCD65E
- *
- * Suggested binding: bindrx lvo showlvo
- */
-
- options results
- if ( arg() > 0 ) then
- DO
- argline = arg(1)
- parse var argline library" "function
- if ( right(library,8) = ".library" ) then
- DO
- library = left(library,length(library)-8)
- END
- findlibrary library".library"
- libaddr = result
- if ( rc ~= 0 ) then
- DO
- Print "Couldn't find "library".library"
- exit
- END
- call open 'pragmafile', "include:pragmas/"library"_pragmas.h"
- done = 0
- line = ""
- DO until (done ~= 0)
- readdata = readln('pragmafile')
- if (eof('pragmafile')) then
- done = 2
- else
- DO
- /* Only check lines beginning with #pragma, and
- * strip off the register descriptor number, since
- * it might just match the offset the caller wanted.
- */
- if ( left(readdata,7) = "#pragma" ) then
- DO
- readdata = left(readdata,lastpos(' ',readdata))
- if ( pos(function,readdata,1) > 0 ) then
- DO
- parse var readdata "Base" func offset .
- done = 1
- END
- END
- END
- END
- if ( done ~= 1 ) then
- DO
- Print "Couldn't find function "function"() in" library".library"
- exit
- END
-
- call close 'pragmafile'
- lvoaddr = d2x(x2d(libaddr)-x2d(offset))
- readlong d2x( x2d(lvoaddr)+2 )
- addr = result
- Print library".library "func"(), offset "offset", jumps to "addr
- spareaddr addr
- END
- else
- DO
- 'print Bad syntax'
- END
-