home *** CD-ROM | disk | FTP | other *** search
- Path: hub-n.franken.de!sokrates!snfuchs
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing a patch -A POSSIBLE SOULTION
- From: snfuchs@sokrates.franken.de (Stefan Fuchs)
- Message-ID: <snfuchs.0ci8@sokrates.franken.de>
- Date: Tue, 30 Jan 96 22:45:59 GMT
- Organization: USS Enterprise BBS, Fuerth, Germany, +49-(0)911-7568701
-
- Genie wrote:
-
- >
- > The code for the patch which is SetFunctioned somewhere looks like this:
-
- This is simlair to what my patch.library (yes I'm the author) does.
- But your code does not take into account that there might be any number of
- patches installed for the same function and that these might be removed
- in the 'wrong' order.
-
- So patch.library basically does the following:
-
-
- 1. When installing a new patch:
-
- Is there already a patch installed for this function?
- No:
- - Create the following code:
- a.: JMP b
-
- b.: addq.l #1,Usecount
- jsr NewFunction
- subq.l #1,Usecount
- JMP c ;This jump may also directly go to d,
- ;if there is no need to call the original
-
- c.: addq.l #1,Usecount
- jsr OldFunction
- subq.l #1,Usecount
- JMP d
-
- d.: rts
- - Change the jump-list in the library to point to a
-
- Yes:
- - Add a new code like seen in b
- - Recalculate the jmp instructions
-
-
- 2. When removing the patch:
- - Recalculate the jmp instructions, ignoring b
- - wait until the Usecount of b is zero
- - free the memory for b
- - if there are more functions installed (see b), we are done
- - check, if the jump-list in the library still points to a
- yes: Reinstall OldFunction in the jump-list
- wait until usecount of c is zero
- Remove the rest
- no: No luck this time (try again later when a patch.library function
- is called, or in a low-memory situation)
-
-
- This is the theory! Practically it is a still more complex task.
- Just look at all the options you have with patch.library.
-
- And even in theory this is not 100% save. A task switch may take place
- just after any of the jmp instructions, but before the addq.l #1,usecount.
-
- The only way to fix this, would be to keep this functions any memory until
- the next boot. In this case I would say this method is 100% save.
-
-
- You can find patch.library on the Aminet: util/libs/PatchLibV3.lha
- or on the Aminet Set I Cds
-
-
- Besides patch.library V4 is nearly completed (some documentation stuff)
- Some support files are also soon to be released on Aminet.
-
-
- Bye, Stefan Fuchs E-Mail: snfuchs@sokrates.franken.de
-
-