Open francisdb opened 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.
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 `
GetDMDColor Sub GetDMDColor Dim WshShell,filecheck,directory Set WshShell = CreateObject("WScript.Shell") If DMDSize then WshShell.RegWrite "HKCU\Software\UltraDMD\w",DMDWidth,"REG_DWORD" WshShell.RegWrite "HKCU\Software\UltraDMD\h",DMDHeight,"REG_DWORD" End if If DMDPosition then WshShell.RegWrite "HKCU\Software\UltraDMD\x",DMDPosX,"REG_DWORD" WshShell.RegWrite "HKCU\Software\UltraDMD\y",DMDPosY,"REG_DWORD" End if WshShell.RegWrite "HKCU\Software\UltraDMD\fullcolor",UseFullColor,"REG_SZ" WshShell.RegWrite "HKCU\Software\UltraDMD\color",DMDColorSelect,"REG_SZ" End Sub
Seems like this issue rhymes with #1188 , where core.vbs is using WshShell to pull registry values. Might be a similar solution for both.
Currently the main issue here is that we would prefer to not let scripts have unrestricted write access to the filesystem.
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
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?