memory.h (2545B)
1/** 2 * WinPR: Windows Portable Runtime 3 * Memory Allocation 4 * 5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef WINPR_MEMORY_H 21#define WINPR_MEMORY_H 22 23#include <stdio.h> 24#include <stdlib.h> 25#include <string.h> 26 27#include <winpr/winpr.h> 28#include <winpr/wtypes.h> 29 30#include <winpr/crt.h> 31#include <winpr/file.h> 32#include <winpr/heap.h> 33 34#ifndef _WIN32 35 36#ifdef __cplusplus 37extern "C" 38{ 39#endif 40 41 WINPR_API HANDLE CreateFileMappingA(HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, 42 DWORD flProtect, DWORD dwMaximumSizeHigh, 43 DWORD dwMaximumSizeLow, LPCSTR lpName); 44 WINPR_API HANDLE CreateFileMappingW(HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes, 45 DWORD flProtect, DWORD dwMaximumSizeHigh, 46 DWORD dwMaximumSizeLow, LPCWSTR lpName); 47 48 WINPR_API HANDLE OpenFileMappingA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName); 49 WINPR_API HANDLE OpenFileMappingW(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCWSTR lpName); 50 51 WINPR_API LPVOID MapViewOfFile(HANDLE hFileMappingObject, DWORD dwDesiredAccess, 52 DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, 53 SIZE_T dwNumberOfBytesToMap); 54 55 WINPR_API LPVOID MapViewOfFileEx(HANDLE hFileMappingObject, DWORD dwDesiredAccess, 56 DWORD dwFileOffsetHigh, DWORD dwFileOffsetLow, 57 SIZE_T dwNumberOfBytesToMap, LPVOID lpBaseAddress); 58 59 WINPR_API BOOL FlushViewOfFile(LPCVOID lpBaseAddress, SIZE_T dwNumberOfBytesToFlush); 60 61 WINPR_API BOOL UnmapViewOfFile(LPCVOID lpBaseAddress); 62 63#ifdef __cplusplus 64} 65#endif 66 67#ifdef UNICODE 68#define CreateFileMapping CreateFileMappingW 69#define OpenFileMapping OpenFileMappingW 70#else 71#define CreateFileMapping CreateFileMappingA 72#define OpenFileMapping OpenFileMappingA 73#endif 74 75#endif 76 77#endif /* WINPR_MEMORY_H */