Rewrote the apihooks plugin to be more robust and work on 64 bits.

BUG=

Review URL: https://codereview.appspot.com/104460043