home *** CD-ROM | disk | FTP | other *** search
- Path: norconnect.no!not-for-mail
- From: kenneth@norconnect.no (Kenneth C. Nilsen)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing a patch -A POSSIBLE SOULTION
- Date: 30 Jan 1996 00:35:57 +0100
- Organization: NorConnect Internet Services AS
- Message-ID: <2650.6603T32T2733@norconnect.no>
- References: <1996Jan29.141204.23597@ludens>
- NNTP-Posting-Host: norconnect.no
- X-Newsreader: THOR 2.21 (Amiga;SOUP)
-
- >PatchMan: addq #1,UseCount ;how many tasks using this patch?
- [...]
-
- >Good for a discussion, isn't it? Any thougths?
-
- Hi.
-
- It will only disallow the patch to be removed while it is in use. It will not
- be safe when another program patches the same vector and calling your
- routine and you remove the patch:
-
- Your patch -> original function
-
- This is ok, now you can remove your patch (-> = calls)
-
- The other patch installs itself:
-
- 2. Patch -> Your patch -> original function
-
- /\
- |
- Vector not in use -> remove (according to your routine)
-
- Use vector: 2.Patch -> ??? = guru/hangup (most likely)
-
- Your patch keeps the pointer to the original function. When the new patch is
- installed it gets the pointer to *your* routine from SetFunction(). If you
- remove your patch the new patch will jump into unsafe memory/code since your
- routine don't exists anymore.
-
- Your patch need something like this:
-
- Not in use -> Forbid() -> Remove -> Compare new pointer ->
-
- Is it the same as the pointer to your code when you installed your patch?
- no -> reinstall/enable() and wait/retry/prompt
- yes -> remove/enable()
-
- That means if a program has installed a patch after your patch on the same
- vector you cannot remove it before the latest patch has removed itself cause:
-
- If another patch is installed after yours, the SetFunction() will return a
- pointer to this function. If not it should be the same as the pointer as to
- your routine when first installing your patch.
-
-
- Pseduo:
-
- -> Pointer to MyRoutine
- -> Vector
- -> Library
- Call SetFunction()
- Pointer -> OldFunc
-
- [bla bla]
-
- Remove:
-
- Forbid()
- -> Orginal pointer
- -> Vector
- -> Library
- Call SetFunction()
- Pointer -> ThisFunc
- Compare ThisFunc with MyRoutine
- if = then continue, else stay patched (reinstall with SetFunction())
- Permit()
-
- Reinstall: (stay patched)
-
- ->ThisFunc
- ->Vector
- ->Library
- Call SetFunction()
- ...
- Permit()
- Prompt requester "Can't remove: vector is patched by another program"
-
- When installing patches:
-
- Patch 1 -> 2 -> 3 -> 4 etc.
-
- Must be removed like this:
-
- Patch 4 -> 3 -> 2 -> 1
-
- Since the patch installed last is depended on the old patch/routine before.
-
- Again: you cannot remove patch no. 2 before patch 3 and 4 are removed.
-
- Hope this clears things up a little :-)
-
-
- ---
- CREATIVE LINKS __ Kenneth C. Nilsen
- http://www.norconnect.no/~kenneth /_/\ e-mail: kenneth@norconnect.no
- "Everything you want" \_\/ Software & MultiMedia developer
-