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, 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. 3
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();
 }
Esempio n. 4
0
 public static void ServerShareConn(ProgramData thisProg)
 {
     string messBoxStr1 = " Sessions from other computers to the shared drives still exist\r\n";
     string messBoxStr2 = " Session from another computer to the shared drives still exists\r\n";
     string messBoxStr3 = "This likely means that workstations are still powered on\r\nIf everyone is logged out of Taxwise continuing will do no harm\r\n\r\nDo you want to continue anyway?";
     StringBuilder messBoxStr = new StringBuilder();
     int conn = 0;
     try
     {
         ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_ConnectionShare");
         ManagementObjectCollection connShares = searcher.Get();
         foreach (ManagementObject queryObj in searcher.Get())
         {
             if (queryObj.GetPropertyValue("Antecedent").ToString().Contains(TC_Data_FileStop.shareName))
             {
                 string str = queryObj.GetPropertyValue("Dependent").ToString();
                 messBoxStr.AppendLine("Connection to " + TC_Data_FileStop.shareName + " from " + str.Substring(str.IndexOf("ComputerName"),str.IndexOf("ShareName")-str.IndexOf("ComputerName")));
                 conn++;
             }
             if (queryObj.GetPropertyValue("Antecedent").ToString().Contains(TC_Data_FileStop.shareNameLegacy))
             {
                 string str = queryObj.GetPropertyValue("Dependent").ToString();
                 messBoxStr.AppendLine("Connection to " + TC_Data_FileStop.shareNameLegacy + " from " + str.Substring(str.IndexOf("ComputerName"), str.IndexOf("ShareName") - str.IndexOf("ComputerName")));
                 conn++;
             }
         }
         if (conn > 0)
         {
             if (conn == 1)
                 messBoxStr.Append(Environment.NewLine + conn.ToString() + messBoxStr2);
             else
                 messBoxStr.Append(Environment.NewLine + conn.ToString() + messBoxStr1);
             messBoxStr.Append(messBoxStr3);
             DialogResult dr = MessageBox.Show(messBoxStr.ToString(), thisProg.mbCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (dr == DialogResult.No)
                 Environment.Exit(1);
         }
     }
     catch (ManagementException e)
     {
         MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
     }
 }
Esempio n. 5
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
        }
 // initialize all static entries
 public TrueCryptSWObj(ProgramData thisProg)
 {
     tCryptRegEntry = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TrueCryptVolume\Shell\open\command", "", "");
     if (tCryptRegEntry != null)
     {
         tcProgramFQN = tCryptRegEntry.Substring(1, tCryptRegEntry.Length - 10); //registry entry has a leading quote that needs to go
         tcProgramDirectory = tcProgramFQN.Substring(0, tcProgramFQN.Length - 14);
         if (!File.Exists(tcProgramFQN))
         {
             MessageBox.Show("Windows has registry entries for the TrueCrypt Program but no program exists. Please reinstall", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
             Environment.Exit(1);
         }
         if (thisProg.removable == true && string.Compare(FileVersionInfo.GetVersionInfo(tcProgramFQN).FileVersion, tcSetupVersion) < 0)
         {   // we have host version that needs upgrading
             MessageBox.Show("The TrueCrypt software version on this Flash Drive will not work with the version of TrueCrypt on this host system. The Tax-Aide TrueCrypt Utility will be started so that the Host's TrueCrypt can be upgraded. Then restart this Start Tax-Aide drive program", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
             try
             {
                 Process proc = Process.Start(thisProg.drvLetter + ":\\" + travDir + TAtcSetupProgramName);
                 Environment.Exit(1);
             }
             catch (Exception e)
             {
                 MessageBox.Show("Exception on starting Tax-Aide TrueCrypt Utility\r\n" + e.ToString(), thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         if (thisProg.removable == true)
         {
             tcProgramFQN = thisProg.drvLetter + ":\\" + travDir + tcProgramName;
             tcProgramDirectory = thisProg.drvLetter + ":\\" + travDir;
             if (!File.Exists(tcProgramFQN))
             {
                 MessageBox.Show("The TrueCrypt Program does not exist on the Traveler drive. Please reinistall" + "\r" + tcProgramFQN, thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 Environment.Exit(1);
             }
         }
         else
         {
             MessageBox.Show("The TrueCrypt program does not exist. Please run the Tax-Aide TrueCrypt Installer", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
             Environment.Exit(1);
         }
     }
     if (thisProg.removable == true)
     {
         string tempFolder = Environment.GetEnvironmentVariable("temp");
         File.Copy(thisProg.scriptExePath + stopTravDrv, tempFolder + stopTravDrv, true);
         File.Copy(thisProg.scriptExePath + "\\decryption.ico", tempFolder + "\\decryption.ico", true);
         ShellLink desktopShortcut = new ShellLink();
         desktopShortcut.ShortCutFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\Stop Traveler.lnk";
         desktopShortcut.Target = tempFolder + stopTravDrv;
         desktopShortcut.IconPath = tempFolder + "\\" + "decryption.ico";
         desktopShortcut.Save();
         desktopShortcut.Dispose();
     }
 }
 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)
 {
     if (Directory.Exists(tCryptDriveName + ":\\"))
     {
         MessageBox.Show("The P Drive exists. Please close it and restart this program", thisProg.mbCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         Environment.Exit(1);
     }
     if (!Environment.GetEnvironmentVariable("SystemDrive").StartsWith(thisProg.drvLetter, StringComparison.CurrentCultureIgnoreCase) | Environment.OSVersion.Version.Major < 6)
     {
         path = thisProg.drvLetter + ":\\" + dataFileName;
     }
     else
     {
         path = Environment.GetEnvironmentVariable("Public") + "\\" + dataFileName;
     }
     if (!File.Exists(path))
     {
         MessageBox.Show("we have a problem no tpdatafile exists on " + path);
         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
        }