ntdll: Replace __wine_make_process_system by a Wine-specific NtSetInformationProcess() class.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-05-24 15:56:26 +02:00
parent d7b9b306cb
commit 4e8fcc41ca
10 changed files with 31 additions and 30 deletions

View File

@ -1610,7 +1610,6 @@
@ cdecl -syscall -norelay wine_server_call(ptr) @ cdecl -syscall -norelay wine_server_call(ptr)
@ cdecl -syscall wine_server_fd_to_handle(long long long ptr) @ cdecl -syscall wine_server_fd_to_handle(long long long ptr)
@ cdecl -syscall wine_server_handle_to_fd(long long ptr ptr) @ cdecl -syscall wine_server_handle_to_fd(long long ptr ptr)
@ cdecl -syscall __wine_make_process_system()
# Unix interface # Unix interface
@ cdecl __wine_set_unix_funcs(long ptr) @ cdecl __wine_set_unix_funcs(long ptr)

View File

@ -1485,6 +1485,17 @@ NTSTATUS WINAPI NtSetInformationProcess( HANDLE handle, PROCESSINFOCLASS class,
break; break;
} }
case ProcessWineMakeProcessSystem:
if (size != sizeof(HANDLE *)) return STATUS_INFO_LENGTH_MISMATCH;
SERVER_START_REQ( make_process_system )
{
req->handle = wine_server_obj_handle( handle );
if (!(ret = wine_server_call( req )))
*(HANDLE *)info = wine_server_ptr_handle( reply->event );
}
SERVER_END_REQ;
return ret;
default: default:
FIXME( "(%p,0x%08x,%p,0x%08x) stub\n", handle, class, info, size ); FIXME( "(%p,0x%08x,%p,0x%08x) stub\n", handle, class, info, size );
ret = STATUS_NOT_IMPLEMENTED; ret = STATUS_NOT_IMPLEMENTED;
@ -1605,22 +1616,3 @@ NTSTATUS WINAPI NtDebugContinue( HANDLE handle, CLIENT_ID *client, NTSTATUS stat
SERVER_END_REQ; SERVER_END_REQ;
return ret; return ret;
} }
/***********************************************************************
* __wine_make_process_system (NTDLL.@)
*
* Mark the current process as a system process.
* Returns the event that is signaled when all non-system processes have exited.
*/
HANDLE CDECL __wine_make_process_system(void)
{
HANDLE ret = 0;
SERVER_START_REQ( make_process_system )
{
if (!wine_server_call( req )) ret = wine_server_ptr_handle( reply->event );
}
SERVER_END_REQ;
return ret;
}

View File

@ -90,8 +90,6 @@ static unsigned int nb_services;
static HANDLE service_event; static HANDLE service_event;
static BOOL stop_service; static BOOL stop_service;
extern HANDLE CDECL __wine_make_process_system(void);
static WCHAR *heap_strdupAtoW( const char *src ) static WCHAR *heap_strdupAtoW( const char *src )
{ {
WCHAR *dst = NULL; WCHAR *dst = NULL;
@ -1845,7 +1843,8 @@ static BOOL service_run_main_thread(void)
stop_service = FALSE; stop_service = FALSE;
/* FIXME: service_control_dispatcher should be merged into the main thread */ /* FIXME: service_control_dispatcher should be merged into the main thread */
wait_handles[0] = __wine_make_process_system(); NtSetInformationProcess( GetCurrentProcess(), ProcessWineMakeProcessSystem,
&wait_handles[0], sizeof(HANDLE *) );
wait_handles[1] = CreateThread( NULL, 0, service_control_dispatcher, disp, 0, NULL ); wait_handles[1] = CreateThread( NULL, 0, service_control_dispatcher, disp, 0, NULL );
wait_handles[2] = service_event; wait_handles[2] = service_event;

View File

@ -4917,7 +4917,7 @@ struct get_kernel_object_handle_reply
struct make_process_system_request struct make_process_system_request
{ {
struct request_header __header; struct request_header __header;
char __pad_12[4]; obj_handle_t handle;
}; };
struct make_process_system_reply struct make_process_system_reply
{ {
@ -6267,7 +6267,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 703 #define SERVER_PROTOCOL_VERSION 704
/* ### protocol_version end ### */ /* ### protocol_version end ### */

View File

@ -1455,7 +1455,10 @@ typedef enum _PROCESSINFOCLASS {
ProcessThreadStackAllocation = 41, ProcessThreadStackAllocation = 41,
ProcessWorkingSetWatchEx = 42, ProcessWorkingSetWatchEx = 42,
ProcessImageFileNameWin32 = 43, ProcessImageFileNameWin32 = 43,
MaxProcessInfoClass MaxProcessInfoClass,
#ifdef __WINESRC__
ProcessWineMakeProcessSystem = 1000,
#endif
} PROCESSINFOCLASS, PROCESS_INFORMATION_CLASS; } PROCESSINFOCLASS, PROCESS_INFORMATION_CLASS;
#define MEM_EXECUTE_OPTION_DISABLE 0x01 #define MEM_EXECUTE_OPTION_DISABLE 0x01

View File

@ -35,8 +35,6 @@
#include "services.h" #include "services.h"
#include "svcctl.h" #include "svcctl.h"
extern HANDLE CDECL __wine_make_process_system(void);
WINE_DEFAULT_DEBUG_CHANNEL(service); WINE_DEFAULT_DEBUG_CHANNEL(service);
static const GENERIC_MAPPING g_scm_generic = static const GENERIC_MAPPING g_scm_generic =
@ -2135,7 +2133,8 @@ DWORD RPC_Init(void)
return err; return err;
} }
exit_event = __wine_make_process_system(); NtSetInformationProcess( GetCurrentProcess(), ProcessWineMakeProcessSystem,
&exit_event, sizeof(HANDLE *) );
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }

