From 80affdba445cc755c36366accdbace7384a71b94 Mon Sep 17 00:00:00 2001 From: GittyMac Date: Sat, 23 Apr 2022 00:48:48 -0400 Subject: [PATCH] Updated the fetched OCX --- OpenFK/Form1.cs | 8 ------ OpenFK/Program.cs | 49 ++++++++++++++++++++++++++++++++--- OpenFK/Resources/FetchOCX.bat | 10 +++---- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/OpenFK/Form1.cs b/OpenFK/Form1.cs index af77e26..056c821 100644 --- a/OpenFK/Form1.cs +++ b/OpenFK/Form1.cs @@ -349,14 +349,6 @@ namespace OpenFK setRP("Exploring", "Paradox Green", currentBitty, currentBittyName); } } - - if (Properties.Settings.Default.IsOnline) - { - if (e.args.Contains(@"=""config""")) - { - - } - } } } diff --git a/OpenFK/Program.cs b/OpenFK/Program.cs index a4e3fbb..d199733 100644 --- a/OpenFK/Program.cs +++ b/OpenFK/Program.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Security.Cryptography; using System.Windows.Forms; namespace OpenFK @@ -27,13 +28,41 @@ namespace OpenFK } else if (File.Exists(Directory.GetCurrentDirectory() + @"\Flash.ocx")) { - try + if(CalculateMD5(Directory.GetCurrentDirectory() + @"\Flash.ocx") == "0c8fbd12f40dcd5a1975b671f9989900" || + CalculateMD5(Directory.GetCurrentDirectory() + @"\Flash.ocx") == "28642aa6626e42701677a1f3822306b0") { - Application.Run(new Form1()); + if (MessageBox.Show("The current Flash.ocx is a buggy version! It causes several problems in the game. Do you want to fetch a compatible OCX?", "OpenFK", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) + { + File.WriteAllText(Directory.GetCurrentDirectory() + @"\FetchOCX.bat", Properties.Resources.FetchOCX); + ProcessStartInfo fetchocx = new ProcessStartInfo(Directory.GetCurrentDirectory() + @"\FetchOCX.bat"); + fetchocx.UseShellExecute = false; + var ocxprocess = Process.Start(fetchocx); + ocxprocess.WaitForExit(); + File.Delete(Directory.GetCurrentDirectory() + @"\FetchOCX.bat"); + Application.Restart(); + } + else + { + try + { + Application.Run(new Form1()); + } + catch + { + MessageBox.Show("There was an error starting the game! This could happen because of a 64 bit OCX running on a 32 bit OpenFK.", "OpenFK", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } - catch + else { - MessageBox.Show("There was an error starting the game! This could happen because of a 64 bit OCX running on a 32 bit OpenFK.", "OpenFK", MessageBoxButtons.OK, MessageBoxIcon.Error); + try + { + Application.Run(new Form1()); + } + catch + { + MessageBox.Show("There was an error starting the game! This could happen because of a 64 bit OCX running on a 32 bit OpenFK.", "OpenFK", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } }else if (MessageBox.Show("Flash.ocx is not found! Do you want to fetch a compatible OCX?", "OpenFK", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { @@ -46,5 +75,17 @@ namespace OpenFK Application.Restart(); } } + + static string CalculateMD5(string filename) //Generates the MD5 hash. + { + using (var md5 = MD5.Create()) + { + using (var stream = File.OpenRead(filename)) + { + var hash = md5.ComputeHash(stream); //Computes the MD5 hash of the swf. + return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant(); //Converts the hash to a readable string to compare. + } + } + } } } diff --git a/OpenFK/Resources/FetchOCX.bat b/OpenFK/Resources/FetchOCX.bat index 0c0fcab..6392f3c 100644 --- a/OpenFK/Resources/FetchOCX.bat +++ b/OpenFK/Resources/FetchOCX.bat @@ -7,23 +7,23 @@ if %var% lss 3 @echo Your Powershell version is too old to fetch the OCX. Update echo Downloading data... mkdir tempdl cd tempdl -powershell -Command "Invoke-WebRequest http://download.windowsupdate.com/d/msdownload/update/software/secu/2015/09/windows10.0-kb3087040-x64_ad0f78efb7b122fa9472dbb8050c4f358aceab49.msu -OutFile update.msu" +powershell -Command "Invoke-WebRequest http://download.windowsupdate.com/c/msdownload/update/software/secu/2019/06/windows10.0-kb4503308-x64_b6478017674279c8ba4f06e60fc3bab04ed7ae02.msu -OutFile update.msu" echo Extracting MSU... expand -f:* update.msu ./ echo Extracting CAB... -expand Windows10.0-KB3087040-x64.cab -F:* ./ +expand Windows10.0-KB4503308-x64.cab -F:* ./ echo Fetching OCX... IF EXIST "%PROGRAMFILES(X86)%" (GOTO 64BIT) ELSE (GOTO 32BIT) :64BIT -copy "%cd%\amd64_adobe-flash-for-windows_31bf3856ad364e35_10.0.10240.16513_none_33a2f3db043a608d\flash.ocx" "..\Flash.ocx" +copy "%cd%\amd64_adobe-flash-for-windows_31bf3856ad364e35_10.0.18362.172_none_815470a5fb446c4e\flash.ocx" "..\Flash.ocx" GOTO END :32BIT -copy "%cd%\wow64_adobe-flash-for-windows_31bf3856ad364e35_10.0.10240.16513_none_3df79e2d389b2288\flash.ocx" "..\Flash.ocx" +copy "%cd%\wow64_adobe-flash-for-windows_31bf3856ad364e35_10.0.18362.172_none_8ba91af82fa52e49\flash.ocx" "..\Flash.ocx" GOTO END :END cd .. rmdir /s /q tempdl -echo Your Flash.OCX is served! +echo Your Flash.OCX is served! \ No newline at end of file