Alexandre Julliard : kernel32: Move file mapping functions to kernelbase.
Alexandre Julliard
julliard at winehq.org
Mon Jul 1 15:15:15 CDT 2019
Module: wine
Branch: master
Commit: 628d4450cdd84230780235f78798ab47bd2e2ab8
URL: https://source.winehq.org/git/wine.git/?a=commit;h=628d4450cdd84230780235f78798ab47bd2e2ab8
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jun 27 17:01:01 2019 +0200
kernel32: Move file mapping functions to kernelbase.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/kernel32.spec | 4 +-
dlls/kernel32/sync.c | 97 --------------------------------------
dlls/kernelbase/kernelbase.spec | 4 +-
dlls/kernelbase/sync.c | 102 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 106 insertions(+), 101 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 3f3f903..bd4f551 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -285,7 +285,7 @@
@ stdcall CreateFileMappingA(long ptr long long long str)
# @ stub CreateFileMappingNumaA
# @ 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 CreateHardLinkA(str str ptr)
@ stdcall CreateHardLinkTransactedA(str str ptr ptr)
@@ -1117,7 +1117,7 @@
@ stdcall OpenFile(str ptr long)
@ stdcall OpenFileById(long ptr long long ptr long)
@ stdcall OpenFileMappingA(long long str)
-@ stdcall OpenFileMappingW(long long wstr)
+@ stdcall -import OpenFileMappingW(long long wstr)
@ stdcall OpenJobObjectA(long long str)
@ stdcall OpenJobObjectW(long long wstr)
@ stdcall OpenMutexA(long long str)
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index 7667af9..036bf85 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -663,73 +663,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.@)
*/
HANDLE WINAPI OpenFileMappingA( DWORD access, BOOL inherit, LPCSTR name )
@@ -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
*/
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index e9fa0d2..7851675 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -189,7 +189,7 @@
@ stdcall CreateFileA(str long long ptr long long long) kernel32.CreateFileA
# @ stub CreateFileMappingFromApp
@ 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 CreateHardLinkA(str str ptr) kernel32.CreateHardLinkA
@ stdcall CreateHardLinkW(wstr wstr ptr) kernel32.CreateHardLinkW
@@ -985,7 +985,7 @@
@ stdcall OpenEventW(long long wstr)
@ stdcall OpenFileById(long ptr long long ptr long) kernel32.OpenFileById
# @ stub OpenFileMappingFromApp
-@ stdcall OpenFileMappingW(long long wstr) kernel32.OpenFileMappingW
+@ stdcall OpenFileMappingW(long long wstr)
# @ stub OpenGlobalizationUserSettingsKey
@ stdcall OpenMutexW(long long wstr)
# @ stub OpenPackageInfoByFullName
diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c
index 21ba6d2..5ab9005 100644
--- a/dlls/kernelbase/sync.c
+++ b/dlls/kernelbase/sync.c
@@ -617,3 +617,105 @@ BOOL WINAPI DECLSPEC_HOTPATCH InitializeCriticalSectionEx( CRITICAL_SECTION *cri
if (ret) RtlRaiseStatus( 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;
+}
More information about the wine-cvs
mailing list