home *** CD-ROM | disk | FTP | other *** search
- Path: news.ind.mh.se!ing9435
- From: ing9435@ind.mh.se (Jimmy Westerlund)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing a patch - solved?
- Date: 1 Feb 1996 11:01:01 GMT
- Organization: Mid Sweden University, Dept. of Industrial technology
- Message-ID: <slrn4h17b3.5rq.ing9435@xerxes.to.mh.se>
- References: <1996Jan22.150212.23377@ludens> <4e1p58$4l2@misery.millcomm.com> <815.6602T1142T756@norconnect.no> <1433.6603T1100T1439@stud.cs.uit.no>
- NNTP-Posting-Host: xerxes.ind.mh.se
- X-Newsreader: slrn (0.8.4)
-
- In article <1433.6603T1100T1439@stud.cs.uit.no>, Nils Peter Sudmann wrote:
- >On 29-Jan-96 20:53:41, Kenneth C. Nilsen (kenneth@norconnect.no) wrote:
- >>>genie@ludens.elte.hu wrote:
- >>>: - Has the removing of a patch problem been already solved?
- >>>Nope. I gave it a try myself, but ran in to the Exception processing
- >>>problem.
- >
- >>You have to remove the patches the opposite way they where installed. A
- >>patch has to check the pointer it got when first installed and compare it to
- >>the pointer it gets when removing it selv. If they are not alike it have to
- >>reinstall with this new pointer and wait. As you can see this is a critical
- >>point cause there is a theoretical possibility that other programs patches
- >>this vector while ours is comparing pointers.
- >
- >This critical point is easily avoided by enclosing the check with a
- >forbid()/permit(). This is not the problem. The problem is that some program
- >could be executing inside your patched code (and currently waiting for a time
- >slice). AFAIK there is *no* way to safely know when the last thread of control
- >has left your code (and you may unload it). So a patch should actually never
- >remove itself (only render itself inactive). I did miss the previous patch
- >discussion, but I wrote one myself and came to the above conclusion. Right or
- >wrong?
-
- Wouldn't this work:
-
- patch:
- addq.l #1,counter
-
- ; Patch stuff
-
- exit_patch:
- subq.l #1,counter
- rts
-
-
- RemovePatch()
- {
- Forbid();
- while(has_function_been_repacthed())
- {
- Permit();
- Delay_or_notify_user();
- Forbid();
- }
-
- Restore_old_patch();
-
- while(counter > 0)
- {
- Permit();
- Delay_or_notify_user();
- Forbid();
- }
- Permit();
- unload_patch_code();
- }
-
- >
- >--
- >Nils Peter Sudmann // Using Thor v2.21/#1113, sign v1.5
- >"Truth, a random variable possibly // EMAIL: nilss@stud.cs.uit.no
- > containing complex numbers" // WWW: http://www.cs.uit.no/~nilss
- >
- >
-
- /Jimmy Westerlund -- jimmy@eagle.ovik.se
-
-