Commit 1ceba353 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

kernelbase: Add MapViewOfFileFromApp().

parent 3ede82e2
......@@ -984,7 +984,7 @@
@ stdcall MapViewOfFile3(long long ptr int64 long long long ptr long)
@ stdcall MapViewOfFileEx(long long long long long ptr)
@ stdcall MapViewOfFileExNuma(long long long long long ptr long)
# @ stub MapViewOfFileFromApp
@ stdcall MapViewOfFileFromApp(long long int64 long)
@ stdcall MoveFileExW(wstr wstr long)
# @ stub MoveFileWithProgressTransactedW
@ stdcall MoveFileWithProgressW(wstr wstr ptr ptr long)
......
......@@ -237,6 +237,15 @@ LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileEx( HANDLE handle, DWORD access, DW
return addr;
}
/***********************************************************************
* MapViewOfFileFromApp (kernelbase.@)
*/
LPVOID WINAPI DECLSPEC_HOTPATCH MapViewOfFileFromApp( HANDLE handle, ULONG access, ULONG64 offset, SIZE_T size )
{
return MapViewOfFile( handle, access, offset << 32, offset, size );
}
/***********************************************************************
* MapViewOfFile3 (kernelbase.@)
*/
......
......@@ -40,6 +40,7 @@ static LPVOID (WINAPI *pVirtualAlloc2FromApp)(HANDLE, void *, SIZE_T, DWORD, DWO
static PVOID (WINAPI *pVirtualAllocFromApp)(PVOID, SIZE_T, DWORD, DWORD);
static HANDLE (WINAPI *pOpenFileMappingFromApp)( ULONG, BOOL, LPCWSTR);
static HANDLE (WINAPI *pCreateFileMappingFromApp)(HANDLE, PSECURITY_ATTRIBUTES, ULONG, ULONG64, PCWSTR);
static LPVOID (WINAPI *pMapViewOfFileFromApp)(HANDLE, ULONG, ULONG64, SIZE_T);
static void test_CompareObjectHandles(void)
{
......@@ -386,6 +387,40 @@ static void test_CreateFileMappingFromApp(void)
CloseHandle(file);
}
static void test_MapViewOfFileFromApp(void)
{
static const char testfile[] = "testfile.xxx";
HANDLE file, mapping;
void *ptr;
BOOL ret;
if (!pMapViewOfFileFromApp)
{
win_skip("MapViewOfFileFromApp() is not supported.\n");
return;
}
SetLastError(0xdeadbeef);
file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
ok( file != INVALID_HANDLE_VALUE, "Failed to create a file, error %lu.\n", GetLastError() );
SetFilePointer( file, 12288, NULL, FILE_BEGIN );
SetEndOfFile( file );
SetLastError(0xdeadbeef);
mapping = CreateFileMappingA( file, NULL, PAGE_READWRITE, 0, 4096, NULL );
ok( mapping != 0, "Failed to create file mapping, error %lu.\n", GetLastError() );
SetLastError(0xdeadbeef);
ptr = pMapViewOfFileFromApp( mapping, PAGE_EXECUTE_READWRITE, 0, 4096 );
ok( ptr != NULL, "Mapping failed, error %lu.\n", GetLastError() );
UnmapViewOfFile( ptr );
CloseHandle( mapping );
CloseHandle( file );
ret = DeleteFileA( testfile );
ok(ret, "Failed to delete a test file.\n");
}
static void init_funcs(void)
{
HMODULE hmod = GetModuleHandleA("kernelbase.dll");
......@@ -394,6 +429,7 @@ static void init_funcs(void)
X(CompareObjectHandles);
X(CreateFileMappingFromApp);
X(MapViewOfFile3);
X(MapViewOfFileFromApp);
X(OpenFileMappingFromApp);
X(VirtualAlloc2);
X(VirtualAlloc2FromApp);
......@@ -416,4 +452,5 @@ START_TEST(process)
test_VirtualAlloc2FromApp();
test_OpenFileMappingFromApp();
test_CreateFileMappingFromApp();
test_MapViewOfFileFromApp();
}
......@@ -2493,6 +2493,7 @@ WINBASEAPI BOOL WINAPI MapUserPhysicalPages(PVOID,ULONG_PTR,PULONG_PTR);
WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE,DWORD,DWORD,DWORD,SIZE_T);
WINBASEAPI LPVOID WINAPI MapViewOfFile3(HANDLE,HANDLE,PVOID,ULONG64,SIZE_T,ULONG,ULONG,MEM_EXTENDED_PARAMETER*,ULONG);
WINBASEAPI LPVOID WINAPI MapViewOfFileEx(HANDLE,DWORD,DWORD,DWORD,SIZE_T,LPVOID);
WINBASEAPI LPVOID WINAPI MapViewOfFileFromApp(HANDLE,ULONG,ULONG64,SIZE_T);
WINBASEAPI BOOL WINAPI MoveFileA(LPCSTR,LPCSTR);
WINBASEAPI BOOL WINAPI MoveFileW(LPCWSTR,LPCWSTR);
#define MoveFile WINELIB_NAME_AW(MoveFile)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment