Re: How does setpatch work?
- From: Ben Hutchings <ben-public-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Aug 2005 13:27:31 +0100
<a1_nocrap_exh@xxxxxxxxxxx> wrote:
> Anyone here know how setpatch actually works?
>
> I dont mean what are the command line options etc. But how does it
> work?
>
> Kickstart is in ROM, the Amiga hardware is designed to boot off
> kickstart. I'm guessing it loads as usual, enough drivers to access the
> hard disk and run the set-patch command.
>
> I guess the Kickstart ROM code loads some function jump table into RAM.
> Set-patch loads OS patches into RAM also and then modifies this jump
> table.
That is pretty much correct.
> What I am curious about is the structure of this table (if there is
> one) and approximately how it works.
<snip>
When a shared library is first opened, it generates a jump table in
RAM. Usually this is done from an array of function entry points. On
a 68000 system, each entry in the jump table takes up 6 bytes and
normally consists of a JMP absolute instruction. (There are
exceptions such as dos.library prior to v36 (r2.0) and exec.library's
GetCC function.)
Device drivers also have a jump table along the same lines, though
almost all device driver calls are done through just two functions.
Opening a library returns a "base pointer" for the library; starting
at this address is a standard library structure followed by any
library-specific variables and before it is the jump table. This
allows the two structures to grow in opposite directions as new
features are added to the library. Shared library calls are performed
using a JSR relative instruction with the base pointer loaded into A6
(usually; a few functions don't require this) and the appropriate jump
table offset (also called library vector offset or LVO for short).
Since the jump tables are in RAM, any entry in them can be replaced.
There is a function in exec.library called SetFunction which will do
this, assuming that the entry is initially a JMP instruction. However
this isn't suitable for use by a patch that wraps rather than
replacing the original function.
What I don't know is how SetPatch patches code that isn't called
(at least, not directly) through library functions. For example
SetPatch v38 (r2.1) internationalises Workbench v37 (r2.0).
--
Ben Hutchings
Man invented language to satisfy his deep need to complain. - Lily Tomlin
.
- References:
- How does setpatch work?
- From: a1_nocrap_exh
- How does setpatch work?
- Prev by Date: How does setpatch work?
- Previous by thread: How does setpatch work?
- Index(es):
Relevant Pages
|