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.

143 lines
3.8 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntrtlmmapio.h
  5. Abstract:
  6. Functions to aid in
  7. rigorously safe
  8. reasonably efficient
  9. reasonably easy to code
  10. memory mapped i/o that captures with "tight" __try/__excepts to
  11. catch status_in_page_errors, and captures only as much as is needed,
  12. like only individual struct fields, to keep stack usage low.
  13. Author:
  14. Jay Krell (JayKrell) January 2002
  15. Revision History:
  16. --*/
  17. #ifndef _NTRTLMMAPIO_
  18. #define _NTRTLMMAPIO_
  19. #if (_MSC_VER > 1020)
  20. #pragma once
  21. #endif
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #pragma warning(disable:4214) // bit field types other than int
  26. #pragma warning(disable:4201) // nameless struct/union
  27. #pragma warning(disable:4115) // named type definition in parentheses
  28. #pragma warning(disable:4127) // condition expression is constant
  29. typedef unsigned char BYTE;
  30. typedef BYTE * PBYTE;
  31. typedef CONST BYTE * PCBYTE;
  32. typedef CONST VOID * PCVOID;
  33. //
  34. // if (Index < GetExceptionInformation()->ExceptionRecord->NumberParameters)
  35. // Info = GetExceptionInformation()->ExceptionRecord->ExceptionInformation[Index]
  36. //
  37. #define RTL_IN_PAGE_ERROR_EXCEPTION_INFO_IS_WRITE_INDEX 0
  38. #define RTL_IN_PAGE_ERROR_EXCEPTION_INFO_FAULTING_VA_INDEX 1
  39. #define RTL_IN_PAGE_ERROR_EXCEPTION_INFO_UNDERLYING_STATUS_INDEX 2
  40. NTSTATUS
  41. NTAPI
  42. RtlCopyMappedMemory(
  43. PVOID ToAddress,
  44. PCVOID FromAddress,
  45. SIZE_T Size
  46. );
  47. NTSYSAPI
  48. NTSTATUS
  49. NTAPI
  50. RtlCopyMemoryFromMappedView(
  51. PCVOID ViewBase,
  52. SIZE_T ViewSize,
  53. PVOID ToAddress,
  54. PCVOID FromAddress,
  55. SIZE_T Size,
  56. PSIZE_T BytesCopied OPTIONAL,
  57. PEXCEPTION_RECORD ExceptionRecordOut OPTIONAL
  58. );
  59. NTSYSAPI
  60. NTSTATUS
  61. NTAPI
  62. RtlMappedViewStrlen(
  63. PCVOID VoidViewBase,
  64. SIZE_T ViewSize,
  65. PCVOID VoidString,
  66. OUT PSIZE_T OutLength OPTIONAL
  67. );
  68. NTSYSAPI
  69. NTSTATUS
  70. NTAPI
  71. RtlMappedViewRangeCheck(
  72. PCVOID ViewBase,
  73. SIZE_T ViewSize,
  74. PCVOID DataAddress,
  75. SIZE_T DataSize
  76. );
  77. typedef struct _MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR {
  78. SIZE_T MemberSize;
  79. SIZE_T MemberOffsetInFile;
  80. SIZE_T MemberOffsetInMemory;
  81. } MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR, *PMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR;
  82. typedef const MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR * PCMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR;
  83. typedef struct _MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR {
  84. SIZE_T EntireStructFileSize;
  85. SIZE_T PartialStructMemorySize;
  86. SIZE_T NumberOfMembers;
  87. PCMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_MEMBER_DESCRIPTOR MemberDescriptors;
  88. } MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR, *PMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR;
  89. typedef const MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR * PCMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR;
  90. NTSYSAPI
  91. NTSTATUS
  92. NTAPI
  93. RtlMemoryMappedIoCapturePartialStruct(
  94. PCVOID ViewBase,
  95. SIZE_T ViewSize,
  96. PCMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR Descriptor,
  97. PCVOID VoidStructInViewBase,
  98. PVOID VoidSafeBuffer,
  99. SIZE_T SafeBufferSize
  100. );
  101. #define RTL_VALIDATE_MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR_DISPOSITION_GOOD 1
  102. #define RTL_VALIDATE_MEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR_DISPOSITION_BAD 2
  103. NTSYSAPI
  104. NTSTATUS
  105. NTAPI
  106. RtlValidateMemoryMappedIoCapturePartialStructDescriptor(
  107. PCMEMORY_MAPPED_IO_CAPTURE_PARTIAL_STRUCT_DESCRIPTOR Struct,
  108. OUT PULONG Disposition,
  109. OUT PULONG_PTR Detail OPTIONAL,
  110. OUT PULONG_PTR Detail2 OPTIONAL
  111. );
  112. #ifdef __cplusplus
  113. } // extern "C"
  114. #endif
  115. #endif