Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
4.1 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. simpldis.h
  5. Abstract:
  6. Generic C language interface to PUMA disassembler.
  7. This is designed to expose the functionality of the PUMA disassembler
  8. via a simple C language API. It is not intended to be as flexible or
  9. as efficient as using the DIS class interface. It is intended to provide
  10. "least common denominator" access to the disassembler for C code which
  11. does not have stringent performance demands. A minimum set of types is
  12. exposed, and they are named so as to minimize the chance of collisions.
  13. Author:
  14. KentF 16-Jan-1996
  15. --*/
  16. #ifndef _SIMPLDIS_H
  17. #define _SIMPLDIS_H
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. enum _SIMPLE_ARCHITECTURE {
  22. Simple_Arch_X86,
  23. Simple_Arch_Mips,
  24. Simple_Arch_AlphaAxp,
  25. Simple_Arch_PowerPc
  26. };
  27. //
  28. // enumeration for x86 registers.
  29. // all of the other platforms currently supported
  30. // use an intuitively obvious register numbering
  31. // scheme - e.g. r0..r31 represented as 0..31
  32. //
  33. enum _SIMPLE_REGX86
  34. {
  35. SimpleRegEax = 0,
  36. SimpleRegEcx = 1,
  37. SimpleRegEdx = 2,
  38. SimpleRegEbx = 3,
  39. SimpleRegEsp = 4,
  40. SimpleRegEbp = 5,
  41. SimpleRegEsi = 6,
  42. SimpleRegEdi = 7,
  43. };
  44. #define SD_STRINGMAX 100
  45. //
  46. // disassembly return structure. this contains
  47. // all of the data returned from the disassembler.
  48. // it contains no input data, and need not be
  49. // initialized by the caller.
  50. //
  51. typedef struct _SIMPLEDIS {
  52. DWORD dwEA0; // First effective address
  53. size_t cbEA0; // data size
  54. DWORD dwEA1; // Second effective address
  55. size_t cbEA1; // data size
  56. DWORD dwEA2; // Third effective address
  57. size_t cbEA2; // data size
  58. DWORD cbMemref; // size of data at EA0
  59. DWORD dwBranchTarget; // branch target, if IsBranch or IsCall
  60. DWORD dwJumpTable; // jump table for indirect jumps
  61. DWORD cbJumpEntry; // size of each jump table entry
  62. BOOL IsCall;
  63. BOOL IsBranch;
  64. BOOL IsTrap;
  65. char szAddress[SD_STRINGMAX];
  66. char szRaw[SD_STRINGMAX];
  67. char szOpcode[SD_STRINGMAX];
  68. char szOperands[SD_STRINGMAX];
  69. char szComment[SD_STRINGMAX];
  70. char szEA0[SD_STRINGMAX];
  71. char szEA1[SD_STRINGMAX];
  72. char szEA2[SD_STRINGMAX];
  73. } SIMPLEDIS, *PSIMPLEDIS;
  74. // Pfncchaddr() is the callback function for symbol lookup.
  75. // If the address is non-zero, the callback function is called during
  76. // CchFormatInstr to query the symbol for the supplied address. If there
  77. // is no symbol at this address, the callback should return 0.
  78. typedef
  79. size_t (WINAPI *PFNCCHADDR) (
  80. PVOID pv,
  81. DWORD addr,
  82. PCHAR symbol,
  83. size_t symsize,
  84. DWORD *displacement
  85. );
  86. // Pfncchfixup() is the callback function for symbol lookup.
  87. // If the address is non-zero, the callback function is called during
  88. // CchFormatInstr to query the symbol and displacement referenced by
  89. // operands of the current instruction. The callback should examine the
  90. // contents of the memory identified by the supplied address and size and
  91. // return the name of any symbol targeted by a fixup on this memory and the
  92. // displacement from that symbol. If there is no fixup on the specified
  93. // memory, the callback should return 0.
  94. typedef
  95. size_t (WINAPI *PFNCCHFIXUP) (
  96. PVOID pv,
  97. DWORD ipaddr,
  98. DWORD addr,
  99. size_t opsize,
  100. PCHAR symbol,
  101. size_t symsize,
  102. DWORD *displacement
  103. );
  104. typedef
  105. size_t (WINAPI *PFNCCHREGREL) (
  106. PVOID pv,
  107. DWORD ipaddr,
  108. int reg,
  109. DWORD offset,
  110. PCHAR symbol,
  111. size_t symsize,
  112. DWORD *displacement
  113. );
  114. typedef
  115. DWORDLONG (WINAPI *PFNQWGETREG) (
  116. PVOID pv,
  117. int reg
  118. );
  119. int
  120. WINAPI
  121. SimplyDisassemble(
  122. PBYTE pb,
  123. const size_t cbMax,
  124. const DWORD Address,
  125. const int Architecture,
  126. PSIMPLEDIS Sdis,
  127. PFNCCHADDR pfnCchAddr,
  128. PFNCCHFIXUP pfnCchFixup,
  129. PFNCCHREGREL pfnCchRegrel,
  130. PFNQWGETREG pfnQwGetreg,
  131. const PVOID pv
  132. );
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif // _SIMPLDIS_H