vpinball / vpinball

Visual Pinball
https://www.vpforums.org
Other
537 stars 89 forks source link

Standalone: Add missing implementations for Taito tables (nvram patch) #1595

Open francisdb opened 6 months ago

francisdb commented 6 months ago

This is a continuation of https://github.com/jsm174/vpx-standalone-scripts/issues/89

Currently this specific code for making sure nvram is reset when exiting a table is not working on standalone:

NVram patch for Taito do Brasil tables by Pmax65

To implement

nvram_directory

WshShell.RegRead("HKCU\Software\Freeware\Visual PinMame\globals\nvram_directory")

should return "/path/to/tables/Fire Action (Taito 1980)/pinmame/nvram" (or ~/.pinmame/nvram)

file copy

https://github.com/vpinball/vpinball/blob/5b459c5c0fa0b50b0b5f475781b05b0cbc849641/standalone/inc/wine/wine.c#L1068-L1071

file delete

https://github.com/vpinball/vpinball/blob/5b459c5c0fa0b50b0b5f475781b05b0cbc849641/standalone/inc/wine/wine.c#L1146-L1149

Alternative

If we don't want to implement this vpinball/libpinmame should come up with some way to take and restore nvram snapshots?

jsm174 commented 6 months ago

Yeh, I personally don't want to try to replicate a WshShell object or the CopyFileW / DeleteFileW functions as I think these can lead to bad things. (security wise)

We could add standalone specific global vbscript functions to get at vpinmame's nvram directory, but I would defer to @toxieainc and @vbousquet as they probably would have a better solution.

rh6423 commented 6 months ago

I did a quick scan of the vex-standalone-scripts repo and found a few non-Taito do Brasil tables using WshShell.

Reading nvram path via WshShell:

If there was somewhere to source the pinmame or nvram path (ini file or a constant available to the .vbs), patching these is super straightforward, and you could use if windows or if vpx_standalone type logic to use Wsh or the ini accordingly.

Some other tables are writing DMD settings to registry via WshShell. I'm not sure what you'd do about these...

Sub DMD_Exit If UltraDMD.IsRendering Then UltraDMD.CancelRendering Dim WshShell:Set WshShell = CreateObject("WScript.Shell") WshShell.RegWrite "HKCU\Software\UltraDMD\color", DMDOldColor, "REG_SZ" WshShell.RegWrite "HKCU\Software\UltraDMD\fullcolor", DMDOldFullColor, "REG_SZ" UltraDMD = Null End Sub `

rh6423 commented 6 months ago

Seems like this issue rhymes with #1188 , where core.vbs is using WshShell to pull registry values. Might be a similar solution for both.

francisdb commented 6 months ago

Currently the main issue here is that we would prefer to not let scripts have unrestricted write access to the filesystem.