home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / be.zip / bedisext.h < prev    next >
C/C++ Source or Header  |  2000-01-07  |  4KB  |  148 lines

  1. //
  2. // bedisext.h - Interface needed by implementors of BE disassemblers
  3. //
  4. // bedis_init will be called before any other function.
  5. // If initialisation fails, FALSE is returned and err says why.
  6. //
  7. // bedis_term is called after all the other functions.
  8. // bedis_term can be omitted, if there is no module termination.
  9. //
  10. // bedis_disassemble is fed an address, and generates a text version.
  11. // How many bytes were needed is returned also.
  12. // It uses read (set up earlier) to fetch data.
  13. // It uses symbolic (set up earlier) to get symbolic addresses.
  14. // If couldn't fetch data for disassembly, returns FALSE.
  15. // BE displays addresses of instructions, and opcodes, but bedis_dissasemble
  16. // displays addresses in operands.
  17. //
  18. // bedis_code returns TRUE if the instruction at a given address contains
  19. // a branch, branch and link, jump, call etc. to an address, and returns
  20. // that address, if it is known.
  21. // If it is a computed branch (eg: via a register), then FALSE is returned.
  22. // BE can bring up a disassembly listing for numbers annotated 'code', and
  23. // values returned from this function.
  24. // A simple disassembler not supporting this feature could omit this function.
  25. //
  26. // bedis_data returns TRUE if instruction references a data item.
  27. // The '*' keypress can be used to jump to data.
  28. // A simple disassembler not supporting this feature could omit this function.
  29. //
  30. // bedis_options is a way to request disassembly to be done in a given way,
  31. // based on a user typed option string.
  32. // This function is optional.
  33. //
  34. // If 64 bit address space entrypoints are implemented, then BE will use
  35. // these, otherwise it will call the older 32 bit entrypoints.
  36. //
  37.  
  38. #ifndef BEDISEXT_H
  39. #define    BEDISEXT_H
  40.  
  41. #ifndef Boolean_DEFINED
  42. #define    Boolean_DEFINED
  43. typedef int Boolean;
  44. #define    TRUE  1
  45. #define FALSE 0
  46. #endif
  47.  
  48. #if   defined(OS2)
  49. #define    BEDISEXPORT
  50. #define    BEDISENTRY _System
  51. #define    BEDISADDR32 unsigned
  52. #define    BEDISADDR64 unsigned_long_long
  53. #elif defined(WIN32)
  54. #define    BEDISEXPORT __declspec(dllexport)
  55. #define    BEDISENTRY __stdcall
  56. #define    BEDISADDR32 unsigned
  57. #define    BEDISADDR64 unsigned __int64
  58. #elif defined(DOS32)
  59. #define    BEDISEXPORT
  60. #define    BEDISENTRY __export _cdecl
  61. #define    BEDISADDR32 unsigned
  62. #define    BEDISADDR64 unsigned __int64
  63. #elif defined(NW)
  64. #define    BEDISEXPORT
  65. #define    BEDISENTRY
  66. #define    BEDISADDR32 unsigned
  67. #define    BEDISADDR64 unsigned __int64
  68. #else
  69. #define    BEDISEXPORT
  70. #define    BEDISENTRY
  71. #define    BEDISADDR32 unsigned
  72. #define    BEDISADDR64 unsigned long long
  73. #endif
  74.  
  75. #ifdef AIX
  76. typedef void (*BEDIS_EP)(void);
  77. typedef struct { BEDIS_EP ep; const char *name; } BEDIS_EXPORT;
  78. #endif
  79.  
  80. typedef Boolean (*BEDISREAD32)(BEDISADDR32 addr, unsigned char & b);
  81. typedef Boolean (*BEDISSYMBOLIC32)(BEDISADDR32 addr, char *id, BEDISADDR32 & offset);
  82.  
  83. #ifdef BE64
  84. typedef Boolean (*BEDISREAD64)(BEDISADDR64 addr, unsigned char & b);
  85. typedef Boolean (*BEDISSYMBOLIC64)(BEDISADDR64 addr, char *id, BEDISADDR64 & offset);
  86. #endif
  87.  
  88. extern "C" {
  89.  
  90. BEDISEXPORT Boolean BEDISENTRY bedis_init(
  91.     BEDISREAD32 read,
  92.     BEDISSYMBOLIC32 symbolic,
  93.     const char *(&err)
  94.     );
  95.  
  96. BEDISEXPORT Boolean BEDISENTRY bedis_disassemble(
  97.     BEDISADDR32 addr,
  98.     BEDISADDR32 & bytes,
  99.     char *display
  100.     );
  101.  
  102. BEDISEXPORT Boolean BEDISENTRY bedis_ref_code(
  103.     BEDISADDR32 addr,
  104.     BEDISADDR32 & ref_addr
  105.     );
  106.  
  107. BEDISEXPORT Boolean BEDISENTRY bedis_ref_data(
  108.     BEDISADDR32 addr,
  109.     BEDISADDR32 & ref_addr
  110.     );
  111.  
  112. #ifdef BE64
  113.  
  114. BEDISEXPORT Boolean BEDISENTRY bedis_init_64(
  115.     BEDISREAD64 read,
  116.     BEDISSYMBOLIC64 symbolic,
  117.     const char *(&err)
  118.     );
  119.  
  120. BEDISEXPORT Boolean BEDISENTRY bedis_disassemble_64(
  121.     BEDISADDR64 addr,
  122.     BEDISADDR64 & bytes,
  123.     char *display
  124.     );
  125.  
  126. BEDISEXPORT Boolean BEDISENTRY bedis_ref_code_64(
  127.     BEDISADDR64 addr,
  128.     BEDISADDR64 & ref_addr
  129.     );
  130.  
  131. BEDISEXPORT Boolean BEDISENTRY bedis_ref_data_64(
  132.     BEDISADDR64 addr,
  133.     BEDISADDR64 & ref_addr
  134.     );
  135.  
  136. #endif
  137.  
  138. BEDISEXPORT Boolean BEDISENTRY bedis_options(
  139.     const char *options,
  140.     const char *(&err)
  141.     );
  142.  
  143. BEDISEXPORT void BEDISENTRY bedis_term(void);
  144.  
  145. }
  146.  
  147. #endif
  148.