Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
35cd4115
Commit
35cd4115
authored
Apr 13, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Always pass object attributes to nt_to_unix_file_name().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
90024e49
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
53 deletions
+58
-53
file.c
dlls/ntdll/unix/file.c
+23
-19
loader.c
dlls/ntdll/unix/loader.c
+4
-2
process.c
dlls/ntdll/unix/process.c
+30
-31
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-1
No files found.
dlls/ntdll/unix/file.c
View file @
35cd4115
...
...
@@ -3217,16 +3217,10 @@ static NTSTATUS lookup_unix_name( const WCHAR *name, int name_len, char **buffer
/******************************************************************************
* nt_to_unix_file_name
*
* Convert a file name from NT namespace to Unix namespace.
*
* If disposition is not FILE_OPEN or FILE_OVERWRITE, the last path
* element doesn't have to exist; in that case STATUS_NO_SUCH_FILE is
* returned, but the unix name is still filled in properly.
* nt_to_unix_file_name_no_root
*/
NTSTATUS
nt_to_unix_file_name
(
const
UNICODE_STRING
*
nameW
,
char
**
unix_name_ret
,
UNICODE_STRING
*
nt_name
,
UINT
disposition
)
static
NTSTATUS
nt_to_unix_file_name_no_root
(
const
UNICODE_STRING
*
nameW
,
char
**
unix_name_ret
,
UNICODE_STRING
*
nt_name
,
UINT
disposition
)
{
static
const
WCHAR
unixW
[]
=
{
'u'
,
'n'
,
'i'
,
'x'
};
static
const
WCHAR
invalid_charsW
[]
=
{
INVALID_NT_CHARS
,
0
};
...
...
@@ -3331,10 +3325,16 @@ NTSTATUS nt_to_unix_file_name( const UNICODE_STRING *nameW, char **unix_name_ret
/******************************************************************************
* nt_to_unix_file_name_attr
* nt_to_unix_file_name
*
* Convert a file name from NT namespace to Unix namespace.
*
* If disposition is not FILE_OPEN or FILE_OVERWRITE, the last path
* element doesn't have to exist; in that case STATUS_NO_SUCH_FILE is
* returned, but the unix name is still filled in properly.
*/
static
NTSTATUS
nt_to_unix_file_name_attr
(
const
OBJECT_ATTRIBUTES
*
attr
,
char
**
name_ret
,
UNICODE_STRING
*
nt_name
,
UINT
disposition
)
NTSTATUS
nt_to_unix_file_name
(
const
OBJECT_ATTRIBUTES
*
attr
,
char
**
name_ret
,
UNICODE_STRING
*
nt_name
,
UINT
disposition
)
{
enum
server_fd_type
type
;
int
old_cwd
,
root_fd
,
needs_close
;
...
...
@@ -3344,7 +3344,7 @@ static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char *
NTSTATUS
status
;
if
(
!
attr
->
RootDirectory
)
/* without root dir fall back to normal lookup */
return
nt_to_unix_file_name
(
attr
->
ObjectName
,
name_ret
,
nt_name
,
disposition
);
return
nt_to_unix_file_name
_no_root
(
attr
->
ObjectName
,
name_ret
,
nt_name
,
disposition
);
name
=
attr
->
ObjectName
->
Buffer
;
name_len
=
attr
->
ObjectName
->
Length
/
sizeof
(
WCHAR
);
...
...
@@ -3406,7 +3406,11 @@ NTSTATUS CDECL wine_nt_to_unix_file_name( const UNICODE_STRING *nameW, char *nam
UINT
disposition
)
{
char
*
buffer
=
NULL
;
NTSTATUS
status
=
nt_to_unix_file_name
(
nameW
,
&
buffer
,
NULL
,
disposition
);
NTSTATUS
status
;
OBJECT_ATTRIBUTES
attr
;
InitializeObjectAttributes
(
&
attr
,
(
UNICODE_STRING
*
)
nameW
,
OBJ_CASE_INSENSITIVE
,
0
,
NULL
);
status
=
nt_to_unix_file_name
(
&
attr
,
&
buffer
,
NULL
,
disposition
);
if
(
buffer
)
{
...
...
@@ -3716,7 +3720,7 @@ NTSTATUS WINAPI NtCreateFile( HANDLE *handle, ACCESS_MASK access, OBJECT_ATTRIBU
if
(
options
&
FILE_OPEN_BY_FILE_ID
)
io
->
u
.
Status
=
file_id_to_unix_file_name
(
attr
,
&
unix_name
,
&
nt_name
);
else
io
->
u
.
Status
=
nt_to_unix_file_name
_attr
(
attr
,
&
unix_name
,
&
nt_name
,
disposition
);
io
->
u
.
Status
=
nt_to_unix_file_name
(
attr
,
&
unix_name
,
&
nt_name
,
disposition
);
if
(
io
->
u
.
Status
==
STATUS_BAD_DEVICE_TYPE
)
{
...
...
@@ -3903,7 +3907,7 @@ NTSTATUS WINAPI NtQueryFullAttributesFile( const OBJECT_ATTRIBUTES *attr,
char
*
unix_name
;
NTSTATUS
status
;
if
(
!
(
status
=
nt_to_unix_file_name
_attr
(
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
)))
if
(
!
(
status
=
nt_to_unix_file_name
(
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
)))
{
ULONG
attributes
;
struct
stat
st
;
...
...
@@ -3944,7 +3948,7 @@ NTSTATUS WINAPI NtQueryAttributesFile( const OBJECT_ATTRIBUTES *attr, FILE_BASIC
char
*
unix_name
;
NTSTATUS
status
;
if
(
!
(
status
=
nt_to_unix_file_name
_attr
(
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
)))
if
(
!
(
status
=
nt_to_unix_file_name
(
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
)))
{
ULONG
attributes
;
struct
stat
st
;
...
...
@@ -4506,7 +4510,7 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io,
attr
.
RootDirectory
=
info
->
RootDirectory
;
attr
.
Attributes
=
OBJ_CASE_INSENSITIVE
;
io
->
u
.
Status
=
nt_to_unix_file_name
_attr
(
&
attr
,
&
unix_name
,
&
nt_name
,
FILE_OPEN_IF
);
io
->
u
.
Status
=
nt_to_unix_file_name
(
&
attr
,
&
unix_name
,
&
nt_name
,
FILE_OPEN_IF
);
if
(
io
->
u
.
Status
!=
STATUS_SUCCESS
&&
io
->
u
.
Status
!=
STATUS_NO_SUCH_FILE
)
break
;
...
...
@@ -4546,7 +4550,7 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io,
attr
.
RootDirectory
=
info
->
RootDirectory
;
attr
.
Attributes
=
OBJ_CASE_INSENSITIVE
;
io
->
u
.
Status
=
nt_to_unix_file_name
_attr
(
&
attr
,
&
unix_name
,
&
nt_name
,
FILE_OPEN_IF
);
io
->
u
.
Status
=
nt_to_unix_file_name
(
&
attr
,
&
unix_name
,
&
nt_name
,
FILE_OPEN_IF
);
if
(
io
->
u
.
Status
!=
STATUS_SUCCESS
&&
io
->
u
.
Status
!=
STATUS_NO_SUCH_FILE
)
break
;
...
...
dlls/ntdll/unix/loader.c
View file @
35cd4115
...
...
@@ -1104,13 +1104,15 @@ static NTSTATUS CDECL init_unix_lib( void *module, DWORD reason, const void *ptr
static
NTSTATUS
CDECL
load_so_dll
(
UNICODE_STRING
*
nt_name
,
void
**
module
)
{
static
const
WCHAR
soW
[]
=
{
'.'
,
's'
,
'o'
,
0
};
OBJECT_ATTRIBUTES
attr
;
pe_image_info_t
info
;
char
*
unix_name
;
NTSTATUS
status
;
DWORD
len
;
if
(
get_load_order
(
nt_name
)
==
LO_DISABLED
)
return
STATUS_DLL_NOT_FOUND
;
if
(
nt_to_unix_file_name
(
nt_name
,
&
unix_name
,
NULL
,
FILE_OPEN
))
return
STATUS_DLL_NOT_FOUND
;
InitializeObjectAttributes
(
&
attr
,
nt_name
,
OBJ_CASE_INSENSITIVE
,
0
,
0
);
if
(
nt_to_unix_file_name
(
&
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
))
return
STATUS_DLL_NOT_FOUND
;
/* remove .so extension from Windows name */
len
=
nt_name
->
Length
/
sizeof
(
WCHAR
);
...
...
@@ -1437,7 +1439,7 @@ static NTSTATUS open_main_image( WCHAR *image, void **module, SECTION_IMAGE_INFO
init_unicode_string
(
&
nt_name
,
image
);
InitializeObjectAttributes
(
&
attr
,
&
nt_name
,
OBJ_CASE_INSENSITIVE
,
0
,
NULL
);
if
(
nt_to_unix_file_name
(
&
nt_name
,
&
unix_name
,
NULL
,
FILE_OPEN
))
return
STATUS_DLL_NOT_FOUND
;
if
(
nt_to_unix_file_name
(
&
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
))
return
STATUS_DLL_NOT_FOUND
;
status
=
open_dll_file
(
unix_name
,
&
attr
,
&
mapping
);
if
(
!
status
)
...
...
dlls/ntdll/unix/process.c
View file @
35cd4115
...
...
@@ -331,22 +331,20 @@ static BOOL get_so_file_info( HANDLE handle, pe_image_info_t *info )
/***********************************************************************
* get_pe_file_info
*/
static
NTSTATUS
get_pe_file_info
(
UNICODE_STRING
*
path
,
HANDLE
*
handle
,
pe_image_info_t
*
info
)
static
NTSTATUS
get_pe_file_info
(
OBJECT_ATTRIBUTES
*
attr
,
HANDLE
*
handle
,
pe_image_info_t
*
info
)
{
NTSTATUS
status
;
HANDLE
mapping
;
OBJECT_ATTRIBUTES
attr
;
IO_STATUS_BLOCK
io
;
*
handle
=
0
;
memset
(
info
,
0
,
sizeof
(
*
info
)
);
InitializeObjectAttributes
(
&
attr
,
path
,
OBJ_CASE_INSENSITIVE
,
0
,
0
);
if
((
status
=
NtOpenFile
(
handle
,
GENERIC_READ
,
&
attr
,
&
io
,
if
((
status
=
NtOpenFile
(
handle
,
GENERIC_READ
,
attr
,
&
io
,
FILE_SHARE_READ
|
FILE_SHARE_DELETE
,
FILE_SYNCHRONOUS_IO_NONALERT
)))
{
if
(
is_builtin_path
(
path
,
&
info
->
machine
))
if
(
is_builtin_path
(
attr
->
ObjectName
,
&
info
->
machine
))
{
TRACE
(
"assuming %04x builtin for %s
\n
"
,
info
->
machine
,
debugstr_us
(
path
));
TRACE
(
"assuming %04x builtin for %s
\n
"
,
info
->
machine
,
debugstr_us
(
attr
->
ObjectName
));
return
STATUS_SUCCESS
;
}
return
status
;
...
...
@@ -540,7 +538,7 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so
*
* Fork and exec a new Unix binary, checking for errors.
*/
static
NTSTATUS
fork_and_exec
(
UNICODE_STRING
*
path
,
int
unixdir
,
static
NTSTATUS
fork_and_exec
(
OBJECT_ATTRIBUTES
*
attr
,
int
unixdir
,
const
RTL_USER_PROCESS_PARAMETERS
*
params
)
{
pid_t
pid
;
...
...
@@ -549,7 +547,7 @@ static NTSTATUS fork_and_exec( UNICODE_STRING *path, int unixdir,
char
*
unix_name
;
NTSTATUS
status
;
status
=
nt_to_unix_file_name
(
path
,
&
unix_name
,
NULL
,
FILE_OPEN
);
status
=
nt_to_unix_file_name
(
attr
,
&
unix_name
,
NULL
,
FILE_OPEN
);
if
(
status
)
return
status
;
#ifdef HAVE_PIPE2
...
...
@@ -669,7 +667,7 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
OBJECT_ATTRIBUTES
*
process_attr
,
OBJECT_ATTRIBUTES
*
thread_attr
,
ULONG
process_flags
,
ULONG
thread_flags
,
RTL_USER_PROCESS_PARAMETERS
*
params
,
PS_CREATE_INFO
*
info
,
PS_ATTRIBUTE_LIST
*
attr
)
PS_ATTRIBUTE_LIST
*
ps_
attr
)
{
NTSTATUS
status
;
BOOL
success
=
FALSE
;
...
...
@@ -684,36 +682,36 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
CLIENT_ID
id
;
HANDLE
parent
=
0
,
debug
=
0
,
token
=
0
;
UNICODE_STRING
path
=
{
0
};
OBJECT_ATTRIBUTES
empty_attr
=
{
sizeof
(
empty_attr
)
};
SIZE_T
i
,
attr_count
=
(
attr
->
TotalLength
-
sizeof
(
attr
->
TotalLength
))
/
sizeof
(
PS_ATTRIBUTE
);
OBJECT_ATTRIBUTES
attr
,
empty_attr
=
{
sizeof
(
empty_attr
)
};
SIZE_T
i
,
attr_count
=
(
ps_attr
->
TotalLength
-
sizeof
(
ps_
attr
->
TotalLength
))
/
sizeof
(
PS_ATTRIBUTE
);
const
PS_ATTRIBUTE
*
handles_attr
=
NULL
;
data_size_t
handles_size
;
obj_handle_t
*
handles
;
for
(
i
=
0
;
i
<
attr_count
;
i
++
)
{
switch
(
attr
->
Attributes
[
i
].
Attribute
)
switch
(
ps_
attr
->
Attributes
[
i
].
Attribute
)
{
case
PS_ATTRIBUTE_PARENT_PROCESS
:
parent
=
attr
->
Attributes
[
i
].
ValuePtr
;
parent
=
ps_
attr
->
Attributes
[
i
].
ValuePtr
;
break
;
case
PS_ATTRIBUTE_DEBUG_PORT
:
debug
=
attr
->
Attributes
[
i
].
ValuePtr
;
debug
=
ps_
attr
->
Attributes
[
i
].
ValuePtr
;
break
;
case
PS_ATTRIBUTE_IMAGE_NAME
:
path
.
Length
=
attr
->
Attributes
[
i
].
Size
;
path
.
Buffer
=
attr
->
Attributes
[
i
].
ValuePtr
;
path
.
Length
=
ps_
attr
->
Attributes
[
i
].
Size
;
path
.
Buffer
=
ps_
attr
->
Attributes
[
i
].
ValuePtr
;
break
;
case
PS_ATTRIBUTE_TOKEN
:
token
=
attr
->
Attributes
[
i
].
ValuePtr
;
token
=
ps_
attr
->
Attributes
[
i
].
ValuePtr
;
break
;
case
PS_ATTRIBUTE_HANDLE_LIST
:
if
(
process_flags
&
PROCESS_CREATE_FLAGS_INHERIT_HANDLES
)
handles_attr
=
&
attr
->
Attributes
[
i
];
handles_attr
=
&
ps_
attr
->
Attributes
[
i
];
break
;
default:
if
(
attr
->
Attributes
[
i
].
Attribute
&
PS_ATTRIBUTE_INPUT
)
FIXME
(
"unhandled input attribute %lx
\n
"
,
attr
->
Attributes
[
i
].
Attribute
);
if
(
ps_
attr
->
Attributes
[
i
].
Attribute
&
PS_ATTRIBUTE_INPUT
)
FIXME
(
"unhandled input attribute %lx
\n
"
,
ps_
attr
->
Attributes
[
i
].
Attribute
);
break
;
}
}
...
...
@@ -724,9 +722,10 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
unixdir
=
get_unix_curdir
(
params
);
if
((
status
=
get_pe_file_info
(
&
path
,
&
file_handle
,
&
pe_info
)))
InitializeObjectAttributes
(
&
attr
,
&
path
,
OBJ_CASE_INSENSITIVE
,
0
,
0
);
if
((
status
=
get_pe_file_info
(
&
attr
,
&
file_handle
,
&
pe_info
)))
{
if
(
status
==
STATUS_INVALID_IMAGE_NOT_MZ
&&
!
fork_and_exec
(
&
path
,
unixdir
,
params
))
if
(
status
==
STATUS_INVALID_IMAGE_NOT_MZ
&&
!
fork_and_exec
(
&
attr
,
unixdir
,
params
))
{
memset
(
info
,
0
,
sizeof
(
*
info
)
);
return
STATUS_SUCCESS
;
...
...
@@ -860,28 +859,28 @@ NTSTATUS WINAPI NtCreateUserProcess( HANDLE *process_handle_ptr, HANDLE *thread_
for
(
i
=
0
;
i
<
attr_count
;
i
++
)
{
switch
(
attr
->
Attributes
[
i
].
Attribute
)
switch
(
ps_
attr
->
Attributes
[
i
].
Attribute
)
{
case
PS_ATTRIBUTE_CLIENT_ID
:
{
SIZE_T
size
=
min
(
attr
->
Attributes
[
i
].
Size
,
sizeof
(
id
)
);
memcpy
(
attr
->
Attributes
[
i
].
ValuePtr
,
&
id
,
size
);
if
(
attr
->
Attributes
[
i
].
ReturnLength
)
*
attr
->
Attributes
[
i
].
ReturnLength
=
size
;
SIZE_T
size
=
min
(
ps_
attr
->
Attributes
[
i
].
Size
,
sizeof
(
id
)
);
memcpy
(
ps_
attr
->
Attributes
[
i
].
ValuePtr
,
&
id
,
size
);
if
(
ps_attr
->
Attributes
[
i
].
ReturnLength
)
*
ps_
attr
->
Attributes
[
i
].
ReturnLength
=
size
;
break
;
}
case
PS_ATTRIBUTE_IMAGE_INFO
:
{
SECTION_IMAGE_INFORMATION
info
;
SIZE_T
size
=
min
(
attr
->
Attributes
[
i
].
Size
,
sizeof
(
info
)
);
SIZE_T
size
=
min
(
ps_
attr
->
Attributes
[
i
].
Size
,
sizeof
(
info
)
);
virtual_fill_image_information
(
&
pe_info
,
&
info
);
memcpy
(
attr
->
Attributes
[
i
].
ValuePtr
,
&
info
,
size
);
if
(
attr
->
Attributes
[
i
].
ReturnLength
)
*
attr
->
Attributes
[
i
].
ReturnLength
=
size
;
memcpy
(
ps_
attr
->
Attributes
[
i
].
ValuePtr
,
&
info
,
size
);
if
(
ps_attr
->
Attributes
[
i
].
ReturnLength
)
*
ps_
attr
->
Attributes
[
i
].
ReturnLength
=
size
;
break
;
}
case
PS_ATTRIBUTE_TEB_ADDRESS
:
default:
if
(
!
(
attr
->
Attributes
[
i
].
Attribute
&
PS_ATTRIBUTE_INPUT
))
FIXME
(
"unhandled output attribute %lx
\n
"
,
attr
->
Attributes
[
i
].
Attribute
);
if
(
!
(
ps_
attr
->
Attributes
[
i
].
Attribute
&
PS_ATTRIBUTE_INPUT
))
FIXME
(
"unhandled output attribute %lx
\n
"
,
ps_
attr
->
Attributes
[
i
].
Attribute
);
break
;
}
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
35cd4115
...
...
@@ -249,7 +249,7 @@ extern NTSTATUS tape_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTI
ULONG
in_size
,
void
*
out_buffer
,
ULONG
out_size
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
errno_to_status
(
int
err
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
nt_to_unix_file_name
(
const
UNICODE_STRING
*
nameW
,
char
**
unix_
name_ret
,
extern
NTSTATUS
nt_to_unix_file_name
(
const
OBJECT_ATTRIBUTES
*
attr
,
char
**
name_ret
,
UNICODE_STRING
*
nt_name
,
UINT
disposition
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
unix_to_nt_file_name
(
const
char
*
name
,
WCHAR
**
nt
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
get_full_path
(
const
WCHAR
*
name
,
const
WCHAR
*
curdir
,
WCHAR
**
path
)
DECLSPEC_HIDDEN
;
...
...
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