Commit e9e5c950 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move the process information functions to the Unix library.

parent c4c3b06e
......@@ -3592,8 +3592,7 @@ void WINAPI RtlExitUserProcess( DWORD status )
RtlAcquirePebLock();
NtTerminateProcess( 0, status );
LdrShutdownProcess();
NtTerminateProcess( GetCurrentProcess(), status );
exit( get_unix_exit_code( status ));
for (;;) NtTerminateProcess( GetCurrentProcess(), status );
}
/******************************************************************
......
......@@ -196,13 +196,6 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
return (struct ntdll_thread_data *)&NtCurrentTeb()->GdiTebBatch;
}
static inline int get_unix_exit_code( NTSTATUS status )
{
/* prevent a nonzero exit code to end up truncated to zero in unix */
if (status && !(status & 0xff)) return 1;
return status;
}
extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
#define HASH_STRING_ALGORITHM_DEFAULT 0
......
......@@ -867,6 +867,7 @@ static struct unix_funcs unix_funcs =
NtQueryFullAttributesFile,
NtQueryInformationFile,
NtQueryInformationJobObject,
NtQueryInformationProcess,
NtQueryIoCompletion,
NtQueryMutant,
NtQueryPerformanceCounter,
......@@ -890,6 +891,7 @@ static struct unix_funcs unix_funcs =
NtSetEvent,
NtSetInformationFile,
NtSetInformationJobObject,
NtSetInformationProcess,
NtSetIoCompletion,
NtSetLdtEntries,
NtSetSystemTime,
......@@ -897,6 +899,7 @@ static struct unix_funcs unix_funcs =
NtSignalAndWaitForSingleObject,
NtSuspendThread,
NtTerminateJobObject,
NtTerminateProcess,
NtTerminateThread,
NtUnlockVirtualMemory,
NtUnmapViewOfSection,
......@@ -941,7 +944,6 @@ static struct unix_funcs unix_funcs =
virtual_locked_recvmsg,
virtual_check_buffer_for_read,
virtual_check_buffer_for_write,
virtual_set_force_exec,
virtual_release_address_space,
virtual_set_large_address_space,
init_threading,
......
......@@ -327,12 +327,21 @@ done:
void abort_thread( int status )
{
pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
if (InterlockedDecrement( nb_threads ) <= 0) _exit( get_unix_exit_code( status ));
if (InterlockedDecrement( nb_threads ) <= 0) abort_process( status );
signal_exit_thread( status, pthread_exit_wrapper );
}
/***********************************************************************
* abort_process
*/
void abort_process( int status )
{
_exit( get_unix_exit_code( status ));
}
/***********************************************************************
* exit_thread
*/
void CDECL exit_thread( int status )
......
......@@ -94,7 +94,6 @@ extern ssize_t CDECL virtual_locked_pread( int fd, void *addr, size_t size, off_
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 void CDECL virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN;
extern void CDECL virtual_release_address_space(void) DECLSPEC_HIDDEN;
extern void CDECL virtual_set_large_address_space(void) DECLSPEC_HIDDEN;
......@@ -160,6 +159,7 @@ extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN;
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;
extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN;
extern void DECLSPEC_NORETURN abort_process( int status ) DECLSPEC_HIDDEN;
extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN;
extern NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance ) DECLSPEC_HIDDEN;
extern NTSTATUS set_thread_context( HANDLE handle, const context_t *context, BOOL *self ) DECLSPEC_HIDDEN;
......@@ -168,6 +168,7 @@ extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct o
data_size_t *ret_len ) DECLSPEC_HIDDEN;
extern void virtual_init(void) DECLSPEC_HIDDEN;
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
......@@ -177,6 +178,7 @@ extern BOOL virtual_is_valid_code_address( const void *addr, SIZE_T size ) DECLS
extern int virtual_handle_stack_fault( void *addr ) 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 void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN;
extern void virtual_fill_image_information( const pe_image_info_t *pe_info,
SECTION_IMAGE_INFORMATION *info ) DECLSPEC_HIDDEN;
......
......@@ -2458,7 +2458,7 @@ void virtual_init(void)
}
static ULONG_PTR get_system_affinity_mask(void)
ULONG_PTR get_system_affinity_mask(void)
{
ULONG num_cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
if (num_cpus >= sizeof(ULONG_PTR) * 8) return ~(ULONG_PTR)0;
......@@ -3180,7 +3180,7 @@ NTSTATUS virtual_uninterrupted_write_memory( void *addr, const void *buffer, SIZ
*
* Whether to force exec prot on all views.
*/
void CDECL virtual_set_force_exec( BOOL enable )
void virtual_set_force_exec( BOOL enable )
{
struct file_view *view;
sigset_t sigset;
......
......@@ -28,7 +28,7 @@ struct ldt_copy;
struct msghdr;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 47
#define NTDLL_UNIXLIB_VERSION 48
struct unix_funcs
{
......@@ -139,6 +139,8 @@ struct unix_funcs
void *ptr, LONG len, FILE_INFORMATION_CLASS class );
NTSTATUS (WINAPI *NtQueryInformationJobObject)( HANDLE handle, JOBOBJECTINFOCLASS class,
void *info, ULONG len, ULONG *ret_len );
NTSTATUS (WINAPI *NtQueryInformationProcess)( HANDLE handle, PROCESSINFOCLASS class, void *info,
ULONG size, ULONG *ret_len );
NTSTATUS (WINAPI *NtQueryIoCompletion)( HANDLE handle, IO_COMPLETION_INFORMATION_CLASS class,
void *buffer, ULONG len, ULONG *ret_len );
NTSTATUS (WINAPI *NtQueryMutant)( HANDLE handle, MUTANT_INFORMATION_CLASS class,
......@@ -177,6 +179,8 @@ struct unix_funcs
void *ptr, ULONG len, FILE_INFORMATION_CLASS class );
NTSTATUS (WINAPI *NtSetInformationJobObject)( HANDLE handle, JOBOBJECTINFOCLASS class,
void *info, ULONG len );
NTSTATUS (WINAPI *NtSetInformationProcess)( HANDLE handle, PROCESSINFOCLASS class,
void *info, ULONG size );
NTSTATUS (WINAPI *NtSetIoCompletion)( HANDLE handle, ULONG_PTR key, ULONG_PTR value,
NTSTATUS status, SIZE_T count );
NTSTATUS (WINAPI *NtSetLdtEntries)( ULONG sel1, LDT_ENTRY entry1, ULONG sel2, LDT_ENTRY entry2 );
......@@ -188,6 +192,7 @@ struct unix_funcs
BOOLEAN alertable, const LARGE_INTEGER *timeout );
NTSTATUS (WINAPI *NtSuspendThread)( HANDLE handle, ULONG *count );
NTSTATUS (WINAPI *NtTerminateJobObject)( HANDLE handle, NTSTATUS status );
NTSTATUS (WINAPI *NtTerminateProcess)( HANDLE handle, LONG exit_code );
NTSTATUS (WINAPI *NtTerminateThread)( HANDLE handle, LONG exit_code );
NTSTATUS (WINAPI *NtUnlockVirtualMemory)( HANDLE process, PVOID *addr,
SIZE_T *size, ULONG unknown );
......@@ -253,7 +258,6 @@ struct unix_funcs
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 );
void (CDECL *virtual_set_force_exec)( BOOL enable );
void (CDECL *virtual_release_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