2020-05-14 15:33:36 +02:00
|
|
|
/*
|
|
|
|
* Ntdll Unix private interface
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NTDLL_UNIX_PRIVATE_H
|
|
|
|
#define __NTDLL_UNIX_PRIVATE_H
|
|
|
|
|
2020-07-03 12:02:58 +02:00
|
|
|
#include <pthread.h>
|
2020-07-18 11:02:58 +02:00
|
|
|
#include <signal.h>
|
2020-05-14 15:33:36 +02:00
|
|
|
#include "unixlib.h"
|
2021-08-12 13:46:35 +02:00
|
|
|
#include "wine/unixlib.h"
|
2021-02-16 11:37:38 +01:00
|
|
|
#include "wine/server.h"
|
2020-06-18 12:37:50 +02:00
|
|
|
#include "wine/list.h"
|
2020-05-14 15:33:36 +02:00
|
|
|
|
2021-05-27 06:36:52 +02:00
|
|
|
struct msghdr;
|
|
|
|
|
2020-06-22 16:16:17 +02:00
|
|
|
#ifdef __i386__
|
2021-03-17 10:38:43 +01:00
|
|
|
static const WORD current_machine = IMAGE_FILE_MACHINE_I386;
|
2020-06-22 16:16:17 +02:00
|
|
|
#elif defined(__x86_64__)
|
2021-03-17 10:38:43 +01:00
|
|
|
static const WORD current_machine = IMAGE_FILE_MACHINE_AMD64;
|
2020-06-22 16:16:17 +02:00
|
|
|
#elif defined(__arm__)
|
2021-03-17 10:38:43 +01:00
|
|
|
static const WORD current_machine = IMAGE_FILE_MACHINE_ARMNT;
|
2020-06-22 16:16:17 +02:00
|
|
|
#elif defined(__aarch64__)
|
2021-03-17 10:38:43 +01:00
|
|
|
static const WORD current_machine = IMAGE_FILE_MACHINE_ARM64;
|
2020-06-22 16:16:17 +02:00
|
|
|
#endif
|
2021-05-03 11:02:21 +02:00
|
|
|
extern WORD native_machine DECLSPEC_HIDDEN;
|
2020-06-22 16:16:17 +02:00
|
|
|
|
2021-03-26 14:23:02 +01:00
|
|
|
static const BOOL is_win64 = (sizeof(void *) > sizeof(int));
|
|
|
|
|
2021-05-03 11:02:21 +02:00
|
|
|
static inline BOOL is_machine_64bit( WORD machine )
|
|
|
|
{
|
|
|
|
return (machine == IMAGE_FILE_MACHINE_AMD64 || machine == IMAGE_FILE_MACHINE_ARM64);
|
|
|
|
}
|
|
|
|
|
2020-05-29 15:48:44 +02:00
|
|
|
/* thread private data, stored in NtCurrentTeb()->GdiTebBatch */
|
|
|
|
struct ntdll_thread_data
|
|
|
|
{
|
2020-07-23 20:35:00 +02:00
|
|
|
void *cpu_data[16]; /* reserved for CPU-specific data */
|
2021-06-11 10:56:36 +02:00
|
|
|
void *kernel_stack; /* stack for thread startup and kernel syscalls */
|
2020-05-29 15:48:44 +02:00
|
|
|
int request_fd; /* fd for sending server requests */
|
|
|
|
int reply_fd; /* fd for receiving server replies */
|
|
|
|
int wait_fd[2]; /* fd for sleeping server requests */
|
|
|
|
pthread_t pthread_id; /* pthread thread id */
|
2020-06-18 12:37:50 +02:00
|
|
|
struct list entry; /* entry in TEB list */
|
2020-07-24 11:15:42 +02:00
|
|
|
PRTL_THREAD_START_ROUTINE start; /* thread entry point */
|
|
|
|
void *param; /* thread entry point parameter */
|
2021-06-01 15:16:23 +02:00
|
|
|
void *jmp_buf; /* setjmp buffer for exception handling */
|
2020-05-29 15:48:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
C_ASSERT( sizeof(struct ntdll_thread_data) <= sizeof(((TEB *)0)->GdiTebBatch) );
|
|
|
|
|
|
|
|
static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
|
|
|
|
{
|
|
|
|
return (struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch;
|
|
|
|
}
|
|
|
|
|
2021-09-14 08:02:48 +02:00
|
|
|
/* returns TRUE if the async is complete; FALSE if it should be restarted */
|
|
|
|
typedef BOOL async_callback_t( void *user, ULONG_PTR *info, NTSTATUS *status );
|
2021-05-22 05:08:47 +02:00
|
|
|
|
|
|
|
struct async_fileio
|
|
|
|
{
|
|
|
|
async_callback_t *callback;
|
|
|
|
struct async_fileio *next;
|
|
|
|
HANDLE handle;
|
|
|
|
};
|
|
|
|
|
2020-07-24 11:24:31 +02:00
|
|
|
static const SIZE_T page_size = 0x1000;
|
2021-06-15 16:31:49 +02:00
|
|
|
static const SIZE_T teb_size = 0x3800; /* TEB64 + TEB32 + debug info */
|
2020-07-24 11:24:31 +02:00
|
|
|
static const SIZE_T signal_stack_mask = 0xffff;
|
2021-06-15 16:31:49 +02:00
|
|
|
static const SIZE_T signal_stack_size = 0x10000 - 0x3800;
|
2021-06-11 10:56:36 +02:00
|
|
|
static const SIZE_T kernel_stack_size = 0x20000;
|
2021-08-17 12:16:56 +02:00
|
|
|
static const SIZE_T min_kernel_stack = 0x2000;
|
2021-04-27 12:21:47 +02:00
|
|
|
static const LONG teb_offset = 0x2000;
|
2020-06-16 12:02:00 +02:00
|
|
|
|
2021-08-05 17:22:35 +02:00
|
|
|
#define FILE_WRITE_TO_END_OF_FILE ((LONGLONG)-1)
|
|
|
|
#define FILE_USE_FILE_POINTER_POSITION ((LONGLONG)-2)
|
|
|
|
|
2020-06-17 11:57:32 +02:00
|
|
|
/* callbacks to PE ntdll from the Unix side */
|
2022-01-03 17:32:39 +01:00
|
|
|
extern void (WINAPI *pDbgUiRemoteBreakin)( void *arg ) DECLSPEC_HIDDEN;
|
2020-08-11 15:25:55 +02:00
|
|
|
extern NTSTATUS (WINAPI *pKiRaiseUserExceptionDispatcher)(void) DECLSPEC_HIDDEN;
|
2020-06-17 11:57:32 +02:00
|
|
|
extern NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) DECLSPEC_HIDDEN;
|
2021-08-17 11:55:39 +02:00
|
|
|
extern void (WINAPI *pKiUserApcDispatcher)(CONTEXT*,ULONG_PTR,ULONG_PTR,ULONG_PTR,PNTAPCFUNC) DECLSPEC_HIDDEN;
|
|
|
|
extern void (WINAPI *pKiUserCallbackDispatcher)(ULONG,void*,ULONG) DECLSPEC_HIDDEN;
|
2020-06-17 11:57:32 +02:00
|
|
|
extern void (WINAPI *pLdrInitializeThunk)(CONTEXT*,void**,ULONG_PTR,ULONG_PTR) DECLSPEC_HIDDEN;
|
|
|
|
extern void (WINAPI *pRtlUserThreadStart)( PRTL_THREAD_START_ROUTINE entry, void *arg ) DECLSPEC_HIDDEN;
|
2021-06-09 15:19:43 +02:00
|
|
|
extern void (WINAPI *p__wine_ctrl_routine)(void *) DECLSPEC_HIDDEN;
|
2021-07-07 11:39:57 +02:00
|
|
|
extern SYSTEM_DLL_INIT_BLOCK *pLdrSystemDllInitBlock DECLSPEC_HIDDEN;
|
2020-06-25 18:07:38 +02:00
|
|
|
extern LONGLONG CDECL fast_RtlGetSystemTimePrecise(void) DECLSPEC_HIDDEN;
|
2020-06-09 12:35:01 +02:00
|
|
|
|
2020-06-25 10:32:47 +02:00
|
|
|
extern NTSTATUS CDECL unwind_builtin_dll( ULONG type, struct _DISPATCHER_CONTEXT *dispatch,
|
|
|
|
CONTEXT *context ) DECLSPEC_HIDDEN;
|
2020-05-29 14:17:55 +02:00
|
|
|
|
2021-12-27 18:51:16 +01:00
|
|
|
struct _FILE_FS_DEVICE_INFORMATION;
|
|
|
|
|
2021-08-13 02:48:09 +02:00
|
|
|
extern const char wine_build[] DECLSPEC_HIDDEN;
|
|
|
|
|
2020-06-24 09:20:33 +02:00
|
|
|
extern const char *home_dir DECLSPEC_HIDDEN;
|
2020-05-29 14:17:55 +02:00
|
|
|
extern const char *data_dir DECLSPEC_HIDDEN;
|
|
|
|
extern const char *build_dir DECLSPEC_HIDDEN;
|
|
|
|
extern const char *config_dir DECLSPEC_HIDDEN;
|
2020-06-24 09:20:33 +02:00
|
|
|
extern const char *user_name DECLSPEC_HIDDEN;
|
2020-06-24 09:21:48 +02:00
|
|
|
extern const char **dll_paths DECLSPEC_HIDDEN;
|
2021-11-12 18:55:37 +01:00
|
|
|
extern const char **system_dll_paths DECLSPEC_HIDDEN;
|
2021-06-15 12:40:01 +02:00
|
|
|
extern PEB *peb DECLSPEC_HIDDEN;
|
2020-06-12 10:55:21 +02:00
|
|
|
extern USHORT *uctable DECLSPEC_HIDDEN;
|
|
|
|
extern USHORT *lctable DECLSPEC_HIDDEN;
|
2020-06-29 12:10:58 +02:00
|
|
|
extern SIZE_T startup_info_size DECLSPEC_HIDDEN;
|
2021-04-08 12:22:25 +02:00
|
|
|
extern BOOL is_prefix_bootstrap DECLSPEC_HIDDEN;
|
2021-04-07 10:46:34 +02:00
|
|
|
extern SECTION_IMAGE_INFORMATION main_image_info DECLSPEC_HIDDEN;
|
2020-06-23 19:39:12 +02:00
|
|
|
extern int main_argc DECLSPEC_HIDDEN;
|
|
|
|
extern char **main_argv DECLSPEC_HIDDEN;
|
|
|
|
extern char **main_envp DECLSPEC_HIDDEN;
|
2020-09-03 12:16:52 +02:00
|
|
|
extern WCHAR **main_wargv DECLSPEC_HIDDEN;
|
2021-03-19 11:24:46 +01:00
|
|
|
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
|
2021-04-23 11:58:32 +02:00
|
|
|
extern unsigned int supported_machines_count DECLSPEC_HIDDEN;
|
|
|
|
extern USHORT supported_machines[8] DECLSPEC_HIDDEN;
|
2020-09-22 11:28:41 +02:00
|
|
|
extern BOOL process_exiting DECLSPEC_HIDDEN;
|
2020-06-04 21:27:22 +02:00
|
|
|
extern HANDLE keyed_event DECLSPEC_HIDDEN;
|
2020-06-04 19:37:35 +02:00
|
|
|
extern timeout_t server_start_time DECLSPEC_HIDDEN;
|
2020-06-01 12:52:05 +02:00
|
|
|
extern sigset_t server_block_set DECLSPEC_HIDDEN;
|
2020-06-11 10:07:09 +02:00
|
|
|
extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
|
2021-02-26 17:41:31 +01:00
|
|
|
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
|
2021-05-17 10:12:01 +02:00
|
|
|
#ifndef _WIN64
|
|
|
|
extern BOOL is_wow64 DECLSPEC_HIDDEN;
|
|
|
|
#endif
|
2020-06-29 12:10:00 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
|
|
|
|
#endif
|
2020-05-29 14:17:55 +02:00
|
|
|
|
2020-06-11 10:50:11 +02:00
|
|
|
extern void init_environment( int argc, char *argv[], char *envp[] ) DECLSPEC_HIDDEN;
|
2021-02-15 12:30:28 +01:00
|
|
|
extern void init_startup_info(void) DECLSPEC_HIDDEN;
|
2021-04-15 12:58:22 +02:00
|
|
|
extern void *create_startup_info( const UNICODE_STRING *nt_image, const RTL_USER_PROCESS_PARAMETERS *params,
|
|
|
|
DWORD *info_size ) DECLSPEC_HIDDEN;
|
2020-06-12 09:26:50 +02:00
|
|
|
extern char **build_envp( const WCHAR *envW ) DECLSPEC_HIDDEN;
|
2020-07-03 19:42:45 +02:00
|
|
|
extern NTSTATUS exec_wineloader( char **argv, int socketfd, const pe_image_info_t *pe_info ) DECLSPEC_HIDDEN;
|
2021-03-30 10:06:44 +02:00
|
|
|
extern NTSTATUS load_builtin( const pe_image_info_t *image_info, WCHAR *filename,
|
2021-03-22 09:56:57 +01:00
|
|
|
void **addr_ptr, SIZE_T *size_ptr ) DECLSPEC_HIDDEN;
|
2021-03-26 11:34:36 +01:00
|
|
|
extern BOOL is_builtin_path( const UNICODE_STRING *path, WORD *machine ) DECLSPEC_HIDDEN;
|
2021-03-25 11:24:35 +01:00
|
|
|
extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir, WCHAR **image,
|
2021-04-07 10:46:34 +02:00
|
|
|
void **module ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS load_start_exe( WCHAR **image, void **module ) DECLSPEC_HIDDEN;
|
2020-06-18 14:14:19 +02:00
|
|
|
extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
|
2020-06-11 10:50:11 +02:00
|
|
|
|
2020-06-02 17:08:59 +02:00
|
|
|
extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN;
|
2020-07-03 12:02:58 +02:00
|
|
|
extern void server_enter_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
|
|
|
extern void server_leave_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN;
|
2020-06-09 12:39:49 +02:00
|
|
|
extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags,
|
2021-11-30 23:18:46 +01:00
|
|
|
timeout_t abs_timeout, context_t *context, user_apc_t *user_apc ) DECLSPEC_HIDDEN;
|
2020-06-09 13:05:58 +02:00
|
|
|
extern unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT flags,
|
|
|
|
const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
|
2020-06-09 12:39:49 +02:00
|
|
|
extern unsigned int server_queue_process_apc( HANDLE process, const apc_call_t *call,
|
|
|
|
apc_result_t *result ) DECLSPEC_HIDDEN;
|
2020-06-21 16:56:05 +02:00
|
|
|
extern int 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;
|
2021-04-05 13:18:39 +02:00
|
|
|
extern void wine_server_send_fd( int fd ) DECLSPEC_HIDDEN;
|
|
|
|
extern void process_exit_wrapper( int status ) DECLSPEC_HIDDEN;
|
2021-02-02 10:18:26 +01:00
|
|
|
extern size_t server_init_process(void) DECLSPEC_HIDDEN;
|
2020-09-01 13:03:44 +02:00
|
|
|
extern void server_init_process_done(void) DECLSPEC_HIDDEN;
|
2021-02-02 10:18:26 +01:00
|
|
|
extern void server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDDEN;
|
2020-06-05 14:09:19 +02:00
|
|
|
extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;
|
2020-05-29 14:17:55 +02:00
|
|
|
|
2021-06-26 11:11:01 +02:00
|
|
|
extern void fpux_to_fpu( I386_FLOATING_SAVE_AREA *fpu, const XSAVE_FORMAT *fpux ) DECLSPEC_HIDDEN;
|
|
|
|
extern void fpu_to_fpux( XSAVE_FORMAT *fpux, const I386_FLOATING_SAVE_AREA *fpu ) DECLSPEC_HIDDEN;
|
2021-07-01 11:16:27 +02:00
|
|
|
extern void *get_cpu_area( USHORT machine ) DECLSPEC_HIDDEN;
|
2021-05-17 09:39:34 +02:00
|
|
|
extern void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) DECLSPEC_HIDDEN;
|
2021-06-11 10:56:36 +02:00
|
|
|
extern NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size, SIZE_T commit_size ) DECLSPEC_HIDDEN;
|
2020-06-09 12:34:37 +02:00
|
|
|
extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN;
|
2020-06-16 11:35:55 +02:00
|
|
|
extern void DECLSPEC_NORETURN abort_process( int status ) DECLSPEC_HIDDEN;
|
2020-07-22 13:04:54 +02:00
|
|
|
extern void DECLSPEC_NORETURN exit_process( int status ) DECLSPEC_HIDDEN;
|
2020-06-03 16:32:02 +02:00
|
|
|
extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN;
|
2020-06-09 12:32:41 +02:00
|
|
|
extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) DECLSPEC_HIDDEN;
|
2021-05-18 10:18:19 +02:00
|
|
|
extern NTSTATUS set_thread_context( HANDLE handle, const void *context, BOOL *self, USHORT machine ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS get_thread_context( HANDLE handle, void *context, BOOL *self, USHORT machine ) DECLSPEC_HIDDEN;
|
2020-06-05 14:09:19 +02:00
|
|
|
extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
|
|
|
|
data_size_t *ret_len ) DECLSPEC_HIDDEN;
|
2020-06-01 13:40:25 +02:00
|
|
|
|
2020-09-03 10:51:09 +02:00
|
|
|
extern void *anon_mmap_fixed( void *start, size_t size, int prot, int flags ) DECLSPEC_HIDDEN;
|
2020-09-03 10:52:11 +02:00
|
|
|
extern void *anon_mmap_alloc( size_t size, int prot ) DECLSPEC_HIDDEN;
|
2020-06-04 19:37:35 +02:00
|
|
|
extern void virtual_init(void) DECLSPEC_HIDDEN;
|
2020-06-16 11:35:55 +02:00
|
|
|
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
|
2021-07-05 12:02:39 +02:00
|
|
|
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info, BOOL wow64 ) DECLSPEC_HIDDEN;
|
2021-03-22 09:57:03 +01:00
|
|
|
extern NTSTATUS virtual_map_builtin_module( HANDLE mapping, void **module, SIZE_T *size,
|
|
|
|
SECTION_IMAGE_INFORMATION *info, WORD machine, BOOL prefer_native ) DECLSPEC_HIDDEN;
|
2021-02-15 12:24:15 +01:00
|
|
|
extern NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_name,
|
2021-03-16 10:58:14 +01:00
|
|
|
pe_image_info_t *info, void *so_handle ) DECLSPEC_HIDDEN;
|
2020-06-04 19:37:35 +02:00
|
|
|
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
|
2020-06-03 21:09:13 +02:00
|
|
|
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
|
2020-06-03 21:26:47 +02:00
|
|
|
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
|
2020-06-18 12:37:50 +02:00
|
|
|
extern NTSTATUS virtual_clear_tls_index( ULONG index ) DECLSPEC_HIDDEN;
|
2021-05-07 16:02:54 +02:00
|
|
|
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR zero_bits, SIZE_T reserve_size,
|
2021-06-11 10:56:36 +02:00
|
|
|
SIZE_T commit_size, SIZE_T extra_size ) DECLSPEC_HIDDEN;
|
2020-06-04 19:48:26 +02:00
|
|
|
extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN;
|
2020-07-15 10:28:26 +02:00
|
|
|
extern NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:35 +02:00
|
|
|
extern unsigned int virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:00 +02:00
|
|
|
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;
|
2021-05-27 06:36:52 +02:00
|
|
|
extern ssize_t virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN;
|
2020-06-09 12:32:41 +02:00
|
|
|
extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
|
2020-07-15 10:30:45 +02:00
|
|
|
extern void *virtual_setup_exception( void *stack_ptr, size_t size, EXCEPTION_RECORD *rec ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:00 +02:00
|
|
|
extern BOOL virtual_check_buffer_for_read( const void *ptr, SIZE_T size ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:35 +02:00
|
|
|
extern BOOL virtual_check_buffer_for_write( void *ptr, SIZE_T size ) DECLSPEC_HIDDEN;
|
2020-06-09 12:32:41 +02:00
|
|
|
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;
|
2020-06-16 11:35:55 +02:00
|
|
|
extern void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN;
|
2020-07-22 14:27:33 +02:00
|
|
|
extern void virtual_set_large_address_space(void) DECLSPEC_HIDDEN;
|
2020-06-16 11:34:48 +02:00
|
|
|
extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
|
|
|
|
SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN;
|
2021-09-10 20:09:38 +02:00
|
|
|
extern void release_builtin_module( void *module ) DECLSPEC_HIDDEN;
|
2021-03-16 10:58:14 +01:00
|
|
|
extern void *get_builtin_so_handle( void *module ) DECLSPEC_HIDDEN;
|
2021-12-09 10:43:56 +01:00
|
|
|
extern NTSTATUS load_builtin_unixlib( void *module, const char *name ) DECLSPEC_HIDDEN;
|
2020-06-03 21:09:13 +02:00
|
|
|
|
2020-06-18 12:37:50 +02:00
|
|
|
extern NTSTATUS get_thread_ldt_entry( HANDLE handle, void *data, ULONG len, ULONG *ret_len ) DECLSPEC_HIDDEN;
|
2021-06-26 11:13:05 +02:00
|
|
|
extern void *get_native_context( CONTEXT *context ) DECLSPEC_HIDDEN;
|
|
|
|
extern void *get_wow_context( CONTEXT *context ) DECLSPEC_HIDDEN;
|
2020-06-29 03:43:18 +02:00
|
|
|
extern BOOL get_thread_times( int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time,
|
|
|
|
LARGE_INTEGER *user_time ) DECLSPEC_HIDDEN;
|
2020-06-01 12:52:05 +02:00
|
|
|
extern void signal_init_threading(void) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS signal_alloc_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
|
|
|
extern void signal_free_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
|
|
|
extern void signal_init_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
2020-06-09 12:32:41 +02:00
|
|
|
extern void signal_init_process(void) DECLSPEC_HIDDEN;
|
2020-06-03 16:32:02 +02:00
|
|
|
extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg,
|
2021-06-21 15:57:26 +02:00
|
|
|
BOOL suspend, TEB *teb ) DECLSPEC_HIDDEN;
|
2021-06-14 12:56:38 +02:00
|
|
|
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int), TEB *teb ) DECLSPEC_HIDDEN;
|
2021-08-30 12:20:03 +02:00
|
|
|
extern SYSTEM_SERVICE_TABLE KeServiceDescriptorTable[4] DECLSPEC_HIDDEN;
|
2020-07-07 10:47:02 +02:00
|
|
|
extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
|
2021-06-21 15:43:22 +02:00
|
|
|
extern void WINAPI DECLSPEC_NORETURN __wine_syscall_dispatcher_return( void *frame, ULONG_PTR retval ) DECLSPEC_HIDDEN;
|
2021-06-11 12:40:08 +02:00
|
|
|
extern NTSTATUS signal_set_full_context( CONTEXT *context ) DECLSPEC_HIDDEN;
|
2021-05-18 11:58:40 +02:00
|
|
|
extern NTSTATUS get_thread_wow64_context( HANDLE handle, void *ctx, ULONG size ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS set_thread_wow64_context( HANDLE handle, const void *ctx, ULONG size ) DECLSPEC_HIDDEN;
|
2020-07-09 04:14:53 +02:00
|
|
|
extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) DECLSPEC_HIDDEN;
|
2021-03-03 10:00:29 +01:00
|
|
|
extern NTSTATUS open_hkcu_key( const char *path, HANDLE *key ) DECLSPEC_HIDDEN;
|
2020-06-01 12:52:05 +02:00
|
|
|
|
2020-06-16 12:02:35 +02:00
|
|
|
extern NTSTATUS cdrom_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user,
|
|
|
|
IO_STATUS_BLOCK *io, ULONG code, void *in_buffer,
|
|
|
|
ULONG in_size, void *out_buffer, ULONG out_size ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS serial_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user,
|
|
|
|
IO_STATUS_BLOCK *io, ULONG code, void *in_buffer,
|
|
|
|
ULONG in_size, void *out_buffer, ULONG out_size ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS serial_FlushBuffersFile( int fd ) DECLSPEC_HIDDEN;
|
2021-05-22 05:08:48 +02:00
|
|
|
extern NTSTATUS sock_ioctl( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user, IO_STATUS_BLOCK *io,
|
|
|
|
ULONG code, void *in_buffer, ULONG in_size, void *out_buffer, ULONG out_size ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:35 +02:00
|
|
|
extern NTSTATUS tape_DeviceIoControl( HANDLE device, HANDLE event, PIO_APC_ROUTINE apc, void *apc_user,
|
|
|
|
IO_STATUS_BLOCK *io, ULONG code, void *in_buffer,
|
|
|
|
ULONG in_size, void *out_buffer, ULONG out_size ) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-05-22 05:08:48 +02:00
|
|
|
extern struct async_fileio *alloc_fileio( DWORD size, async_callback_t callback, HANDLE handle ) DECLSPEC_HIDDEN;
|
|
|
|
extern void release_fileio( struct async_fileio *io ) DECLSPEC_HIDDEN;
|
2020-06-16 12:02:35 +02:00
|
|
|
extern NTSTATUS errno_to_status( int err ) DECLSPEC_HIDDEN;
|
2021-04-15 12:58:22 +02:00
|
|
|
extern BOOL get_redirect( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *redir ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS nt_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, char **name_ret, UINT disposition ) DECLSPEC_HIDDEN;
|
2020-07-09 10:01:19 +02:00
|
|
|
extern NTSTATUS unix_to_nt_file_name( const char *name, WCHAR **nt ) DECLSPEC_HIDDEN;
|
2021-03-24 10:53:53 +01:00
|
|
|
extern NTSTATUS get_full_path( const WCHAR *name, const WCHAR *curdir, WCHAR **path ) DECLSPEC_HIDDEN;
|
2020-07-10 07:56:02 +02:00
|
|
|
extern NTSTATUS open_unix_file( HANDLE *handle, const char *unix_name, ACCESS_MASK access,
|
|
|
|
OBJECT_ATTRIBUTES *attr, ULONG attributes, ULONG sharing, ULONG disposition,
|
|
|
|
ULONG options, void *ea_buffer, ULONG ea_length ) DECLSPEC_HIDDEN;
|
2021-12-27 18:51:16 +01:00
|
|
|
extern NTSTATUS get_device_info( int fd, struct _FILE_FS_DEVICE_INFORMATION *info ) DECLSPEC_HIDDEN;
|
2020-06-12 14:20:16 +02:00
|
|
|
extern void init_files(void) DECLSPEC_HIDDEN;
|
2020-06-23 14:29:31 +02:00
|
|
|
extern void init_cpu_info(void) DECLSPEC_HIDDEN;
|
2021-06-02 17:30:18 +02:00
|
|
|
extern void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ) DECLSPEC_HIDDEN;
|
2020-06-12 14:20:16 +02:00
|
|
|
|
2020-06-04 19:37:35 +02:00
|
|
|
extern void dbg_init(void) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-06-11 12:40:08 +02:00
|
|
|
extern NTSTATUS call_user_apc_dispatcher( CONTEXT *context_ptr, ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3,
|
|
|
|
PNTAPCFUNC func, NTSTATUS status ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS call_user_exception_dispatcher( EXCEPTION_RECORD *rec, CONTEXT *context ) DECLSPEC_HIDDEN;
|
|
|
|
extern void call_raise_user_exception_dispatcher(void) DECLSPEC_HIDDEN;
|
2020-06-30 22:34:34 +02:00
|
|
|
|
2021-03-22 09:57:03 +01:00
|
|
|
#define IMAGE_DLLCHARACTERISTICS_PREFER_NATIVE 0x0010 /* Wine extension */
|
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)86400)
|
2020-11-22 06:33:20 +01:00
|
|
|
|
|
|
|
static inline ULONGLONG ticks_from_time_t( time_t time )
|
|
|
|
{
|
|
|
|
if (sizeof(time_t) == sizeof(int)) /* time_t may be signed */
|
|
|
|
return ((ULONGLONG)(ULONG)time + SECS_1601_TO_1970) * TICKSPERSEC;
|
|
|
|
else
|
|
|
|
return ((ULONGLONG)time + SECS_1601_TO_1970) * TICKSPERSEC;
|
|
|
|
}
|
2020-06-12 14:20:16 +02:00
|
|
|
|
|
|
|
static inline const char *debugstr_us( const UNICODE_STRING *us )
|
|
|
|
{
|
|
|
|
if (!us) return "<null>";
|
|
|
|
return debugstr_wn( us->Buffer, us->Length / sizeof(WCHAR) );
|
|
|
|
}
|
|
|
|
|
2020-06-25 15:28:26 +02:00
|
|
|
/* convert from straight ASCII to Unicode without depending on the current codepage */
|
|
|
|
static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len )
|
|
|
|
{
|
|
|
|
while (len--) *dst++ = (unsigned char)*src++;
|
|
|
|
}
|
|
|
|
|
2020-07-15 10:23:00 +02:00
|
|
|
static inline void *get_signal_stack(void)
|
|
|
|
{
|
2021-04-27 12:21:47 +02:00
|
|
|
return (void *)(((ULONG_PTR)NtCurrentTeb() & ~signal_stack_mask) + teb_size);
|
2020-07-15 10:23:00 +02:00
|
|
|
}
|
|
|
|
|
2021-07-09 21:08:35 +02:00
|
|
|
static inline BOOL is_inside_signal_stack( void *ptr )
|
|
|
|
{
|
|
|
|
return ((char *)ptr >= (char *)get_signal_stack() &&
|
|
|
|
(char *)ptr < (char *)get_signal_stack() + signal_stack_size);
|
|
|
|
}
|
|
|
|
|
2020-09-22 11:28:25 +02:00
|
|
|
static inline void mutex_lock( pthread_mutex_t *mutex )
|
|
|
|
{
|
2020-09-22 11:28:41 +02:00
|
|
|
if (!process_exiting) pthread_mutex_lock( mutex );
|
2020-09-22 11:28:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void mutex_unlock( pthread_mutex_t *mutex )
|
|
|
|
{
|
2020-09-22 11:28:41 +02:00
|
|
|
if (!process_exiting) pthread_mutex_unlock( mutex );
|
2020-09-22 11:28:25 +02:00
|
|
|
}
|
|
|
|
|
2021-08-05 17:22:35 +02:00
|
|
|
static inline async_data_t server_async( HANDLE handle, struct async_fileio *user, HANDLE event,
|
2021-08-05 17:42:57 +02:00
|
|
|
PIO_APC_ROUTINE apc, void *apc_context, client_ptr_t iosb )
|
2021-08-05 17:22:35 +02:00
|
|
|
{
|
|
|
|
async_data_t async;
|
|
|
|
async.handle = wine_server_obj_handle( handle );
|
|
|
|
async.user = wine_server_client_ptr( user );
|
2021-08-05 17:42:57 +02:00
|
|
|
async.iosb = iosb;
|
2021-08-05 17:22:35 +02:00
|
|
|
async.event = wine_server_obj_handle( event );
|
|
|
|
async.apc = wine_server_client_ptr( apc );
|
|
|
|
async.apc_context = wine_server_client_ptr( apc_context );
|
|
|
|
return async;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline NTSTATUS wait_async( HANDLE handle, BOOL alertable )
|
|
|
|
{
|
|
|
|
return NtWaitForSingleObject( handle, alertable, NULL );
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:27:31 +01:00
|
|
|
static inline BOOL in_wow64_call(void)
|
|
|
|
{
|
|
|
|
#ifdef _WIN64
|
|
|
|
return !!NtCurrentTeb()->WowTebOffset;
|
|
|
|
#endif
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-08-05 19:36:28 +02:00
|
|
|
static inline void set_async_iosb( client_ptr_t iosb, NTSTATUS status, ULONG_PTR info )
|
|
|
|
{
|
|
|
|
if (!iosb) return;
|
2021-12-10 18:27:31 +01:00
|
|
|
|
|
|
|
if (in_wow64_call())
|
2021-08-05 19:36:28 +02:00
|
|
|
{
|
|
|
|
struct iosb32
|
|
|
|
{
|
|
|
|
NTSTATUS Status;
|
|
|
|
ULONG Information;
|
|
|
|
} *io = wine_server_get_ptr( iosb );
|
|
|
|
io->Status = status;
|
|
|
|
io->Information = info;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IO_STATUS_BLOCK *io = wine_server_get_ptr( iosb );
|
|
|
|
#ifdef NONAMELESSUNION
|
|
|
|
io->u.Status = status;
|
|
|
|
#else
|
|
|
|
io->Status = status;
|
|
|
|
#endif
|
|
|
|
io->Information = info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 17:42:57 +02:00
|
|
|
static inline client_ptr_t iosb_client_ptr( IO_STATUS_BLOCK *io )
|
|
|
|
{
|
2021-08-05 19:36:28 +02:00
|
|
|
#ifdef NONAMELESSUNION
|
2021-12-10 18:27:31 +01:00
|
|
|
if (io && in_wow64_call()) return wine_server_client_ptr( io->u.Pointer );
|
2021-08-05 19:36:28 +02:00
|
|
|
#else
|
2021-12-10 18:27:31 +01:00
|
|
|
if (io && in_wow64_call()) return wine_server_client_ptr( io->Pointer );
|
2021-08-05 19:36:28 +02:00
|
|
|
#endif
|
2021-08-05 17:42:57 +02:00
|
|
|
return wine_server_client_ptr( io );
|
|
|
|
}
|
|
|
|
|
2021-04-01 12:25:21 +02:00
|
|
|
#ifdef _WIN64
|
2021-06-17 09:25:06 +02:00
|
|
|
typedef TEB32 WOW_TEB;
|
2021-04-01 12:25:21 +02:00
|
|
|
static inline TEB64 *NtCurrentTeb64(void) { return NULL; }
|
|
|
|
#else
|
2021-06-17 09:25:06 +02:00
|
|
|
typedef TEB64 WOW_TEB;
|
2020-07-24 13:29:31 +02:00
|
|
|
static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; }
|
|
|
|
#endif
|
|
|
|
|
2021-06-17 09:25:06 +02:00
|
|
|
static inline WOW_TEB *get_wow_teb( TEB *teb )
|
|
|
|
{
|
|
|
|
return teb->WowTebOffset ? (WOW_TEB *)((char *)teb + teb->WowTebOffset) : NULL;
|
|
|
|
}
|
|
|
|
|
2021-03-30 10:20:54 +02:00
|
|
|
enum loadorder
|
|
|
|
{
|
|
|
|
LO_INVALID,
|
|
|
|
LO_DISABLED,
|
|
|
|
LO_NATIVE,
|
|
|
|
LO_BUILTIN,
|
|
|
|
LO_NATIVE_BUILTIN, /* native then builtin */
|
|
|
|
LO_BUILTIN_NATIVE, /* builtin then native */
|
|
|
|
LO_DEFAULT /* nothing specified, use default strategy */
|
|
|
|
};
|
|
|
|
|
2021-05-05 10:55:36 +02:00
|
|
|
extern void set_load_order_app_name( const WCHAR *app_name ) DECLSPEC_HIDDEN;
|
2021-03-30 10:20:54 +02:00
|
|
|
extern enum loadorder get_load_order( const UNICODE_STRING *nt_name ) DECLSPEC_HIDDEN;
|
2021-03-16 11:04:05 +01:00
|
|
|
|
2020-06-12 10:55:21 +02:00
|
|
|
static inline WCHAR ntdll_towupper( WCHAR ch )
|
|
|
|
{
|
|
|
|
return ch + uctable[uctable[uctable[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0x0f)];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WCHAR ntdll_towlower( WCHAR ch )
|
|
|
|
{
|
|
|
|
return ch + lctable[lctable[lctable[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0x0f)];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WCHAR *ntdll_wcsupr( WCHAR *str )
|
|
|
|
{
|
|
|
|
WCHAR *ret;
|
|
|
|
for (ret = str; *str; str++) *str = ntdll_towupper(*str);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define wcsupr(str) ntdll_wcsupr(str)
|
|
|
|
#define towupper(c) ntdll_towupper(c)
|
|
|
|
#define towlower(c) ntdll_towlower(c)
|
2020-06-11 10:50:11 +02:00
|
|
|
|
2021-03-03 09:50:34 +01:00
|
|
|
static inline void init_unicode_string( UNICODE_STRING *str, const WCHAR *data )
|
|
|
|
{
|
|
|
|
str->Length = wcslen(data) * sizeof(WCHAR);
|
|
|
|
str->MaximumLength = str->Length + sizeof(WCHAR);
|
|
|
|
str->Buffer = (WCHAR *)data;
|
|
|
|
}
|
|
|
|
|
2020-05-14 15:33:36 +02:00
|
|
|
#endif /* __NTDLL_UNIX_PRIVATE_H */
|