<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[First menu item unexpectedly being called on startup]]></title><description><![CDATA[<p dir="auto">I’ve been playing around with <a href="https://github.com/deadem/notepad-pp-linter" rel="nofollow ugc">https://github.com/deadem/notepad-pp-linter</a> and discovered something odd has started happening (using notepad++ 8.5.6).</p>
<p dir="auto">When I start notepad++ it behaves as though I’ve clicked the first menu entry for the plugin (which calls editConfig here <a href="https://github.com/deadem/notepad-pp-linter/blob/49586fd72d54bd068fc5e8b0d085b6bac360c3e1/plugin.cpp#L93" rel="nofollow ugc">https://github.com/deadem/notepad-pp-linter/blob/49586fd72d54bd068fc5e8b0d085b6bac360c3e1/plugin.cpp#L93</a> which opens the configuration file).</p>
<p dir="auto">I have experimented a bit. It is ONLY the first menu entry - if I add a second one, it doesn’t get called. If I swap the order, the new first one gets called, and the 2nd one (editConfig) doesn’t get called.</p>
<p dir="auto">Is this something that started in 8.5.6? Or is there some variable that I’m not initialising properly and is therefore doing different things at different times? Or A.N.Other thing?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24927/first-menu-item-unexpectedly-being-called-on-startup</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 16:28:10 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24927.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 16 Sep 2023 17:41:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sun, 24 Sep 2023 07:10:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a> it’s not so much the ability to break/abuse it, it’s the fact that there is a correlation between the order of entries in your plugin menu and the docking dialogue(s) you can open from your plugin.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89458</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89458</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Sun, 24 Sep 2023 07:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sun, 24 Sep 2023 05:19:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thosrtanner" aria-label="Profile: ThosRTanner">@<bdi>ThosRTanner</bdi></a> said in <a href="/post/89447">First menu item unexpectedly being called on startup</a>:</p>
<blockquote>
<p dir="auto">One of those things that should really be in the ‘how to write your own plugin’ documentation  or the C++ template doc</p>
</blockquote>
<p dir="auto">That would be appropriate — if what I described was a deliberate design. My impression is that it’s just an accident of a short-sighted implementation. This may be the first time anyone has ever looked into it. Fortunately it’s no more exploitable than dropping a comprised DLL into the load path (a precondition to making it work). Otherwise it would be irresponsible to publicly document it.</p>
<p dir="auto">Even the supposed benefit of relaunching dialogs with saved co-ordinates is questionable, given how many times the “Folder as Workspace” or “Find” dialog seems to go missing because the dimensions became negative through naïve rounding or integer overflow:</p>
<ul>
<li><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13084" rel="nofollow ugc">[Feature request] Solution to the “lost panel” problem</a></li>
<li><a href="https://community.notepad-plus-plus.org/post/78924">not able to see the search results windows in notepad++</a></li>
</ul>
]]></description><link>https://community.notepad-plus-plus.org/post/89457</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89457</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Sun, 24 Sep 2023 05:19:41 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sat, 23 Sep 2023 07:40:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a> Thanks. That’s helpful to have confirmed. One of those things that should really be in the ‘how to write your own plugin’ documentation  or the C++ template doc</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89447</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89447</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Sat, 23 Sep 2023 07:40:13 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Fri, 22 Sep 2023 21:25:03 GMT]]></title><description><![CDATA[<p dir="auto">On start-up, the data in <code>config.xml</code> is marshaled into an instance of the <code>PluginDlgDockingInfo</code> structure, which is used to recreate any plugin dialog windows that were left open in a previous session. To make the dialogs appear, the application <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/cb1f2d1479895d2a365eb34b79cd4697e00655f3/PowerEditor/src/Notepad_plus.cpp#L838-L844" rel="nofollow ugc">executes the associated function</a>, which is looked up by a numeric index that is parsed from the <code>id</code> attribute of the XML node at <code>/NotepadPlus/GUIConfigs/GUIConfig[@name="DockingManager"]/PluginDlg[@pluginName="PLUGIN_MODULE_NAME.dll"]</code>:</p>
<pre><code class="language-cpp">  if (pdi._isVisible &amp;&amp; showPanel)
  {
    if (isInternalFunc)
      _internalFuncIDs.push_back(pdi._internalID);
    else
      _pluginsManager.runPluginCommand(pdi._name.c_str(), pdi._internalID);
  }
</code></pre>
<p dir="auto">If <code>pdi._name</code> refers to <em>any</em> real module in the load path, and <code>pdi._internalID</code> is <em>any</em> real index defined in the plugin source code, the function will execute, as long as the <code>isVisible</code> attribute is <code>"yes"</code> in <code>config.xml</code>. This also means that a crafted <code>config.xml</code> can make Notepad++ execute potentially any plugin function at start-up. Keep in mind that the plugin must be already in the load path, and the menu ID of the plugin function must be valid and known beforehand.</p>
<p dir="auto"><strong>Proof of Concept</strong></p>
<ol>
<li>Build a simple plugin from this code:</li>
</ol>
<pre><code class="language-cpp">#define UNICODE
#include &lt;windows.h&gt;

#define PLUGIN_CMD_ID 0ULL
#define NB_PLUGIN_FUNCS 1ULL
#define MENU_TITLE_LENGTH 64ULL
#define PLUGIN_FUNC extern "C" __declspec(dllexport)

typedef void(__cdecl *PFUNCPLUGINCMD)(void);

struct NppData {
  HWND _nppHandle = nullptr;
  HWND _scintillaMainHandle = nullptr;
  HWND _scintillaSecondHandle = nullptr;
};

struct ShortcutKey {
  bool _isCtrl = false;
  bool _isAlt = false;
  bool _isShift = false;
  UCHAR _key = 0;
};

struct FuncItem {
  TCHAR _itemName[MENU_TITLE_LENGTH] = { 0 };
  PFUNCPLUGINCMD _pFunc = nullptr;
  int _cmdID = 0;
  bool _init2Check = false;
  ShortcutKey *_pShKey = nullptr;
};

static FuncItem funcItem[NB_PLUGIN_FUNCS];
static NppData nppData;

void surprise(void) {
  ::MessageBoxW(nppData._nppHandle, L"Surprise!", L"Message from PoC Plugin", MB_OK);
}
PLUGIN_FUNC void setInfo(NppData data) {
  nppData = data;
  lstrcpy(funcItem[PLUGIN_CMD_ID]._itemName, L"Surprise me!");
  funcItem[PLUGIN_CMD_ID]._pFunc = surprise;
  funcItem[PLUGIN_CMD_ID]._init2Check = false;
  funcItem[PLUGIN_CMD_ID]._pShKey = nullptr;
}
PLUGIN_FUNC FuncItem *getFuncsArray(int *nbF) {
  *nbF = (int)NB_PLUGIN_FUNCS;
  return funcItem;
}
PLUGIN_FUNC const TCHAR *getName(void) { return L"PoC Npp Plugin"; }
PLUGIN_FUNC LRESULT messageProc(UINT /*na*/, WPARAM /*na*/, LPARAM /*na*/) { return 0; }
PLUGIN_FUNC BOOL isUnicode(void) { return TRUE; }
PLUGIN_FUNC void beNotified(void *) {}
BOOL APIENTRY DllMain(HANDLE /*na*/, DWORD /*na*/, LPVOID /*na*/) { return TRUE; }
</code></pre>
<ol start="2">
<li>
<p dir="auto">Save the compiled module as <code>poc_plugin.dll</code> and copy it to the correct plugin path for the given N++ installation.</p>
</li>
<li>
<p dir="auto">Open the correct <code>config.xml</code> configuration file for the given N++ installation.</p>
</li>
<li>
<p dir="auto">Edit <code>config.xml</code> by creating the following node under the path <code>/NotepadPlus/GUIConfigs/GUIConfig[@name="DockingManager"]</code>:</p>
</li>
</ol>
<pre><code class="language-xml">&lt;GUIConfig name="DockingManager" leftWidth="200" rightWidth="200" topHeight="200" bottomHeight="200"&gt;
    &lt;PluginDlg pluginName="poc_plugin.dll" id="0" curr="1" prev="-1" isVisible="yes" /&gt;
    &lt;!-- . . . --&gt;
&lt;/GUIConfig&gt;
</code></pre>
<p dir="auto">When Notepad++ starts, the <code>surprise()</code> function will display a message box. This works in any N++ version, including 8.5.7.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89445</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89445</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Fri, 22 Sep 2023 21:25:03 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Fri, 22 Sep 2023 19:22:39 GMT]]></title><description><![CDATA[<p dir="auto">Well, that was enlightening - sort of.</p>
<p dir="auto">I deleted config.xml from the notepad++ appdata directory and everything started working again. Of course. all the settings make everything dreadful. So there’s clearly something in the config that causes this. It’d be nice to know what.</p>
<p dir="auto">Later:</p>
<p dir="auto">It appears to be the result of having created a docking window somehow. I deleted the docking window info in the config file + 3 others (one called dummy, 2 called notepad++ internal) and it’s fine.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89441</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89441</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Fri, 22 Sep 2023 19:22:39 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Fri, 22 Sep 2023 19:05:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/coises" aria-label="Profile: Coises">@<bdi>Coises</bdi></a> i tried removing and then installing via plugins admin and it is still happening for me.but <a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: Thomas-Knoefel">@<bdi>Thomas-Knoefel</bdi></a> seems to have it working as normal from his post earlier.</p>
<p dir="auto">It is very odd. or possibly i have a conflicting plugin. i’d really like to see the call stack explaining where this call is coming from.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89440</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89440</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Fri, 22 Sep 2023 19:05:15 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Fri, 22 Sep 2023 18:42:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thosrtanner" aria-label="Profile: ThosRTanner">@<bdi>ThosRTanner</bdi></a> said in <a href="/post/89438">First menu item unexpectedly being called on startup</a>:</p>
<blockquote>
<p dir="auto">I took latest version of notepad++, built master branch of linter (in debug mode) and get the same problem.</p>
<p dir="auto">The call is definitely from notepad++ - not sure where though as I don’t have debug symbols for it.</p>
</blockquote>
<p dir="auto">Forgive me if this is a dumb question, but… does the same thing happen with the release DLL from the repository? (It looks like the latest release is up to date with master, so there <em>should</em> be no difference.)</p>
<p dir="auto">If it happens with the release DLL, it’s probably worth raising an issue in that repository. If it doesn’t, the next thing I’d try is building release mode from source, to see if the problem is specific to debug build.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89439</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89439</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Fri, 22 Sep 2023 18:42:10 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Fri, 22 Sep 2023 17:59:21 GMT]]></title><description><![CDATA[<p dir="auto">I took latest version of notepad++, built master branch of linter (in debug mode) and get the same problem.</p>
<p dir="auto">The call is definitely from notepad++ - not sure where though as I don’t have debug symbols for it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89438</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89438</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Fri, 22 Sep 2023 17:59:21 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sun, 17 Sep 2023 21:14:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thosrtanner" aria-label="Profile: ThosRTanner">@<bdi>ThosRTanner</bdi></a> I’ve tested ‘Linter’ with my N++ installation, and I didn’t experience this issue: no window opened before the main N++ window. I can only offer some suggestions. Have you tried deleting the N++ config.xml?<br />
Additionally, I would suggest updating to the 8.5.7 version.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89310</guid><dc:creator><![CDATA[Thomas Knoefel]]></dc:creator><pubDate>Sun, 17 Sep 2023 21:14:52 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sun, 17 Sep 2023 16:17:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thomas-knoefel" aria-label="Profile: Thomas-Knoefel">@<bdi>Thomas-Knoefel</bdi></a></p>
<p dir="auto">I tried both</p>
<pre><code>setCommand(0, TEXT("&amp;FirstMenuPoint"), firstFunction, NULL, false);
setCommand(1, TEXT("&amp;SecondMenuPoint"), secondFunction, NULL, false);
</code></pre>
<p dir="auto">and</p>
<pre><code>setCommand(0, TEXT("&amp;SecondMenuPoint"), secondFunction, NULL, false);
setCommand(1, TEXT("&amp;FirstMenuPoint"), firstFunction, NULL, false);
</code></pre>
<p dir="auto">In both cases, command entry 0 gets called before notepad++ has displayed any windows</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89305</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89305</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Sun, 17 Sep 2023 16:17:58 GMT</pubDate></item><item><title><![CDATA[Reply to First menu item unexpectedly being called on startup on Sun, 17 Sep 2023 09:57:11 GMT]]></title><description><![CDATA[<p dir="auto">Can you show us the code for how you add the second menu entry? In the code you provided, only one entry is visible.</p>
<p dir="auto">I assume you add the second menu entry like this with 1:</p>
<pre><code>setCommand(0, TEXT("&amp;FirstMenuPoint"), firstFunction, NULL, false);
setCommand(1, TEXT("&amp;SecondMenuPoint"), secondFunction, NULL, false);
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/89295</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89295</guid><dc:creator><![CDATA[Thomas Knoefel]]></dc:creator><pubDate>Sun, 17 Sep 2023 09:57:11 GMT</pubDate></item></channel></rss>