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.

93 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Abstract:
  4. Manages a set of regions indexed by virtual addresses
  5. and backed by mapped memory.
  6. Author:
  7. Matthew D Hendel (math) 16-Sept-1999
  8. Revision History:
  9. --*/
  10. #ifndef __MMAP_HPP__
  11. #define __MMAP_HPP__
  12. #define HR_REGION_CONFLICT HRESULT_FROM_NT(STATUS_CONFLICTING_ADDRESSES)
  13. typedef struct _MEMORY_MAP_ENTRY
  14. {
  15. ULONG64 BaseOfRegion;
  16. ULONG SizeOfRegion;
  17. PVOID Region;
  18. PVOID UserData;
  19. BOOL AllowOverlap;
  20. struct _MEMORY_MAP_ENTRY * Next;
  21. } MEMORY_MAP_ENTRY, * PMEMORY_MAP_ENTRY;
  22. class MappedMemoryMap
  23. {
  24. public:
  25. MappedMemoryMap(void);
  26. ~MappedMemoryMap(void);
  27. HRESULT AddRegion(
  28. ULONG64 BaseOfRegion,
  29. ULONG SizeOfRegion,
  30. PVOID Buffer,
  31. PVOID UserData,
  32. BOOL AllowOverlap
  33. );
  34. BOOL ReadMemory(
  35. ULONG64 BaseOfRange,
  36. OUT PVOID Buffer,
  37. ULONG SizeOfRange,
  38. PULONG BytesRead
  39. );
  40. BOOL CheckMap(
  41. IN PVOID Map
  42. );
  43. BOOL GetRegionInfo(
  44. IN ULONG64 Addr,
  45. OUT ULONG64* BaseOfRegion, OPTIONAL
  46. OUT ULONG* SizeOfRegion, OPTIONAL
  47. OUT PVOID* Buffer, OPTIONAL
  48. OUT PVOID* UserData OPTIONAL
  49. );
  50. BOOL GetNextRegion(
  51. IN ULONG64 Addr,
  52. OUT PULONG64 Next
  53. );
  54. BOOL RemoveRegion(
  55. IN ULONG64 BaseOfRegion,
  56. IN ULONG SizeOfRegion
  57. );
  58. BOOL GetRegionByUserData(
  59. IN PVOID UserData,
  60. OUT PULONG64 Base,
  61. OUT PULONG Size
  62. );
  63. private:
  64. PMEMORY_MAP_ENTRY AddMapEntry(ULONG64 BaseOfRegion, ULONG SizeOfRegion,
  65. PVOID Buffer, PVOID UserData,
  66. BOOL AllowOverlap);
  67. PMEMORY_MAP_ENTRY FindPreceedingRegion(ULONG64 Addr);
  68. PMEMORY_MAP_ENTRY FindContainingRegion(ULONG64 Addr);
  69. PMEMORY_MAP_ENTRY m_List;
  70. ULONG m_RegionCount;
  71. };
  72. #endif // #ifndef __MMAP_HPP__