RubyInject is a Mac OS X framework that allows you to inject at runtime the Ruby interpreter into any running application, using the mach_star∞ mechanism.
It will spawn a new thread on the remote process, initialize the Ruby interpreter, start a new DRb server that exposes an expression evaluator object, and advertises the DRb server URI on Bonjour.
A client is provided, inject.rb, that waits on Bonjour for the DRb server URI, connects to it, then either executes a given Ruby script or starts an IRB session.
RubyInject is especially useful when combined with RubyCocoa. You can at runtime inject RubyCocoa into an Objective-C application and start introspecting and messaging its objects:
Mac OS X 10.5 or later.
RubyCocoa 0.13.0 or later.
You can download from the source archives∞ or get the latest bits from SVN:
See the README file for details about installation, and COPYRIGHT about licensing terms.
It will spawn a new thread on the remote process, initialize the Ruby interpreter, start a new DRb server that exposes an expression evaluator object, and advertises the DRb server URI on Bonjour.
A client is provided, inject.rb, that waits on Bonjour for the DRb server URI, connects to it, then either executes a given Ruby script or starts an IRB session.
RubyInject is especially useful when combined with RubyCocoa. You can at runtime inject RubyCocoa into an Objective-C application and start introspecting and messaging its objects:
$ open -a textedit $ ps auxwww | grep TextEdit | grep -v grep lrz 69194 0.0 0.3 423316 6136 ?? S 8:12PM 0:00.15 /Applications/TextEdit.app/Contents/MacOS/TextEdit -psn_0_10574357 $ sudo ruby inject.rb 69194 Password: >> require 'osx/cocoa' => "true" >> include OSX => "Object" >> NSApp => "#<OSX::NSApplication:0xafd0962 class='NSApplication' id=0x1168e0>" >> NSApp.windows => "#<NSCFArray [#<OSX::NSWindow:0xafc7074 class='NSWindow' id=0x177f10>]>" >>
Requirements
Mac OS X 10.5 or later.
RubyCocoa 0.13.0 or later.
Download
You can download from the source archives∞ or get the latest bits from SVN:
$ svn co https://rubycocoa.svn.sourceforge.net/svnroot/rubycocoa/branches/users/lrz/RubyInject
See the README file for details about installation, and COPYRIGHT about licensing terms.