Logout

Alt-N Discussion Groups > Discussions > Creating a Plugin using .NET

 [F] Alt-N Discussion Groups  / Discussions  /

Creating a Plugin using .NET

[Pohlmann, Charl]
Charl Pohlmann
Newbie
Newbie
Posts: 7
Charl Pohlmann - 07:12am, May 10 2019

Good day,

I have managed to create a working (sort off) plugin using VB.NET. This was done by using a tool (a href='https://darinhiggins.com/2011/10/10/exposing-c-style-entry-points-in-a-net-assembly-revisited/' target='DLLExportVB')(/a) to create the C style exported functions. The image attached shows the Plugin loading, and also that the PreMessageFuncName works. The problem that I am having, is that no matter what I do, I cannot get any of the SMTP functions to even be called by MDaemon, yet the function signatures for the SMTP function and the Pre/PostMessageFuncName functions are exactly the same. I can even show a dialog when the ConfigFuncName function is called.

I have attached the complete .NET project for both the DLLExportVB tool as well as the project for the Plugin. Dependency Walker can be used to verify that the entry points for the exported functions do indeed exist in both MDaemonPluginVBx64.dll and MDaemonPluginVBx86.dll

The MDaemonPluginVB project contains a batch file in it's root that can be used to recreate the dlls after the project has been recompiled.

The zip file also contains the Plugins.dat that I used.

I would really appreciate it if somebody can shed some light onto why the Pre/Post functions will work but not the SMTP or even Domain/MultiPop functions, when all of their signatures are identical.

Attachments:

Capture.PNG (26 KB)

 

MDaemonPlugin.zip (162 KB)


  All MessagesOldest ItemsOlder ItemsNewer ItemsNewest Items

