userdbg.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /*++
  2. Copyright (c) 2013 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. userdbg.h
  5. Abstract:
  6. This header defines the API between the common debugger client and the OS
  7. specific portions needed to support user mode debugging.
  8. Author:
  9. Evan Green 3-Jun-2013
  10. --*/
  11. //
  12. // ------------------------------------------------------------------- Includes
  13. //
  14. //
  15. // ---------------------------------------------------------------- Definitions
  16. //
  17. //
  18. // ------------------------------------------------------ Data Type Definitions
  19. //
  20. //
  21. // -------------------------------------------------------------------- Globals
  22. //
  23. //
  24. // -------------------------------------------------------- Function Prototypes
  25. //
  26. BOOL
  27. LaunchChildProcess (
  28. ULONG ArgumentCount,
  29. PSTR *Arguments
  30. );
  31. /*++
  32. Routine Description:
  33. This routine launches a new child process to be debugged.
  34. Arguments:
  35. ArgumentCount - Supplies the number of command line arguments for the
  36. executable.
  37. Arguments - Supplies the array of arguments to pass.
  38. Return Value:
  39. TRUE on success.
  40. FALSE on failure.
  41. --*/
  42. BOOL
  43. DbgpUserContinue (
  44. ULONG SignalToDeliver
  45. );
  46. /*++
  47. Routine Description:
  48. This routine sends the "go" command to the target, signaling to continue
  49. execution.
  50. Arguments:
  51. SignalToDeliver - Supplies the signal number to actually send to the
  52. application. For kernel debugging, this parameter is ignored.
  53. Return Value:
  54. Returns TRUE if successful, or FALSE if there was an error.
  55. --*/
  56. BOOL
  57. DbgpUserSetRegisters (
  58. PREGISTERS_UNION Registers
  59. );
  60. /*++
  61. Routine Description:
  62. This routine sets the registers of the debugging target.
  63. Arguments:
  64. Registers - Supplies a pointer to the registers to set. All register values
  65. will be written.
  66. Return Value:
  67. Returns TRUE if successful, or FALSE if there was an error.
  68. --*/
  69. BOOL
  70. DbgpUserSingleStep (
  71. ULONG SignalToDeliver
  72. );
  73. /*++
  74. Routine Description:
  75. This routine steps the target by one instruction.
  76. Arguments:
  77. SignalToDeliver - Supplies the signal number to actually send to the
  78. application. For kernel debugging, this parameter is ignored.
  79. Return Value:
  80. Returns TRUE if successful, or FALSE if there was an error.
  81. --*/
  82. BOOL
  83. DbgpUserWaitForEvent (
  84. PDEBUGGER_EVENT Event
  85. );
  86. /*++
  87. Routine Description:
  88. This routine gets an event from the target, such as a break event or other
  89. exception.
  90. Arguments:
  91. Event - Supplies a pointer where the event details will be returned.
  92. Return Value:
  93. Returns TRUE on success, or FALSE on failure.
  94. --*/
  95. BOOL
  96. DbgpUserRangeStep (
  97. PRANGE_STEP RangeStep,
  98. ULONG SignalToDeliver
  99. );
  100. /*++
  101. Routine Description:
  102. This routine continues execution until a range of execution addresses is
  103. reached.
  104. Arguments:
  105. RangeStep - Supplies a pointer to the range to go to.
  106. SignalToDeliver - Supplies the signal number to actually send to the
  107. application. For kernel debugging, this parameter is ignored.
  108. Return Value:
  109. Returns TRUE if successful, or FALSE on failure.
  110. --*/
  111. BOOL
  112. DbgpUserReadWriteMemory (
  113. BOOL WriteOperation,
  114. BOOL VirtualMemory,
  115. ULONGLONG Address,
  116. PVOID Buffer,
  117. ULONG BufferSize,
  118. PULONG BytesCompleted
  119. );
  120. /*++
  121. Routine Description:
  122. This routine retrieves or writes to the target's memory.
  123. Arguments:
  124. WriteOperation - Supplies a flag indicating whether this is a read
  125. operation (FALSE) or a write operation (TRUE).
  126. VirtualMemory - Supplies a flag indicating whether the memory accessed
  127. should be virtual or physical.
  128. Address - Supplies the address to read from or write to in the target's
  129. memory.
  130. Buffer - Supplies a pointer to the buffer where the memory contents will be
  131. returned for read operations, or supplies a pointer to the values to
  132. write to memory on for write operations.
  133. BufferSize - Supplies the size of the supplied buffer, in bytes.
  134. BytesCompleted - Supplies a pointer that receive the number of bytes that
  135. were actually read from or written to the target.
  136. Return Value:
  137. Returns TRUE if the operation was successful.
  138. FALSE if there was an error.
  139. --*/
  140. BOOL
  141. DbgpUserGetThreadList (
  142. PULONG ThreadCount,
  143. PULONG *ThreadIds
  144. );
  145. /*++
  146. Routine Description:
  147. This routine gets the list of active threads in the process (or active
  148. processors in the machine for kernel mode).
  149. Arguments:
  150. ThreadCount - Supplies a pointer where the number of threads will be
  151. returned on success.
  152. ThreadIds - Supplies a pointer where an array of thread IDs (or processor
  153. numbers) will be returned on success. It is the caller's responsibility
  154. to free this memory.
  155. Return Value:
  156. Returns TRUE if successful, FALSE on failure.
  157. --*/
  158. BOOL
  159. DbgpUserSwitchThread (
  160. ULONG ThreadId,
  161. PDEBUGGER_EVENT NewBreakInformation
  162. );
  163. /*++
  164. Routine Description:
  165. This routine switches the debugger to another thread.
  166. Arguments:
  167. ThreadId - Supplies the ID of the thread to switch to.
  168. NewBreakInformation - Supplies a pointer where the updated break information
  169. will be returned.
  170. Return Value:
  171. Returns TRUE if successful, or FALSE if there was no change.
  172. --*/
  173. BOOL
  174. DbgpUserGetLoadedModuleList (
  175. PMODULE_LIST_HEADER *ModuleList
  176. );
  177. /*++
  178. Routine Description:
  179. This routine retrieves the list of loaded binaries from the kernel
  180. debugging target.
  181. Arguments:
  182. ModuleList - Supplies a pointer where a pointer to the loaded module header
  183. and subsequent array of entries will be returned. It is the caller's
  184. responsibility to free this allocated memory when finished.
  185. Return Value:
  186. Returns TRUE on success, or FALSE on failure.
  187. --*/
  188. VOID
  189. DbgpUserRequestBreakIn (
  190. VOID
  191. );
  192. /*++
  193. Routine Description:
  194. This routine attempts to stop the running target.
  195. Arguments:
  196. None.
  197. Return Value:
  198. None.
  199. --*/
  200. ULONG
  201. DbgpUserGetSignalToDeliver (
  202. ULONG SignalNumber
  203. );
  204. /*++
  205. Routine Description:
  206. This routine returns the value for the "signal to deliver" parameters when
  207. letting the target continue. For user mode processes, breaks into the
  208. debugger occur because of signal delivery, and the debugger has the choice
  209. of whether or not to actually deliver a signal.
  210. Arguments:
  211. SignalNumber - Supplies the last signal caught by the debugger.
  212. Return Value:
  213. Returns the signal to deliver for the upcoming target continuation.
  214. 0 if no signal should be delivered to the target.
  215. --*/