From cf89fdf018d500dfacd80ce48f35733bbb2baef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 19 Oct 2023 10:38:37 +0200 Subject: [PATCH] lsteamclient: Use unixlib interface for C API functions. CW-Bug-Id: #22729 --- lsteamclient/gen_wrapper.py | 21 +++ lsteamclient/steam_networking_manual.c | 15 ++- lsteamclient/steamclient_main.c | 80 ++++++++---- lsteamclient/unix_private.h | 16 +++ lsteamclient/unix_steam_networking_manual.cpp | 45 +++++-- lsteamclient/unixlib.cpp | 120 +++++++++++------- lsteamclient/unixlib.h | 107 +++++++++++++--- lsteamclient/unixlib_generated.cpp | 15 +++ lsteamclient/unixlib_generated.h | 15 +++ 9 files changed, 329 insertions(+), 105 deletions(-) diff --git a/lsteamclient/gen_wrapper.py b/lsteamclient/gen_wrapper.py index 6d63fd28..4013d36a 100755 --- a/lsteamclient/gen_wrapper.py +++ b/lsteamclient/gen_wrapper.py @@ -200,6 +200,23 @@ MANUAL_STRUCTS = [ "SteamNetworkingMessage_t" ] +UNIX_FUNCS = [ + 'steamclient_init', + 'steamclient_next_callback', + 'steamclient_CreateInterface', + 'steamclient_Steam_GetAPICallResult', + 'steamclient_Steam_BGetCallback', + 'steamclient_callback_message_receive', + 'steamclient_Steam_FreeLastCallback', + 'steamclient_Steam_ReleaseThreadLocalMemory', + 'steamclient_Steam_IsKnownInterface', + 'steamclient_Steam_NotifyMissingInterface', + 'steamclient_networking_messages_receive_144', + 'steamclient_networking_messages_receive_147', + 'steamclient_networking_messages_receive_153a', + 'steamclient_networking_message_release_147', + 'steamclient_networking_message_release_153a', +] MANUAL_METHODS = { #TODO: 001 005 007 @@ -1497,6 +1514,8 @@ with open(u"unixlib_generated.h", "w") as file: out(u'enum unix_funcs\n') out(u'{\n') + for func in UNIX_FUNCS: + out(f' unix_{func},\n') for klass, method in all_methods: sdkver = klass._sdkver if type(method) is Destructor: @@ -1518,6 +1537,8 @@ with open('unixlib_generated.cpp', 'w') as file: out(u'extern "C" const unixlib_entry_t __wine_unix_call_funcs[] =\n') out(u'{\n') + for func in UNIX_FUNCS: + out(f' {func},\n') for klass, method in all_methods: sdkver = klass._sdkver if type(method) is Destructor: diff --git a/lsteamclient/steam_networking_manual.c b/lsteamclient/steam_networking_manual.c index 7b401177..bbbf2214 100644 --- a/lsteamclient/steam_networking_manual.c +++ b/lsteamclient/steam_networking_manual.c @@ -92,8 +92,9 @@ static bool networking_message_pool_receive_144( int32_t capacity, int32_t count if (count > 0) { + struct steamclient_networking_messages_receive_144_params params = {.count = count, .w_msgs = messages}; if (!networking_message_pool_alloc_data( count, pool )) return false; - unix_networking_messages_receive_144( count, messages ); + STEAMCLIENT_CALL( steamclient_networking_messages_receive_144, ¶ms ); } return true; @@ -117,7 +118,8 @@ static void W_STDCALL w_SteamNetworkingMessage_t_147_Release( w_SteamNetworkingM if (message->pool) networking_message_pool_release( message->pool ); else { - unix_networking_message_release_147( msg ); + struct steamclient_networking_message_release_147_params params = {.w_msg = msg}; + STEAMCLIENT_CALL( steamclient_networking_message_release_147, ¶ms ); HeapFree( GetProcessHeap(), 0, message ); } } @@ -158,8 +160,9 @@ static bool networking_message_pool_receive_147( uint32_t capacity, uint32_t cou if (count) { + struct steamclient_networking_messages_receive_147_params params = {.count = count, .w_msgs = messages}; if (!networking_message_pool_alloc_data( count, pool )) return false; - unix_networking_messages_receive_147( count, messages ); + STEAMCLIENT_CALL( steamclient_networking_messages_receive_147, ¶ms ); } return true; @@ -183,7 +186,8 @@ static void W_STDCALL w_SteamNetworkingMessage_t_153a_Release( w_SteamNetworking if (message->pool) networking_message_pool_release( message->pool ); else { - unix_networking_message_release_153a( msg ); + struct steamclient_networking_message_release_153a_params params = {.w_msg = msg}; + STEAMCLIENT_CALL( steamclient_networking_message_release_153a, ¶ms ); HeapFree( GetProcessHeap(), 0, message ); } } @@ -224,8 +228,9 @@ static bool networking_message_pool_receive_153a( uint32_t capacity, uint32_t co if (count) { + struct steamclient_networking_messages_receive_153a_params params = {.count = count, .w_msgs = messages}; if (!networking_message_pool_alloc_data( count, pool )) return false; - unix_networking_messages_receive_153a( count, messages ); + STEAMCLIENT_CALL( steamclient_networking_messages_receive_153a, ¶ms ); } return true; diff --git a/lsteamclient/steamclient_main.c b/lsteamclient/steamclient_main.c index 66e92307..e9f2ca82 100644 --- a/lsteamclient/steamclient_main.c +++ b/lsteamclient/steamclient_main.c @@ -477,48 +477,51 @@ static int load_steamclient(void) else params.ignore_child_processes = ignore_child_processes; - if (!unix_steamclient_init( ¶ms )) return 0; + if (STEAMCLIENT_CALL( steamclient_init, ¶ms )) return 0; return 1; } void *CDECL CreateInterface(const char *name, int *return_code) { + struct steamclient_CreateInterface_params params = {.name = name, .return_code = return_code}; + TRACE("name: %s, return_code: %p\n", name, return_code); if (!load_steamclient()) return NULL; - return create_win_interface( name, unix_CreateInterface( name, return_code ) ); + if (STEAMCLIENT_CALL( steamclient_CreateInterface, ¶ms )) return NULL; + return create_win_interface( name, params._ret ); } static void execute_pending_callbacks(void) { - struct callback *callback = NULL; - uint32_t callback_size = 0; + struct steamclient_next_callback_params params = {0}; - while (unix_steamclient_next_callback( callback, &callback_size )) + while (!STEAMCLIENT_CALL( steamclient_next_callback, ¶ms ) && params._ret) { - if (!callback || callback_size > callback->size) - callback = realloc( callback, callback_size ); - else switch (callback->type) + if (!params.callback || params.size > params.callback->size) + params.callback = realloc( params.callback, params.size ); + else switch (params.callback->type) { case SOCKETS_DEBUG_OUTPUT: - TRACE( "SOCKETS_DEBUG_OUTPUT func %p, type %u, msg %s.\n", callback->sockets_debug_output.pfnFunc, - callback->sockets_debug_output.type, wine_dbgstr_a( callback->sockets_debug_output.msg ) ); - callback->sockets_debug_output.pfnFunc( callback->sockets_debug_output.type, callback->sockets_debug_output.msg ); + TRACE( "SOCKETS_DEBUG_OUTPUT func %p, type %u, msg %s.\n", params.callback->sockets_debug_output.pfnFunc, + params.callback->sockets_debug_output.type, wine_dbgstr_a( params.callback->sockets_debug_output.msg ) ); + params.callback->sockets_debug_output.pfnFunc( params.callback->sockets_debug_output.type, params.callback->sockets_debug_output.msg ); break; case WARNING_MESSAGE_HOOK: - TRACE( "WARNING_MESSAGE_HOOK func %p, severity %d, msg %s.\n", callback->warning_message_hook.pFunction, - callback->warning_message_hook.severity, wine_dbgstr_a( callback->warning_message_hook.msg ) ); - callback->warning_message_hook.pFunction( callback->warning_message_hook.severity, callback->warning_message_hook.msg ); + TRACE( "WARNING_MESSAGE_HOOK func %p, severity %d, msg %s.\n", params.callback->warning_message_hook.pFunction, + params.callback->warning_message_hook.severity, wine_dbgstr_a( params.callback->warning_message_hook.msg ) ); + params.callback->warning_message_hook.pFunction( params.callback->warning_message_hook.severity, params.callback->warning_message_hook.msg ); break; } } - free( callback ); + free( params.callback ); } static void *last_callback_data; bool CDECL Steam_FreeLastCallback( int32_t pipe ) { + struct steamclient_Steam_FreeLastCallback_params params = {.pipe = pipe}; TRACE( "%u\n", pipe ); if (!load_steamclient()) return 0; @@ -526,13 +529,25 @@ bool CDECL Steam_FreeLastCallback( int32_t pipe ) HeapFree( GetProcessHeap(), 0, last_callback_data ); last_callback_data = NULL; - return unix_Steam_FreeLastCallback( pipe ); + STEAMCLIENT_CALL( steamclient_Steam_FreeLastCallback, ¶ms ); + return params._ret; } bool CDECL Steam_BGetCallback( int32_t pipe, w_CallbackMsg_t *win_msg, int32_t *ignored ) { u_CallbackMsg_t u_msg; - bool ret; + struct steamclient_Steam_BGetCallback_params params = + { + .pipe = pipe, + .w_msg = win_msg, + .ignored = ignored, + .u_msg = &u_msg, + }; + struct steamclient_callback_message_receive_params receive_params = + { + .u_msg = &u_msg, + .w_msg = win_msg, + }; TRACE("%u, %p, %p\n", pipe, win_msg, ignored); @@ -541,11 +556,12 @@ bool CDECL Steam_BGetCallback( int32_t pipe, w_CallbackMsg_t *win_msg, int32_t * execute_pending_callbacks(); next_event: - if (!(ret = unix_Steam_BGetCallback( pipe, win_msg, ignored, &u_msg ))) return FALSE; + STEAMCLIENT_CALL( steamclient_Steam_BGetCallback, ¶ms ); + if (!params._ret) return FALSE; if (!(win_msg->m_pubParam = HeapAlloc( GetProcessHeap(), 0, win_msg->m_cubParam ))) return FALSE; last_callback_data = win_msg->m_pubParam; - unix_callback_message_receive( &u_msg, win_msg ); + STEAMCLIENT_CALL( steamclient_callback_message_receive, &receive_params ); if (win_msg->m_iCallback == 0x14b) /* GameOverlayActivated_t::k_iCallback */ { @@ -572,24 +588,37 @@ next_event: } execute_pending_callbacks(); - return ret; + return params._ret; } bool CDECL Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback, int w_callback_len, int id, bool *failed ) { + struct steamclient_Steam_GetAPICallResult_params params = + { + .pipe = pipe, + .call = call, + .w_callback = w_callback, + .w_callback_len = w_callback_len, + .id = id, + .failed = failed, + }; + TRACE( "%u, x, %p, %u, %u, %p\n", pipe, w_callback, w_callback_len, id, failed ); if (!load_steamclient()) return FALSE; - return unix_Steam_GetAPICallResult( pipe, call, w_callback, w_callback_len, id, failed ); + STEAMCLIENT_CALL( steamclient_Steam_GetAPICallResult, ¶ms ); + return params._ret; } void CDECL Steam_ReleaseThreadLocalMemory(int bThreadExit) { + struct steamclient_Steam_ReleaseThreadLocalMemory_params params = {.thread_exit = bThreadExit}; TRACE("%d\n", bThreadExit); if (!load_steamclient()) return; - unix_Steam_ReleaseThreadLocalMemory( bThreadExit ); + + STEAMCLIENT_CALL( steamclient_Steam_ReleaseThreadLocalMemory, ¶ms ); } void CDECL Breakpad_SteamMiniDumpInit( uint32_t a, const char *b, const char *c ) @@ -621,14 +650,17 @@ void CDECL Breakpad_SteamWriteMiniDumpUsingExceptionInfoWithBuildId(int a, int b bool CDECL Steam_IsKnownInterface( const char *pchVersion ) { + struct steamclient_Steam_IsKnownInterface_params params = {.version = pchVersion}; TRACE("%s\n", pchVersion); load_steamclient(); - return unix_Steam_IsKnownInterface( pchVersion ); + STEAMCLIENT_CALL( steamclient_Steam_IsKnownInterface, ¶ms ); + return params._ret; } void CDECL Steam_NotifyMissingInterface( int32_t hSteamPipe, const char *pchVersion ) { + struct steamclient_Steam_NotifyMissingInterface_params params = {.pipe = hSteamPipe, .version = pchVersion}; TRACE("%u %s\n", hSteamPipe, pchVersion); load_steamclient(); - unix_Steam_NotifyMissingInterface( hSteamPipe, pchVersion ); + STEAMCLIENT_CALL( steamclient_Steam_NotifyMissingInterface, ¶ms ); } diff --git a/lsteamclient/unix_private.h b/lsteamclient/unix_private.h index 5a53bf57..d6457964 100644 --- a/lsteamclient/unix_private.h +++ b/lsteamclient/unix_private.h @@ -62,6 +62,22 @@ extern void queue_sockets_debug_output( void (*W_STDCALL pfnFunc)( uint32_t, con extern void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char * ), int32_t severity, const char *msg ); +extern NTSTATUS steamclient_init( void * ); +extern NTSTATUS steamclient_next_callback( void * ); +extern NTSTATUS steamclient_CreateInterface( void * ); +extern NTSTATUS steamclient_Steam_GetAPICallResult( void * ); +extern NTSTATUS steamclient_Steam_BGetCallback( void * ); +extern NTSTATUS steamclient_callback_message_receive( void * ); +extern NTSTATUS steamclient_Steam_FreeLastCallback( void * ); +extern NTSTATUS steamclient_Steam_ReleaseThreadLocalMemory( void * ); +extern NTSTATUS steamclient_Steam_IsKnownInterface( void * ); +extern NTSTATUS steamclient_Steam_NotifyMissingInterface( void * ); +extern NTSTATUS steamclient_networking_messages_receive_144( void * ); +extern NTSTATUS steamclient_networking_messages_receive_147( void * ); +extern NTSTATUS steamclient_networking_messages_receive_153a( void * ); +extern NTSTATUS steamclient_networking_message_release_147( void * ); +extern NTSTATUS steamclient_networking_message_release_153a( void * ); + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ diff --git a/lsteamclient/unix_steam_networking_manual.cpp b/lsteamclient/unix_steam_networking_manual.cpp index ac25b48d..9a75482f 100644 --- a/lsteamclient/unix_steam_networking_manual.cpp +++ b/lsteamclient/unix_steam_networking_manual.cpp @@ -24,13 +24,14 @@ static void receive_messages_utow_144( uint32_t count, u_SteamNetworkingMessage_ } } -void unix_networking_messages_receive_144( uint32_t count, w_SteamNetworkingMessage_t_144 **w_msgs ) +NTSTATUS steamclient_networking_messages_receive_144( void *args ) { + struct steamclient_networking_messages_receive_144_params *params = (struct steamclient_networking_messages_receive_144_params *)args; uint32_t i; - for (i = 0; i < count; i++) + for (i = 0; i < params->count; i++) { - struct networking_message *message = CONTAINING_RECORD( w_msgs[i], struct networking_message, w_msg_144 ); + struct networking_message *message = CONTAINING_RECORD( params->w_msgs[i], struct networking_message, w_msg_144 ); w_SteamNetworkingMessage_t_144 *w_msg = &message->w_msg_144; u_SteamNetworkingMessage_t_144 *u_msg = message->u_msg_144; @@ -38,6 +39,8 @@ void unix_networking_messages_receive_144( uint32_t count, w_SteamNetworkingMess u_msg->m_pfnRelease( u_msg ); message->u_msg_144 = NULL; } + + return 0; } /* ISteamNetworkingSockets_SteamNetworkingSockets002 */ @@ -108,13 +111,14 @@ static void receive_messages_utow_147( uint32_t count, u_SteamNetworkingMessage_ } } -void unix_networking_messages_receive_147( uint32_t count, w_SteamNetworkingMessage_t_147 **w_msgs ) +NTSTATUS steamclient_networking_messages_receive_147( void *args ) { + struct steamclient_networking_messages_receive_147_params *params = (struct steamclient_networking_messages_receive_147_params *)args; uint32_t i; - for (i = 0; i < count; i++) + for (i = 0; i < params->count; i++) { - struct networking_message *message = CONTAINING_RECORD( w_msgs[i], struct networking_message, w_msg_147 ); + struct networking_message *message = CONTAINING_RECORD( params->w_msgs[i], struct networking_message, w_msg_147 ); w_SteamNetworkingMessage_t_147 *w_msg = &message->w_msg_147; u_SteamNetworkingMessage_t_147 *u_msg = message->u_msg_147; @@ -122,6 +126,8 @@ void unix_networking_messages_receive_147( uint32_t count, w_SteamNetworkingMess u_msg->m_pfnRelease( u_msg ); message->u_msg_147 = NULL; } + + return 0; } static void U_STDCALL u_SteamNetworkingMessage_t_147_FreeData( u_SteamNetworkingMessage_t_147 *msg ) @@ -164,7 +170,7 @@ static void send_messages_wtou_147( uint32_t count, w_SteamNetworkingMessage_t_1 } } -void unix_networking_message_release_147( w_SteamNetworkingMessage_t_147 *w_msg ) +static void networking_message_release_147( w_SteamNetworkingMessage_t_147 *w_msg ) { struct networking_message *message = CONTAINING_RECORD( w_msg, struct networking_message, w_msg_147 ); u_SteamNetworkingMessage_t_147 *u_msg = message->u_msg_147; @@ -174,6 +180,13 @@ void unix_networking_message_release_147( w_SteamNetworkingMessage_t_147 *w_msg message->u_msg_147 = NULL; } +NTSTATUS steamclient_networking_message_release_147( void *args ) +{ + struct steamclient_networking_message_release_147_params *params = (struct steamclient_networking_message_release_147_params *)args; + networking_message_release_147( params->w_msg ); + return 0; +} + /* ISteamNetworkingSockets_SteamNetworkingSockets006 */ NTSTATUS ISteamNetworkingSockets_SteamNetworkingSockets006_ReceiveMessagesOnConnection( void *args ) @@ -389,13 +402,14 @@ static void receive_messages_utow_153a( uint32_t count, u_SteamNetworkingMessage } } -void unix_networking_messages_receive_153a( uint32_t count, w_SteamNetworkingMessage_t_153a **w_msgs ) +NTSTATUS steamclient_networking_messages_receive_153a( void *args ) { + struct steamclient_networking_messages_receive_153a_params *params = (struct steamclient_networking_messages_receive_153a_params *)args; uint32_t i; - for (i = 0; i < count; i++) + for (i = 0; i < params->count; i++) { - struct networking_message *message = CONTAINING_RECORD( w_msgs[i], struct networking_message, w_msg_153a ); + struct networking_message *message = CONTAINING_RECORD( params->w_msgs[i], struct networking_message, w_msg_153a ); w_SteamNetworkingMessage_t_153a *w_msg = &message->w_msg_153a; u_SteamNetworkingMessage_t_153a *u_msg = message->u_msg_153a; @@ -403,6 +417,8 @@ void unix_networking_messages_receive_153a( uint32_t count, w_SteamNetworkingMes u_msg->m_pfnRelease( u_msg ); message->u_msg_153a = NULL; } + + return 0; } static void U_STDCALL u_SteamNetworkingMessage_t_153a_FreeData( u_SteamNetworkingMessage_t_153a *msg ) @@ -446,7 +462,7 @@ static void send_messages_wtou_153a( uint32_t count, w_SteamNetworkingMessage_t_ } } -void unix_networking_message_release_153a( w_SteamNetworkingMessage_t_153a *w_msg ) +static void networking_message_release_153a( w_SteamNetworkingMessage_t_153a *w_msg ) { struct networking_message *message = CONTAINING_RECORD( w_msg, struct networking_message, w_msg_153a ); u_SteamNetworkingMessage_t_153a *u_msg = message->u_msg_153a; @@ -456,6 +472,13 @@ void unix_networking_message_release_153a( w_SteamNetworkingMessage_t_153a *w_ms message->u_msg_153a = NULL; } +NTSTATUS steamclient_networking_message_release_153a( void *args ) +{ + struct steamclient_networking_message_release_153a_params *params = (struct steamclient_networking_message_release_153a_params *)args; + networking_message_release_153a( params->w_msg ); + return 0; +} + /* ISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001 */ NTSTATUS ISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001_ReceiveMessages( void *args ) diff --git a/lsteamclient/unixlib.cpp b/lsteamclient/unixlib.cpp index a9c1b2be..f1532064 100644 --- a/lsteamclient/unixlib.cpp +++ b/lsteamclient/unixlib.cpp @@ -57,8 +57,9 @@ void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char pthread_mutex_unlock( &callbacks_lock ); } -bool unix_steamclient_next_callback( struct callback *callback, uint32_t *size ) +NTSTATUS steamclient_next_callback( void *args ) { + struct steamclient_next_callback_params *params = (struct steamclient_next_callback_params *)args; struct list *ptr; pthread_mutex_lock( &callbacks_lock ); @@ -66,18 +67,19 @@ bool unix_steamclient_next_callback( struct callback *callback, uint32_t *size ) { struct callback_entry *entry = LIST_ENTRY( ptr, struct callback_entry, entry ); - if (entry->callback.size <= *size) + if (entry->callback.size <= params->size) { - memcpy( callback, &entry->callback, entry->callback.size ); + memcpy( params->callback, &entry->callback, entry->callback.size ); list_remove( &entry->entry ); free( entry ); } - *size = entry->callback.size; + params->size = entry->callback.size; } pthread_mutex_unlock( &callbacks_lock ); - return !!ptr; + params->_ret = !!ptr; + return 0; } static void *(*p_CreateInterface)( const char *name, int *return_code ); @@ -88,46 +90,60 @@ static void (*p_Steam_ReleaseThreadLocalMemory)( int ); static bool (*p_Steam_IsKnownInterface)( const char * ); static void (*p_Steam_NotifyMissingInterface)( int32_t, const char * ); -bool unix_Steam_BGetCallback( uint32_t pipe, w_CallbackMsg_t *w_msg, int32_t *ignored, u_CallbackMsg_t *u_msg ) +NTSTATUS steamclient_Steam_BGetCallback( void *args ) { - if (!p_Steam_BGetCallback( pipe, u_msg, ignored )) return false; - callback_message_utow( u_msg, w_msg ); - return true; -} + struct steamclient_Steam_BGetCallback_params *params = (struct steamclient_Steam_BGetCallback_params *)args; -void unix_callback_message_receive( u_CallbackMsg_t *u_msg, w_CallbackMsg_t *w_msg ) -{ - convert_callback_utow( u_msg->m_iCallback, (void *)u_msg->m_pubParam, u_msg->m_cubParam, - (void *)w_msg->m_pubParam, w_msg->m_cubParam ); -} - -bool unix_Steam_FreeLastCallback( uint32_t pipe ) -{ - return p_Steam_FreeLastCallback( pipe ); -} - -bool unix_Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback, int w_callback_len, - int id, bool *failed ) -{ - int u_callback_len = w_callback_len; - void *u_callback; - bool ret; - - if (!(u_callback = alloc_callback_wtou( id, w_callback, &u_callback_len ))) return false; - - ret = p_Steam_GetAPICallResult( pipe, call, u_callback, u_callback_len, id, failed ); - - if (ret && u_callback != w_callback) + if (!p_Steam_BGetCallback( params->pipe, params->u_msg, params->ignored )) + params->_ret = false; + else { - convert_callback_utow( id, u_callback, u_callback_len, w_callback, w_callback_len ); + callback_message_utow( params->u_msg, params->w_msg ); + params->_ret = true; + } + + return 0; +} + +NTSTATUS steamclient_callback_message_receive( void *args ) +{ + struct steamclient_callback_message_receive_params *params = (struct steamclient_callback_message_receive_params *)args; + convert_callback_utow( params->u_msg->m_iCallback, (void *)params->u_msg->m_pubParam, + params->u_msg->m_cubParam, (void *)params->w_msg->m_pubParam, + params->w_msg->m_cubParam ); + return 0; +} + +NTSTATUS steamclient_Steam_FreeLastCallback( void *args ) +{ + struct steamclient_Steam_FreeLastCallback_params *params = (struct steamclient_Steam_FreeLastCallback_params *)args; + params->_ret = p_Steam_FreeLastCallback( params->pipe ); + return 0; +} + +NTSTATUS steamclient_Steam_GetAPICallResult( void *args ) +{ + struct steamclient_Steam_GetAPICallResult_params *params = (struct steamclient_Steam_GetAPICallResult_params *)args; + int u_callback_len = params->w_callback_len; + void *u_callback; + + if (!(u_callback = alloc_callback_wtou( params->id, params->w_callback, &u_callback_len ))) return false; + + params->_ret = p_Steam_GetAPICallResult( params->pipe, params->call, u_callback, u_callback_len, + params->id, params->failed ); + + if (params->_ret && u_callback != params->w_callback) + { + convert_callback_utow( params->id, u_callback, u_callback_len, params->w_callback, params->w_callback_len ); HeapFree( GetProcessHeap(), 0, u_callback ); } - return ret; + return 0; } -bool unix_steamclient_init( struct steamclient_init_params *params ) +NTSTATUS steamclient_init( void *args ) { + struct steamclient_init_params *params = (struct steamclient_init_params *)args; char path[PATH_MAX], resolved_path[PATH_MAX]; static void *steamclient; @@ -136,7 +152,7 @@ bool unix_steamclient_init( struct steamclient_init_params *params ) if (params->ignore_child_processes_unset) unsetenv( "IgnoreChildProcesses" ); else if (params->ignore_child_processes) setenv( "IgnoreChildProcesses", params->ignore_child_processes, TRUE ); - if (steamclient) return true; + if (steamclient) return 0; #ifdef __APPLE__ if (getenv( "STEAM_COMPAT_CLIENT_INSTALL_PATH" )) @@ -163,14 +179,14 @@ bool unix_steamclient_init( struct steamclient_init_params *params ) if (!(steamclient = dlopen( path, RTLD_NOW ))) { ERR( "unable to load native steamclient library\n" ); - return false; + return -1; } #define LOAD_FUNC( x ) \ if (!(p_##x = (decltype(p_##x))dlsym( steamclient, #x ))) \ { \ ERR( "unable to load " #x "\n" ); \ - return false; \ + return -1; \ } LOAD_FUNC( CreateInterface ); @@ -181,25 +197,33 @@ bool unix_steamclient_init( struct steamclient_init_params *params ) LOAD_FUNC( Steam_IsKnownInterface ); LOAD_FUNC( Steam_NotifyMissingInterface ); - return true; + return 0; } -void *unix_CreateInterface( const char *name, int *return_code ) +NTSTATUS steamclient_CreateInterface( void *args ) { - return p_CreateInterface( name, return_code ); + struct steamclient_CreateInterface_params *params = (struct steamclient_CreateInterface_params *)args; + params->_ret = p_CreateInterface( params->name, params->return_code ); + return 0; } -void unix_Steam_ReleaseThreadLocalMemory( int thread_exit ) +NTSTATUS steamclient_Steam_ReleaseThreadLocalMemory( void *args ) { - p_Steam_ReleaseThreadLocalMemory( thread_exit ); + struct steamclient_Steam_ReleaseThreadLocalMemory_params *params = (struct steamclient_Steam_ReleaseThreadLocalMemory_params *)args; + p_Steam_ReleaseThreadLocalMemory( params->thread_exit ); + return 0; } -bool unix_Steam_IsKnownInterface( const char *version ) +NTSTATUS steamclient_Steam_IsKnownInterface( void *args ) { - return p_Steam_IsKnownInterface( version ); + struct steamclient_Steam_IsKnownInterface_params *params = (struct steamclient_Steam_IsKnownInterface_params *)args; + params->_ret = p_Steam_IsKnownInterface( params->version ); + return 0; } -void unix_Steam_NotifyMissingInterface( int32_t pipe, const char *version ) +NTSTATUS steamclient_Steam_NotifyMissingInterface( void *args ) { - p_Steam_NotifyMissingInterface( pipe, version ); + struct steamclient_Steam_NotifyMissingInterface_params *params = (struct steamclient_Steam_NotifyMissingInterface_params *)args; + p_Steam_NotifyMissingInterface( params->pipe, params->version ); + return 0; } diff --git a/lsteamclient/unixlib.h b/lsteamclient/unixlib.h index d5c7d652..d2cbf573 100644 --- a/lsteamclient/unixlib.h +++ b/lsteamclient/unixlib.h @@ -67,17 +67,96 @@ struct callback }; }; -extern bool unix_steamclient_init( struct steamclient_init_params *params ); -extern bool unix_steamclient_next_callback( struct callback *callback, uint32_t *length ); -extern void *unix_CreateInterface( const char *name, int *return_code ); -extern bool unix_Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback, - int w_callback_len, int id, bool *failed ); -extern bool unix_Steam_BGetCallback( uint32_t pipe, w_CallbackMsg_t *w_msg, int32_t *ignored, u_CallbackMsg_t *u_msg ); -extern void unix_callback_message_receive( u_CallbackMsg_t *u_msg, w_CallbackMsg_t *w_msg ); -extern bool unix_Steam_FreeLastCallback( uint32_t pipe ); -extern void unix_Steam_ReleaseThreadLocalMemory( int thread_exit ); -extern bool unix_Steam_IsKnownInterface( const char *version ); -extern void unix_Steam_NotifyMissingInterface( int32_t pipe, const char *version ); +struct steamclient_next_callback_params +{ + bool _ret; + struct callback *callback; + uint32_t size; +}; + +struct steamclient_CreateInterface_params +{ + void *_ret; + const char *name; + int *return_code; +}; + +struct steamclient_Steam_GetAPICallResult_params +{ + bool _ret; + int32_t pipe; + uint64_t call; + void *w_callback; + int w_callback_len; + int id; + bool *failed; +}; + +struct steamclient_Steam_BGetCallback_params +{ + bool _ret; + uint32_t pipe; + w_CallbackMsg_t *w_msg; + int32_t *ignored; + u_CallbackMsg_t *u_msg; +}; + +struct steamclient_callback_message_receive_params +{ + u_CallbackMsg_t *u_msg; + w_CallbackMsg_t *w_msg; +}; + +struct steamclient_Steam_FreeLastCallback_params +{ + bool _ret; + uint32_t pipe; +}; + +struct steamclient_Steam_ReleaseThreadLocalMemory_params +{ + int thread_exit; +}; + +struct steamclient_Steam_IsKnownInterface_params +{ + bool _ret; + const char *version; +}; + +struct steamclient_Steam_NotifyMissingInterface_params +{ + int32_t pipe; + const char *version; +}; + +struct steamclient_networking_messages_receive_144_params +{ + uint32_t count; + w_SteamNetworkingMessage_t_144 **w_msgs; +}; + +struct steamclient_networking_messages_receive_147_params +{ + uint32_t count; + w_SteamNetworkingMessage_t_147 **w_msgs; +}; + +struct steamclient_networking_messages_receive_153a_params +{ + uint32_t count; + w_SteamNetworkingMessage_t_153a **w_msgs; +}; + +struct steamclient_networking_message_release_147_params +{ + w_SteamNetworkingMessage_t_147 *w_msg; +}; + +struct steamclient_networking_message_release_153a_params +{ + w_SteamNetworkingMessage_t_153a *w_msg; +}; struct networking_message_pool; struct networking_message @@ -100,12 +179,6 @@ struct networking_message }; }; -extern void unix_networking_messages_receive_144( uint32_t count, w_SteamNetworkingMessage_t_144 **w_msgs ); -extern void unix_networking_messages_receive_147( uint32_t count, w_SteamNetworkingMessage_t_147 **w_msgs ); -extern void unix_networking_messages_receive_153a( uint32_t count, w_SteamNetworkingMessage_t_153a **w_msgs ); -extern void unix_networking_message_release_147( w_SteamNetworkingMessage_t_147 *w_msg ); -extern void unix_networking_message_release_153a( w_SteamNetworkingMessage_t_153a *w_msg ); - typedef NTSTATUS (*unixlib_entry_t)( void *args ); extern const unixlib_entry_t __wine_unix_call_funcs[]; diff --git a/lsteamclient/unixlib_generated.cpp b/lsteamclient/unixlib_generated.cpp index f634d0db..55f83327 100644 --- a/lsteamclient/unixlib_generated.cpp +++ b/lsteamclient/unixlib_generated.cpp @@ -4,6 +4,21 @@ extern "C" const unixlib_entry_t __wine_unix_call_funcs[] = { + steamclient_init, + steamclient_next_callback, + steamclient_CreateInterface, + steamclient_Steam_GetAPICallResult, + steamclient_Steam_BGetCallback, + steamclient_callback_message_receive, + steamclient_Steam_FreeLastCallback, + steamclient_Steam_ReleaseThreadLocalMemory, + steamclient_Steam_IsKnownInterface, + steamclient_Steam_NotifyMissingInterface, + steamclient_networking_messages_receive_144, + steamclient_networking_messages_receive_147, + steamclient_networking_messages_receive_153a, + steamclient_networking_message_release_147, + steamclient_networking_message_release_153a, ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetNumInstalledApps, ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetInstalledApps, ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetAppName, diff --git a/lsteamclient/unixlib_generated.h b/lsteamclient/unixlib_generated.h index 0efa43e1..0b68e4f2 100644 --- a/lsteamclient/unixlib_generated.h +++ b/lsteamclient/unixlib_generated.h @@ -45560,6 +45560,21 @@ struct ISteamUtils_SteamUtils010_DismissFloatingGamepadTextInput_params enum unix_funcs { + unix_steamclient_init, + unix_steamclient_next_callback, + unix_steamclient_CreateInterface, + unix_steamclient_Steam_GetAPICallResult, + unix_steamclient_Steam_BGetCallback, + unix_steamclient_callback_message_receive, + unix_steamclient_Steam_FreeLastCallback, + unix_steamclient_Steam_ReleaseThreadLocalMemory, + unix_steamclient_Steam_IsKnownInterface, + unix_steamclient_Steam_NotifyMissingInterface, + unix_steamclient_networking_messages_receive_144, + unix_steamclient_networking_messages_receive_147, + unix_steamclient_networking_messages_receive_153a, + unix_steamclient_networking_message_release_147, + unix_steamclient_networking_message_release_153a, unix_ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetNumInstalledApps, unix_ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetInstalledApps, unix_ISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001_GetAppName,