1
0

userdbg.h 6.7 KB

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