1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
// file_mapping.hpp --------------------------------------------------------------//
// Copyright 2010 Vicente J. Botet Escriba
// Copyright 2015 Andrey Semashev
// Copyright 2016 Jorge Lodos
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP
#define BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP
#include <boost/detail/winapi/basic_types.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if !defined( BOOST_USE_WINDOWS_H )
extern "C" {
#if !defined( BOOST_NO_ANSI_APIS )
BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
CreateFileMappingA(
boost::detail::winapi::HANDLE_ hFile,
::_SECURITY_ATTRIBUTES* lpFileMappingAttributes,
boost::detail::winapi::DWORD_ flProtect,
boost::detail::winapi::DWORD_ dwMaximumSizeHigh,
boost::detail::winapi::DWORD_ dwMaximumSizeLow,
boost::detail::winapi::LPCSTR_ lpName);
BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
OpenFileMappingA(
boost::detail::winapi::DWORD_ dwDesiredAccess,
boost::detail::winapi::BOOL_ bInheritHandle,
boost::detail::winapi::LPCSTR_ lpName);
#endif
BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
CreateFileMappingW(
boost::detail::winapi::HANDLE_ hFile,
::_SECURITY_ATTRIBUTES* lpFileMappingAttributes,
boost::detail::winapi::DWORD_ flProtect,
boost::detail::winapi::DWORD_ dwMaximumSizeHigh,
boost::detail::winapi::DWORD_ dwMaximumSizeLow,
boost::detail::winapi::LPCWSTR_ lpName);
BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
OpenFileMappingW(
boost::detail::winapi::DWORD_ dwDesiredAccess,
boost::detail::winapi::BOOL_ bInheritHandle,
boost::detail::winapi::LPCWSTR_ lpName);
BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI
MapViewOfFile(
boost::detail::winapi::HANDLE_ hFileMappingObject,
boost::detail::winapi::DWORD_ dwDesiredAccess,
boost::detail::winapi::DWORD_ dwFileOffsetHigh,
boost::detail::winapi::DWORD_ dwFileOffsetLow,
boost::detail::winapi::SIZE_T_ dwNumberOfBytesToMap);
BOOST_SYMBOL_IMPORT boost::detail::winapi::LPVOID_ WINAPI
MapViewOfFileEx(
boost::detail::winapi::HANDLE_ hFileMappingObject,
boost::detail::winapi::DWORD_ dwDesiredAccess,
boost::detail::winapi::DWORD_ dwFileOffsetHigh,
boost::detail::winapi::DWORD_ dwFileOffsetLow,
boost::detail::winapi::SIZE_T_ dwNumberOfBytesToMap,
boost::detail::winapi::LPVOID_ lpBaseAddress);
BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
FlushViewOfFile(
boost::detail::winapi::LPCVOID_ lpBaseAddress,
boost::detail::winapi::SIZE_T_ dwNumberOfBytesToFlush);
BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
UnmapViewOfFile(boost::detail::winapi::LPCVOID_ lpBaseAddress);
}
#endif
namespace boost {
namespace detail {
namespace winapi {
#if defined( BOOST_USE_WINDOWS_H )
const DWORD_ SEC_FILE_ = SEC_FILE;
const DWORD_ SEC_IMAGE_ = SEC_IMAGE;
const DWORD_ SEC_RESERVE_ = SEC_RESERVE;
const DWORD_ SEC_COMMIT_ = SEC_COMMIT;
const DWORD_ SEC_NOCACHE_ = SEC_NOCACHE;
// These permission flags are undocumented and some of them are equivalent to the FILE_MAP_* flags.
// SECTION_QUERY enables NtQuerySection.
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FSection%2FNtQuerySection.html
const DWORD_ SECTION_QUERY_ = SECTION_QUERY;
const DWORD_ SECTION_MAP_WRITE_ = SECTION_MAP_WRITE;
const DWORD_ SECTION_MAP_READ_ = SECTION_MAP_READ;
const DWORD_ SECTION_MAP_EXECUTE_ = SECTION_MAP_EXECUTE;
const DWORD_ SECTION_EXTEND_SIZE_ = SECTION_EXTEND_SIZE;
const DWORD_ SECTION_ALL_ACCESS_ = SECTION_ALL_ACCESS;
const DWORD_ FILE_MAP_COPY_ = FILE_MAP_COPY;
const DWORD_ FILE_MAP_WRITE_ = FILE_MAP_WRITE;
const DWORD_ FILE_MAP_READ_ = FILE_MAP_READ;
const DWORD_ FILE_MAP_ALL_ACCESS_ = FILE_MAP_ALL_ACCESS;
#else // defined( BOOST_USE_WINDOWS_H )
const DWORD_ SEC_FILE_ = 0x800000;
const DWORD_ SEC_IMAGE_ = 0x1000000;
const DWORD_ SEC_RESERVE_ = 0x4000000;
const DWORD_ SEC_COMMIT_ = 0x8000000;
const DWORD_ SEC_NOCACHE_ = 0x10000000;
// These permission flags are undocumented and some of them are equivalent to the FILE_MAP_* flags.
// SECTION_QUERY enables NtQuerySection.
// http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FSection%2FNtQuerySection.html
const DWORD_ SECTION_QUERY_ = 0x00000001;
const DWORD_ SECTION_MAP_WRITE_ = 0x00000002;
const DWORD_ SECTION_MAP_READ_ = 0x00000004;
const DWORD_ SECTION_MAP_EXECUTE_ = 0x00000008;
const DWORD_ SECTION_EXTEND_SIZE_ = 0x00000010;
const DWORD_ SECTION_ALL_ACCESS_ = 0x000F001F; // STANDARD_RIGHTS_REQUIRED | SECTION_*
const DWORD_ FILE_MAP_COPY_ = SECTION_QUERY_;
const DWORD_ FILE_MAP_WRITE_ = SECTION_MAP_WRITE_;
const DWORD_ FILE_MAP_READ_ = SECTION_MAP_READ_;
const DWORD_ FILE_MAP_ALL_ACCESS_ = SECTION_ALL_ACCESS_;
#endif // defined( BOOST_USE_WINDOWS_H )
// These constants are not defined in Windows SDK up until the one shipped with MSVC 8 and MinGW (as of 2016-02-14)
const DWORD_ SECTION_MAP_EXECUTE_EXPLICIT_ = 0x00000020; // not included in SECTION_ALL_ACCESS
const DWORD_ FILE_MAP_EXECUTE_ = SECTION_MAP_EXECUTE_EXPLICIT_; // not included in FILE_MAP_ALL_ACCESS
// These constants are not defined in Windows SDK up until 6.0A and MinGW (as of 2016-02-14)
const DWORD_ SEC_PROTECTED_IMAGE_ = 0x2000000;
const DWORD_ SEC_WRITECOMBINE_ = 0x40000000;
const DWORD_ SEC_LARGE_PAGES_ = 0x80000000;
const DWORD_ SEC_IMAGE_NO_EXECUTE_ = (SEC_IMAGE_ | SEC_NOCACHE_);
#if !defined( BOOST_NO_ANSI_APIS )
using ::OpenFileMappingA;
#endif
using ::OpenFileMappingW;
using ::MapViewOfFile;
using ::MapViewOfFileEx;
using ::FlushViewOfFile;
using ::UnmapViewOfFile;
#if !defined( BOOST_NO_ANSI_APIS )
BOOST_FORCEINLINE HANDLE_ CreateFileMappingA(
HANDLE_ hFile,
SECURITY_ATTRIBUTES_* lpFileMappingAttributes,
DWORD_ flProtect,
DWORD_ dwMaximumSizeHigh,
DWORD_ dwMaximumSizeLow,
LPCSTR_ lpName)
{
return ::CreateFileMappingA(
hFile,
reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes),
flProtect,
dwMaximumSizeHigh,
dwMaximumSizeLow,
lpName);
}
#endif
BOOST_FORCEINLINE HANDLE_ CreateFileMappingW(
HANDLE_ hFile,
SECURITY_ATTRIBUTES_* lpFileMappingAttributes,
DWORD_ flProtect,
DWORD_ dwMaximumSizeHigh,
DWORD_ dwMaximumSizeLow,
LPCWSTR_ lpName)
{
return ::CreateFileMappingW(
hFile,
reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes),
flProtect,
dwMaximumSizeHigh,
dwMaximumSizeLow,
lpName);
}
#if !defined( BOOST_NO_ANSI_APIS )
BOOST_FORCEINLINE HANDLE_ create_file_mapping(
HANDLE_ hFile,
SECURITY_ATTRIBUTES_* lpFileMappingAttributes,
DWORD_ flProtect,
DWORD_ dwMaximumSizeHigh,
DWORD_ dwMaximumSizeLow,
LPCSTR_ lpName)
{
return ::CreateFileMappingA(
hFile,
reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes),
flProtect,
dwMaximumSizeHigh,
dwMaximumSizeLow,
lpName);
}
BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCSTR_ lpName)
{
return ::OpenFileMappingA(dwDesiredAccess, bInheritHandle, lpName);
}
#endif
BOOST_FORCEINLINE HANDLE_ create_file_mapping(
HANDLE_ hFile,
SECURITY_ATTRIBUTES_* lpFileMappingAttributes,
DWORD_ flProtect,
DWORD_ dwMaximumSizeHigh,
DWORD_ dwMaximumSizeLow,
LPCWSTR_ lpName)
{
return ::CreateFileMappingW(
hFile,
reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpFileMappingAttributes),
flProtect,
dwMaximumSizeHigh,
dwMaximumSizeLow,
lpName);
}
BOOST_FORCEINLINE HANDLE_ open_file_mapping(DWORD_ dwDesiredAccess, BOOL_ bInheritHandle, LPCWSTR_ lpName)
{
return ::OpenFileMappingW(dwDesiredAccess, bInheritHandle, lpName);
}
}
}
}
#endif // BOOST_DETAIL_WINAPI_FILE_MAPPING_HPP
|