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.

122 lines
4.3 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: stdexts.h
  3. *
  4. * Copyright (c) Microsoft Corporation. All rights reserved.
  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 DWORD dwCurrentPc;
  34. extern WINDBG_EXTENSION_APIS *lpExtensionApis;
  35. #ifdef KERNEL
  36. extern DWORD dwProcessor;
  37. extern WINDBG_EXTENSION_APIS ExtensionApis;
  38. #endif // KERNEL
  39. #define Print (lpExtensionApis->lpOutputRoutine)
  40. #define OUTAHERE() RtlRaiseStatus(STATUS_NONCONTINUABLE_EXCEPTION);
  41. #define GetSym (lpExtensionApis->lpGetSymbolRoutine)
  42. #define ReadMem (lpExtensionApis->lpReadProcessMemoryRoutine)
  43. #define IsWinDbg() (lpExtensionApis->nSize >= sizeof(WINDBG_EXTENSION_APIS))
  44. #define SAFEWHILE(exp) while (!IsCtrlCHit() && (exp))
  45. extern PSTR pszAccessViolation;
  46. extern PSTR pszMoveException;
  47. extern PSTR pszReadFailure;
  48. #define OPTS_ERROR 0xFFFFFFFF
  49. #define OFLAG(l) (1L << ((DWORD)#@l - (DWORD)'a'))
  50. #define move(dst, src) moveBlock(&(dst), src, sizeof(dst))
  51. #define tryMove(dst, src) tryMoveBlock(&(dst), src, sizeof(dst))
  52. #define tryDword(pdst, src) tryMoveBlock(pdst, src, sizeof(DWORD))
  53. //#define DEBUGPRINT Print // set this when debuging your extensions
  54. #define DEBUGPRINT
  55. VOID moveBlock(PVOID pdst, PVOID src, DWORD size);
  56. BOOL tryMoveBlock(PVOID pdst, PVOID src, DWORD size);
  57. VOID moveExp(PVOID pdst, LPSTR pszExp);
  58. BOOL tryMoveExp(PVOID pdst, LPSTR pszExp);
  59. VOID moveExpValue(PVOID pdst, LPSTR pszExp);
  60. BOOL tryMoveExpValue(PVOID pdst, LPSTR pszExp);
  61. BOOL tryMoveExpPtr(PVOID pdst, LPSTR pszExp);
  62. VOID moveExpValuePtr(PVOID pdst, LPSTR pszExp);
  63. BOOL IsCtrlCHit(VOID);
  64. PVOID OptEvalExp(LPSTR psz);
  65. PVOID OptEvalExp2(LPSTR *ppsz);
  66. DWORD StringToOpts(LPSTR psz);
  67. DWORD GetOpts(LPSTR *ppszArgs, LPSTR pszLegalArgs);
  68. VOID PrintHuge(LPSTR psz);
  69. PVOID EvalExp(LPSTR psz);
  70. /*
  71. * entrypoint function type values
  72. */
  73. #define NOARGS 0
  74. #define STDARGS0 1
  75. #define STDARGS1 2
  76. #define STDARGS2 3
  77. #define STDARGS3 4
  78. #define STDARGS4 5
  79. #define CUSTOM 9
  80. /*
  81. * worker function prototype types
  82. */
  83. typedef BOOL (* TYPE_NOARGS)(VOID);
  84. typedef BOOL (* TYPE_STDARGS0)(DWORD);
  85. typedef BOOL (* TYPE_STDARGS1)(DWORD, PVOID);
  86. typedef BOOL (* TYPE_STDARGS2)(DWORD, PVOID, PVOID);
  87. typedef BOOL (* TYPE_STDARGS3)(DWORD, PVOID, PVOID, PVOID);
  88. typedef BOOL (* TYPE_STDARGS4)(DWORD, PVOID, PVOID, PVOID, PVOID);
  89. typedef BOOL (* TYPE_CUSTOM)(DWORD, LPSTR);
  90. /*
  91. * worker function proto-prototypes
  92. */
  93. #define PROTO_NOARGS(name, opts) BOOL I##name(VOID)
  94. #define PROTO_STDARGS0(name, opts) BOOL I##name(DWORD options)
  95. #define PROTO_STDARGS1(name, opts) BOOL I##name(DWORD options, PVOID param1)
  96. #define PROTO_STDARGS2(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2)
  97. #define PROTO_STDARGS3(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2, PVOID param3)
  98. #define PROTO_STDARGS4(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2, PVOID param3, PVOID param4)
  99. #define PROTO_CUSTOM(name, opts) BOOL I##name(DWORD options, LPSTR pszArg)
  100. /*
  101. * worker function prototypes (generated from exts.h)
  102. */
  103. #define DOIT(name, h1, h2, opts, type) PROTO_##type(name, opts);
  104. #include "exts.h"
  105. #undef DOIT