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.

151 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name:
  4. mod.cxx
  5. Abstract:
  6. This module contains an NTSD debugger extension for dumping module
  7. information.
  8. Author:
  9. Keith Moore (keithmo) 16-Sep-1997
  10. Revision History:
  11. --*/
  12. #include "inetdbgp.h"
  13. typedef struct _ENUM_CONTEXT {
  14. BOOLEAN FirstTime;
  15. } ENUM_CONTEXT, *PENUM_CONTEXT;
  16. /************************************************************
  17. * Dump Module Info
  18. ************************************************************/
  19. BOOLEAN
  20. CALLBACK
  21. ModpEnumProc(
  22. IN PVOID Param,
  23. IN PMODULE_INFO ModuleInfo
  24. )
  25. {
  26. PENUM_CONTEXT context;
  27. context = (PENUM_CONTEXT)Param;
  28. if( context->FirstTime ) {
  29. context->FirstTime = FALSE;
  30. dprintf( "Start End Entry Path\n" );
  31. }
  32. dprintf(
  33. "%08lp %08lp %08lp %s\n",
  34. ModuleInfo->DllBase,
  35. ModuleInfo->DllBase + ModuleInfo->SizeOfImage,
  36. ModuleInfo->EntryPoint,
  37. ModuleInfo->FullName
  38. );
  39. return TRUE;
  40. } // ModpEnumProc
  41. DECLARE_API( mod )
  42. /*++
  43. Routine Description:
  44. This function is called as an NTSD extension to format and dump
  45. module information.
  46. Arguments:
  47. hCurrentProcess - Supplies a handle to the current process (at the
  48. time the extension was called).
  49. hCurrentThread - Supplies a handle to the current thread (at the
  50. time the extension was called).
  51. CurrentPc - Supplies the current pc at the time the extension is
  52. called.
  53. lpExtensionApis - Supplies the address of the functions callable
  54. by this extension.
  55. lpArgumentString - Supplies the asciiz string that describes the
  56. ansi string to be dumped.
  57. Return Value:
  58. None.
  59. --*/
  60. {
  61. ENUM_CONTEXT context;
  62. MODULE_INFO modInfo;
  63. ULONG address;
  64. PSTR endPointer;
  65. INIT_API();
  66. context.FirstTime = TRUE;
  67. //
  68. // Skip leading blanks.
  69. //
  70. while( *lpArgumentString == ' ' ||
  71. *lpArgumentString == '\t' ) {
  72. lpArgumentString++;
  73. }
  74. if( *lpArgumentString == '\0' ) {
  75. //
  76. // No argument passed, dump all modules.
  77. //
  78. if( !EnumModules(
  79. ModpEnumProc,
  80. (PVOID)&context
  81. ) ) {
  82. dprintf( "error retrieving module list\n" );
  83. }
  84. } else {
  85. //
  86. // Try to find the module containing the specified address.
  87. //
  88. address = strtoul( lpArgumentString, &endPointer, 16 );
  89. if( *endPointer != ' ' && *endPointer != '\t' && *endPointer != '\0' ) {
  90. PrintUsage( "mod" );
  91. return;
  92. }
  93. if( FindModuleByAddress( address, &modInfo ) ) {
  94. ModpEnumProc( (PVOID)&context, &modInfo );
  95. } else {
  96. dprintf( "Cannot find %08lp\n", address );
  97. }
  98. }
  99. } // DECLARE_API( mod )