private bool PrepareForBind()
{
//Check all required items are present
//serial.txt
if (!File.Exists(FromBase64("c2VyaWFsLnR4dA==").ToLower()) ||
!HardwareLock.verifySerial(File.ReadAllText(FromBase64("c2VyaWFsLnR4dA==").ToLower()), HardwareLock.GetHardwareID()))
{
//Invalid serial, Error
//MessageBox.Show(FromBase64("SW52YWxpZCBzZXJpYWw="), FromBase64("RXJyb3I="), MessageBoxButtons.OK, MessageBoxIcon.Error);
// Environment.Exit(-1);
}
//stub.exe
if (!File.Exists(FromBase64("c3R1Yi5leGU=").ToLower()))
{
//stub.exe not found
MessageBox.Show(FromBase64("c3R1Yi5leGUgbm90IGZvdW5k"));
return false;
}
if (!File.Exists(Instance.TextHostFile.Text)) { MessageBox.Show("Target file not found"); return false; }
//Choose file to save as
Instance.svdlg.FileName = null;
Instance.svdlg.Filter = "exe files (*.exe)|*.exe";
Instance.svdlg.Title = "Save As";
Instance.svdlg.InitialDirectory = Application.StartupPath;
Instance.svdlg.ShowDialog();
if (Instance.svdlg.FileName == String.Empty) { return false; }
if (Path.GetDirectoryName(Instance.svdlg.FileName) != Instance.svdlg.InitialDirectory)
{
MessageBox.Show("Must save in the same dir. as binder/stub", "Error", MessageBoxButtons.OK);
return false;
}
string SaveName = Path.GetFileName(Instance.svdlg.FileName);
if (File.Exists(SaveName)) { File.Delete(SaveName); }
Instance.DebugLBL1.Text = String.Empty;
//Clean up
if (File.Exists("icon.ico")) { File.Delete("icon.ico"); }
if (File.Exists("icon.exe")) { File.Delete("icon.exe"); }
if (Instance.textIconPath.Text == String.Empty) { Instance.textIconPath.Text = @"\null\"; }
//Copy icon or the file which the icon will be taken from to the same directory.
//Needed for Compiling the loader, all files to be compiled need to be in the same directory.
if (Instance.checkmainicon.Checked)
{
if (!(Path.GetDirectoryName(Instance.TextHostFile.Text) == Application.StartupPath))
File.Copy(Instance.TextHostFile.Text, "icon.exe");
}
if (Instance.CheckChangeIcon.Checked)
{
if (!(Path.GetDirectoryName(textIconPath.Text) == Application.StartupPath) &
(Path.GetExtension(Instance.textIconPath.Text.ToLower()) == ".ico"))
File.Copy(Instance.textIconPath.Text, "icon.ico");
}
if (!Instance.TextHostFile.Text.ToLower().EndsWith(".exe") || !File.Exists(Instance.TextHostFile.Text))
{
Interaction.MsgBox("Invalid file to bind with. Need a .exe", MsgBoxStyle.OkOnly, "Error");
return false;
}
return true;
}