home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 6 / Sonderheft_6-96.iso / pd / libraries / patchlib / include / patch.i < prev    next >
Encoding:
Text File  |  1996-11-04  |  6.7 KB  |  180 lines

  1.     IFND LIBRARIES_PATCH_I
  2. LIBRARIES_PATCH_I SET 1
  3. **
  4. **    Filename:    libraries/patch.i
  5. **    Release:    5.0 BETA
  6. **    Date:        20.08.96
  7. **
  8. **    (C) Copyright 1993-96 Stefan Fuchs
  9. **    All rights reserved
  10. **
  11. **      definition of patch.library public structures, returncodes and macros
  12.  
  13.  
  14.     IFND EXEC_TYPES_I
  15.     include "exec/types.i"
  16.     ENDC
  17.  
  18.     IFND EXEC_LISTS_I
  19.     include "exec/lists.i"
  20.     ENDC
  21.  
  22.     IFND EXEC_LIBRARIES_I
  23.     include "exec/libraries.i"
  24.     ENDC
  25.  
  26.     IFND EXEC_SEMAPHORES_I
  27.     include "exec/semaphores.i"
  28.     ENDC
  29.  
  30. ;-------------------------------------------------------------------------
  31. ;ErrorCodes:
  32. PATERR_Ok        equ    0    ;Everything Ok
  33. PATERR_PatchInUse    equ    1    ;Patch Usecount <> 0
  34. PATERR_InvalidHandle    equ    2    ;Pointer to patch is not (no longer) valid
  35. PATERR_OutOfMem        equ    3    ;Out of memory
  36. PATERR_OpenLib        equ    4    ;Failed to open requested library
  37. PATERR_FuncNotStd    equ    5    ;Function to patch is not in the standard format
  38. PATERR_PatchInstalled    equ    6    ;Can't remove patch because another program has
  39.                     ;installed a non-patch.library patch later
  40. PATERR_InvalidTags    equ    7    ;There was an error in the combination of the specified Tags
  41. PATERR_OpenDev        equ    8    ;Failed to open requested device
  42. PATERR_NoTaskList    equ    9    ;PATT_AddTask... or PATT_RemTask... was specified for a patch,
  43.                     ;which had no PATT_CreateTaskList set
  44. PATERR_TaskListExists    equ    10    ;PATT_CreateTaskList was specified, but there already exists a TaskList
  45. PATERR_InvalidTaskList    equ    11    ;PATT_CreateTaskList was specified with a wrong parameter
  46. PATERR_PatchUnnamed    equ    12    ;PATT_PatchName with GetPatch was specified, for a patch without an IDString
  47. PATERR_NoSemaphore    equ    13    ;Could not allocate semaphore
  48.  
  49. PATERR_KickTooOld    equ    14    ;Kickstart version is too old for this function
  50. PATERR_InvalidPattern    equ    15    ;Pattern passed via PATT_AddTaskPattern is not valid
  51. PATERR_Restricted    equ    16    ;Certain tags/features may not be used when patching certain functions
  52.  
  53. ;-------------------------------------------------------------------------
  54.  STRUCTURE PatchNotifyMessage,0
  55.     STRUCT pnm_ExecMessage,MN_SIZE
  56.     ULONG  pnm_Class
  57.     UWORD  pnm_Code
  58.     APTR   pnm_Object
  59.     LABEL  PatchNotifyMessage_SIZEOF
  60.  
  61. ;-------------------------------------------------------------------------
  62. PATCHNOTIFY_CLASS    equ    $50000000
  63. ;-------------------------------------------------------------------------
  64. ;Notification codes (pnm_Code) (ignore messages with other codes):
  65. PATCOD_PatchInstalled    equ     1    ;new patch has been added
  66. PATCOD_PatchRemoved    equ    2    ;a patch has been removed
  67. PATCOD_PatchChanged    equ    3    ;attributes of a patch have been changed
  68.  
  69. ;-------------------------------------------------------------------------
  70. PATCHNAME    MACRO
  71.     dc.b "patch.library",0
  72.     ENDM
  73.  
  74. ;---------------------------------------------------------------
  75. ;--- FALLBACK - Call this macro instead of a 'rts' instruction
  76. ;--- in your patchcode, if you want to return to the original
  77. ;--- library code
  78. ;--- WARNING: The FALLBACK macro may be replaced by a better solution in V5,
  79. ;--- and may eventually no longer work in later versions. Please E-Mail me,
  80. ;--- if you use the FALLBACK macro.
  81. ;---------------------------------------------------------------
  82. FALLBACK    MACRO
  83.     move.l (sp),-(sp)
  84.     clr.l 4(sp)
  85.     rts
  86.  
  87.     ENDM
  88.  
  89. ;---------------------------------------------------------------
  90. ;--- GETPATCHBASE - Call this macro, if you need to call patch.library
  91. ;--- functions within a patchcode
  92. ;--- - DO NOT USE OUTSIDE A PATCHCODE
  93. ;--- - DO NOT USE, IF YOU PATCH EXEC.LIBRARY/FINDNAME()
  94. ;--- Returns patchbase in a6
  95. ;---------------------------------------------------------------
  96. GETPATCHBASE    MACRO
  97.     movem.l d0/d1/a0/a1,-(sp)
  98.     move.l 4.w,a6
  99.     move.l LibList(a6),a0
  100.     lea.l 2$(pc),a1
  101.     jsr -276(a6)        ;FindName
  102.     move.l d0,a6
  103.     movem.l (sp)+,d0/d1/a0/a1
  104.     bra 1$
  105. 2$    dc.b "patch.library",0
  106.     even
  107. 1$
  108.     ENDM
  109.  
  110.  
  111. ;----------------------------------------------------------------------------
  112. ;----------------------------------------------------------------------------
  113. ;The following structures are not needed by normal patch.library applications
  114. ;----------------------------------------------------------------------------
  115. ;----------------------------------------------------------------------------
  116.     STRUCTURE PatchBase,LIB_SIZE
  117.     UBYTE PB_Flags                ;see below
  118.     UBYTE PB_reserved1
  119.     ULONG PB_private1
  120.  
  121.     STRUCT    PB_Semaphore,SS_SIZE        ;Semaphore to protect MasterPatchList
  122.     STRUCT    PB_MasterPatchHeader,LH_SIZE    ;Listheader structure for MasterPatch structures
  123.  
  124.     ;...
  125.  
  126. ;PB_Flags:
  127.     BITDEF    PB,CheckPC,0        ;If TRUE: Enable safe removal of patches!
  128.                     ;Patch.library will use a hack, which
  129.                     ;is highly dependent on OS versions and installed
  130.                     ;processors and may therefore not work with
  131.                     ;certain configurations
  132.                     ;It's unlikely to crash the machine though
  133.                     ;New with V5, default: FALSE */
  134.  
  135. ;-------------------------------------------------------------------------
  136. ; Before accessing this structure, make sure MPS_TYPE is PS_TYPE_MASTER
  137.  
  138.  STRUCTURE MasterPatch,0    ;This structure is READONLY
  139.     APTR    MPS_SUCC    ;Pointer to next (successor)
  140.     APTR    MPS_PRED    ;Pointer to previous (predecessor)
  141.     UBYTE    MPS_TYPE    ;MUST be PS_TYPE_MASTER
  142.     BYTE    MPS_PRI        ;Priority, for sorting
  143.     APTR    MPS_NAME    ;may contain a pointer to the name of the patched library
  144.                 ;To compensate the loss of a valid librarybase
  145.                 ;MPS_NAME is now (V4) guaranteed to contain a valid name
  146.                 ;this may however be a library, device or resource name
  147.     UWORD    MPS_Flags            ;no public flags defined
  148.     STRUCT    MPS_PatchHeader,MLH_SIZE    ;Listheader Structure for Patch structures
  149.     APTR    MPS_Private01            ;This pointer, up to V3 known as MPS_PatchedLibraryBase
  150.                         ;has been renamed, because with the introduction of the
  151.                         ;PatchSupervisor it may or may not contain a valid
  152.                         ;librarybase, it may even contain 0.
  153.     UWORD    MPS_PatchedLVO            ;Library Vector Offset in patched Library
  154.  
  155.     ;...
  156.  
  157. ;--------------------------------------------------------------------------
  158. ; Before accessing this structure, make sure PS_TYPE is either PS_TYPE_USER or PS_TYPE_SYSTEM
  159. ; Make sure your program can handle lists, that do not contain any nodes of
  160. ; PS_TYPE_USER or PS_TYPE_SYSTEM
  161.  
  162.  STRUCTURE Patch,0        ;This structure is READONLY
  163.     APTR    PS_SUCC        ;Pointer to next (successor)
  164.     APTR    PS_PRED        ;Pointer to previous (predecessor)
  165.     UBYTE    PS_TYPE        ;MUST be PS_TYPE_USER or PS_TYPE_SYSTEM
  166.     BYTE    PS_PRI        ;Priority, for sorting
  167.     APTR    PS_NAME        ;may contain a pointer to the name of the patch
  168.     UWORD    PS_Flags    ;no public flags defined
  169.  
  170.     ;...
  171.  
  172. ;-------------------------------------------------------------------------
  173. ;Public types for patch and masterpatch structures:
  174. PS_TYPE_MASTER    = 1    ;node is MasterPatch structure
  175. PS_TYPE_USER    = 2    ;node was installed by an Application using the library interface
  176. PS_TYPE_SYSTEM    = 3    ;node was installed by the support program PatchSetFunc
  177.  
  178.  
  179.     ENDC    ;LIBRARIES_PATCH_I
  180.