From 101de9d68b6eaf8cdc1287e6488d454963dc1b33 Mon Sep 17 00:00:00 2001 From: CakeLancelot Date: Thu, 9 Feb 2023 06:07:00 +0000 Subject: [PATCH] Added WebPlayer verification/reinstallation logic --- index.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c5db6e2..f038cc6 100644 --- a/index.js +++ b/index.js @@ -10,7 +10,20 @@ var mainWindow = null; app.commandLine.appendSwitch("--enable-npapi"); function verifyUnity() { - console.log("Unimplemented!"); + var dllpath = + app.getPath("appData") + + "\\..\\LocalLow\\Unity\\WebPlayer\\player\\fusion-2.x.x\\webplayer_win.dll"; + + if (fs.existsSync(dllpath)) { + var buff = fs.readFileSync(dllpath); + var hash = require("crypto") + .createHash("md5") + .update(buff) + .digest("hex"); + if (hash == "e5028405b4483de9e5e5fe9cd5f1e98f") { + return true; + } + } return false; } @@ -30,7 +43,7 @@ function installUnity(callback) { child.on("exit", function () { // overwrite 3.5.2 loader/player with FF's custom version var dstfolder = - process.env.USERPROFILE + "\\AppData\\LocalLow\\Unity\\WebPlayer"; + app.getPath("appData") + "..\\LocalLow\\Unity\\WebPlayer"; fs.copySync(utilsdir + "\\WebPlayer", dstfolder, { clobber: true, }); @@ -133,7 +146,11 @@ app.on("ready", function () { console.log("Pre-1.4 config detected. Running migration."); initialSetup(false); } else { - showMainWindow(); + if (verifyUnity()) { + showMainWindow(); + } else { + installUnity(showMainWindow); + } } } } catch (ex) {