// * // // Invalidate a drive letter (it is no longer valid) // public static BooleanResult InvalidateDrive(string drive) { // Loop through all drives looking for ones matching input RegistryKey OurKey = Registry.CurrentUser; OurKey = OurKey.OpenSubKey(@"Software\Keenou\drives"); if (OurKey != null) { foreach (string Keyname in OurKey.GetSubKeyNames()) { RegistryKey key = OurKey.OpenSubKey(Keyname); if (key.GetValue("encDrive") != null && key.GetValue("encDrive").ToString().ToLower() == drive.ToLower()) { // Found a match! Invalidate it string guid = Keyname.ToString(); Registry.SetValue(Config.CURR_USR_REG_DRIVE_ROOT + guid, "encDrive", string.Empty); } } } return(new BooleanResult() { Success = true }); }
/// <summary> /// Doesnt work /// </summary> /// <returns></returns> static string GetPythonPath() { RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Installer\Assemblies"); string regfilepath = ""; if (key != null) // Make sure there are Assemblies { foreach (string Keyname in key.GetSubKeyNames()) { if (Keyname.IndexOf("python.exe") > 0) { regfilepath = Keyname.Replace('|', '\\'); return(regfilepath); } } } return(null); }
private void b_cloudAction_Click(object sender, EventArgs e) { // Determine which type of cloud service they want to perform action on Config.Clouds cloudSelected; if (rb_cloud_Google.Checked) { cloudSelected = Config.Clouds.GoogleDrive; } else if (rb_cloud_OneDrive.Checked) { cloudSelected = Config.Clouds.OneDrive; } else if (rb_cloud_Dropbox.Checked) { cloudSelected = Config.Clouds.Dropbox; } else { ReportEncryptCloudError(new BooleanResult() { Success = false, Message = "ERROR: Unsupported cloud type selected!" }); return; } // * // // Figure out where the cloud's folder is on this computer // string cloudPath = EncryptFS.GetCloudServicePath(cloudSelected); if (cloudPath == null) { ReportEncryptCloudError(new BooleanResult() { Success = false, Message = "ERROR: Cannot determine the location of your cloud service!" }); return; } // * // // Find guid of desired cloud folder // string guid = null; RegistryKey OurKey = Registry.CurrentUser; OurKey = OurKey.OpenSubKey(@"Software\Keenou\drives"); if (OurKey != null) { foreach (string Keyname in OurKey.GetSubKeyNames()) { RegistryKey key = OurKey.OpenSubKey(Keyname); if (key.GetValue("encContainerLoc") != null && key.GetValue("encContainerLoc").ToString() == cloudPath) { guid = Keyname.ToString(); } } } // * // // Helper result object BooleanResult res = null; // If there is no registered guid yet, then it's the first time (set up) // if (guid == null) { res = this.encryptCloud(cloudSelected, cloudPath); if (res == null || !res.Success) { ReportEncryptCloudError(res); return; } return; } // * // // Check to see if it is mounted // Dictionary <string, string> mounts = EncryptFS.GetAllMountedEncFS(); if (mounts == null) { ReportEncryptCloudError(new BooleanResult() { Success = false, Message = "ERROR: Cannot figure out which EncFS instances are mounted!" }); return; } if (mounts.ContainsKey(guid)) { // already mounted -- unmount res = this.unmountCloud(guid); if (res == null || !res.Success) { ReportEncryptCloudError(res); return; } return; } else { // not yet mounted -- mount res = this.mountCloud(guid, cloudSelected, cloudPath); if (res == null || !res.Success) { ReportEncryptCloudError(res); return; } return; } // * // // We should never make it to here }
public virtual void Init(KeynameMatchResult matchRequirement, Keyname keyname) { Init(matchRequirement); RequestedKeynames.Add(keyname); }
// Return a list of all EncFS instances that are currently mounted // public static Dictionary <string, string> GetAllMountedEncFS(string filter = null) { Dictionary <string, string> ret = new Dictionary <string, string>(); try { using (ManagementClass diskClass = new ManagementClass("Win32_LogicalDisk")) { using (ManagementObjectCollection mocDisks = diskClass.GetInstances()) { // Loop through all of the logical disks foreach (ManagementObject moDisk in mocDisks) { string drive = null, guid = null; // Determine the drive letter string driveRaw = moDisk.GetPropertyValue("DeviceID").ToString(); if (driveRaw == null || driveRaw.Length != 2 || !driveRaw.EndsWith(":")) { continue; } drive = driveRaw.Substring(0, 1); // Skip if this isn't the one they want (if specified) if (filter != null && drive.ToLower() != filter.ToLower()) { continue; } // If this is not an EncFS mount, skip it string fs = (moDisk.GetPropertyValue("FileSystem") ?? string.Empty).ToString(); if (!fs.ToLower().Contains("encfs")) { continue; } // Loop through all saved EncFS drives looking for ones matching this one RegistryKey OurKey = Registry.CurrentUser; OurKey = OurKey.OpenSubKey(@"Software\Keenou\drives"); if (OurKey != null) { foreach (string Keyname in OurKey.GetSubKeyNames()) { RegistryKey key = OurKey.OpenSubKey(Keyname); if (key.GetValue("encDrive") != null && key.GetValue("encDrive").ToString().ToLower() == drive.ToLower()) { // Found a match guid = Keyname.ToString(); break; } } } // TODO: above code can be streamlined in future instead of scanning registry each time // Save this result if it is valid // If guid is null, it might be an EncFS not managed by Keenou if (guid != null) { ret.Add(guid, drive); } // If filter was given, we've matched it (so stop!) if (filter != null) { break; } } } } } catch (Exception) { return(null); } return(ret); }
public override string ToString() { this.Init__jsonIgnore(); string json = string.Concat( __jsonIgnore.ContainsKey("Id") ? string.Empty : string.Format(", Id : {0}", Id == null ? "null" : Id.ToString()), __jsonIgnore.ContainsKey("Create_time") ? string.Empty : string.Format(", Create_time : {0}", Create_time == null ? "null" : Create_time.Value.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds.ToString()), __jsonIgnore.ContainsKey("Keyname") ? string.Empty : string.Format(", Keyname : {0}", Keyname == null ? "null" : string.Format("'{0}'", Keyname.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), __jsonIgnore.ContainsKey("Name") ? string.Empty : string.Format(", Name : {0}", Name == null ? "null" : string.Format("'{0}'", Name.Replace("\\", "\\\\").Replace("\r\n", "\\r\\n").Replace("'", "\\'"))), " }"); return(string.Concat("{", json.Substring(1))); }