kernel32: Move file mapping functions to kernelbase.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
aa7f8e930d
commit
628d4450cd
|
@ -285,7 +285,7 @@
|
||||||
@ stdcall CreateFileMappingA(long ptr long long long str)
|
@ stdcall CreateFileMappingA(long ptr long long long str)
|
||||||
# @ stub CreateFileMappingNumaA
|
# @ stub CreateFileMappingNumaA
|
||||||
# @ stub CreateFileMappingNumaW
|
# @ stub CreateFileMappingNumaW
|
||||||
@ stdcall CreateFileMappingW(long ptr long long long wstr)
|
@ stdcall -import CreateFileMappingW(long ptr long long long wstr)
|
||||||
@ stdcall CreateFileW(wstr long long ptr long long long)
|
@ stdcall CreateFileW(wstr long long ptr long long long)
|
||||||
@ stdcall CreateHardLinkA(str str ptr)
|
@ stdcall CreateHardLinkA(str str ptr)
|
||||||
@ stdcall CreateHardLinkTransactedA(str str ptr ptr)
|
@ stdcall CreateHardLinkTransactedA(str str ptr ptr)
|
||||||
|
@ -1117,7 +1117,7 @@
|
||||||
@ stdcall OpenFile(str ptr long)
|
@ stdcall OpenFile(str ptr long)
|
||||||
@ stdcall OpenFileById(long ptr long long ptr long)
|
@ stdcall OpenFileById(long ptr long long ptr long)
|
||||||
@ stdcall OpenFileMappingA(long long str)
|
@ stdcall OpenFileMappingA(long long str)
|
||||||
@ stdcall OpenFileMappingW(long long wstr)
|
@ stdcall -import OpenFileMappingW(long long wstr)
|
||||||
@ stdcall OpenJobObjectA(long long str)
|
@ stdcall OpenJobObjectA(long long str)
|
||||||
@ stdcall OpenJobObjectW(long long wstr)
|
@ stdcall OpenJobObjectW(long long wstr)
|
||||||
@ stdcall OpenMutexA(long long str)
|
@ stdcall OpenMutexA(long long str)
|
||||||
|
|
|
@ -662,73 +662,6 @@ HANDLE WINAPI CreateFileMappingA( HANDLE file, SECURITY_ATTRIBUTES *sa, DWORD pr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* CreateFileMappingW (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
HANDLE WINAPI CreateFileMappingW( HANDLE file, LPSECURITY_ATTRIBUTES sa, DWORD protect,
|
|
||||||
DWORD size_high, DWORD size_low, LPCWSTR name )
|
|
||||||
{
|
|
||||||
static const int sec_flags = (SEC_FILE | SEC_IMAGE | SEC_RESERVE | SEC_COMMIT |
|
|
||||||
SEC_NOCACHE | SEC_WRITECOMBINE | SEC_LARGE_PAGES);
|
|
||||||
HANDLE ret;
|
|
||||||
NTSTATUS status;
|
|
||||||
DWORD access, sec_type;
|
|
||||||
LARGE_INTEGER size;
|
|
||||||
UNICODE_STRING nameW;
|
|
||||||
OBJECT_ATTRIBUTES attr;
|
|
||||||
|
|
||||||
sec_type = protect & sec_flags;
|
|
||||||
protect &= ~sec_flags;
|
|
||||||
if (!sec_type) sec_type = SEC_COMMIT;
|
|
||||||
|
|
||||||
/* Win9x compatibility */
|
|
||||||
if (!protect && !is_version_nt()) protect = PAGE_READONLY;
|
|
||||||
|
|
||||||
switch(protect)
|
|
||||||
{
|
|
||||||
case PAGE_READONLY:
|
|
||||||
case PAGE_WRITECOPY:
|
|
||||||
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ;
|
|
||||||
break;
|
|
||||||
case PAGE_READWRITE:
|
|
||||||
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE;
|
|
||||||
break;
|
|
||||||
case PAGE_EXECUTE_READ:
|
|
||||||
case PAGE_EXECUTE_WRITECOPY:
|
|
||||||
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_EXECUTE;
|
|
||||||
break;
|
|
||||||
case PAGE_EXECUTE_READWRITE:
|
|
||||||
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size.u.LowPart = size_low;
|
|
||||||
size.u.HighPart = size_high;
|
|
||||||
|
|
||||||
if (file == INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
file = 0;
|
|
||||||
if (!size.QuadPart)
|
|
||||||
{
|
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get_create_object_attributes( &attr, &nameW, sa, name );
|
|
||||||
|
|
||||||
status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, file );
|
|
||||||
if (status == STATUS_OBJECT_NAME_EXISTS)
|
|
||||||
SetLastError( ERROR_ALREADY_EXISTS );
|
|
||||||
else
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* OpenFileMappingA (KERNEL32.@)
|
* OpenFileMappingA (KERNEL32.@)
|
||||||
*/
|
*/
|
||||||
|
@ -747,36 +680,6 @@ HANDLE WINAPI OpenFileMappingA( DWORD access, BOOL inherit, LPCSTR name )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* OpenFileMappingW (KERNEL32.@)
|
|
||||||
*/
|
|
||||||
HANDLE WINAPI OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES attr;
|
|
||||||
UNICODE_STRING nameW;
|
|
||||||
HANDLE ret;
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
|
|
||||||
|
|
||||||
if (access == FILE_MAP_COPY) access = SECTION_MAP_READ;
|
|
||||||
|
|
||||||
if (!is_version_nt())
|
|
||||||
{
|
|
||||||
/* win9x doesn't do access checks, so try with full access first */
|
|
||||||
if (!NtOpenSection( &ret, access | SECTION_MAP_READ | SECTION_MAP_WRITE, &attr )) return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = NtOpenSection( &ret, access, &attr );
|
|
||||||
if (status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
SetLastError( RtlNtStatusToDosError(status) );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pipes
|
* Pipes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -189,7 +189,7 @@
|
||||||
@ stdcall CreateFileA(str long long ptr long long long) kernel32.CreateFileA
|
@ stdcall CreateFileA(str long long ptr long long long) kernel32.CreateFileA
|
||||||
# @ stub CreateFileMappingFromApp
|
# @ stub CreateFileMappingFromApp
|
||||||
@ stub CreateFileMappingNumaW
|
@ stub CreateFileMappingNumaW
|
||||||
@ stdcall CreateFileMappingW(long ptr long long long wstr) kernel32.CreateFileMappingW
|
@ stdcall CreateFileMappingW(long ptr long long long wstr)
|
||||||
@ stdcall CreateFileW(wstr long long ptr long long long) kernel32.CreateFileW
|
@ stdcall CreateFileW(wstr long long ptr long long long) kernel32.CreateFileW
|
||||||
@ stdcall CreateHardLinkA(str str ptr) kernel32.CreateHardLinkA
|
@ stdcall CreateHardLinkA(str str ptr) kernel32.CreateHardLinkA
|
||||||
@ stdcall CreateHardLinkW(wstr wstr ptr) kernel32.CreateHardLinkW
|
@ stdcall CreateHardLinkW(wstr wstr ptr) kernel32.CreateHardLinkW
|
||||||
|
@ -985,7 +985,7 @@
|
||||||
@ stdcall OpenEventW(long long wstr)
|
@ stdcall OpenEventW(long long wstr)
|
||||||
@ stdcall OpenFileById(long ptr long long ptr long) kernel32.OpenFileById
|
@ stdcall OpenFileById(long ptr long long ptr long) kernel32.OpenFileById
|
||||||
# @ stub OpenFileMappingFromApp
|
# @ stub OpenFileMappingFromApp
|
||||||
@ stdcall OpenFileMappingW(long long wstr) kernel32.OpenFileMappingW
|
@ stdcall OpenFileMappingW(long long wstr)
|
||||||
# @ stub OpenGlobalizationUserSettingsKey
|
# @ stub OpenGlobalizationUserSettingsKey
|
||||||
@ stdcall OpenMutexW(long long wstr)
|
@ stdcall OpenMutexW(long long wstr)
|
||||||
# @ stub OpenPackageInfoByFullName
|
# @ stub OpenPackageInfoByFullName
|
||||||
|
|
|
@ -617,3 +617,105 @@ BOOL WINAPI DECLSPEC_HOTPATCH InitializeCriticalSectionEx( CRITICAL_SECTION *cri
|
||||||
if (ret) RtlRaiseStatus( ret );
|
if (ret) RtlRaiseStatus( ret );
|
||||||
return !ret;
|
return !ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* File mappings
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* CreateFileMappingW (kernelbase.@)
|
||||||
|
*/
|
||||||
|
HANDLE WINAPI DECLSPEC_HOTPATCH CreateFileMappingW( HANDLE file, LPSECURITY_ATTRIBUTES sa, DWORD protect,
|
||||||
|
DWORD size_high, DWORD size_low, LPCWSTR name )
|
||||||
|
{
|
||||||
|
static const int sec_flags = (SEC_FILE | SEC_IMAGE | SEC_RESERVE | SEC_COMMIT |
|
||||||
|
SEC_NOCACHE | SEC_WRITECOMBINE | SEC_LARGE_PAGES);
|
||||||
|
HANDLE ret;
|
||||||
|
NTSTATUS status;
|
||||||
|
DWORD access, sec_type;
|
||||||
|
LARGE_INTEGER size;
|
||||||
|
UNICODE_STRING nameW;
|
||||||
|
OBJECT_ATTRIBUTES attr;
|
||||||
|
|
||||||
|
sec_type = protect & sec_flags;
|
||||||
|
protect &= ~sec_flags;
|
||||||
|
if (!sec_type) sec_type = SEC_COMMIT;
|
||||||
|
|
||||||
|
/* Win9x compatibility */
|
||||||
|
if (!protect && !is_version_nt()) protect = PAGE_READONLY;
|
||||||
|
|
||||||
|
switch(protect)
|
||||||
|
{
|
||||||
|
case PAGE_READONLY:
|
||||||
|
case PAGE_WRITECOPY:
|
||||||
|
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ;
|
||||||
|
break;
|
||||||
|
case PAGE_READWRITE:
|
||||||
|
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE;
|
||||||
|
break;
|
||||||
|
case PAGE_EXECUTE_READ:
|
||||||
|
case PAGE_EXECUTE_WRITECOPY:
|
||||||
|
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_EXECUTE;
|
||||||
|
break;
|
||||||
|
case PAGE_EXECUTE_READWRITE:
|
||||||
|
access = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size.u.LowPart = size_low;
|
||||||
|
size.u.HighPart = size_high;
|
||||||
|
|
||||||
|
if (file == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
file = 0;
|
||||||
|
if (!size.QuadPart)
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get_create_object_attributes( &attr, &nameW, sa, name );
|
||||||
|
|
||||||
|
status = NtCreateSection( &ret, access, &attr, &size, protect, sec_type, file );
|
||||||
|
if (status == STATUS_OBJECT_NAME_EXISTS)
|
||||||
|
SetLastError( ERROR_ALREADY_EXISTS );
|
||||||
|
else
|
||||||
|
SetLastError( RtlNtStatusToDosError(status) );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* OpenFileMappingW (kernelbase.@)
|
||||||
|
*/
|
||||||
|
HANDLE WINAPI DECLSPEC_HOTPATCH OpenFileMappingW( DWORD access, BOOL inherit, LPCWSTR name )
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES attr;
|
||||||
|
UNICODE_STRING nameW;
|
||||||
|
HANDLE ret;
|
||||||
|
NTSTATUS status;
|
||||||
|
|
||||||
|
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
|
||||||
|
|
||||||
|
if (access == FILE_MAP_COPY) access = SECTION_MAP_READ;
|
||||||
|
|
||||||
|
if (!is_version_nt())
|
||||||
|
{
|
||||||
|
/* win9x doesn't do access checks, so try with full access first */
|
||||||
|
if (!NtOpenSection( &ret, access | SECTION_MAP_READ | SECTION_MAP_WRITE, &attr )) return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = NtOpenSection( &ret, access, &attr );
|
||||||
|
if (status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError(status) );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue