vrclient_x64: Unload native vrclient shared library on process detach.

CW-Bug-Id: #23390
This commit is contained in:
Paul Gofman 2024-02-09 18:20:52 -06:00 committed by Arkadiusz Hiler
parent 250242f66a
commit 8f03470527
6 changed files with 22 additions and 5 deletions

View file

@ -222,6 +222,7 @@ UNIX_FUNCS = [
'vrclient_init',
'vrclient_HmdSystemFactory',
'vrclient_VRClientCoreFactory',
'vrclient_unload',
]
MANUAL_METHODS = {

View file

@ -26,6 +26,7 @@ extern char *json_convert_startup_info(const char *startup_info);
extern char *json_convert_paths(const char *input);
extern NTSTATUS vrclient_init( void *args );
extern NTSTATUS vrclient_unload( void *args );
extern NTSTATUS vrclient_HmdSystemFactory( void *args );
extern NTSTATUS vrclient_VRClientCoreFactory( void *args );

View file

@ -72,10 +72,11 @@ static BOOL load_vk_unwrappers( HMODULE winevulkan )
return TRUE;
}
static void *vrclient;
NTSTATUS vrclient_init( void *args )
{
struct vrclient_init_params *params = (struct vrclient_init_params *)args;
static void *vrclient;
params->_ret = false;
@ -110,6 +111,16 @@ NTSTATUS vrclient_init( void *args )
return 0;
}
NTSTATUS vrclient_unload( void *args )
{
if (!vrclient) return 0;
dlclose( vrclient );
vrclient = NULL;
p_HmdSystemFactory = NULL;
p_VRClientCoreFactory = NULL;
return 0;
}
NTSTATUS vrclient_HmdSystemFactory( void *args )
{
struct vrclient_HmdSystemFactory_params *params = (struct vrclient_HmdSystemFactory_params *)args;

View file

@ -10,6 +10,7 @@ extern "C" const unixlib_entry_t __wine_unix_call_funcs[] =
vrclient_init,
vrclient_HmdSystemFactory,
vrclient_VRClientCoreFactory,
vrclient_unload,
IVRApplications_IVRApplications_001_AddApplicationManifest,
IVRApplications_IVRApplications_001_RemoveApplicationManifest,
IVRApplications_IVRApplications_001_IsApplicationInstalled,

View file

@ -28865,6 +28865,7 @@ enum unix_funcs
unix_vrclient_init,
unix_vrclient_HmdSystemFactory,
unix_vrclient_VRClientCoreFactory,
unix_vrclient_unload,
unix_IVRApplications_IVRApplications_001_AddApplicationManifest,
unix_IVRApplications_IVRApplications_001_RemoveApplicationManifest,
unix_IVRApplications_IVRApplications_001_IsApplicationInstalled,

View file

@ -28,6 +28,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
CREATE_TYPE_INFO_VTABLE;
struct compositor_data compositor_data = {0};
static BOOL vrclient_loaded;
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
@ -54,6 +55,8 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
VRCLIENT_CALL( IVRClientCore_IVRClientCore_003_Cleanup, &params );
compositor_data.client_core_linux_side = NULL;
}
VRCLIENT_CALL( vrclient_unload, NULL );
vrclient_loaded = FALSE;
break;
}
@ -107,7 +110,6 @@ static int load_vrclient(void)
{
static const WCHAR PROTON_VR_RUNTIME_W[] = {'P','R','O','T','O','N','_','V','R','_','R','U','N','T','I','M','E',0};
static const WCHAR winevulkanW[] = {'w','i','n','e','v','u','l','k','a','n','.','d','l','l',0};
static BOOL loaded;
struct vrclient_init_params params = {.winevulkan = LoadLibraryW( winevulkanW )};
WCHAR pathW[PATH_MAX];
@ -119,7 +121,7 @@ static int load_vrclient(void)
static const char append_path[] = "/bin/vrclient.so";
#endif
if (loaded) return 1;
if (vrclient_loaded) return 1;
/* PROTON_VR_RUNTIME is provided by the proton setup script */
if(!GetEnvironmentVariableW(PROTON_VR_RUNTIME_W, pathW, ARRAY_SIZE(pathW)))
@ -172,10 +174,10 @@ static int load_vrclient(void)
TRACE( "got openvr runtime path: %s\n", params.unix_path );
VRCLIENT_CALL( vrclient_init, &params );
if (params._ret) loaded = TRUE;
if (params._ret) vrclient_loaded = TRUE;
HeapFree( GetProcessHeap(), 0, params.unix_path );
return loaded;
return vrclient_loaded;
}
void *CDECL HmdSystemFactory(const char *name, int *return_code)