public void OnKeyPrompt(KeyPromptForm keyPromptForm) { if (keyPromptForm.SecureDesktopMode) { return; } if (!Settings.Instance.Enabled) { return; } CompositeKey compositeKey; if (ExtractCompositeKey(GetDbPath(keyPromptForm), out compositeKey)) { SetCompositeKey(keyPromptForm, compositeKey); // Remove flushing keyPromptForm.Visible = false; keyPromptForm.Opacity = 0; keyPromptForm.DialogResult = DialogResult.OK; keyPromptForm.Close(); } }
/// <summary> /// Closes the KeyPromptForm with a specific result (Equivalent to click the specific button) /// </summary> /// <param name="keyPromptForm">KeyPromptForm to close.</param> /// <param name="result">Result to close the form with.</param> internal static void CloseFormWithResult(KeyPromptForm keyPromptForm, DialogResult result) { // Remove flushing keyPromptForm.Visible = false; keyPromptForm.Opacity = 0; keyPromptForm.DialogResult = result; keyPromptForm.Close(); }
/// <summary> /// Unlocks the database using KeyPromptForm /// </summary> internal static void Unlock(KeyPromptForm keyPromptForm, CompositeKey compositeKey) { try { var fieldInfo = keyPromptForm.GetType().GetField("m_pKey", BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo != null) { fieldInfo.SetValue(keyPromptForm, compositeKey); } //keyPromptForm.Visible = false; //keyPromptForm.Opacity = 1; keyPromptForm.DialogResult = DialogResult.OK; keyPromptForm.Close(); } catch (Exception) { } }
private void Restart() { PluginDebug.AddInfo("Restart started", DebugPrint); if (m_kpf != null) { PluginDebug.AddInfo("Closing KeyPromptForm", 0, DebugPrint); m_kpf.DialogResult = DialogResult.Cancel; if (m_kpf != null) { m_kpf.Close(); } if (m_kpf != null) { m_kpf.Dispose(); } Application.DoEvents(); if (m_kpf != null) { GlobalWindowManager.RemoveWindow(m_kpf); } } if (m_slUpdateCheck != null) { PluginDebug.AddInfo("Closing update check progress form", 0, DebugPrint); m_slUpdateCheck.EndLogging(); } if (MonoWorkarounds.IsRequired(620618)) { MethodInfo miSetEnabled = typeof(MonoWorkarounds).GetMethod("SetEnabled", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (miSetEnabled == null) { PluginDebug.AddError("Could not locate MonoWorkarounds.SetEnabled", 0); } else { miSetEnabled.Invoke(null, new object[] { "620618", false }); } if (MonoWorkarounds.IsRequired(620618)) { PluginDebug.AddError("Could not disable MonoWorkaround 620618"); } else { PluginDebug.AddSuccess("Disabled MonoWorkaround 620618"); } } else { PluginDebug.AddSuccess("Disabling MonoWorkaround 620618 not required"); } FieldInfo fi = m_host.MainWindow.GetType().GetField("m_bRestart", BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) { PluginDebug.AddInfo("Restart started, m_bRestart found", DebugPrint); RemoveAndBackupFormLoadPostHandlers(); HandleMutex(true); fi.SetValue(m_host.MainWindow, true); m_host.MainWindow.ProcessAppMessage((IntPtr)KeePass.Program.AppMessage.Exit, IntPtr.Zero); HandleMutex(false); } else { PluginDebug.AddError("Restart started, m_bRestart not found" + DebugPrint); } }