Solved

Patch *TWOWORDINLINE*  function

Posted on 1997-01-16
1
557 Views
Last Modified: 2012-06-27
I want to patch a MacOS function which is declared like this:
   extern ... MacOSFunction(...)
      TWOWORDINLINE(...,...);
With *ONEWORDINLINE* functions, I known I must use Get/SetToolTrapAddress(). But for *TWO/THREEWORDINLINE functions, how can I do ?
0
Comment
Question by:bod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
mummu earned 200 total points
ID: 1535223
When a function is declared as ONEWORDINLINE, that word is a reference to an A-Trap. As you are aware, Get/SetToolTrapAddress retrieves or sets the function pointer referenced by that A-Trap.

Some toolbox functions, however, do not have individual trap words but are referenced through a subsidiary dispatch function. This is very common with File Manager routines, for example.

When such a function is called, what actually happens is that a "selector" is pushed onto the stack and then the A-Trap of a selector dispatch routine is called. That dispatch routine then looks at the selector and determines what subsidiary function to call.

This is what a TWOWORDINLINE function is. The first word is the selector code that gets pushed onto the stack. The second is the A-trap of the dispatch routine.

For example, PBGetCatInfoSync is declared as TWOWORDINLINE {0x7009, 0xA260}

0x7009 is the selector code and
0xA260 is the _HFSDispatch A-trap.

When the routine is called, it pushes 0x7009 onto the stack and then jumps to the address referenced by _HFSDispatch. _HFSDispatch then looks at the selector code and dispatches the call to the PBGetCatInfoSync call as appropriate.

Most of the HFS PB calls are actually calls to _HFSDispatch.

In this case, on a 68K machine, you can patch _HFSDispatch, check to see if the selector code is the one you're interested in, do what you need to do, and then pass anything else on to the old _HFSDispatch. This should work with any TWOWORDINLINE functions.

However, InsideMac: PPC System Software states that it isn't possible to individually patch selector-based functions on a PowerPC so if you have to do this, you should write it in 680x0 code.

In general, patching a TWOWORDINLINE function is fairly risky and you must be very careful when doing it. If at all possible, you should try to find an alternative way to do it.
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Even though Mac OS X has been around for many years now, certain well-liked and eminently useful software apps never made the jump from Mac OS 9 to Mac OS X. Ever used Word Perfect for Mac? Version 3.5 was the last version, built for Mac OS 9. Who c…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question