home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2511 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: news.ind.mh.se!ing9435
  2. From: ing9435@ind.mh.se (Jimmy Westerlund)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Removing a patch - solved?
  5. Date: 1 Feb 1996 11:01:01 GMT
  6. Organization: Mid Sweden University, Dept. of Industrial technology
  7. Message-ID: <slrn4h17b3.5rq.ing9435@xerxes.to.mh.se>
  8. References: <1996Jan22.150212.23377@ludens> <4e1p58$4l2@misery.millcomm.com> <815.6602T1142T756@norconnect.no> <1433.6603T1100T1439@stud.cs.uit.no>
  9. NNTP-Posting-Host: xerxes.ind.mh.se
  10. X-Newsreader: slrn (0.8.4)
  11.  
  12. In article <1433.6603T1100T1439@stud.cs.uit.no>, Nils Peter Sudmann wrote:
  13. >On 29-Jan-96 20:53:41, Kenneth C. Nilsen (kenneth@norconnect.no) wrote:
  14. >>>genie@ludens.elte.hu wrote:
  15. >>>:  - Has the removing of a patch problem been already solved?
  16. >>>Nope.  I gave it a try myself, but ran in to the Exception processing 
  17. >>>problem.
  18. >
  19. >>You have to remove the patches the opposite way they where installed. A
  20. >>patch has to check the pointer it got when first installed and compare it to
  21. >>the pointer it gets when removing it selv. If they are not alike it have to
  22. >>reinstall with this new pointer and wait. As you can see this is a critical
  23. >>point cause there is a theoretical possibility that other programs patches
  24. >>this vector while ours is comparing pointers.
  25. >
  26. >This critical point is easily avoided by enclosing the check with a
  27. >forbid()/permit(). This is not the problem. The problem is that some program
  28. >could be executing inside your patched code (and currently waiting for a time
  29. >slice). AFAIK there is *no* way to safely know when the last thread of control
  30. >has left your code (and you may unload it). So a patch should actually never
  31. >remove itself (only render itself inactive). I did miss the previous patch
  32. >discussion, but I wrote one myself and came to the above conclusion. Right or
  33. >wrong?
  34.  
  35.  Wouldn't this work:
  36.  
  37.  patch:
  38.     addq.l    #1,counter
  39.  
  40.     ; Patch stuff
  41.  
  42. exit_patch:
  43.     subq.l    #1,counter
  44.     rts
  45.  
  46.  
  47. RemovePatch()
  48. {
  49.     Forbid();
  50.     while(has_function_been_repacthed())
  51.     {
  52.         Permit();
  53.         Delay_or_notify_user();
  54.         Forbid();
  55.     }
  56.  
  57.     Restore_old_patch();
  58.     
  59.     while(counter > 0)
  60.     {
  61.         Permit();
  62.         Delay_or_notify_user();
  63.         Forbid();
  64.     }
  65.     Permit();
  66.     unload_patch_code();
  67. }    
  68.  
  69. >
  70. >--
  71. >Nils Peter Sudmann                  // Using Thor v2.21/#1113, sign v1.5
  72. >"Truth, a random variable possibly // EMAIL: nilss@stud.cs.uit.no
  73. > containing complex numbers"      // WWW: http://www.cs.uit.no/~nilss
  74. >
  75. >
  76.  
  77.  /Jimmy Westerlund -- jimmy@eagle.ovik.se
  78.  
  79.