On Wed Sep 21 21:27:06 2022 +0000, Jacek Caban wrote:
I think that we could fix the logic in exec_script() instead of of duplicating it here. What do you think about something like https://gitlab.winehq.org/jacek/wine/-/commit/f1ce7f0962cbc9dac7cc5df420d31f... ?
I didn't think of doing it that way, since the mismatch I was seeing came from a non-vbscript source (VBscript calling an oleautomation interface implemented in c++) and that had me thinking about disp_call. But yeah, it shouldn't really matter whether the translation is done before disp_call returns, or after the HRESULT has bubbled up through do_icall -> interp_icall -> exec_script. That would still gets it it translated before anything observes ctx->ei sees it (report_script_error or script code inspecting/logging from the `Err` singleton, so it should work the same in practice).
Your patch lost the `if(HRESULT_FACILITY(hres) == FACILITY_VBS)` check though - I think that's necessary, `VBS_RUNTIME_ERROR` and `get_vbscript_error_string` should only be used if `map_hres` translated something. There's a lot of HRESULT values that map_hres just passes through unchanged, and those shouldn't all just get squashed to `VBS_UNKNOWN_RUNTIME_ERROR`.
I suppose another way would be if the signature of map_hres changed to work on the whole `EXCEPINFO` at once. The get_vbscript_error_string wouldn't need to be a public function, the switch in map_hres could just assign the re-mapped `scode`/`bstrDescription`/`bstrSource` all together (or else do nothing).