diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index 4da79598..08a7a163 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -214,6 +214,12 @@ all_versions = {} unique_structs = [] +UNIX_FUNCS = [ + 'vrclient_init', + 'vrclient_HmdSystemFactory', + 'vrclient_VRClientCoreFactory', +] + MANUAL_METHODS = { "IVRClientCore_BIsHmdPresent": lambda ver, abi: abi == 'w', "IVRClientCore_Init": lambda ver, abi: True, @@ -1583,6 +1589,8 @@ with open(u"vrclient_x64/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: @@ -1604,6 +1612,8 @@ with open('vrclient_x64/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/vrclient_x64/vrclient_x64/unix_private.h b/vrclient_x64/vrclient_x64/unix_private.h index 37e7998d..d3f308b9 100644 --- a/vrclient_x64/vrclient_x64/unix_private.h +++ b/vrclient_x64/vrclient_x64/unix_private.h @@ -25,6 +25,10 @@ extern VkQueue_T *(WINAPI *p_get_native_VkQueue)( VkQueue_T * ); 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_HmdSystemFactory( void *args ); +extern NTSTATUS vrclient_VRClientCoreFactory( void *args ); + #ifdef __cplusplus } /* extern "C" */ #endif /* __cplusplus */ diff --git a/vrclient_x64/vrclient_x64/unixlib.cpp b/vrclient_x64/vrclient_x64/unixlib.cpp index ef2f1aa7..2081d5fe 100644 --- a/vrclient_x64/vrclient_x64/unixlib.cpp +++ b/vrclient_x64/vrclient_x64/unixlib.cpp @@ -67,23 +67,28 @@ static void load_vk_unwrappers( HMODULE winevulkan ) dlclose(unix_handle); } -bool unix_vrclient_init( struct vrclient_init_params *params ) +NTSTATUS vrclient_init( void *args ) { + struct vrclient_init_params *params = (struct vrclient_init_params *)args; static void *vrclient; - if (vrclient) return true; + if (vrclient) + { + params->_ret = true; + return 0; + } if (!(vrclient = dlopen( params->unix_path, RTLD_NOW ))) { TRACE( "unable to load %s\n", params->unix_path ); - return false; + return -1; } #define LOAD_FUNC( x ) \ if (!(p_##x = (decltype(p_##x))dlsym( vrclient, #x ))) \ { \ ERR( "unable to load " #x "\n" ); \ - return false; \ + return -1; \ } LOAD_FUNC( HmdSystemFactory ); @@ -92,15 +97,20 @@ bool unix_vrclient_init( struct vrclient_init_params *params ) #undef LOAD_FUNC load_vk_unwrappers( params->winevulkan ); - return true; + params->_ret = true; + return 0; } -void *unix_HmdSystemFactory( const char *name, int *return_code ) +NTSTATUS vrclient_HmdSystemFactory( void *args ) { - return p_HmdSystemFactory( name, return_code ); + struct vrclient_HmdSystemFactory_params *params = (struct vrclient_HmdSystemFactory_params *)args; + params->_ret = p_HmdSystemFactory( params->name, params->return_code ); + return 0; } -void *unix_VRClientCoreFactory( const char *name, int *return_code ) +NTSTATUS vrclient_VRClientCoreFactory( void *args ) { - return p_VRClientCoreFactory( name, return_code ); + struct vrclient_VRClientCoreFactory_params *params = (struct vrclient_VRClientCoreFactory_params *)args; + params->_ret = p_VRClientCoreFactory( params->name, params->return_code ); + return 0; } diff --git a/vrclient_x64/vrclient_x64/unixlib.h b/vrclient_x64/vrclient_x64/unixlib.h index 319290e5..83246213 100644 --- a/vrclient_x64/vrclient_x64/unixlib.h +++ b/vrclient_x64/vrclient_x64/unixlib.h @@ -45,13 +45,24 @@ struct render_model_texture_map struct vrclient_init_params { + bool _ret; HMODULE winevulkan; char *unix_path; }; -extern bool unix_vrclient_init( struct vrclient_init_params *params ); -extern void *unix_HmdSystemFactory( const char *name, int *return_code ); -extern void *unix_VRClientCoreFactory( const char *name, int *return_code ); +struct vrclient_HmdSystemFactory_params +{ + void *_ret; + const char *name; + int *return_code; +}; + +struct vrclient_VRClientCoreFactory_params +{ + void *_ret; + const char *name; + int *return_code; +}; typedef NTSTATUS (*unixlib_entry_t)( void *args ); extern const unixlib_entry_t __wine_unix_call_funcs[]; diff --git a/vrclient_x64/vrclient_x64/unixlib_generated.cpp b/vrclient_x64/vrclient_x64/unixlib_generated.cpp index 73e202f3..da7f4cb6 100644 --- a/vrclient_x64/vrclient_x64/unixlib_generated.cpp +++ b/vrclient_x64/vrclient_x64/unixlib_generated.cpp @@ -4,6 +4,9 @@ extern "C" const unixlib_entry_t __wine_unix_call_funcs[] = { + vrclient_init, + vrclient_HmdSystemFactory, + vrclient_VRClientCoreFactory, IVRApplications_IVRApplications_001_AddApplicationManifest, IVRApplications_IVRApplications_001_RemoveApplicationManifest, IVRApplications_IVRApplications_001_IsApplicationInstalled, diff --git a/vrclient_x64/vrclient_x64/unixlib_generated.h b/vrclient_x64/vrclient_x64/unixlib_generated.h index 630e4680..8e41a79b 100644 --- a/vrclient_x64/vrclient_x64/unixlib_generated.h +++ b/vrclient_x64/vrclient_x64/unixlib_generated.h @@ -28859,6 +28859,9 @@ struct IVRTrackedCamera_IVRTrackedCamera_006_GetCameraTrackingSpace_params enum unix_funcs { + unix_vrclient_init, + unix_vrclient_HmdSystemFactory, + unix_vrclient_VRClientCoreFactory, unix_IVRApplications_IVRApplications_001_AddApplicationManifest, unix_IVRApplications_IVRApplications_001_RemoveApplicationManifest, unix_IVRApplications_IVRApplications_001_IsApplicationInstalled, diff --git a/vrclient_x64/vrclient_x64/vrclient_main.c b/vrclient_x64/vrclient_x64/vrclient_main.c index 40061b7f..dea43357 100644 --- a/vrclient_x64/vrclient_x64/vrclient_main.c +++ b/vrclient_x64/vrclient_x64/vrclient_main.c @@ -260,7 +260,8 @@ static int load_vrclient(void) TRACE( "got openvr runtime path: %s\n", params.unix_path ); - if (unix_vrclient_init( ¶ms )) loaded = TRUE; + VRCLIENT_CALL( vrclient_init, ¶ms ); + if (params._ret) loaded = TRUE; HeapFree( GetProcessHeap(), 0, params.unix_path ); return loaded; @@ -268,16 +269,20 @@ static int load_vrclient(void) void *CDECL HmdSystemFactory(const char *name, int *return_code) { + struct vrclient_HmdSystemFactory_params params = {.name = name, .return_code = return_code}; TRACE("name: %s, return_code: %p\n", name, return_code); if (!load_vrclient()) return NULL; - return create_win_interface( name, unix_HmdSystemFactory( name, return_code ) ); + VRCLIENT_CALL( vrclient_HmdSystemFactory, ¶ms ); + return create_win_interface( name, params._ret ); } void *CDECL VRClientCoreFactory(const char *name, int *return_code) { + struct vrclient_VRClientCoreFactory_params params = {.name = name, .return_code = return_code}; TRACE("name: %s, return_code: %p\n", name, return_code); if (!load_vrclient()) return NULL; - return create_win_interface( name, unix_VRClientCoreFactory( name, return_code ) ); + VRCLIENT_CALL( vrclient_VRClientCoreFactory, ¶ms ); + return create_win_interface( name, params._ret ); } static bool is_hmd_present_reg(void)