static void Main(string[] args) { SparkGlobals.InitializeGlobals(args.ToList()); string a = System.IO.Directory.GetCurrentDirectory(); string dir = System.IO.Path.GetDirectoryName(ExeUtils.GetCurrentExePath()); System.IO.Directory.SetCurrentDirectory(dir); string b = System.IO.Directory.GetCurrentDirectory(); // // Args to build // if (SparkGlobals.ProgramMode == SparkProgramMode.Build) { BuildForm bf = new BuildForm(); try { bf.Show(); InstallerBuilder ib = new InstallerBuilder(); ib.BuildInstaller(bf); bf.Hide(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } }
public void OpenStream() { long exeSize = ExeUtils.GetCurrentExeVirtualSize(); long fileSize = ExeUtils.GetCurrentExeDiskSize(); // Validate size if ((exeSize + _cOffsetToken.Length) > fileSize) { Globals.Throw("Installer exe file size was too short. It appears the installer did not pack any data. (0094812)."); } byte[] buffer = new byte[_cOffsetToken.Length]; string exePath = ExeUtils.GetCurrentExePath(); // Create stream _objFileStream = new System.IO.FileStream(exePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); _objReader = new System.IO.BinaryReader(_objFileStream); //_objReader.BaseStream.Seek(exeSize, System.IO.SeekOrigin.Begin); //Read the binary. _binaryData = new byte[exeSize]; _objReader.Read(_binaryData, 0, _binaryData.Length); //Read the token _objReader.Read(buffer, 0, buffer.Length); // Validate Token string strToken = System.Text.Encoding.ASCII.GetString(buffer); if (!strToken.Equals(_cOffsetToken)) { //**This is no longer valid. The uninstaller MUST have the file table and the config (just no files) //Globals.Logger.LogError("Installer data token was invalid. The installer exe computed size may be wrong. OR the user has tried to run the uninstaller without the /u switdch. App will now exit.", false, true); //Environment.Exit(1); //This will throw Globals.Logger.LogError("Error installing/Uninstalling, Invalid binary Token. (01903)", true, true); } }