Commit 888d66a2 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the file read/write functions to the Unix library.

parent e9e5c950
...@@ -150,10 +150,6 @@ extern void virtual_fill_image_information( const pe_image_info_t *pe_info, ...@@ -150,10 +150,6 @@ extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN; SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN;
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN; extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
/* completion */
extern NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
NTSTATUS CompletionStatus, ULONG Information, BOOL async) DECLSPEC_HIDDEN;
/* locale */ /* locale */
extern LCID user_lcid, system_lcid; extern LCID user_lcid, system_lcid;
extern DWORD ntdll_umbstowcs( const char* src, DWORD srclen, WCHAR* dst, DWORD dstlen ) DECLSPEC_HIDDEN; extern DWORD ntdll_umbstowcs( const char* src, DWORD srclen, WCHAR* dst, DWORD dstlen ) DECLSPEC_HIDDEN;
......
...@@ -582,24 +582,6 @@ NTSTATUS WINAPI NtQueryIoCompletion( HANDLE handle, IO_COMPLETION_INFORMATION_CL ...@@ -582,24 +582,6 @@ NTSTATUS WINAPI NtQueryIoCompletion( HANDLE handle, IO_COMPLETION_INFORMATION_CL
return unix_funcs->NtQueryIoCompletion( handle, class, buffer, len, ret_len ); return unix_funcs->NtQueryIoCompletion( handle, class, buffer, len, ret_len );
} }
NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
NTSTATUS CompletionStatus, ULONG Information, BOOL async )
{
NTSTATUS status;
SERVER_START_REQ( add_fd_completion )
{
req->handle = wine_server_obj_handle( hFile );
req->cvalue = CompletionValue;
req->status = CompletionStatus;
req->information = Information;
req->async = async;
status = wine_server_call( req );
}
SERVER_END_REQ;
return status;
}
/****************************************************************** /******************************************************************
* RtlRunOnceInitialize (NTDLL.@) * RtlRunOnceInitialize (NTDLL.@)
*/ */
......
...@@ -878,6 +878,8 @@ static struct unix_funcs unix_funcs = ...@@ -878,6 +878,8 @@ static struct unix_funcs unix_funcs =
NtQueryVirtualMemory, NtQueryVirtualMemory,
NtQueueApcThread, NtQueueApcThread,
NtRaiseException, NtRaiseException,
NtReadFile,
NtReadFileScatter,
NtReadVirtualMemory, NtReadVirtualMemory,
NtReleaseKeyedEvent, NtReleaseKeyedEvent,
NtReleaseMutant, NtReleaseMutant,
...@@ -906,6 +908,8 @@ static struct unix_funcs unix_funcs = ...@@ -906,6 +908,8 @@ static struct unix_funcs unix_funcs =
NtWaitForKeyedEvent, NtWaitForKeyedEvent,
NtWaitForMultipleObjects, NtWaitForMultipleObjects,
NtWaitForSingleObject, NtWaitForSingleObject,
NtWriteFile,
NtWriteFileGather,
NtWriteVirtualMemory, NtWriteVirtualMemory,
NtYieldExecution, NtYieldExecution,
DbgUiIssueRemoteBreakin, DbgUiIssueRemoteBreakin,
...@@ -939,10 +943,7 @@ static struct unix_funcs unix_funcs = ...@@ -939,10 +943,7 @@ static struct unix_funcs unix_funcs =
virtual_create_builtin_view, virtual_create_builtin_view,
virtual_alloc_thread_stack, virtual_alloc_thread_stack,
virtual_locked_server_call, virtual_locked_server_call,
virtual_locked_read,
virtual_locked_pread,
virtual_locked_recvmsg, virtual_locked_recvmsg,
virtual_check_buffer_for_read,
virtual_check_buffer_for_write, virtual_check_buffer_for_write,
virtual_release_address_space, virtual_release_address_space,
virtual_set_large_address_space, virtual_set_large_address_space,
......
...@@ -54,6 +54,8 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void) ...@@ -54,6 +54,8 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
return (struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch; return (struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch;
} }
static const UINT_PTR page_size = 0x1000;
NTSTATUS WINAPI KiUserExceptionDispatcher(EXCEPTION_RECORD*,CONTEXT*); NTSTATUS WINAPI KiUserExceptionDispatcher(EXCEPTION_RECORD*,CONTEXT*);
void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR); void WINAPI LdrInitializeThunk(CONTEXT*,void**,ULONG_PTR,ULONG_PTR);
...@@ -89,10 +91,7 @@ extern void CDECL virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECL ...@@ -89,10 +91,7 @@ extern void CDECL virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECL
extern NTSTATUS CDECL virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL virtual_create_builtin_view( void *module ) DECLSPEC_HIDDEN;
extern NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN; extern NTSTATUS CDECL virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
extern unsigned int CDECL virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN; extern unsigned int CDECL virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN;
extern ssize_t CDECL virtual_locked_read( int fd, void *addr, size_t size ) DECLSPEC_HIDDEN;
extern ssize_t CDECL virtual_locked_pread( int fd, void *addr, size_t size, off_t offset ) DECLSPEC_HIDDEN;
extern ssize_t CDECL virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN; extern ssize_t CDECL virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN;
extern BOOL CDECL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) DECLSPEC_HIDDEN;
extern BOOL CDECL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) DECLSPEC_HIDDEN; extern BOOL CDECL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) DECLSPEC_HIDDEN;
extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN; extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN;
extern void CDECL virtual_set_large_address_space(void) DECLSPEC_HIDDEN; extern void CDECL virtual_set_large_address_space(void) DECLSPEC_HIDDEN;
...@@ -174,8 +173,11 @@ extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN; ...@@ -174,8 +173,11 @@ extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN; extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN; extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_handle_fault( LPCVOID addr, DWORD err, BOOL on_signal_stack ) DECLSPEC_HIDDEN;
extern ssize_t virtual_locked_read( int fd, void *addr, size_t size ) DECLSPEC_HIDDEN;
extern ssize_t virtual_locked_pread( int fd, void *addr, size_t size, off_t offset ) DECLSPEC_HIDDEN;
extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLSPEC_HIDDEN; extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
extern int virtual_handle_stack_fault( void *addr ) DECLSPEC_HIDDEN; extern int virtual_handle_stack_fault( void *addr ) DECLSPEC_HIDDEN;
extern BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) DECLSPEC_HIDDEN;
extern SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size ) DECLSPEC_HIDDEN; extern SIZE_T virtual_uninterrupted_read_memory( const void *addr, void *buffer, SIZE_T size ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) DECLSPEC_HIDDEN; extern NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZE_T size ) DECLSPEC_HIDDEN;
extern void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN; extern void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN;
......
...@@ -134,7 +134,6 @@ static RTL_CRITICAL_SECTION csVirtual = { &critsect_debug, -1, 0, 0, 0, 0 }; ...@@ -134,7 +134,6 @@ static RTL_CRITICAL_SECTION csVirtual = { &critsect_debug, -1, 0, 0, 0, 0 };
static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
static const UINT page_shift = 12; static const UINT page_shift = 12;
static const UINT_PTR page_size = 0x1000;
static const UINT_PTR page_mask = 0xfff; static const UINT_PTR page_mask = 0xfff;
static const UINT_PTR granularity_mask = 0xffff; static const UINT_PTR granularity_mask = 0xffff;
...@@ -2866,7 +2865,7 @@ unsigned int CDECL virtual_locked_server_call( void *req_ptr ) ...@@ -2866,7 +2865,7 @@ unsigned int CDECL virtual_locked_server_call( void *req_ptr )
/*********************************************************************** /***********************************************************************
* virtual_locked_read * virtual_locked_read
*/ */
ssize_t CDECL virtual_locked_read( int fd, void *addr, size_t size ) ssize_t virtual_locked_read( int fd, void *addr, size_t size )
{ {
sigset_t sigset; sigset_t sigset;
BOOL has_write_watch = FALSE; BOOL has_write_watch = FALSE;
...@@ -2891,7 +2890,7 @@ ssize_t CDECL virtual_locked_read( int fd, void *addr, size_t size ) ...@@ -2891,7 +2890,7 @@ ssize_t CDECL virtual_locked_read( int fd, void *addr, size_t size )
/*********************************************************************** /***********************************************************************
* virtual_locked_pread * virtual_locked_pread
*/ */
ssize_t CDECL virtual_locked_pread( int fd, void *addr, size_t size, off_t offset ) ssize_t virtual_locked_pread( int fd, void *addr, size_t size, off_t offset )
{ {
sigset_t sigset; sigset_t sigset;
BOOL has_write_watch = FALSE; BOOL has_write_watch = FALSE;
...@@ -3007,7 +3006,7 @@ int virtual_handle_stack_fault( void *addr ) ...@@ -3007,7 +3006,7 @@ int virtual_handle_stack_fault( void *addr )
* *
* Check if a memory buffer can be read, triggering page faults if needed for DIB section access. * Check if a memory buffer can be read, triggering page faults if needed for DIB section access.
*/ */
BOOL CDECL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size )
{ {
if (!size) return TRUE; if (!size) return TRUE;
if (!ptr) return FALSE; if (!ptr) return FALSE;
......
...@@ -28,7 +28,7 @@ struct ldt_copy; ...@@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr; struct msghdr;
/* increment this when you change the function table */ /* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 48 #define NTDLL_UNIXLIB_VERSION 49
struct unix_funcs struct unix_funcs
{ {
...@@ -159,6 +159,13 @@ struct unix_funcs ...@@ -159,6 +159,13 @@ struct unix_funcs
NTSTATUS (WINAPI *NtQueueApcThread)( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1, NTSTATUS (WINAPI *NtQueueApcThread)( HANDLE handle, PNTAPCFUNC func, ULONG_PTR arg1,
ULONG_PTR arg2, ULONG_PTR arg3 ); ULONG_PTR arg2, ULONG_PTR arg3 );
NTSTATUS (WINAPI *NtRaiseException)( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ); NTSTATUS (WINAPI *NtRaiseException)( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance );
NTSTATUS (WINAPI *NtReadFile)( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user,
IO_STATUS_BLOCK *io, void *buffer, ULONG length,
LARGE_INTEGER *offset, ULONG *key );
NTSTATUS (WINAPI *NtReadFileScatter)( HANDLE file, HANDLE event, PIO_APC_ROUTINE apc,
void *apc_user, IO_STATUS_BLOCK *io,
FILE_SEGMENT_ELEMENT *segments, ULONG length,
LARGE_INTEGER *offset, ULONG *key );
NTSTATUS (WINAPI *NtReadVirtualMemory)( HANDLE process, const void *addr, void *buffer, NTSTATUS (WINAPI *NtReadVirtualMemory)( HANDLE process, const void *addr, void *buffer,
SIZE_T size, SIZE_T *bytes_read ); SIZE_T size, SIZE_T *bytes_read );
NTSTATUS (WINAPI *NtReleaseKeyedEvent)( HANDLE handle, const void *key, NTSTATUS (WINAPI *NtReleaseKeyedEvent)( HANDLE handle, const void *key,
...@@ -204,6 +211,13 @@ struct unix_funcs ...@@ -204,6 +211,13 @@ struct unix_funcs
const LARGE_INTEGER *timeout ); const LARGE_INTEGER *timeout );
NTSTATUS (WINAPI *NtWaitForSingleObject)( HANDLE handle, BOOLEAN alertable, NTSTATUS (WINAPI *NtWaitForSingleObject)( HANDLE handle, BOOLEAN alertable,
const LARGE_INTEGER *timeout ); const LARGE_INTEGER *timeout );
NTSTATUS (WINAPI *NtWriteFile)( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user,
IO_STATUS_BLOCK *io, const void *buffer, ULONG length,
LARGE_INTEGER *offset, ULONG *key );
NTSTATUS (WINAPI *NtWriteFileGather)( HANDLE file, HANDLE event, PIO_APC_ROUTINE apc,
void *apc_user, IO_STATUS_BLOCK *io,
FILE_SEGMENT_ELEMENT *segments, ULONG length,
LARGE_INTEGER *offset, ULONG *key );
NTSTATUS (WINAPI *NtWriteVirtualMemory)( HANDLE process, void *addr, const void *buffer, NTSTATUS (WINAPI *NtWriteVirtualMemory)( HANDLE process, void *addr, const void *buffer,
SIZE_T size, SIZE_T *bytes_written ); SIZE_T size, SIZE_T *bytes_written );
NTSTATUS (WINAPI *NtYieldExecution)(void); NTSTATUS (WINAPI *NtYieldExecution)(void);
...@@ -253,10 +267,7 @@ struct unix_funcs ...@@ -253,10 +267,7 @@ struct unix_funcs
NTSTATUS (CDECL *virtual_create_builtin_view)( void *module ); NTSTATUS (CDECL *virtual_create_builtin_view)( void *module );
NTSTATUS (CDECL *virtual_alloc_thread_stack)( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size ); NTSTATUS (CDECL *virtual_alloc_thread_stack)( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size, SIZE_T *pthread_size );
unsigned int (CDECL *virtual_locked_server_call)( void *req_ptr ); unsigned int (CDECL *virtual_locked_server_call)( void *req_ptr );
ssize_t (CDECL *virtual_locked_read)( int fd, void *addr, size_t size );
ssize_t (CDECL *virtual_locked_pread)( int fd, void *addr, size_t size, off_t offset );
ssize_t (CDECL *virtual_locked_recvmsg)( int fd, struct msghdr *hdr, int flags ); ssize_t (CDECL *virtual_locked_recvmsg)( int fd, struct msghdr *hdr, int flags );
BOOL (CDECL *virtual_check_buffer_for_read)( const void *ptr, SIZE_T size );
BOOL (CDECL *virtual_check_buffer_for_write)( void *ptr, SIZE_T size ); BOOL (CDECL *virtual_check_buffer_for_write)( void *ptr, SIZE_T size );
void (CDECL *virtual_release_address_space)(void); void (CDECL *virtual_release_address_space)(void);
void (CDECL *virtual_set_large_address_space)(void); void (CDECL *virtual_set_large_address_space)(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment