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.

105 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1995-1997 Microsoft Corporation
  3. Module Name:
  4. findmod.cxx
  5. Abstract:
  6. Locates module in the debugee containing a specific address.
  7. Author:
  8. Keith Moore (keithmo) 12-Nov-1997
  9. Revision History:
  10. --*/
  11. #include "inetdbgp.h"
  12. typedef struct _ENUM_CONTEXT {
  13. ULONG_PTR ModuleAddress;
  14. PMODULE_INFO ModuleInfo;
  15. BOOLEAN Successful;
  16. } ENUM_CONTEXT, *PENUM_CONTEXT;
  17. BOOLEAN
  18. CALLBACK
  19. FmpEnumProc(
  20. IN PVOID Param,
  21. IN PMODULE_INFO ModuleInfo
  22. )
  23. {
  24. PENUM_CONTEXT context;
  25. context = (PENUM_CONTEXT)Param;
  26. if( context->ModuleAddress >= ModuleInfo->DllBase &&
  27. context->ModuleAddress < ( ModuleInfo->DllBase + ModuleInfo->SizeOfImage ) ) {
  28. CopyMemory(
  29. context->ModuleInfo,
  30. ModuleInfo,
  31. sizeof(*ModuleInfo)
  32. );
  33. context->Successful = TRUE;
  34. }
  35. return !context->Successful;
  36. } // FmpEnumProc
  37. BOOLEAN
  38. FindModuleByAddress(
  39. IN ULONG_PTR ModuleAddress,
  40. OUT PMODULE_INFO ModuleInfo
  41. )
  42. /*++
  43. Routine Description:
  44. Finds a module in the debugee that contains the specified address.
  45. Arguments:
  46. ModuleAddress - The module address to search for.
  47. ModuleInfo - If successful, receives information describing the
  48. module found.
  49. Return Value:
  50. BOOLEAN - TRUE if successful, FALSE otherwise.
  51. --*/
  52. {
  53. BOOLEAN result;
  54. ENUM_CONTEXT context;
  55. context.ModuleAddress = ModuleAddress;
  56. context.ModuleInfo = ModuleInfo;
  57. context.Successful = FALSE;
  58. result = EnumModules(
  59. FmpEnumProc,
  60. (PVOID)&context
  61. );
  62. if( result ) {
  63. result = context.Successful;
  64. }
  65. return result;
  66. } // FindModuleByAddress