Windows NT 4.0 source code leak
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.

121 lines
4.0 KiB

4 years ago
  1. /****************************** Module Header ******************************\
  2. * Module Name: stdexts.h
  3. *
  4. * Copyright (c) 1995, 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 DWORD dwCurrentPc;
  34. extern PWINDBG_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 GetSymbol (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 IsCtrlCHit(VOID);
  62. PVOID OptEvalExp(LPSTR psz);
  63. PVOID OptEvalExp2(LPSTR *ppsz);
  64. DWORD StringToOpts(LPSTR psz);
  65. DWORD GetOpts(LPSTR *ppszArgs, LPSTR pszLegalArgs);
  66. VOID PrintHuge(LPSTR psz);
  67. PVOID 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, PVOID);
  84. typedef BOOL (* TYPE_STDARGS2)(DWORD, PVOID, PVOID);
  85. typedef BOOL (* TYPE_STDARGS3)(DWORD, PVOID, PVOID, PVOID);
  86. typedef BOOL (* TYPE_STDARGS4)(DWORD, PVOID, PVOID, PVOID, PVOID);
  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, PVOID param1)
  94. #define PROTO_STDARGS2(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2)
  95. #define PROTO_STDARGS3(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2, PVOID param3)
  96. #define PROTO_STDARGS4(name, opts) BOOL I##name(DWORD options, PVOID param1, PVOID param2, PVOID param3, PVOID 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