dlls/ntdll/server.c
/***********************************************************************
 *           server_init_thread
 *
 * Send an init thread request. Return 0 if OK.
 */
server_init_thread
Send an init thread request. Return 0 if OK.
server_init_thread Send an init thread request . Return 0 if OK .
size_t server_init_thread( void *entry_point )
{
    static const int is_win64 = (sizeof(void *) > sizeof(int));
    const char *arch = getenv( "WINEARCH" );
    int ret;
    int reply_pipe[2];
    struct sigaction sig_act;
    size_t info_size;
    sig_act.sa_handler = SIG_IGN;
    sig_act.sa_flags   = 0;
    sigemptyset( &sig_act.sa_mask );
    sigaction( SIGPIPE, &sig_act, NULL );
    if (server_pipe( reply_pipe ) == -1) server_protocol_perror( "pipe" );
    if (server_pipe( ntdll_get_thread_data()->wait_fd ) == -1) server_protocol_perror( "pipe" );
    wine_server_send_fd( reply_pipe[1] );
    wine_server_send_fd( ntdll_get_thread_data()->wait_fd[1] );
    ntdll_get_thread_data()->reply_fd = reply_pipe[0];
    close( reply_pipe[1] );
    SERVER_START_REQ( init_thread )
    {
        req->unix_pid    = getpid();
        req->unix_tid    = get_unix_tid();
        req->teb         = wine_server_client_ptr( NtCurrentTeb() );
        req->entry       = wine_server_client_ptr( entry_point );
        req->reply_fd    = reply_pipe[1];
        req->wait_fd     = ntdll_get_thread_data()->wait_fd[1];
        req->debug_level = (TRACE_ON(server) != 0);
        req->cpu         = client_cpu;
        ret = wine_server_call( req );
        NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid);
        NtCurrentTeb()->ClientId.UniqueThread  = ULongToHandle(reply->tid);
        info_size         = reply->info_size;
        server_start_time = reply->server_start;
        server_cpus       = reply->all_cpus;
    }
    SERVER_END_REQ;
    is_wow64 = !is_win64 && (server_cpus & (1 << CPU_x86_64)) != 0;
    ntdll_get_thread_data()->wow64_redir = is_wow64;
    switch (ret)
    {
    case STATUS_SUCCESS:
        if (arch)
        {
            if (!strcmp( arch, "win32" ) && (is_win64 || is_wow64))
                fatal_error( "WINEARCH set to win32 but '%s' is a 64-bit installation.\n",
                             wine_get_config_dir() );
            if (!strcmp( arch, "win64" ) && !is_win64 && !is_wow64)
                fatal_error( "WINEARCH set to win64 but '%s' is a 32-bit installation.\n",
                             wine_get_config_dir() );
        }
        return info_size;
    case STATUS_NOT_REGISTRY_FILE:
        fatal_error( "'%s' is a 32-bit installation, it cannot support 64-bit applications.\n",
                     wine_get_config_dir() );
    case STATUS_NOT_SUPPORTED:
        if (is_win64)
            fatal_error( "wineserver is 32-bit, it cannot support 64-bit applications.\n" );
        else
            fatal_error( "'%s' is a 64-bit installation, it cannot be used with a 32-bit wineserver.\n",
                         wine_get_config_dir() );
    default:
        server_protocol_error( "init_thread failed with status %x\n", ret );
    }
}
size_t server_init_thread ( void * entry_point ) { static const int is_win64 = ( sizeof ( void * ) > sizeof ( int ) ) ; const char * arch = getenv ( " " ) ; int ret ; int reply_pipe [ 2 ] ; struct sigaction sig_act ; size_t info_size ; sig_act . sa_handler = SIG_IGN ; sig_act . sa_flags = 0 ; sigemptyset ( & sig_act . sa_mask ) ; sigaction ( SIGPIPE , & sig_act , NULL ) ; if ( server_pipe ( reply_pipe ) == -1 ) server_protocol_perror ( " " ) ; if ( server_pipe ( ntdll_get_thread_data ( ) -> wait_fd ) == -1 ) server_protocol_perror ( " " ) ; wine_server_send_fd ( reply_pipe [ 1 ] ) ; wine_server_send_fd ( ntdll_get_thread_data ( ) -> wait_fd [ 1 ] ) ; ntdll_get_thread_data ( ) -> reply_fd = reply_pipe [ 0 ] ; close ( reply_pipe [ 1 ] ) ; SERVER_START_REQ ( init_thread ) { req -> unix_pid = getpid ( ) ; req -> unix_tid = get_unix_tid ( ) ; req -> teb = wine_server_client_ptr ( NtCurrentTeb ( ) ) ; req -> entry = wine_server_client_ptr ( entry_point ) ; req -> reply_fd = reply_pipe [ 1 ] ; req -> wait_fd = ntdll_get_thread_data ( ) -> wait_fd [ 1 ] ; req -> debug_level = ( TRACE_ON ( server ) != 0 ) ; req -> cpu = client_cpu ; ret = wine_server_call ( req ) ; NtCurrentTeb ( ) -> ClientId . UniqueProcess = ULongToHandle ( reply -> pid ) ; NtCurrentTeb ( ) -> ClientId . UniqueThread = ULongToHandle ( reply -> tid ) ; info_size = reply -> info_size ; server_start_time = reply -> server_start ; server_cpus = reply -> all_cpus ; } SERVER_END_REQ ; is_wow64 = ! is_win64 && ( server_cpus & ( 1 << CPU_x86_64 ) ) != 0 ; ntdll_get_thread_data ( ) -> wow64_redir = is_wow64 ; switch ( ret ) { case STATUS_SUCCESS : if ( arch ) { if ( ! strcmp ( arch , " " ) && ( is_win64 || is_wow64 ) ) fatal_error ( " \n " , wine_get_config_dir ( ) ) ; if ( ! strcmp ( arch , " " ) && ! is_win64 && ! is_wow64 ) fatal_error ( " \n " , wine_get_config_dir ( ) ) ; } return info_size ; case STATUS_NOT_REGISTRY_FILE : fatal_error ( " \n " , wine_get_config_dir ( ) ) ; case STATUS_NOT_SUPPORTED : if ( is_win64 ) fatal_error ( " \n " ) ; else fatal_error ( " \n " , wine_get_config_dir ( ) ) ; default : server_protocol_error ( " \n " , ret ) ; } }
server_init_thread
 Send an init thread request.
server_init_thread Send an init thread request .
/* ignore SIGPIPE so that we get an EPIPE error instead  */ /* create the server->client communication pipes */