Leaked source code of windows server 2003
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.

120 lines
4.3 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: stdext64.h
  3. *
  4. * Copyright (c) 1995-1998, Microsoft Corporation
  5. *
  6. * This module contains standard routines for creating sane debuging extensions.
  7. *
  8. * History:
  9. * 11-Apr-1995 Sanfords Created
  10. \***************************************************************************/
  11. #ifdef NOEXTAPI
  12. #undef NOEXTAPI
  13. #endif // !NOEXTAPI
  14. #define NOEXTAPI
  15. #include <wdbgexts.h>
  16. /*
  17. * Preceeding this header the following must have been defined:
  18. * PSTR pszExtName;
  19. *
  20. * This module includes "exts.h" which defines what exported functions are
  21. * supported by each extension and contains all help text and legal option
  22. * information. At a minimum exts.h must have:
  23. DOIT( help
  24. ,"help -v [cmd] - Displays this list or gives details on command\n"
  25. ," help - To dump short help text on all commands.\n"
  26. " help -v - To dump long help text on all commands.\n"
  27. " help cmd - To dump long help on given command.\n"
  28. ,"v"
  29. ,CUSTOM)
  30. */
  31. extern HANDLE hCurrentProcess;
  32. extern HANDLE hCurrentThread;
  33. extern ULONG64 dwCurrentPc;
  34. extern WINDBG_EXTENSION_APIS *lpExtensionApis;
  35. extern DWORD dwProcessor;
  36. extern WINDBG_EXTENSION_APIS ExtensionApis;
  37. #define Print (lpExtensionApis->lpOutputRoutine)
  38. #define OUTAHERE() RtlRaiseStatus(STATUS_NONCONTINUABLE_EXCEPTION);
  39. #define GetSym (lpExtensionApis->lpGetSymbolRoutine)
  40. #define ReadMem (lpExtensionApis->lpReadProcessMemoryRoutine)
  41. #define IsWinDbg() (lpExtensionApis->nSize >= sizeof(WINDBG_EXTENSION_APIS))
  42. #define SAFEWHILE(exp) while (!IsCtrlCHit() && (exp))
  43. extern PSTR pszAccessViolation;
  44. extern PSTR pszMoveException;
  45. extern PSTR pszReadFailure;
  46. #define OPTS_ERROR 0xFFFFFFFF
  47. #define OFLAG(l) (1L << ((DWORD)#@l - (DWORD)'a'))
  48. #define move(dst, src) moveBlock(&(dst), src, sizeof(dst))
  49. #define tryMove(dst, src) tryMoveBlock(&(dst), src, sizeof(dst))
  50. #define tryDword(pdst, src) tryMoveBlock(pdst, src, sizeof(DWORD))
  51. //#define DEBUGPRINT Print // set this when debuging your extensions
  52. #define DEBUGPRINT
  53. VOID moveBlock(PVOID pdst, ULONG64 src, DWORD size);
  54. BOOL tryMoveBlock(PVOID pdst, ULONG64 src, DWORD size);
  55. VOID moveExp(PVOID pdst, LPSTR pszExp);
  56. BOOL tryMoveExp(PVOID pdst, LPSTR pszExp);
  57. VOID moveExpValue(PVOID pdst, LPSTR pszExp);
  58. BOOL tryMoveExpValue(PVOID pdst, LPSTR pszExp);
  59. BOOL tryMoveExpPtr(PULONG64 pdst, LPSTR pszExp);
  60. VOID moveExpValuePtr(PULONG64 pdst, LPSTR pszExp);
  61. BOOL IsCtrlCHit(VOID);
  62. ULONG64 OptEvalExp(LPSTR psz);
  63. ULONG64 OptEvalExp2(LPSTR *ppsz);
  64. DWORD StringToOpts(LPSTR psz);
  65. DWORD GetOpts(LPSTR *ppszArgs, LPSTR pszLegalArgs);
  66. VOID PrintHuge(LPSTR psz);
  67. ULONG64 EvalExp(LPSTR psz);
  68. /*
  69. * entrypoint function type values
  70. */
  71. #define NOARGS 0
  72. #define STDARGS0 1
  73. #define STDARGS1 2
  74. #define STDARGS2 3
  75. #define STDARGS3 4
  76. #define STDARGS4 5
  77. #define CUSTOM 9
  78. /*
  79. * worker function prototype types
  80. */
  81. typedef BOOL (* TYPE_NOARGS)(VOID);
  82. typedef BOOL (* TYPE_STDARGS0)(DWORD);
  83. typedef BOOL (* TYPE_STDARGS1)(DWORD, ULONG64);
  84. typedef BOOL (* TYPE_STDARGS2)(DWORD, ULONG64, ULONG64);
  85. typedef BOOL (* TYPE_STDARGS3)(DWORD, ULONG64, ULONG64, ULONG64);
  86. typedef BOOL (* TYPE_STDARGS4)(DWORD, ULONG64, ULONG64, ULONG64, ULONG64);
  87. typedef BOOL (* TYPE_CUSTOM)(DWORD, LPSTR);
  88. /*
  89. * worker function proto-prototypes
  90. */
  91. #define PROTO_NOARGS(name, opts) BOOL I##name(VOID)
  92. #define PROTO_STDARGS0(name, opts) BOOL I##name(DWORD options)
  93. #define PROTO_STDARGS1(name, opts) BOOL I##name(DWORD options, ULONG64 param1)
  94. #define PROTO_STDARGS2(name, opts) BOOL I##name(DWORD options, ULONG64 param1, ULONG64 param2)
  95. #define PROTO_STDARGS3(name, opts) BOOL I##name(DWORD options, ULONG64 param1, ULONG64 param2, ULONG64 param3)
  96. #define PROTO_STDARGS4(name, opts) BOOL I##name(DWORD options, ULONG64 param1, ULONG64 param2, ULONG64 param3, ULONG64 param4)
  97. #define PROTO_CUSTOM(name, opts) BOOL I##name(DWORD options, LPSTR pszArg)
  98. /*
  99. * worker function prototypes (generated from exts.h)
  100. */
  101. #define DOIT(name, h1, h2, opts, type) PROTO_##type(name, opts);
  102. #include "exts.h"
  103. #undef DOIT