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"
|
2020-06-18 12:37:50 +02:00
|
|
|
#include "wine/list.h"
|
2020-05-14 15:33:36 +02:00
|
|
|
|
2020-06-07 00:38:02 +02:00
|
|
|
#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
|
|
|
|
#define InterlockedCompareExchange64(dest,xchg,cmp) RtlInterlockedCompareExchange64(dest,xchg,cmp)
|
|
|
|
#endif
|
|
|
|
|
2020-06-22 16:16:17 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
static const enum cpu_type client_cpu = CPU_x86;
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
static const enum cpu_type client_cpu = CPU_x86_64;
|
|
|
|
#elif defined(__arm__)
|
|
|
|
static const enum cpu_type client_cpu = CPU_ARM;
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
static const enum cpu_type client_cpu = CPU_ARM64;
|
|
|
|
#endif
|
|
|
|
|
2020-05-29 15:48:44 +02:00
|
|
|
struct debug_info
|
|
|
|
{
|
|
|
|
unsigned int str_pos; /* current position in strings buffer */
|
|
|
|
unsigned int out_pos; /* current position in output buffer */
|
|
|
|
char strings[1024]; /* buffer for temporary strings */
|
|
|
|
char output[1024]; /* current output line */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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 */
|
2020-05-29 15:48:44 +02:00
|
|
|
struct debug_info *debug_info; /* info for debugstr functions */
|
|
|
|
void *start_stack; /* stack for thread startup */
|
|
|
|
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 */
|
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;
|
|
|
|
}
|
|
|
|
|
2020-07-24 11:24:31 +02:00
|
|
|
static const SIZE_T page_size = 0x1000;
|
|
|
|
static const SIZE_T signal_stack_mask = 0xffff;
|
|
|
|
#ifdef _WIN64
|
|
|
|
static const SIZE_T teb_size = 0x2000;
|
|
|
|
static const SIZE_T teb_offset = 0;
|
|
|
|
static const SIZE_T signal_stack_size = 0x10000 - 0x2000;
|
|
|
|
#else
|
|
|
|
static const SIZE_T teb_size = 0x3000; /* TEB64 + TEB */
|
|
|
|
static const SIZE_T teb_offset = 0x2000;
|
|
|
|
static const SIZE_T signal_stack_size = 0x10000 - 0x3000;
|
|
|
|
#endif
|
2020-06-16 12:02:00 +02:00
|
|
|
|
2020-06-17 11:57:32 +02:00
|
|
|
/* callbacks to PE ntdll from the Unix side */
|
|
|
|
extern void (WINAPI *pDbgUiRemoteBreakin)( void *arg ) DECLSPEC_HIDDEN;
|
2020-08-11 15:25:55 +02:00
|
|
|
extern NTSTATUS (WINAPI *pKiRaiseUserExceptionDispatcher)(void) DECLSPEC_HIDDEN;
|
2020-08-06 19:31:24 +02:00
|
|
|
extern void (WINAPI *pKiUserApcDispatcher)(CONTEXT*,ULONG_PTR,ULONG_PTR,ULONG_PTR,PNTAPCFUNC) DECLSPEC_HIDDEN;
|
2020-06-17 11:57:32 +02:00
|
|
|
extern NTSTATUS (WINAPI *pKiUserExceptionDispatcher)(EXCEPTION_RECORD*,CONTEXT*) DECLSPEC_HIDDEN;
|
|
|
|
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;
|
2020-06-09 13:05:58 +02:00
|
|
|
extern NTSTATUS CDECL fast_RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit, int timeout ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) DECLSPEC_HIDDEN;
|
2020-06-09 12:35:01 +02:00
|
|
|
extern NTSTATUS CDECL fast_RtlTryAcquireSRWLockExclusive( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlAcquireSRWLockExclusive( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlTryAcquireSRWLockShared( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlAcquireSRWLockShared( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlReleaseSRWLockExclusive( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlReleaseSRWLockShared( RTL_SRWLOCK *lock ) DECLSPEC_HIDDEN;
|
2020-06-09 12:38:37 +02:00
|
|
|
extern NTSTATUS CDECL fast_RtlSleepConditionVariableSRW( RTL_CONDITION_VARIABLE *variable, RTL_SRWLOCK *lock,
|
|
|
|
const LARGE_INTEGER *timeout, ULONG flags ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlSleepConditionVariableCS( RTL_CONDITION_VARIABLE *variable,
|
|
|
|
RTL_CRITICAL_SECTION *cs,
|
|
|
|
const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL fast_RtlWakeConditionVariable( RTL_CONDITION_VARIABLE *variable, int count ) 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-05-17 11:04:47 +02:00
|
|
|
void CDECL mmap_add_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
|
|
|
|
void CDECL mmap_remove_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
|
|
|
|
int CDECL mmap_is_in_reserved_area( void *addr, SIZE_T size ) DECLSPEC_HIDDEN;
|
|
|
|
int CDECL mmap_enum_reserved_areas( int (CDECL *enum_func)(void *base, SIZE_T size, void *arg), void *arg,
|
|
|
|
int top_down ) DECLSPEC_HIDDEN;
|
2020-06-11 10:50:11 +02:00
|
|
|
extern NTSTATUS CDECL get_initial_environment( WCHAR **wargv[], WCHAR *env, SIZE_T *size ) DECLSPEC_HIDDEN;
|
2020-06-29 12:10:58 +02:00
|
|
|
extern NTSTATUS CDECL get_startup_info( startup_info_t *info, SIZE_T *total_size, SIZE_T *info_size ) DECLSPEC_HIDDEN;
|
2020-06-24 09:21:48 +02:00
|
|
|
extern NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size ) DECLSPEC_HIDDEN;
|
2020-06-17 16:19:38 +02:00
|
|
|
extern void CDECL get_initial_directory( UNICODE_STRING *dir ) DECLSPEC_HIDDEN;
|
2020-06-29 10:39:27 +02:00
|
|
|
extern void CDECL get_initial_console( HANDLE *handle, HANDLE *std_in, HANDLE *std_out, HANDLE *std_err ) DECLSPEC_HIDDEN;
|
2020-07-01 10:37:16 +02:00
|
|
|
extern USHORT * CDECL get_unix_codepage_data(void) DECLSPEC_HIDDEN;
|
2020-06-11 11:38:16 +02:00
|
|
|
extern void CDECL get_locales( WCHAR *sys, WCHAR *user ) DECLSPEC_HIDDEN;
|
2020-06-02 17:08:59 +02:00
|
|
|
extern NTSTATUS CDECL virtual_map_section( HANDLE handle, PVOID *addr_ptr, unsigned short zero_bits_64, SIZE_T commit_size,
|
|
|
|
const LARGE_INTEGER *offset_ptr, SIZE_T *size_ptr, ULONG alloc_type,
|
|
|
|
ULONG protect, pe_image_info_t *image_info ) DECLSPEC_HIDDEN;
|
|
|
|
extern ssize_t CDECL virtual_locked_recvmsg( int fd, struct msghdr *hdr, int flags ) DECLSPEC_HIDDEN;
|
|
|
|
extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN;
|
2020-05-17 11:04:47 +02:00
|
|
|
|
2020-05-29 14:17:55 +02:00
|
|
|
extern void CDECL server_send_fd( int fd ) DECLSPEC_HIDDEN;
|
2020-05-29 15:35:16 +02:00
|
|
|
extern NTSTATUS CDECL server_fd_to_handle( int fd, unsigned int access, unsigned int attributes,
|
|
|
|
HANDLE *handle ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS CDECL server_handle_to_fd( HANDLE handle, unsigned int access, int *unix_fd,
|
|
|
|
unsigned int *options ) DECLSPEC_HIDDEN;
|
|
|
|
extern void CDECL server_release_fd( HANDLE handle, int unix_fd ) DECLSPEC_HIDDEN;
|
2020-06-09 12:32:41 +02:00
|
|
|
extern void CDECL server_init_process_done( void *relay ) DECLSPEC_HIDDEN;
|
2020-06-18 09:05:30 +02:00
|
|
|
extern NTSTATUS CDECL exec_process( UNICODE_STRING *path, UNICODE_STRING *cmdline, NTSTATUS status ) DECLSPEC_HIDDEN;
|
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
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
extern void CDECL set_show_dot_files( BOOL enable ) 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;
|
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;
|
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-06-04 19:37:35 +02:00
|
|
|
extern unsigned int server_cpus DECLSPEC_HIDDEN;
|
2020-06-02 17:08:59 +02:00
|
|
|
extern BOOL is_wow64 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;
|
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;
|
|
|
|
extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen ) DECLSPEC_HIDDEN;
|
2020-06-12 09:26:50 +02:00
|
|
|
extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ) DECLSPEC_HIDDEN;
|
|
|
|
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;
|
2020-06-18 14:14:19 +02:00
|
|
|
extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
|
|
|
|
extern ULONG_PTR get_image_address(void) 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,
|
2020-07-13 18:48:21 +02:00
|
|
|
timeout_t abs_timeout, CONTEXT *context, pthread_mutex_t *mutex,
|
2020-06-09 12:39:49 +02:00
|
|
|
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;
|
2020-06-04 19:37:35 +02:00
|
|
|
extern void server_init_process(void) DECLSPEC_HIDDEN;
|
|
|
|
extern size_t 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
|
|
|
|
2020-06-01 13:40:25 +02:00
|
|
|
extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) 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;
|
2020-06-02 13:11:54 +02:00
|
|
|
extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOOL *self ) DECLSPEC_HIDDEN;
|
2020-06-02 14:05:42 +02:00
|
|
|
extern NTSTATUS get_thread_context( HANDLE handle, context_t *context, unsigned int flags, BOOL *self ) 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-06-04 19:37:35 +02:00
|
|
|
extern void virtual_init(void) DECLSPEC_HIDDEN;
|
2020-06-30 12:00:57 +02:00
|
|
|
extern NTSTATUS virtual_map_ntdll( int fd, void **module ) DECLSPEC_HIDDEN;
|
2020-06-16 11:35:55 +02:00
|
|
|
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
|
2020-06-23 14:29:31 +02:00
|
|
|
extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_HIDDEN;
|
2020-06-23 19:39:12 +02:00
|
|
|
extern NTSTATUS virtual_create_builtin_view( void *module ) 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;
|
2020-07-22 14:16:22 +02:00
|
|
|
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size,
|
|
|
|
SIZE_T *pthread_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;
|
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;
|
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;
|
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,
|
2020-08-20 15:30:08 +02:00
|
|
|
BOOL suspend, void *relay, void *thunk, TEB *teb ) DECLSPEC_HIDDEN;
|
2020-06-01 12:52:05 +02:00
|
|
|
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN;
|
2020-07-07 10:47:02 +02:00
|
|
|
extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
|
2020-07-09 04:14:53 +02:00
|
|
|
extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) 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;
|
|
|
|
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;
|
|
|
|
|
|
|
|
extern NTSTATUS errno_to_status( int err ) DECLSPEC_HIDDEN;
|
2020-07-09 09:57:57 +02:00
|
|
|
extern NTSTATUS nt_to_unix_file_name( const UNICODE_STRING *nameW, 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;
|
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;
|
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;
|
2020-06-12 14:20:16 +02:00
|
|
|
|
2020-06-04 19:37:35 +02:00
|
|
|
extern void dbg_init(void) DECLSPEC_HIDDEN;
|
|
|
|
|
2020-08-20 08:24:00 +02:00
|
|
|
extern void WINAPI DECLSPEC_NORETURN call_user_apc_dispatcher( CONTEXT *context_ptr, ULONG_PTR ctx,
|
|
|
|
ULONG_PTR arg1, ULONG_PTR arg2,
|
|
|
|
PNTAPCFUNC func,
|
|
|
|
void (WINAPI *dispatcher)(CONTEXT*,ULONG_PTR,ULONG_PTR,ULONG_PTR,PNTAPCFUNC) ) DECLSPEC_HIDDEN;
|
2020-08-11 14:49:34 +02:00
|
|
|
extern void WINAPI DECLSPEC_NORETURN call_user_exception_dispatcher( EXCEPTION_RECORD *rec, CONTEXT *context,
|
|
|
|
NTSTATUS (WINAPI *dispatcher)(EXCEPTION_RECORD*,CONTEXT*) ) DECLSPEC_HIDDEN;
|
2020-08-11 15:25:55 +02:00
|
|
|
extern void WINAPI DECLSPEC_NORETURN call_raise_user_exception_dispatcher( NTSTATUS (WINAPI *dispatcher)(void) ) DECLSPEC_HIDDEN;
|
2020-06-30 22:34:34 +02:00
|
|
|
|
2020-06-12 14:20:16 +02:00
|
|
|
#define TICKSPERSEC 10000000
|
|
|
|
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)86400)
|
|
|
|
#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
|
|
|
|
|
|
|
|
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-10 07:56:18 +02:00
|
|
|
static inline IMAGE_NT_HEADERS *get_exe_nt_header(void)
|
|
|
|
{
|
|
|
|
IMAGE_DOS_HEADER *module = (IMAGE_DOS_HEADER *)NtCurrentTeb()->Peb->ImageBaseAddress;
|
|
|
|
return (IMAGE_NT_HEADERS *)((char *)module + module->e_lfanew);
|
|
|
|
}
|
|
|
|
|
2020-07-15 10:23:00 +02:00
|
|
|
static inline void *get_signal_stack(void)
|
|
|
|
{
|
2020-07-24 11:24:31 +02:00
|
|
|
return (char *)NtCurrentTeb() + teb_size - teb_offset;
|
2020-07-15 10:23:00 +02:00
|
|
|
}
|
|
|
|
|
2020-07-24 13:29:31 +02:00
|
|
|
#ifndef _WIN64
|
|
|
|
static inline TEB64 *NtCurrentTeb64(void) { return (TEB64 *)NtCurrentTeb()->GdiBatchCount; }
|
|
|
|
#endif
|
|
|
|
|
2020-08-21 01:42:12 +02:00
|
|
|
#if defined(__i386__) || defined(__x86_64__)
|
|
|
|
struct xcontext
|
|
|
|
{
|
|
|
|
CONTEXT c;
|
|
|
|
XSTATE *xstate; /* points to xstate in sigcontext */
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline XSTATE *xstate_from_context( const CONTEXT *context )
|
|
|
|
{
|
|
|
|
CONTEXT_EX *xctx = (CONTEXT_EX *)(context + 1);
|
|
|
|
|
|
|
|
if ((context->ContextFlags & CONTEXT_XSTATE) != CONTEXT_XSTATE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (XSTATE *)((char *)(context + 1) + xctx->XState.Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void context_init_xstate( CONTEXT *context, void *xstate_buffer )
|
|
|
|
{
|
|
|
|
CONTEXT_EX *xctx;
|
|
|
|
XSTATE *xs;
|
|
|
|
|
|
|
|
xctx = (CONTEXT_EX *)(context + 1);
|
|
|
|
xctx->Legacy.Length = sizeof(CONTEXT);
|
|
|
|
xctx->Legacy.Offset = -(LONG)sizeof(CONTEXT);
|
|
|
|
|
|
|
|
xctx->XState.Length = sizeof(XSTATE);
|
|
|
|
xctx->XState.Offset = xstate_buffer ? (((ULONG_PTR)xstate_buffer + 63) & ~63) - (ULONG_PTR)xctx
|
|
|
|
: (((ULONG_PTR)context + sizeof(CONTEXT) + sizeof(CONTEXT_EX) + 63) & ~63) - (ULONG_PTR)xctx;
|
|
|
|
xctx->All.Length = sizeof(CONTEXT) + xctx->XState.Offset + xctx->XState.Length;
|
|
|
|
xctx->All.Offset = -(LONG)sizeof(CONTEXT);
|
|
|
|
context->ContextFlags |= 0x40;
|
|
|
|
|
|
|
|
xs = xstate_from_context(context);
|
|
|
|
memset( xs, 0, offsetof(XSTATE, YmmContext) );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-06-11 10:50:11 +02:00
|
|
|
static inline size_t ntdll_wcslen( const WCHAR *str )
|
|
|
|
{
|
|
|
|
const WCHAR *s = str;
|
|
|
|
while (*s) s++;
|
|
|
|
return s - str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline WCHAR *ntdll_wcscpy( WCHAR *dst, const WCHAR *src )
|
|
|
|
{
|
|
|
|
WCHAR *p = dst;
|
|
|
|
while ((*p++ = *src++));
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
2020-06-11 11:38:16 +02:00
|
|
|
static inline WCHAR *ntdll_wcscat( WCHAR *dst, const WCHAR *src )
|
|
|
|
{
|
|
|
|
ntdll_wcscpy( dst + ntdll_wcslen(dst), src );
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ntdll_wcscmp( const WCHAR *str1, const WCHAR *str2 )
|
|
|
|
{
|
|
|
|
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
|
|
|
|
return *str1 - *str2;
|
|
|
|
}
|
|
|
|
|
2020-06-12 10:55:21 +02:00
|
|
|
static inline int ntdll_wcsncmp( const WCHAR *str1, const WCHAR *str2, int n )
|
|
|
|
{
|
|
|
|
if (n <= 0) return 0;
|
|
|
|
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
|
|
|
|
return *str1 - *str2;
|
|
|
|
}
|
|
|
|
|
2020-06-11 11:38:16 +02:00
|
|
|
static inline WCHAR *ntdll_wcschr( const WCHAR *str, WCHAR ch )
|
|
|
|
{
|
|
|
|
do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-06-23 14:29:31 +02:00
|
|
|
static inline WCHAR *ntdll_wcsrchr( const WCHAR *str, WCHAR ch )
|
|
|
|
{
|
|
|
|
WCHAR *ret = NULL;
|
|
|
|
do { if (*str == ch) ret = (WCHAR *)(ULONG_PTR)str; } while (*str++);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-06-11 11:38:16 +02:00
|
|
|
static inline WCHAR *ntdll_wcspbrk( const WCHAR *str, const WCHAR *accept )
|
|
|
|
{
|
|
|
|
for ( ; *str; str++) if (ntdll_wcschr( accept, *str )) return (WCHAR *)(ULONG_PTR)str;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ntdll_wcsicmp( const WCHAR *str1, const WCHAR *str2 )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if ((ret = ntdll_towupper( *str1 ) - ntdll_towupper( *str2 )) || !*str1) return ret;
|
|
|
|
str1++;
|
|
|
|
str2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ntdll_wcsnicmp( const WCHAR *str1, const WCHAR *str2, int n )
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
for (ret = 0; n > 0; n--, str1++, str2++)
|
|
|
|
if ((ret = ntdll_towupper(*str1) - ntdll_towupper(*str2)) || !*str1) break;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define wcslen(str) ntdll_wcslen(str)
|
|
|
|
#define wcscpy(dst,src) ntdll_wcscpy(dst,src)
|
|
|
|
#define wcscat(dst,src) ntdll_wcscat(dst,src)
|
|
|
|
#define wcscmp(s1,s2) ntdll_wcscmp(s1,s2)
|
|
|
|
#define wcsncmp(s1,s2,n) ntdll_wcsncmp(s1,s2,n)
|
|
|
|
#define wcschr(str,ch) ntdll_wcschr(str,ch)
|
2020-06-23 14:29:31 +02:00
|
|
|
#define wcsrchr(str,ch) ntdll_wcsrchr(str,ch)
|
2020-06-12 10:55:21 +02:00
|
|
|
#define wcspbrk(str,ac) ntdll_wcspbrk(str,ac)
|
|
|
|
#define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2)
|
|
|
|
#define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n)
|
|
|
|
#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
|
|
|
|
2020-05-14 15:33:36 +02:00
|
|
|
#endif /* __NTDLL_UNIX_PRIVATE_H */
|