Skip to content

Commit

Permalink
Add compatibility to KeeTheme
Browse files Browse the repository at this point in the history
Closes #25
  • Loading branch information
Rookiestyle committed Feb 10, 2024
1 parent 92ba6be commit e57861d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions src/PasswordChangeAssistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ private void PreparePwGenButton(object sender, EventArgs e)

bGenPw.RemoveEventHandlers("Click", oldEventHanderClick);
bGenPw.Click += OnPwGenClick;
bGenPw.Tag = oldEventHanderClick[0].Target;
PluginDebug.AddSuccess("Hooking m_btnGenPw", 0);
}

Expand All @@ -345,22 +344,26 @@ private void OnPwGenClick(object sender, EventArgs e)
return;
}

object myPwGeneratorMenu = bGenPw.Tag;
if (myPwGeneratorMenu == null)
//var mConstructContextMenu = myPwGeneratorMenu.GetType().GetMethod("ConstructContextMenu", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
//KeeTheme might change this, we need to search it using the form as starting point...
var fGenPwForm = bGenPw.FindForm();
var pwGeneratorMenuField = fGenPwForm.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault(x => x.FieldType.Name == "PwGeneratorMenu");
if (pwGeneratorMenuField == null)
{
PluginDebug.AddError("Hooking password profile display", 0, "No PwGeneratorMenu found");
PluginDebug.AddError("Hooking password profile display", 0, "pwGeneratorMenuField not found");
return;
}

var mConstructContextMenu = myPwGeneratorMenu.GetType().GetMethod("ConstructContextMenu", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var mConstructContextMenu = pwGeneratorMenuField.FieldType.GetMethod("ConstructContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
if (mConstructContextMenu == null)
{
PluginDebug.AddError("Hooking password profile display", 0, "Method ConstructContextMenu not found");
return;
}
mConstructContextMenu.Invoke(myPwGeneratorMenu, null);
var pwGeneratorMenu = pwGeneratorMenuField.GetValue(fGenPwForm);
mConstructContextMenu.Invoke(pwGeneratorMenu, null);

ContextMenuStrip ctx = Tools.GetField("m_ctx", myPwGeneratorMenu) as ContextMenuStrip;
var contextMenuField = pwGeneratorMenuField.FieldType.GetField("m_ctx", BindingFlags.Instance | BindingFlags.NonPublic);
var ctx = contextMenuField.GetValue(pwGeneratorMenu) as ContextMenuStrip;
if (ctx == null)
{
PluginDebug.AddError("Hooking password profile display", 0, "Context menu not found");
Expand Down
6 changes: 3 additions & 3 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("rookiestyle")]
[assembly: AssemblyProduct("KeePass Plugin")]
[assembly: AssemblyCopyright("Copyright 2021-2023")]
[assembly: AssemblyCopyright("Copyright 2021-2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
Expand All @@ -24,6 +24,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.16.1")]
[assembly: AssemblyFileVersion("2.16.1")]
[assembly: AssemblyVersion("2.16.2")]
[assembly: AssemblyFileVersion("2.16.2")]
[assembly: Guid("5d5cc62b-d6f6-4e0b-a7ff-3d5ef21dd656")]
2 changes: 1 addition & 1 deletion version.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:
PasswordChangeAssistant:2.16.1
PasswordChangeAssistant:2.16.2
PasswordChangeAssistant!de:11
PasswordChangeAssistant!it:3
PasswordChangeAssistant!pt:9
Expand Down

0 comments on commit e57861d

Please sign in to comment.