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
04f41e87
Commit
04f41e87
authored
May 30, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Move NtClose() and NtDuplicateObject() to the Unix library.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
09fcfe27
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
38 deletions
+64
-38
om.c
dlls/ntdll/om.c
+3
-32
loader.c
dlls/ntdll/unix/loader.c
+2
-1
server.c
dlls/ntdll/unix/server.c
+52
-2
unix_private.h
dlls/ntdll/unix/unix_private.h
+0
-1
unixlib.h
dlls/ntdll/unixlib.h
+7
-2
No files found.
dlls/ntdll/om.c
View file @
04f41e87
...
...
@@ -351,28 +351,8 @@ NTSTATUS WINAPI NtDuplicateObject( HANDLE source_process, HANDLE source,
HANDLE
dest_process
,
PHANDLE
dest
,
ACCESS_MASK
access
,
ULONG
attributes
,
ULONG
options
)
{
NTSTATUS
ret
;
SERVER_START_REQ
(
dup_handle
)
{
req
->
src_process
=
wine_server_obj_handle
(
source_process
);
req
->
src_handle
=
wine_server_obj_handle
(
source
);
req
->
dst_process
=
wine_server_obj_handle
(
dest_process
);
req
->
access
=
access
;
req
->
attributes
=
attributes
;
req
->
options
=
options
;
if
(
!
(
ret
=
wine_server_call
(
req
)))
{
if
(
dest
)
*
dest
=
wine_server_ptr_handle
(
reply
->
handle
);
if
(
reply
->
closed
&&
reply
->
self
)
{
int
fd
=
unix_funcs
->
server_remove_fd_from_cache
(
source
);
if
(
fd
!=
-
1
)
close
(
fd
);
}
}
}
SERVER_END_REQ
;
return
ret
;
return
unix_funcs
->
NtDuplicateObject
(
source_process
,
source
,
dest_process
,
dest
,
access
,
attributes
,
options
);
}
static
LONG
WINAPI
invalid_handle_exception_handler
(
EXCEPTION_POINTERS
*
eptr
)
...
...
@@ -384,16 +364,7 @@ static LONG WINAPI invalid_handle_exception_handler( EXCEPTION_POINTERS *eptr )
/* Everquest 2 / Pirates of the Burning Sea hooks NtClose, so we need a wrapper */
NTSTATUS
close_handle
(
HANDLE
handle
)
{
NTSTATUS
ret
;
int
fd
=
unix_funcs
->
server_remove_fd_from_cache
(
handle
);
SERVER_START_REQ
(
close_handle
)
{
req
->
handle
=
wine_server_obj_handle
(
handle
);
ret
=
wine_server_call
(
req
);
}
SERVER_END_REQ
;
if
(
fd
!=
-
1
)
close
(
fd
);
NTSTATUS
ret
=
unix_funcs
->
NtClose
(
handle
);
if
(
ret
==
STATUS_INVALID_HANDLE
&&
handle
&&
NtCurrentTeb
()
->
Peb
->
BeingDebugged
)
{
...
...
dlls/ntdll/unix/loader.c
View file @
04f41e87
...
...
@@ -983,6 +983,8 @@ static HMODULE load_ntdll(void)
*/
static
struct
unix_funcs
unix_funcs
=
{
NtClose
,
NtDuplicateObject
,
get_main_args
,
get_paths
,
get_dll_path
,
...
...
@@ -999,7 +1001,6 @@ static struct unix_funcs unix_funcs =
server_call_unlocked
,
wine_server_call
,
server_send_fd
,
server_remove_fd_from_cache
,
server_get_unix_fd
,
server_fd_to_handle
,
server_handle_to_fd
,
...
...
dlls/ntdll/unix/server.c
View file @
04f41e87
...
...
@@ -542,9 +542,9 @@ static inline NTSTATUS get_cached_fd( HANDLE handle, int *fd, enum server_fd_typ
/***********************************************************************
*
server_
remove_fd_from_cache
* remove_fd_from_cache
*/
int
CDECL
server_
remove_fd_from_cache
(
HANDLE
handle
)
static
int
remove_fd_from_cache
(
HANDLE
handle
)
{
unsigned
int
entry
,
idx
=
handle_to_index
(
handle
,
&
entry
);
int
fd
=
-
1
;
...
...
@@ -1122,3 +1122,53 @@ size_t CDECL server_init_thread( void *entry_point, BOOL *suspend, unsigned int
server_protocol_error
(
"init_thread failed with status %x
\n
"
,
ret
);
}
}
/******************************************************************************
* NtDuplicateObject
*/
NTSTATUS
WINAPI
NtDuplicateObject
(
HANDLE
source_process
,
HANDLE
source
,
HANDLE
dest_process
,
HANDLE
*
dest
,
ACCESS_MASK
access
,
ULONG
attributes
,
ULONG
options
)
{
NTSTATUS
ret
;
SERVER_START_REQ
(
dup_handle
)
{
req
->
src_process
=
wine_server_obj_handle
(
source_process
);
req
->
src_handle
=
wine_server_obj_handle
(
source
);
req
->
dst_process
=
wine_server_obj_handle
(
dest_process
);
req
->
access
=
access
;
req
->
attributes
=
attributes
;
req
->
options
=
options
;
if
(
!
(
ret
=
wine_server_call
(
req
)))
{
if
(
dest
)
*
dest
=
wine_server_ptr_handle
(
reply
->
handle
);
if
(
reply
->
closed
&&
reply
->
self
)
{
int
fd
=
remove_fd_from_cache
(
source
);
if
(
fd
!=
-
1
)
close
(
fd
);
}
}
}
SERVER_END_REQ
;
return
ret
;
}
/**************************************************************************
* NtClose
*/
NTSTATUS
WINAPI
NtClose
(
HANDLE
handle
)
{
NTSTATUS
ret
;
int
fd
=
remove_fd_from_cache
(
handle
);
SERVER_START_REQ
(
close_handle
)
{
req
->
handle
=
wine_server_obj_handle
(
handle
);
ret
=
wine_server_call
(
req
);
}
SERVER_END_REQ
;
if
(
fd
!=
-
1
)
close
(
fd
);
return
ret
;
}
dlls/ntdll/unix/unix_private.h
View file @
04f41e87
...
...
@@ -62,7 +62,6 @@ extern void CDECL dbg_init(void) DECLSPEC_HIDDEN;
extern
unsigned
int
CDECL
server_call_unlocked
(
void
*
req_ptr
)
DECLSPEC_HIDDEN
;
extern
void
CDECL
server_send_fd
(
int
fd
)
DECLSPEC_HIDDEN
;
extern
int
CDECL
server_remove_fd_from_cache
(
HANDLE
handle
)
DECLSPEC_HIDDEN
;
extern
int
CDECL
server_get_unix_fd
(
HANDLE
handle
,
unsigned
int
wanted_access
,
int
*
unix_fd
,
int
*
needs_close
,
enum
server_fd_type
*
type
,
unsigned
int
*
options
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/unixlib.h
View file @
04f41e87
...
...
@@ -25,10 +25,16 @@
#include "wine/debug.h"
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 1
0
#define NTDLL_UNIXLIB_VERSION 1
1
struct
unix_funcs
{
/* Nt* functions */
NTSTATUS
(
WINAPI
*
NtClose
)(
HANDLE
handle
);
NTSTATUS
(
WINAPI
*
NtDuplicateObject
)(
HANDLE
source_process
,
HANDLE
source
,
HANDLE
dest_process
,
HANDLE
*
dest
,
ACCESS_MASK
access
,
ULONG
attributes
,
ULONG
options
);
/* environment functions */
void
(
CDECL
*
get_main_args
)(
int
*
argc
,
char
**
argv
[],
char
**
envp
[]
);
void
(
CDECL
*
get_paths
)(
const
char
**
builddir
,
const
char
**
datadir
,
const
char
**
configdir
);
...
...
@@ -54,7 +60,6 @@ struct unix_funcs
unsigned
int
(
CDECL
*
server_call_unlocked
)(
void
*
req_ptr
);
unsigned
int
(
CDECL
*
server_call
)(
void
*
req_ptr
);
void
(
CDECL
*
server_send_fd
)(
int
fd
);
int
(
CDECL
*
server_remove_fd_from_cache
)(
HANDLE
handle
);
int
(
CDECL
*
server_get_unix_fd
)(
HANDLE
handle
,
unsigned
int
wanted_access
,
int
*
unix_fd
,
int
*
needs_close
,
enum
server_fd_type
*
type
,
unsigned
int
*
options
);
NTSTATUS
(
CDECL
*
server_fd_to_handle
)(
int
fd
,
unsigned
int
access
,
unsigned
int
attributes
,
...
...
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