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

  1. Path: hub-n.franken.de!sokrates!snfuchs
  2. Newsgroups: comp.sys.amiga.programmer
  3. Subject: Re: Removing a patch -A POSSIBLE SOULTION
  4. From: snfuchs@sokrates.franken.de (Stefan Fuchs)
  5. Message-ID: <snfuchs.0ci8@sokrates.franken.de>
  6. Date: Tue, 30 Jan 96 22:45:59 GMT
  7. Organization: USS Enterprise BBS, Fuerth, Germany, +49-(0)911-7568701
  8.  
  9.  Genie wrote:
  10.  
  11. > The code for the patch which is SetFunctioned somewhere looks like this:
  12.  
  13. This is simlair to what my patch.library (yes I'm the author) does.
  14. But your code does not take into account that there might be any number of
  15. patches installed for the same function and that these might be removed
  16. in the 'wrong' order.
  17.  
  18. So patch.library basically does the following:
  19.  
  20.  
  21. 1. When installing a new patch:
  22.  
  23.   Is there already a patch installed for this function?
  24.   No:
  25.   - Create the following code:
  26.      a.:  JMP b
  27.  
  28.      b.:  addq.l #1,Usecount
  29.           jsr NewFunction
  30.           subq.l #1,Usecount
  31.           JMP c          ;This jump may also directly go to d,
  32.                          ;if there is no need to call the original
  33.  
  34.      c.:  addq.l #1,Usecount
  35.           jsr OldFunction
  36.           subq.l #1,Usecount
  37.           JMP d
  38.  
  39.      d.:  rts
  40.   - Change the jump-list in the library to point to a
  41.  
  42.   Yes:
  43.   - Add a new code like seen in b
  44.   - Recalculate the jmp instructions
  45.  
  46.  
  47. 2. When removing the patch:
  48.   - Recalculate the jmp instructions, ignoring b
  49.   - wait until the Usecount of b is zero
  50.   - free the memory for b
  51.   - if there are more functions installed (see b), we are done
  52.   - check, if the jump-list in the library still points to a
  53.     yes: Reinstall OldFunction in the jump-list
  54.          wait until usecount of c is zero
  55.          Remove the rest
  56.     no: No luck this time (try again later when a patch.library function
  57.         is called, or in a low-memory situation)
  58.  
  59.  
  60. This is the theory! Practically it is a still more complex task.
  61. Just look at all the options you have with patch.library.
  62.  
  63. And even in theory this is not 100% save. A task switch may take place
  64. just after any of the jmp instructions, but before the addq.l #1,usecount.
  65.  
  66. The only way to fix this, would be to keep this functions any memory until
  67. the next boot. In this case I would say this method is 100% save.
  68.  
  69.  
  70. You can find patch.library on the Aminet: util/libs/PatchLibV3.lha
  71. or on the Aminet Set I Cds
  72.  
  73.  
  74. Besides patch.library V4 is nearly completed (some documentation stuff)
  75. Some support files are also soon to be released on Aminet.
  76.  
  77.  
  78. Bye, Stefan Fuchs  E-Mail: snfuchs@sokrates.franken.de
  79.  
  80.