home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d8xx
/
d886
/
patchlibrary.lha
/
PatchLibrary
/
Patch.man
< prev
next >
Wrap
Text File
|
1993-07-16
|
6KB
|
161 lines
patch.library V1.55 manual:
MOTIVATION:
The idea for this library came up to me, when I recently wrote some
programs, which patch into library functions.
FEATURES:
- In general patch.library offers you an easy way of installing and removing
your own patches for library functions.
- Patch.library checks, if your patch can safely be removed (e.g.: when no
other task is running in the patchcode).
- In general patches may only be removed in LIFO order. Patch.library
provides a mechanism that allows you to remove any patch you installed
with patch.library almost any time (currently it is not possible to remove
the last installed patch, if other non-patch.library patches for the same
function have been installed later).
- In addition it provides you a priority system, which allows you to specify
the sequence of the patches, if more than one patch has to be installed for
one library function.
- Patch.library also provides you a way to check, if your patch is already
installed by supplying a name field for every patch.
- Patch.library automatically flushes caches from Kick V37.xxx on, so software
that uses patch.library will continue to work on systems with an 68040 or ....
- With patch.library you have no problems patching pre-V36 dos.library
functions, since patch.library automatically detects these nonstandard
functions and takes the appropriate steps to patch these functions.
- But always remember that installing and especially removing patches can never
be coded without any risk of crashing the machine. Although patch.library does
everything possible to minimize the chances of a crash, do not use its functions
without good care (e.g. minimize the number of install and remove operations)
ABOUT PATCHCODES:
The patchcode you install must obey these rules:
- Patchcodes MUST be reentrant! (i.e. library-functions can always be used
by multiple tasks at the same time)
- Patchcodes MUST preserve ALL registers!
(If replacing a library function a valid returncode must be set as documented
in the Autodocs)
- Patchcodes MUST be pc-relative, if NPAT_NewCodeSize > 0!
- Patchcodes should use as little stack as possible, because tasks using your code
may otherwise run out of stack.
- Patchcodes can be ended either with the rts-instruction, which is the normal
method, or with the FALLBACK macro provided in 'PatchLibrary.i'.
The FALLBACK macro allows You to end the patch and execute the original
library function, if you replaced the library function (NPAT_Priority = 0).
The FALLBACK macro functions like a 'rts'-instruction, if NPAT_Priority <> 0.
NOTES & WARNINGS:
- Some library functions use in-line code (e.g.: exec.library/GetCC() )
Patching these functions will always fail.
- It's up to your patchroutines to preserve the registers.
- There is always a chance (very small) that memory will be deallocated, while
instructions from it will still executed (-> crash).
- Patching functions will use some stack (at least 4 Bytes) from programs
calling the patched function. This might crash the machine, if a program
has only a very small stack reserve.
- Files for C-support are not tested in detail (sorry!!)
MORE PROGRAMMER INFOS:
can be found in the accompanying file 'patch.doc' and in the example programs.
EXAMPLES:
The package includes two programs with assembler source to show you how
to use the patch.library:
1. CPUClr:
Installs a patch routine for graphics.library/BltClear(), which
uses the CPU instead of the BLITTER to clear Chipmem.
It shows how easy and save it can be to install and remove a patch,
without wasting memory or CPU time.
With the program CPUClrTEST you can check how much faster memory
clearing becomes.
2. ShowNeededFiles: (Simple SnoopDos)
Installs a couple of patch routines to monitor dos.library/Open(),
Lock() and LoadSeg() functions. It shows how the priority system
of patch.library works.
Break this program with CTRL-C.
FUTURE PLANS:
- Tags
- Allow patching of devices and resources
- Internal handling of PATERR_PatchInstalled
- ...
LICENSE:
This material is © Copyright 1993 by Stefan Fuchs. All rights reserved.
It may be distributed freely as long as the following restrictions are met:
- The distributor may charge a fee to recover distribution costs.
The fee for diskette distribution should not be more than
the cost to obtain the same diskette from Fred Fish.
- The distributor agrees to cease distributing the programs and
data involved if requested to do so by the author.
- You may copy and distribute verbatim copies of the program's
executable code and documentation as you receive it, in any
medium, provided that you conspicuously and appropriately
publish only the original, unmodified program, with all
copyright notices and disclaimers of warranty intact and
including all the accompanying documentation, example files and
anything else that came with the original.
- If you are interested in including any of this material in a commercial
product, you should contact the author for his permission.
- The author will not be liable for any damage arising from the
failure of the programs or the library to perform as described,
or any destruction of other programs using the library residing
on a system. While I know of no damaging errors, the user of this
package uses it at his or her own risk.
CONTACT:
To contact the author for bugreports, hints, ideas, donations, ....
write to:
Stefan Fuchs
Oskar-von-Miller-Str. 49
8500 Nürnberg 30 (from 1st July 1993 on: 90478 Nürnberg)
GERMANY