Charl Pohlmann - May 23, 2019 6:35 am (#1 Total: 4)  

 

Photo of Author
Charl Pohlmann
Newbie
Newbie
Posts: 7
OK, I solved the problem, and I thought I would post the solution here in case somebody else runs into the same issue.
I would also like to point out that I had zero support from anybody at Alt-N, even after requesting support. I was simply pointed back to my own post here and told that Alt-N developers are constantly monitoring this forum, and will provide support here. Well, nothing was forthcoming, and I still have not had a single reply from any developer at Alt-N.

Anyway, so the only shred of information that is available to try and figure out how plugins work, is the Plugins.txt file which can be found at C:/MDaemon/Docs/API and which was last updated on February 15, 2018.

Setting InlineFuncUsesPluginLog, which is setting number 19 in the text file, is explained as follows:
"This switch controls whether the data logged in the SMTP log due to calling your SMTPMessageFuncName function will be copied to the Plug-in log as well as the SMTP log. MDaemon doesn't read this value directly. Your plug-in should read this and pass it as the WPARAM value when sending log data to the HWnd passed to SMTPMessageFuncName."

No explanation is given as to WHAT value must actually be passed in WPARAM. Also, the explanation gives the impression that if the setting is NOT passed in the WPARAM field, then any message will be logged to the SMTP log ONLY, and will only log to the plugins log if the setting is passed. The problem is that the messages are neither logged to the SMTP nor the PLUGINS logs. I have not tested this yet, but I suspect that if the setting value is passed (still need to figure out what exactly must be passed in WPARAM) then the messages are logged to both the SMTP and PLUGIN logs, but when the setting value is not passed, then messages are not logged at all. This contradicts the part that reads "This switch controls whether the data logged in the SMTP log due to calling your SMTPMessageFuncName function will be copied to the Plug-in log AS WELL AS the SMTP log."

Anyhow, I ended up using LOG4NET to log all the messages to a seperate log file, and low and behold, the SMTP functions are actually being called, but MDaemon is simply just ignoring the messages passed back to it.

From the LOG4NET log file I got:

2019-05-23 11:13:47,165 INFO [(null)] - * L54 URL Filter Plugin starting.

2019-05-23 11:13:47,542 INFO [(null)] - * Initializing log4net PID property.

2019-05-23 11:16:18,720 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:18,806 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc2 [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:18,808 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc3 [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:23,246 INFO [3396] - L54 URL Filter : L54UrlFilter_PreMessageFunc [C:/MDaemon/Queues/Inbound/md50000000004.msg]

2019-05-23 11:16:23,873 INFO [3396] - L54 URL Filter : L54UrlFilter_PostMessageFunc [c:/mdaemon/queues/local/md35000000008.msg]



And from the PLUGINS.LOG file I got:

START Event Log / MDaemon PRO v19.0.1 trial, Plug-ins log information

-------------------------------------------------------------------------------

Event Time/Date Event Description

-------------------------------------------------------------------------------

Thu 2019-05-23 11:13:43.225: Attempting to load 'L54 URL Filter' plug-in

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::StartupFuncName @000007FEF9B53E56

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::ConfigFuncName @000007FEF9B53DF6

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::ReloadFuncName @000007FEF9B53E62

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::PreMessageFuncName @000007FEF9B53E02

Thu 2

Charl Pohlmann - May 23, 2019 6:41 am (#2 Total: 4)  

 

Photo of Author
Charl Pohlmann
Newbie
Newbie
Posts: 7
And after spending time writing up the previous post, and previewing it, and making sure that everything is readable etc, only half my posting actually shows up, and ins imply truncated half way through.

This forum is therefore utterly useless and I will not waste any more of my time sharing anything here.

Arron.Caruth@mdaemon.com - May 23, 2019 10:52 am (#3 Total: 4)  

Guest User  

Photo of Author
Posts: 1

My apologies Charl, it is my fault you did not receive a response.  I began investigating your post and got side tracked before I responded and then forgot to come back to it. 

 

--
Arron Caruth
Director of Product Development
o: 817-601-3222    e: arron.caruth@mdaemon.com

MDaemon Technologies
Simple Secure Email
Visit us on www.mdaemon.com | Facebook | LinkedIn | YouTube
Sent using the MDaemon Email Server

 

From: discuss@mdaemon.com [mailto:discuss@mdaemon.com] On Behalf Of Charl Pohlmann (lists-discuss@mdaemon.com)
Sent: Thursday, May 23, 2019 6:36 AM
To: discuss List Member <discuss@mdaemon.com>
Subject: [discuss] Creating a Plugin using .NET

 

OK, I solved the problem, and I thought I would post the solution here in case somebody else runs into the same issue.
I would also like to point out that I had zero support from anybody at Alt-N, even after requesting support. I was simply pointed back to my own post here and told that Alt-N developers are constantly monitoring this forum, and will provide support here. Well, nothing was forthcoming, and I still have not had a single reply from any developer at Alt-N.

Anyway, so the only shred of information that is available to try and figure out how plugins work, is the Plugins.txt file which can be found at C:/MDaemon/Docs/API and which was last updated on February 15, 2018.

Setting InlineFuncUsesPluginLog, which is setting number 19 in the text file, is explained as follows:
"This switch controls whether the data logged in the SMTP log due to calling your SMTPMessageFuncName function will be copied to the Plug-in log as well as the SMTP log. MDaemon doesn't read this value directly. Your plug-in should read this and pass it as the WPARAM value when sending log data to the HWnd passed to SMTPMessageFuncName."

No explanation is given as to WHAT value must actually be passed in WPARAM. Also, the explanation gives the impression that if the setting is NOT passed in the WPARAM field, then any message will be logged to the SMTP log ONLY, and will only log to the plugins log if the setting is passed. The problem is that the messages are neither logged to the SMTP nor the PLUGINS logs. I have not tested this yet, but I suspect that if the setting value is passed (still need to figure out what exactly must be passed in WPARAM) then the messages are logged to both the SMTP and PLUGIN logs, but when the setting value is not passed, then messages are not logged at all. This contradicts the part that reads "This switch controls whether the data logged in the SMTP log due to calling your SMTPMessageFuncName function will be copied to the Plug-in log AS WELL AS the SMTP log."

Anyhow, I ended up using LOG4NET to log all the messages to a seperate log file, and low and behold, the SMTP functions are actually being called, but MDaemon is simply just ignoring the messages passed back to it.

From the LOG4NET log file I got:

2019-05-23 11:13:47,165 INFO [(null)] - * L54 URL Filter Plugin starting.

2019-05-23 11:13:47,542 INFO [(null)] - * Initializing log4net PID property.

2019-05-23 11:16:18,720 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:18,806 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc2 [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:18,808 INFO [3396] - L54 URL Filter : L54UrlFilter_SMTPMessageFunc3 [c:/mdaemon/queues/temp/md50000000002.tmp]

2019-05-23 11:16:23,246 INFO [3396] - L54 URL Filter : L54UrlFilter_PreMessageFunc [C:/MDaemon/Queues/Inbound/md50000000004.msg]

2019-05-23 11:16:23,873 INFO [3396] - L54 URL Filter : L54UrlFilter_PostMessageFunc [c:/mdaemon/queues/local/md35000000008.msg]



And from the PLUGINS.LOG file I got:

START Event Log / MDaemon PRO v19.0.1 trial, Plug-ins log information

-------------------------------------------------------------------------------

Event Time/Date Event Description

-------------------------------------------------------------------------------

Thu 2019-05-23 11:13:43.225: Attempting to load 'L54 URL Filter' plug-in

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::StartupFuncName @000007FEF9B53E56

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::ConfigFuncName @000007FEF9B53DF6

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::ReloadFuncName @000007FEF9B53E62

Thu 2019-05-23 11:13:43.225: * L54 URL Filter::PreMessageFuncName @000007FEF9B53E02

Thu 2


View/reply at Creating a Plugin using .NET

 
 
--DISCUSS--------------------------------------------------------------
This mailing list is for questions and discussion regarding Alt-N
products.  To unsubscribe from this mailing list send an email to
discuss-unsubscribe@mdaemon.com .
--DISCUSS--------------------------------------------------------------
 
 
-----------------------------------------------------------------------
These forums are provided by MDaemon Technologies for user-to-user 
support and discussion.  MDaemon staff members may participate in the 
forums periodically but please recognize that this is not the official
method of receiving technical support. To receive personal technical 
support please use the form here:
http://www.mdaemon.com/Support/RequestSupport/
-----------------------------------------------------------------------

--DISCUSS--------------------------------------------------------------
This mailing list is for questions and discussion regarding Alt-N
products.  To unsubscribe from this mailing list send an email to
discuss-unsubscribe@mdaemon.com .
--DISCUSS--------------------------------------------------------------


-----------------------------------------------------------------------
These forums are provided by MDaemon Technologies for user-to-user
support and discussion.  MDaemon staff members may participate in the
forums periodically but please recognize that this is not the official
method of receiving technical support. To receive personal technical
support please use the form here:
http://www.mdaemon.com/Support/RequestSupport/
-----------------------------------------------------------------------

Arron.Caruth@mdaemon.com - May 24, 2019 7:05 am (#4 Total: 4)  

Guest User  

Photo of Author
Posts: 1

My apologies again for not responding sooner.

 

Just in case you are still following this thread, we reviewed our plugin code along with the documentation for plugins and found a mistake in the documentation.  MDPLUGIN_MSG should be used instead of WM_COPYDATA to pass log data back to MDaemon. 

 

Here is an updated example:

 

void _stdcall PreMessageFunc(HWND Parent, const char* File)

{

       COPYDATASTRUCT Packet;

 

       char Buffer[512];

       _snprintf_s(Buffer, _TRUNCATE, "Now processing: %s", File);

 

       Packet.dwData = MDPLUGIN_DISPLAY;

       Packet.cbData = strlen(Buffer);

       Packet.lpData = Buffer;

 

       SendMessage(Parent, MDPLUGIN_MSG, 0, (LPARAM)(PCOPYDATASTRUCT)&Packet);

 

       // Do some processing on File

 

       strcpy(Buffer, "----------");

       Packet.cbData = strlen(Buffer);

       Packet.lpData = Buffer;

 

       SendMessage(Parent, MDPLUGIN_MSG, 0, (LPARAM)(PCOPYDATASTRUCT)&Packet);

}

 

We also updated the documentation to include details about the WPARAM value (0 or 1) that should be passed for the InlineFuncUsesPluginLog option and optimized some of the plugin code.

 

These changes will be included in MDaemon 19.0.2.
--
Arron Caruth
Director of Product Development
o: 817-601-3222    e: arron.caruth@mdaemon.com

MDaemon Technologies
Simple Secure Email
Visit us on www.mdaemon.com | Facebook | LinkedIn | YouTube
Sent using the MDaemon Email Server

 

From: discuss@mdaemon.com [mailto:discuss@mdaemon.com] On Behalf Of Charl Pohlmann (lists-discuss@mdaemon.com)
Sent: Thursday, May 23, 2019 6:41 AM
To: discuss List Member <discuss@mdaemon.com>
Subject: [discuss] Creating a Plugin using .NET

 

And after spending time writing up the previous post, and previewing it, and making sure that everything is readable etc, only half my posting actually shows up, and ins imply truncated half way through.

This forum is therefore utterly useless and I will not waste any more of my time sharing anything here.


View/reply at Creating a Plugin using .NET

 
 
--DISCUSS--------------------------------------------------------------
This mailing list is for questions and discussion regarding Alt-N
products.  To unsubscribe from this mailing list send an email to
discuss-unsubscribe@mdaemon.com .
--DISCUSS--------------------------------------------------------------
 
 
-----------------------------------------------------------------------
These forums are provided by MDaemon Technologies for user-to-user 
support and discussion.  MDaemon staff members may participate in the 
forums periodically but please recognize that this is not the official
method of receiving technical support. To receive personal technical 
support please use the form here:
http://www.mdaemon.com/Support/RequestSupport/
-----------------------------------------------------------------------

--DISCUSS--------------------------------------------------------------
This mailing list is for questions and discussion regarding Alt-N
products.  To unsubscribe from this mailing list send an email to
discuss-unsubscribe@mdaemon.com .
--DISCUSS--------------------------------------------------------------


-----------------------------------------------------------------------
These forums are provided by MDaemon Technologies for user-to-user
support and discussion.  MDaemon staff members may participate in the
forums periodically but please recognize that this is not the official
method of receiving technical support. To receive personal technical
support please use the form here:
http://www.mdaemon.com/Support/RequestSupport/
-----------------------------------------------------------------------



  All MessagesOldest ItemsOlder ItemsNewer ItemsNewest Items



 Content:

Read New | Search

 Guest:

Email to Admin



You are visiting as a Guest user.