View File

@ -1635,7 +1635,7 @@ DECL_HANDLER(get_process_idle_event)
/* make the current process a system process */ /* make the current process a system process */
DECL_HANDLER(make_process_system) DECL_HANDLER(make_process_system)
{ {
struct process *process = current->process; struct process *process;
struct thread *thread; struct thread *thread;
if (!shutdown_event) if (!shutdown_event)
@ -1644,8 +1644,13 @@ DECL_HANDLER(make_process_system)
release_object( shutdown_event ); release_object( shutdown_event );
} }
if (!(process = get_process_from_handle( req->handle, PROCESS_SET_INFORMATION ))) return;
if (!(reply->event = alloc_handle( current->process, shutdown_event, SYNCHRONIZE, 0 ))) if (!(reply->event = alloc_handle( current->process, shutdown_event, SYNCHRONIZE, 0 )))
{
release_object( process );
return; return;
}
if (!process->is_system) if (!process->is_system)
{ {
@ -1655,6 +1660,7 @@ DECL_HANDLER(make_process_system)
if (!--user_processes && !shutdown_stage && master_socket_timeout != TIMEOUT_INFINITE) if (!--user_processes && !shutdown_stage && master_socket_timeout != TIMEOUT_INFINITE)
shutdown_timeout = add_timeout_user( master_socket_timeout, server_shutdown_timeout, NULL ); shutdown_timeout = add_timeout_user( master_socket_timeout, server_shutdown_timeout, NULL );
} }
release_object( process );
} }
/* create a new job object */ /* create a new job object */

View File

@ -3430,6 +3430,7 @@ struct handle_info
/* Make the current process a system process */ /* Make the current process a system process */
@REQ(make_process_system) @REQ(make_process_system)
obj_handle_t handle; /* handle to the process */
@REPLY @REPLY
obj_handle_t event; /* event signaled when all user processes have exited */ obj_handle_t event; /* event signaled when all user processes have exited */
@END @END

View File

@ -2091,6 +2091,7 @@ C_ASSERT( FIELD_OFFSET(struct get_kernel_object_handle_request, access) == 24 );
C_ASSERT( sizeof(struct get_kernel_object_handle_request) == 32 ); C_ASSERT( sizeof(struct get_kernel_object_handle_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_kernel_object_handle_reply, handle) == 8 ); C_ASSERT( FIELD_OFFSET(struct get_kernel_object_handle_reply, handle) == 8 );
C_ASSERT( sizeof(struct get_kernel_object_handle_reply) == 16 ); C_ASSERT( sizeof(struct get_kernel_object_handle_reply) == 16 );
C_ASSERT( FIELD_OFFSET(struct make_process_system_request, handle) == 12 );
C_ASSERT( sizeof(struct make_process_system_request) == 16 ); C_ASSERT( sizeof(struct make_process_system_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct make_process_system_reply, event) == 8 ); C_ASSERT( FIELD_OFFSET(struct make_process_system_reply, event) == 8 );
C_ASSERT( sizeof(struct make_process_system_reply) == 16 ); C_ASSERT( sizeof(struct make_process_system_reply) == 16 );

View File

@ -4181,6 +4181,7 @@ static void dump_get_kernel_object_handle_reply( const struct get_kernel_object_
static void dump_make_process_system_request( const struct make_process_system_request *req ) static void dump_make_process_system_request( const struct make_process_system_request *req )
{ {
fprintf( stderr, " handle=%04x", req->handle );
} }
static void dump_make_process_system_reply( const struct make_process_system_reply *req ) static void dump_make_process_system_reply( const struct make_process_system_reply *req )