mirror of
https://git.suyu.dev/suyu/Yucom.git
synced 2025-12-27 01:34:34 +01:00
lsteamclient: Move unix library loading to the unix side.
CW-Bug-Id: #22729
This commit is contained in:
parent
4823be943d
commit
e0b2b50fb1
3 changed files with 121 additions and 132 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
|
||||
|
|
@ -79,9 +80,17 @@ bool unix_steamclient_next_callback( struct callback *callback, uint32_t *size )
|
|||
return !!ptr;
|
||||
}
|
||||
|
||||
static void *(*p_CreateInterface)( const char *name, int *return_code );
|
||||
static bool (*p_Steam_BGetCallback)( int32_t a, u_CallbackMsg_t *b, int32_t *c );
|
||||
static bool (*p_Steam_GetAPICallResult)( int32_t, uint64_t, void *, int, int, bool * );
|
||||
static bool (*p_Steam_FreeLastCallback)( int32_t );
|
||||
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 )
|
||||
{
|
||||
if (!steamclient_BGetCallback( pipe, u_msg, ignored )) return false;
|
||||
if (!p_Steam_BGetCallback( pipe, u_msg, ignored )) return false;
|
||||
callback_message_utow( u_msg, w_msg );
|
||||
return true;
|
||||
}
|
||||
|
|
@ -94,7 +103,7 @@ void unix_callback_message_receive( u_CallbackMsg_t *u_msg, w_CallbackMsg_t *w_m
|
|||
|
||||
bool unix_Steam_FreeLastCallback( uint32_t pipe )
|
||||
{
|
||||
return steamclient_FreeLastCallback( pipe );
|
||||
return p_Steam_FreeLastCallback( pipe );
|
||||
}
|
||||
|
||||
bool unix_Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback, int w_callback_len,
|
||||
|
|
@ -106,7 +115,7 @@ bool unix_Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback,
|
|||
|
||||
if (!(u_callback = alloc_callback_wtou( id, w_callback, &u_callback_len ))) return false;
|
||||
|
||||
ret = steamclient_GetAPICallResult( pipe, call, u_callback, u_callback_len, id, failed );
|
||||
ret = p_Steam_GetAPICallResult( pipe, call, u_callback, u_callback_len, id, failed );
|
||||
|
||||
if (ret && u_callback != w_callback)
|
||||
{
|
||||
|
|
@ -116,3 +125,81 @@ bool unix_Steam_GetAPICallResult( int32_t pipe, uint64_t call, void *w_callback,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool unix_steamclient_init( struct steamclient_init_params *params )
|
||||
{
|
||||
char path[PATH_MAX], resolved_path[PATH_MAX];
|
||||
static void *steamclient;
|
||||
|
||||
if (params->steam_app_id_unset) unsetenv( "SteamAppId" );
|
||||
else if (params->steam_app_id) setenv( "SteamAppId", params->steam_app_id, TRUE );
|
||||
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;
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (getenv( "STEAM_COMPAT_CLIENT_INSTALL_PATH" ))
|
||||
snprintf( path, PATH_MAX, "%s/steamclient.dylib", getenv( "STEAM_COMPAT_CLIENT_INSTALL_PATH" ) );
|
||||
else
|
||||
{
|
||||
WARN( "Old Steam client, falling back to DYLD environment to locate native steamclient "
|
||||
"library\n" );
|
||||
strcpy( path, "steamclient.dylib" );
|
||||
}
|
||||
#else /* __APPLE__ */
|
||||
#ifdef __x86_64__
|
||||
snprintf( path, PATH_MAX, "%s/.steam/sdk64/steamclient.so", getenv( "HOME" ) );
|
||||
#else
|
||||
snprintf( path, PATH_MAX, "%s/.steam/sdk32/steamclient.so", getenv( "HOME" ) );
|
||||
#endif
|
||||
if (realpath( path, resolved_path ))
|
||||
{
|
||||
strcpy( path, resolved_path );
|
||||
path[PATH_MAX - 1] = 0;
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
if (!(steamclient = dlopen( path, RTLD_NOW )))
|
||||
{
|
||||
ERR( "unable to load native steamclient library\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
#define LOAD_FUNC( x ) \
|
||||
if (!(p_##x = (decltype(p_##x))dlsym( steamclient, #x ))) \
|
||||
{ \
|
||||
ERR( "unable to load " #x "\n" ); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
LOAD_FUNC( CreateInterface );
|
||||
LOAD_FUNC( Steam_BGetCallback );
|
||||
LOAD_FUNC( Steam_GetAPICallResult );
|
||||
LOAD_FUNC( Steam_FreeLastCallback );
|
||||
LOAD_FUNC( Steam_ReleaseThreadLocalMemory );
|
||||
LOAD_FUNC( Steam_IsKnownInterface );
|
||||
LOAD_FUNC( Steam_NotifyMissingInterface );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void *unix_CreateInterface( const char *name, int *return_code )
|
||||
{
|
||||
return p_CreateInterface( name, return_code );
|
||||
}
|
||||
|
||||
void unix_Steam_ReleaseThreadLocalMemory( int thread_exit )
|
||||
{
|
||||
p_Steam_ReleaseThreadLocalMemory( thread_exit );
|
||||
}
|
||||
|
||||
bool unix_Steam_IsKnownInterface( const char *version )
|
||||
{
|
||||
return p_Steam_IsKnownInterface( version );
|
||||
}
|
||||
|
||||
void unix_Steam_NotifyMissingInterface( int32_t pipe, const char *version )
|
||||
{
|
||||
p_Steam_NotifyMissingInterface( pipe, version );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue