Esempio n. 1
0
 static void Main()
 {
     ProgramData thisProg = new ProgramData();
     TrueCryptSWObj tcSoftware = new TrueCryptSWObj(thisProg);
     TC_Data_File tcData = new TC_Data_File(thisProg);
     tcData.OpenTcFile(tcSoftware, thisProg);
     MessageBox.Show("tcopen done");
 }
Esempio n. 2
0
        static void Main()
        {
            ProgramData    thisProg   = new ProgramData();
            TrueCryptSWObj tcSoftware = new TrueCryptSWObj(thisProg);
            TC_Data_File   tcData     = new TC_Data_File(thisProg);

            tcData.OpenTcFile(tcSoftware, thisProg);
            MessageBox.Show("tcopen done");
        }
Esempio n. 3
0
 static void Main()
 {
     ProgramData thisProg = new ProgramData();
     TrueCryptSWObj tcSoftware = new TrueCryptSWObj(thisProg);
     TC_Data_File tcData = new TC_Data_File(thisProg, tcSoftware);
     tcData.OpenTcFile();
     tcData.PDrivePerms();
     tcData.SharePDrive();
     MessageBox.Show("Drive " + TC_Data_File.tCryptDriveLetter + " is mounted and shared as " + TC_Data_File.shareName + "\rIf on a network the Workstations can be started now",thisProg.mbCaption,MessageBoxButtons.OK,MessageBoxIcon.Information);
 }
Esempio n. 4
0
        static void Main()
        {
            ProgramData    thisProg   = new ProgramData();
            TrueCryptSWObj tcSoftware = new TrueCryptSWObj(thisProg);
            TC_Data_File   tcData     = new TC_Data_File(thisProg, tcSoftware);

            tcData.OpenTcFile();
            tcData.PDrivePerms();
            tcData.SharePDrive();
            MessageBox.Show("Drive " + TC_Data_File.tCryptDriveLetter + " is mounted and shared as " + TC_Data_File.shareName + "\rIf on a network the Workstations can be started now", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
        }
Esempio n. 5
0
 static void Main()
 {
     #if Log
     Log tcFileResizerLog = new Log(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\TA Utility 4TC TY11.log");
     #endif
     ProgramData thisProg = new ProgramData();
     TrueCryptSWObj tcSoftware = new TrueCryptSWObj(thisProg);
     WMI_Mine.ServerShareConn(thisProg); //does the warning about sessions
     WMI_Mine.DropConn4Share(TC_Data_FileStop.shareName, TC_Data_FileStop.shareNameLegacy);//drop connections to P drive
     TC_Data_FileStop tcFile = new TC_Data_FileStop(thisProg, tcSoftware);
     tcFile.DeleteShares();
     tcFile.CloseTcFile(thisProg.drvLetter);
     tcFile.CleanUp();
 }
        internal void OpenTcFile(TrueCryptSWObj tcSwObj, ProgramData thisProg)
        {
            Process tcproc = new Process();

            tcproc.StartInfo.FileName  = tcSwObj.tcProgramFQN;
            tcproc.StartInfo.Arguments = " /q /v " + path + " /l" + tCryptDriveName;
            try
            {
                tcproc.Start();
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception on starting TrueCrypt \r\n" + e.ToString(), thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
            tcproc.WaitForExit();
            if (tcproc.ExitCode != 0)
            {
                MessageBox.Show("Drive Opening failed in some way, Exiting", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
        }
Esempio n. 7
0
 public TC_Data_FileStop(ProgramData thisProgPass, TrueCryptSWObj tcSWObjPass)
 {
     thisProginst = thisProgPass;
     tcSWobj = tcSWObjPass;
 }
        internal TC_Data_File(ProgramData thisProg, TrueCryptSWObj tcswobjpassed)
        {
            thisProginst = thisProg;
            tcSWobj      = tcswobjpassed;
            if (Directory.Exists(tCryptDriveName))
            {
                CloseTcFile(); //attempt a file close
                if (Directory.Exists(tCryptDriveName))
                {              // test again after trial close
                    MessageBox.Show("The P Drive exists. Please close it and restart this program", thisProginst.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                }
            }
            if (!Environment.GetEnvironmentVariable("HomeDrive").StartsWith(thisProginst.drvLetter, StringComparison.CurrentCultureIgnoreCase) | Environment.OSVersion.Version.Major < 6)
            {//traveler or xp
                tpdataPath = thisProginst.drvLetter + ":\\" + dataFileName;
            }
            else
            {//not traveler, not xp
                tpdataPath = Environment.GetEnvironmentVariable("Public") + "\\" + dataFileName;
            }
            //Find out if we have errors conditions
            // First see if migration registry key is set
            if (thisProginst.removable == false)
            {
                migration = (string)Microsoft.Win32.Registry.GetValue(regKeyName, "TFTAOld", "");
            }
            else
            {
                migration = (string)Microsoft.Win32.Registry.GetValue(regKeyName, "TFTATravOld", "");
            }
            if (migration == "")
            {
                if (File.Exists(tpdataPath))
                {
                    return; //non error path is return here error path below here
                }

                //ERROR PATH BELOW HERE
                #region Deal with Migration errors
                else
                {
                    DialogResult mbResult = MessageBox.Show("The Tax-Aide TrueCypt data file does not exist, Create it?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        StartTAUtility("format"); // go create the file Use Format argument
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
            }
            // below this point have a registry entry when we should not have one means something went wrong in migration
            string migrationS = string.Empty;
            if (migration.Contains(","))
            {                                                          // we have old P & old S
                migrationS = migration.Substring(migration.IndexOf(",") + 1);
                migration  = migration.Remove(migration.IndexOf(",")); // gets the P string
            }
            if (File.Exists(migration))
            {//We have reg entry plus old P
                if (File.Exists(tpdataPath))
                {
                    migrationFileActionForm migForm = new migrationFileActionForm();
                    if (thisProg.removable == true)
                    {//Setup migration form for traveler
                        DriveInfo drv     = new DriveInfo(thisProginst.drvLetter);
                        string    drvName = thisProginst.drvLetter + " (" + drv.VolumeLabel + ") ";
                        migForm.delInitialExplain.Text  = "A TrueCrypt TPDATA file (the P drive) exists on the Traveler Drive\n" + drvName + "In addition an old Traveler TrueCrypt file exists \non the Hard Drive.This looks like a failed migration of user data from \nan old Traveler based Truecrypt file to a new Traveler TrueCrypt file.";
                        migForm.delNewPStartTAutil.Text = "Delete the current traveler TPDATA file, Start the Tax-Aide Utility \nto create a new Traveler TPDATA file and complete the migration \nthat failed. Effectively start the whole process over.";
                        migForm.delOldTCFiles.Text      = "Delete the old Traveler TrueCrypt file, Assumes data migration is \ndone correctly, and the old file is not needed. Warning - it will be \npermanently deleted. Then open the traveler file as the P drive.";
                        migForm.radBtGrpBox.Text       += " for " + drvName;
                    }
                    DialogResult mbResult = migForm.ShowDialog();
                    if (mbResult == DialogResult.OK)
                    {
                        return; // have to simply open p drive ignore state of old stuff
                    }
                    else if (mbResult == DialogResult.Retry)
                    {//Delete new tp File and start over
                        File.Delete(tpdataPath);
                        StartTAUtility("");
                    }
                    else if (mbResult == DialogResult.Yes)
                    {// delete old TC file(s) and open P drive
                        File.Delete(migration);
                        if (migrationS != string.Empty)
                        {
                            File.Delete(migrationS);
                        }
                        DeleteMigrationRegEntries();
                        return;
                    }
                }
                else
                {// have registry entry and old tpdataa no new tpdata
                    DialogResult mbResult = MessageBox.Show("An old TrueCrypt TPDATA file exists, with a migration flag set.\rNo new TrueCrypt TPDATA file exists, the Tax-Aide utility will be started to create a new data file, migration will happen automatically?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        StartTAUtility("");
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
            }
            else
            {// reg entry no old file
                if (File.Exists(tpdataPath))
                {
                    DialogResult mbResult = MessageBox.Show("There is a migration data flag set, but no old TPDATA file, \r\nDelete the Migration Flag?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); //Delete reg entries and return on OK, exit on cancel
                    if (mbResult == DialogResult.OK)
                    {
                        DeleteMigrationRegEntries();
                        return;
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
                else
                {
                    DialogResult mbResult = MessageBox.Show("There is a migration data flag set, but no old TPDATA file, \r\nDelete the Migration Flag?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        DeleteMigrationRegEntries();
                        StartTAUtility("");
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
            }
            #endregion
        }
 internal void OpenTcFile(TrueCryptSWObj tcSwObj,ProgramData thisProg)
 {
     Process tcproc = new Process();
     tcproc.StartInfo.FileName = tcSwObj.tcProgramFQN;
     tcproc.StartInfo.Arguments = " /q /v " + path + " /l" + tCryptDriveName;
     try
     {
         tcproc.Start();
     }
     catch (Exception e)
     {
         MessageBox.Show("Exception on starting TrueCrypt \r\n" + e.ToString(), thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         Environment.Exit(1);
     }
     tcproc.WaitForExit();
     if (tcproc.ExitCode != 0)
     {
         MessageBox.Show("Drive Opening failed in some way, Exiting", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         Environment.Exit(1);
     }
 }
        internal TC_Data_File(ProgramData thisProg,TrueCryptSWObj tcswobjpassed)
        {
            thisProginst = thisProg;
            tcSWobj = tcswobjpassed;
            if (Directory.Exists(tCryptDriveName))
            {
                CloseTcFile(); //attempt a file close
                if (Directory.Exists(tCryptDriveName))
                {// test again after trial close
                    MessageBox.Show("The P Drive exists. Please close it and restart this program", thisProginst.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                }
            }
            if (!Environment.GetEnvironmentVariable("HomeDrive").StartsWith(thisProginst.drvLetter, StringComparison.CurrentCultureIgnoreCase) | Environment.OSVersion.Version.Major < 6)
            {//traveler or xp
                tpdataPath = thisProginst.drvLetter + ":\\" + dataFileName;
            }
            else
            {//not traveler, not xp
                tpdataPath = Environment.GetEnvironmentVariable("Public") + "\\" + dataFileName;
            }
            //Find out if we have errors conditions
            // First see if migration registry key is set
            if (thisProginst.removable == false)
            {
                migration = (string)Microsoft.Win32.Registry.GetValue(regKeyName, "TFTAOld", "");
            }
            else
            {
                migration = (string)Microsoft.Win32.Registry.GetValue(regKeyName, "TFTATravOld", "");
            }
            if (migration == "")
            {
                if (File.Exists(tpdataPath))
                {
                    return; //non error path is return here error path below here
                }

            //ERROR PATH BELOW HERE
            #region Deal with Migration errors
                        else
                {
                    DialogResult mbResult = MessageBox.Show("The Tax-Aide TrueCypt data file does not exist, Create it?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        StartTAUtility("format"); // go create the file Use Format argument
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
            }
            // below this point have a registry entry when we should not have one means something went wrong in migration
            string migrationS = string.Empty;
            if (migration.Contains(","))
            {// we have old P & old S
                migrationS = migration.Substring(migration.IndexOf(",") + 1);
                migration = migration.Remove(migration.IndexOf(",")); // gets the P string
            }
            if (File.Exists(migration))
            {//We have reg entry plus old P
                if (File.Exists(tpdataPath))
                {
                    migrationFileActionForm migForm = new migrationFileActionForm();
                    if (thisProg.removable == true)
                    {//Setup migration form for traveler
                        DriveInfo drv = new DriveInfo(thisProginst.drvLetter);
                        string drvName = thisProginst.drvLetter + " (" + drv.VolumeLabel + ") ";
                        migForm.delInitialExplain.Text = "A TrueCrypt TPDATA file (the P drive) exists on the Traveler Drive\n" + drvName + "In addition an old Traveler TrueCrypt file exists \non the Hard Drive.This looks like a failed migration of user data from \nan old Traveler based Truecrypt file to a new Traveler TrueCrypt file.";
                        migForm.delNewPStartTAutil.Text = "Delete the current traveler TPDATA file, Start the Tax-Aide Utility \nto create a new Traveler TPDATA file and complete the migration \nthat failed. Effectively start the whole process over.";
                        migForm.delOldTCFiles.Text = "Delete the old Traveler TrueCrypt file, Assumes data migration is \ndone correctly, and the old file is not needed. Warning - it will be \npermanently deleted. Then open the traveler file as the P drive.";
                        migForm.radBtGrpBox.Text += " for " + drvName;
                    }
                    DialogResult mbResult = migForm.ShowDialog();
                    if (mbResult == DialogResult.OK)
                        return; // have to simply open p drive ignore state of old stuff
                    else if (mbResult == DialogResult.Retry)
                    {//Delete new tp File and start over
                        File.Delete(tpdataPath);
                        StartTAUtility("");
                    }
                    else if (mbResult == DialogResult.Yes)
                    {// delete old TC file(s) and open P drive
                        File.Delete(migration);
                        if (migrationS != string.Empty)
                            File.Delete(migrationS);
                        DeleteMigrationRegEntries();
                        return;
                    }
                }
                else
                {// have registry entry and old tpdataa no new tpdata
                    DialogResult mbResult = MessageBox.Show("An old TrueCrypt TPDATA file exists, with a migration flag set.\rNo new TrueCrypt TPDATA file exists, the Tax-Aide utility will be started to create a new data file, migration will happen automatically?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        StartTAUtility("");
                    }
                    else
                    {
                        Environment.Exit(1);
                    }
                }
            }
            else
            {// reg entry no old file
                if (File.Exists(tpdataPath))
                {
                    DialogResult mbResult = MessageBox.Show("There is a migration data flag set, but no old TPDATA file, \r\nDelete the Migration Flag?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); //Delete reg entries and return on OK, exit on cancel
                    if (mbResult == DialogResult.OK)
                    {
                        DeleteMigrationRegEntries();
                        return;
                    }
                    else
                        Environment.Exit(1);
                }
                else
                {
                    DialogResult mbResult = MessageBox.Show("There is a migration data flag set, but no old TPDATA file, \r\nDelete the Migration Flag?", thisProginst.mbCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    if (mbResult == DialogResult.OK)
                    {
                        DeleteMigrationRegEntries();
                        StartTAUtility("");
                    }
                    else
                        Environment.Exit(1);
                }
            }
            #endregion
        }