From 948aeac50db07a4599e78034895a907dde2c80ef Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Tue, 6 Aug 2019 10:18:50 +0100 Subject: [PATCH] vrclient: Support for HmdSystemFactory export Fixes a crash in Half-Life 2 in settings, and other legacy VR titles --- vrclient_x64/vrclient_x64/vrclient_main.c | 17 +++++++++++++++++ vrclient_x64/vrclient_x64/vrclient_x64.spec | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/vrclient_x64/vrclient_x64/vrclient_main.c b/vrclient_x64/vrclient_x64/vrclient_main.c index c8e5c2d4..3a441001 100644 --- a/vrclient_x64/vrclient_x64/vrclient_main.c +++ b/vrclient_x64/vrclient_x64/vrclient_main.c @@ -204,6 +204,7 @@ static pfn_dtor get_win_destructor(const char *name) } static void *vrclient_lib; +static void *(*vrclient_HmdSystemFactory)(const char *name, int *return_code); static void *(*vrclient_VRClientCoreFactory)(const char *name, int *return_code); static int load_vrclient(void) @@ -232,6 +233,12 @@ static int load_vrclient(void) return 0; } + vrclient_HmdSystemFactory = wine_dlsym(vrclient_lib, "HmdSystemFactory", NULL, 0); + if(!vrclient_HmdSystemFactory){ + ERR("unable to load HmdSystemFactory method\n"); + return 0; + } + vrclient_VRClientCoreFactory = wine_dlsym(vrclient_lib, "VRClientCoreFactory", NULL, 0); if(!vrclient_VRClientCoreFactory){ ERR("unable to load VRClientCoreFactory method\n"); @@ -241,6 +248,16 @@ static int load_vrclient(void) return 1; } +void *CDECL HmdSystemFactory(const char *name, int *return_code) +{ + TRACE("name: %s, return_code: %p\n", name, return_code); + + if(!load_vrclient()) + return NULL; + + return create_win_interface(name, vrclient_HmdSystemFactory(name, return_code)); +} + void *CDECL VRClientCoreFactory(const char *name, int *return_code) { TRACE("name: %s, return_code: %p\n", name, return_code); diff --git a/vrclient_x64/vrclient_x64/vrclient_x64.spec b/vrclient_x64/vrclient_x64/vrclient_x64.spec index 8d5aaa07..c7e832e5 100644 --- a/vrclient_x64/vrclient_x64/vrclient_x64.spec +++ b/vrclient_x64/vrclient_x64/vrclient_x64.spec @@ -1,4 +1,4 @@ # Generated from vrclient.dll by winedump -1 stub HmdSystemFactory +1 stdcall HmdSystemFactory(ptr ptr) 2 stdcall VRClientCoreFactory(ptr ptr)