Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
c52e3ff2
Commit
c52e3ff2
authored
Mar 02, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move the mapping object functions to sync.c.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
80869310
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
194 deletions
+140
-194
kernel_private.h
dlls/kernel32/kernel_private.h
+0
-3
sync.c
dlls/kernel32/sync.c
+140
-1
virtual.c
dlls/kernel32/virtual.c
+0
-190
No files found.
dlls/kernel32/kernel_private.h
View file @
c52e3ff2
...
...
@@ -107,7 +107,4 @@ extern void LOCALE_InitRegistry(void) DECLSPEC_HIDDEN;
/* oldconfig.c */
extern
void
convert_old_config
(
void
)
DECLSPEC_HIDDEN
;
/* returns directory handle for named objects */
extern
HANDLE
get_BaseNamedObjects_handle
(
void
)
DECLSPEC_HIDDEN
;
#endif
dlls/kernel32/sync.c
View file @
c52e3ff2
...
...
@@ -54,7 +54,7 @@ static inline BOOL is_version_nt(void)
}
/* returns directory handle to \\BaseNamedObjects */
HANDLE
get_BaseNamedObjects_handle
(
void
)
static
HANDLE
get_BaseNamedObjects_handle
(
void
)
{
static
HANDLE
handle
=
NULL
;
static
const
WCHAR
basenameW
[]
=
{
'\\'
,
'S'
,
'e'
,
's'
,
's'
,
'i'
,
'o'
,
'n'
,
's'
,
'\\'
,
'%'
,
'u'
,
...
...
@@ -1254,6 +1254,145 @@ BOOL WINAPI DeleteTimerQueueTimer( HANDLE TimerQueue, HANDLE Timer,
/*
* Mappings
*/
/***********************************************************************
* CreateFileMappingA (KERNEL32.@)
*/
HANDLE
WINAPI
CreateFileMappingA
(
HANDLE
file
,
SECURITY_ATTRIBUTES
*
sa
,
DWORD
protect
,
DWORD
size_high
,
DWORD
size_low
,
LPCSTR
name
)
{
WCHAR
buffer
[
MAX_PATH
];
if
(
!
name
)
return
CreateFileMappingW
(
file
,
sa
,
protect
,
size_high
,
size_low
,
NULL
);
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
buffer
,
MAX_PATH
))
{
SetLastError
(
ERROR_FILENAME_EXCED_RANGE
);
return
0
;
}
return
CreateFileMappingW
(
file
,
sa
,
protect
,
size_high
,
size_low
,
buffer
);
}
/***********************************************************************
* 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
)
{
WCHAR
buffer
[
MAX_PATH
];
if
(
!
name
)
return
OpenFileMappingW
(
access
,
inherit
,
NULL
);
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
buffer
,
MAX_PATH
))
{
SetLastError
(
ERROR_FILENAME_EXCED_RANGE
);
return
0
;
}
return
OpenFileMappingW
(
access
,
inherit
,
buffer
);
}
/***********************************************************************
* 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
*/
...
...
dlls/kernel32/virtual.c
View file @
c52e3ff2
...
...
@@ -299,196 +299,6 @@ SIZE_T WINAPI VirtualQueryEx( HANDLE process, LPCVOID addr,
/***********************************************************************
* CreateFileMappingA (KERNEL32.@)
*
* Creates a named or unnamed file-mapping object for the specified file.
*
* PARAMS
* hFile [I] Handle to the file to map.
* sa [I] Optional security attributes.
* protect [I] Protection for mapping object.
* size_high [I] High-order 32 bits of object size.
* size_low [I] Low-order 32 bits of object size.
* name [I] Name of file-mapping object.
*
* RETURNS
* Success: Handle.
* Failure: NULL. Mapping object does not exist.
*/
HANDLE
WINAPI
CreateFileMappingA
(
HANDLE
hFile
,
SECURITY_ATTRIBUTES
*
sa
,
DWORD
protect
,
DWORD
size_high
,
DWORD
size_low
,
LPCSTR
name
)
{
WCHAR
buffer
[
MAX_PATH
];
if
(
!
name
)
return
CreateFileMappingW
(
hFile
,
sa
,
protect
,
size_high
,
size_low
,
NULL
);
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
buffer
,
MAX_PATH
))
{
SetLastError
(
ERROR_FILENAME_EXCED_RANGE
);
return
0
;
}
return
CreateFileMappingW
(
hFile
,
sa
,
protect
,
size_high
,
size_low
,
buffer
);
}
/***********************************************************************
* CreateFileMappingW (KERNEL32.@)
*
* See CreateFileMappingA.
*/
HANDLE
WINAPI
CreateFileMappingW
(
HANDLE
hFile
,
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
;
sec_type
=
protect
&
sec_flags
;
protect
&=
~
sec_flags
;
if
(
!
sec_type
)
sec_type
=
SEC_COMMIT
;
/* Win9x compatibility */
if
(
!
protect
&&
(
GetVersion
()
&
0x80000000
))
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
;
}
if
(
hFile
==
INVALID_HANDLE_VALUE
)
{
hFile
=
0
;
if
(
!
size_low
&&
!
size_high
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
}
size
.
u
.
LowPart
=
size_low
;
size
.
u
.
HighPart
=
size_high
;
if
(
sa
||
name
)
{
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
0
;
attr
.
ObjectName
=
NULL
;
attr
.
Attributes
=
OBJ_OPENIF
|
((
sa
&&
sa
->
bInheritHandle
)
?
OBJ_INHERIT
:
0
);
attr
.
SecurityDescriptor
=
sa
?
sa
->
lpSecurityDescriptor
:
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
if
(
name
)
{
RtlInitUnicodeString
(
&
nameW
,
name
);
attr
.
ObjectName
=
&
nameW
;
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
}
status
=
NtCreateSection
(
&
ret
,
access
,
&
attr
,
&
size
,
protect
,
sec_type
,
hFile
);
}
else
status
=
NtCreateSection
(
&
ret
,
access
,
NULL
,
&
size
,
protect
,
sec_type
,
hFile
);
if
(
status
==
STATUS_OBJECT_NAME_EXISTS
)
SetLastError
(
ERROR_ALREADY_EXISTS
);
else
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
ret
;
}
/***********************************************************************
* OpenFileMappingA (KERNEL32.@)
*
* Opens a named file-mapping object.
*
* PARAMS
* access [I] Access mode.
* inherit [I] Inherit flag.
* name [I] Name of file-mapping object.
*
* RETURNS
* Success: Handle.
* Failure: NULL.
*/
HANDLE
WINAPI
OpenFileMappingA
(
DWORD
access
,
BOOL
inherit
,
LPCSTR
name
)
{
WCHAR
buffer
[
MAX_PATH
];
if
(
!
name
)
return
OpenFileMappingW
(
access
,
inherit
,
NULL
);
if
(
!
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
buffer
,
MAX_PATH
))
{
SetLastError
(
ERROR_FILENAME_EXCED_RANGE
);
return
0
;
}
return
OpenFileMappingW
(
access
,
inherit
,
buffer
);
}
/***********************************************************************
* OpenFileMappingW (KERNEL32.@)
*
* See OpenFileMappingA.
*/
HANDLE
WINAPI
OpenFileMappingW
(
DWORD
access
,
BOOL
inherit
,
LPCWSTR
name
)
{
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
HANDLE
ret
;
NTSTATUS
status
;
if
(
!
name
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
attr
.
Length
=
sizeof
(
attr
);
attr
.
RootDirectory
=
get_BaseNamedObjects_handle
();
attr
.
ObjectName
=
&
nameW
;
attr
.
Attributes
=
inherit
?
OBJ_INHERIT
:
0
;
attr
.
SecurityDescriptor
=
NULL
;
attr
.
SecurityQualityOfService
=
NULL
;
RtlInitUnicodeString
(
&
nameW
,
name
);
if
(
access
==
FILE_MAP_COPY
)
access
=
SECTION_MAP_READ
;
if
(
GetVersion
()
&
0x80000000
)
{
/* 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
;
}
if
((
status
=
NtOpenSection
(
&
ret
,
access
,
&
attr
)))
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
ret
=
0
;
}
return
ret
;
}
/***********************************************************************
* MapViewOfFile (KERNEL32.@)
*
* Maps a view of a file into the address space.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment