Source code of Windows XP (NT5)
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.

82 lines
3.2 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: transdbg.h
  5. //
  6. // Description: Include file to define some basic debugger extension macros
  7. //
  8. // Author: mikeswa
  9. //
  10. // Copyright (C) 1998 Microsoft Corporation
  11. //
  12. //-----------------------------------------------------------------------------
  13. #ifndef __TRANSDBG_H__
  14. #define __TRANSDBG_H__
  15. #define NOEXTAPI
  16. #include <wdbgexts.h>
  17. //---[ TRANS_DEBUG_EXTENSION ]-------------------------------------------------
  18. //
  19. //
  20. // Description: Macro used to declare a debug extension. The variable names
  21. // used are consistant with the debug function macros defined below
  22. //
  23. // Parameters:
  24. // function - Name of the function to declare
  25. //
  26. // Returns:
  27. // -
  28. //
  29. //-----------------------------------------------------------------------------
  30. #define TRANS_DEBUG_EXTENSION(function) \
  31. void function(HANDLE hCurrentProcess, \
  32. HANDLE hCurrentThread, \
  33. DWORD dwCurrentPc, \
  34. PWINDBG_EXTENSION_APIS pExtensionApis, \
  35. PCSTR szArg)
  36. //---[ Debug function Macros ]-------------------------------------------------
  37. //
  38. //
  39. // Description:
  40. // The following Macros are defined to make writing debugging extensions
  41. // easier.
  42. // dprintf - printf to the debugger
  43. // GetExpression - Resolves symbolic expression to DWORD. Takes a
  44. // LPSTR.
  45. // GetSymbol -
  46. // Disassm - Disasemble code at given location
  47. // CheckControlC -
  48. // ReadMemory - Readmemory in the debuggee. Takes the follow arg:
  49. // a PVOID - Pointer value to read
  50. // b PVOID - Buffer to copy memory to
  51. // c DWORD - # of bytes to read
  52. // d PDWORD - OUT - # of bytes read (can be NULL)
  53. // WriteMemory - Writememory in the process being debugged. Takes
  54. // the same arguments as ReadMemory.
  55. // DebugArgs - Used to pass all the debug args to another extension
  56. //
  57. // Notes:
  58. // It is important to realize that you cannot directly read/write pointers
  59. // that are obtained from the process being debugged. You must use the
  60. // ReadMemory and WriteMemory Macros
  61. //
  62. //-----------------------------------------------------------------------------
  63. #define dprintf (pExtensionApis->lpOutputRoutine)
  64. #define GetExpression (pExtensionApis->lpGetExpressionRoutine)
  65. #define GetSymbol (pExtensionApis->lpGetSymbolRoutine)
  66. #define Disasm (pExtensionApis->lpDisasmRoutine)
  67. #define CheckControlC (pExtensionApis->lpCheckControlCRoutine)
  68. #define ReadMemory(a,b,c,d) \
  69. ((pExtensionApis->nSize == sizeof(WINDBG_OLD_EXTENSION_APIS)) ? \
  70. ReadProcessMemory( hCurrentProcess, (LPCVOID)(a), (b), (c), (d) ) \
  71. : pExtensionApis->lpReadProcessMemoryRoutine( (ULONG_PTR)(a), (b), (c), (d) ))
  72. #define WriteMemory(a,b,c,d) \
  73. ((pExtensionApis->nSize == sizeof(WINDBG_OLD_EXTENSION_APIS)) ? \
  74. WriteProcessMemory( hCurrentProcess, (LPVOID)(a), (LPVOID)(b), (c), (d) ) \
  75. : pExtensionApis->lpWriteProcessMemoryRoutine( (ULONG_PTR)(a), (LPVOID)(b), (c), (d) ))
  76. #define DebugArgs hCurrentProcess, hCurrentThread, dwCurrentPc, pExtensionApis, szArg
  77. #endif //__TRANSDBG_H__