diff --git a/vrclient_x64/gen_wrapper.py b/vrclient_x64/gen_wrapper.py index 69b91cb1..6c229694 100755 --- a/vrclient_x64/gen_wrapper.py +++ b/vrclient_x64/gen_wrapper.py @@ -798,6 +798,14 @@ def handle_method_cpp(method, classname, out): for name, param in sorted(need_output.items()): out(f' if (params->{name}) *params->{name} = u_{name};\n') + path_conv_utow = PATH_CONV_METHODS_UTOW.get(f'{klass.name}_{method.spelling}', {}) + + for name, conv in filter(lambda x: x[0] in names, path_conv_utow.items()): + out(u' ') + if "ret_size" in path_conv_utow: + out(u'params->_ret = ') + out(f'vrclient_unix_path_to_dos_path( params->_ret, params->{name}, params->{name}, params->{conv["len"]} );\n') + for name in filter(lambda x: x in names, sorted(path_conv_wtou)): out(f' vrclient_free_path( u_{name} );\n') @@ -851,8 +859,6 @@ def handle_method_c(klass, method, winclassname, out): out(f' .{name} = {name},\n') out(u' };\n') - path_conv_utow = PATH_CONV_METHODS_UTOW.get(f'{klass.name}_{method.spelling}', {}) - out(u' TRACE("%p\\n", _this);\n') if 'eTextureType' in names: @@ -860,12 +866,6 @@ def handle_method_c(klass, method, winclassname, out): out(f' VRCLIENT_CALL( {method.full_name}, ¶ms );\n') - for name, conv in filter(lambda x: x[0] in names, path_conv_utow.items()): - out(u' ') - if "ret_size" in path_conv_utow: - out(u'params._ret = ') - out(f'vrclient_unix_path_to_dos_path( params._ret, {name}, {name}, {conv["len"]} );\n') - if not returns_void: out(u' return params._ret;\n') out(u'}\n\n') diff --git a/vrclient_x64/vrclient_x64/cppIVRScreenshots_IVRScreenshots_001.cpp b/vrclient_x64/vrclient_x64/cppIVRScreenshots_IVRScreenshots_001.cpp index b00b8929..16fa42b9 100644 --- a/vrclient_x64/vrclient_x64/cppIVRScreenshots_IVRScreenshots_001.cpp +++ b/vrclient_x64/vrclient_x64/cppIVRScreenshots_IVRScreenshots_001.cpp @@ -34,6 +34,7 @@ NTSTATUS IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename( void * struct IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename_params *params = (struct IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename_params *)args; struct u_IVRScreenshots_IVRScreenshots_001 *iface = (struct u_IVRScreenshots_IVRScreenshots_001 *)params->linux_side; params->_ret = (uint32_t)iface->GetScreenshotPropertyFilename( params->screenshotHandle, params->filenameType, params->pchFilename, params->cchFilename, params->pError ); + params->_ret = vrclient_unix_path_to_dos_path( params->_ret, params->pchFilename, params->pchFilename, params->cchFilename ); return 0; } diff --git a/vrclient_x64/vrclient_x64/json_converter.cpp b/vrclient_x64/vrclient_x64/json_converter.cpp index 0d75aa3b..ff2b6223 100644 --- a/vrclient_x64/vrclient_x64/json_converter.cpp +++ b/vrclient_x64/vrclient_x64/json_converter.cpp @@ -80,6 +80,32 @@ void vrclient_free_path( char *path ) HeapFree( GetProcessHeap(), 0, path ); } +/* returns the number of bytes written to dst, not including the NUL terminator */ +unsigned int vrclient_unix_path_to_dos_path( bool api_result, const char *src, char *dst, uint32_t dst_bytes ) +{ + WCHAR *dosW; + uint32_t r; + + if (!src || !*src || !api_result || !dst || !dst_bytes) + { + if (dst && dst_bytes) *dst = 0; + return 0; + } + + dosW = wine_get_dos_file_name( src ); + if (!dosW) + { + WARN( "Unable to convert unix filename to DOS: %s\n", src ); + *dst = 0; + return 0; + } + + r = WideCharToMultiByte( CP_ACP, 0, dosW, -1, dst, dst_bytes, NULL, NULL ); + HeapFree( GetProcessHeap(), 0, dosW ); + + return r == 0 ? 0 : r - 1; +} + extern "C" { static bool ends_with(const std::string &s, char c) diff --git a/vrclient_x64/vrclient_x64/unix_private.h b/vrclient_x64/vrclient_x64/unix_private.h index 628274ba..7b4d8e80 100644 --- a/vrclient_x64/vrclient_x64/unix_private.h +++ b/vrclient_x64/vrclient_x64/unix_private.h @@ -31,6 +31,7 @@ extern NTSTATUS vrclient_VRClientCoreFactory( void *args ); extern char *vrclient_dos_to_unix_path( const char *src ); extern void vrclient_free_path( char *path ); +extern unsigned int vrclient_unix_path_to_dos_path( bool api_result, const char *src, char *dst, uint32_t dst_bytes ); #ifdef __cplusplus } /* extern "C" */ diff --git a/vrclient_x64/vrclient_x64/vrclient_main.c b/vrclient_x64/vrclient_x64/vrclient_main.c index 06879f93..7d79b55e 100644 --- a/vrclient_x64/vrclient_x64/vrclient_main.c +++ b/vrclient_x64/vrclient_x64/vrclient_main.c @@ -57,36 +57,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) return TRUE; } -/* returns the number of bytes written to dst, not including the NUL terminator */ -unsigned int vrclient_unix_path_to_dos_path(bool api_result, const char *src, char *dst, uint32_t dst_bytes) -{ - WCHAR *dosW; - uint32_t r; - - if(!dst || !dst_bytes) - return 0; - - if(!src || !api_result){ - *dst = 0; - return 0; - } - - dosW = wine_get_dos_file_name(src); - *dst = 0; - - if(!dosW){ - WARN("Unable to convert unix filename to DOS: %s\n", src); - return 0; - } - - r = WideCharToMultiByte(CP_ACP, 0, dosW, -1, dst, dst_bytes, - NULL, NULL); - - HeapFree(GetProcessHeap(), 0, dosW); - - return r == 0 ? 0 : r - 1; -} - static BOOL array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) { SIZE_T max_capacity, new_capacity; diff --git a/vrclient_x64/vrclient_x64/vrclient_private.h b/vrclient_x64/vrclient_x64/vrclient_private.h index e3ac5776..c65ba94d 100644 --- a/vrclient_x64/vrclient_x64/vrclient_private.h +++ b/vrclient_x64/vrclient_x64/vrclient_private.h @@ -12,7 +12,6 @@ typedef void (*vtable_ptr)(void); #endif -unsigned int vrclient_unix_path_to_dos_path(bool api_result, const char *src, char *dst, uint32_t dst_bytes); void *create_LinuxMatchmakingServerListResponse(void *win); #ifndef __cplusplus diff --git a/vrclient_x64/vrclient_x64/winIVRScreenshots.c b/vrclient_x64/vrclient_x64/winIVRScreenshots.c index 3a22c3b3..75bd4379 100644 --- a/vrclient_x64/vrclient_x64/winIVRScreenshots.c +++ b/vrclient_x64/vrclient_x64/winIVRScreenshots.c @@ -70,7 +70,6 @@ uint32_t __thiscall winIVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFi }; TRACE("%p\n", _this); VRCLIENT_CALL( IVRScreenshots_IVRScreenshots_001_GetScreenshotPropertyFilename, ¶ms ); - params._ret = vrclient_unix_path_to_dos_path( params._ret, pchFilename, pchFilename, cchFilename ); return params._ret; }