Selaa lähdekoodia

Updated to c++11 and added wxWidgets config dialog

dev
wombat 6 vuotta sitten
vanhempi
commit
cdb9d079b7

+ 184
- 0
SNFMDaemonDLL/configdialog.cpp Näytä tiedosto

@@ -0,0 +1,184 @@
#include "configdialog.h"

//(*InternalHeaders(configdialog)
#include <wx/bitmap.h>
#include <wx/button.h>
#include <wx/font.h>
#include <wx/image.h>
#include <wx/intl.h>
#include <wx/string.h>
//*)

//(*IdInit(configdialog)
const long configdialog::ID_STATICBITMAP1 = wxNewId();
const long configdialog::ID_STATICTEXT2 = wxNewId();
const long configdialog::ID_STATICTEXT3 = wxNewId();
const long configdialog::ID_STATICTEXT1 = wxNewId();
const long configdialog::ID_HYPERLINKCTRL2 = wxNewId();
const long configdialog::ID_HYPERLINKCTRL1 = wxNewId();
//*)

BEGIN_EVENT_TABLE(configdialog,wxDialog)
//(*EventTable(configdialog)
//*)
END_EVENT_TABLE()

bool fileExists(const std::string &fileName) {
return std::ifstream(fileName.c_str()).good();
}

void configdialog::OnQuit(wxCommandEvent& event)
{
Close(TRUE);
}

std::string configdialog::utf8_encode(const std::wstring &wstr)
{
if( wstr.empty() ) return std::string();
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo( size_needed, 0 );
WideCharToMultiByte (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}

std::wstring getSNFFilePath() { // Get the config file path.
std::wstring install_pathW;
HKEY hKey;
WCHAR szBuffer[512];
DWORD dwBufferSize = sizeof(szBuffer);
std::wstring regValue = L"";

if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Alt-N Technologies\\MDaemon", 0, KEY_READ, &hKey)){
if(ERROR_SUCCESS == RegQueryValueEx(hKey, (LPCWSTR) L"AppPath", NULL, NULL, (LPBYTE) &szBuffer, &dwBufferSize)){
RegCloseKey(hKey);
regValue = std::wstring(szBuffer);
std::wstring termCheck;
for(auto val: regValue){
if(val != L'\0'){
termCheck += val;
}
}
if(termCheck.size() == 512){
regValue = L""; // RegValue wasn't null terminated
}
else{
int PathEnd = regValue.length(); // Grab the length.
if(PathEnd > 0) { regValue.erase(PathEnd-1,1); } // Eat the stroke at the end.
PathEnd = regValue.find_last_of(L"\\"); // Find the next stroke in.
int PathLength = regValue.length(); // Grab the path length.
int EraseSpan = PathLength - (PathEnd+1); // Calculate the amount to erase.
regValue.erase(PathEnd+1,EraseSpan); // Erase it to get the root path.
regValue.append(L"SNF\\");
}
}
}
// Return either the empty string or the configuration file path.
return regValue; // Return what we have.
}


configdialog::configdialog(wxWindow* parent,wxWindowID id)
{
install_path = utf8_encode(getSNFFilePath());
wxBitmap logo = wxNullBitmap;
std::string image_loc = install_path + "\\logo.png";
if(fileExists(image_loc)){
logo = wxBitmap(wxImage(image_loc));
}
//(*Initialize(configdialog)
wxFlexGridSizer* FlexGridSizer10;
wxFlexGridSizer* FlexGridSizer1;
wxFlexGridSizer* FlexGridSizer2;
wxFlexGridSizer* FlexGridSizer3;
wxFlexGridSizer* FlexGridSizer4;
wxFlexGridSizer* FlexGridSizer5;
wxFlexGridSizer* FlexGridSizer6;
wxFlexGridSizer* FlexGridSizer7;
wxFlexGridSizer* FlexGridSizer8;
wxFlexGridSizer* FlexGridSizer9;
wxStdDialogButtonSizer* StdDialogButtonSizer1;

Create(parent, wxID_ANY, _("SNF Configuration"), wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP|wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL, _T("wxID_ANY"));
SetFocus();
FlexGridSizer1 = new wxFlexGridSizer(6, 1, 1, 1);
FlexGridSizer6 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer7 = new wxFlexGridSizer(0, 3, 0, 0);
StaticBitmap1 = new wxStaticBitmap(this, ID_STATICBITMAP1, logo, wxDefaultPosition, wxDefaultSize, wxNO_BORDER, _T("ID_STATICBITMAP1"));
FlexGridSizer7->Add(StaticBitmap1, 1, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer6->Add(FlexGridSizer7, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer1->Add(FlexGridSizer6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer8 = new wxFlexGridSizer(3, 1, 0, 0);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("SNF MDaemon Plugin Version 4.0"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
wxFont StaticText2Font(12,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,false,_T("Arial"),wxFONTENCODING_DEFAULT);
StaticText2->SetFont(StaticText2Font);
FlexGridSizer8->Add(StaticText2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer9 = new wxFlexGridSizer(0, 3, 0, 0);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("License ID: "), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
wxFont StaticText3Font(10,wxFONTFAMILY_SWISS,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,true,_T("Arial"),wxFONTENCODING_DEFAULT);
StaticText3->SetFont(StaticText3Font);
FlexGridSizer9->Add(StaticText3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer8->Add(FlexGridSizer9, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer3 = new wxFlexGridSizer(0, 1, 0, 0);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("\n The full range of SNFServer features are provided by the plugin.\n All of these can be configured in the MDaemon/SNF/snfmdplugin.xml file.\n\n HOWEVER, some of the default settings are required in order\n for the plugin to work properly with MDaemon.\n\n In particular be careful about modifying <paths/> or <xheaders/>.\n"), wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER, _T("ID_STATICTEXT1"));
FlexGridSizer3->Add(StaticText1, 1, wxALL, 10);
FlexGridSizer8->Add(FlexGridSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
FlexGridSizer1->Add(FlexGridSizer8, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2 = new wxFlexGridSizer(3, 1, 0, 0);
FlexGridSizer4 = new wxFlexGridSizer(0, 3, 0, 0);
HyperlinkCtrl2 = new wxHyperlinkCtrl(this, ID_HYPERLINKCTRL2, _("Click here to view your configuration file."), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE|wxNO_BORDER, _T("ID_HYPERLINKCTRL2"));
FlexGridSizer4->Add(HyperlinkCtrl2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2->Add(FlexGridSizer4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0);
HyperlinkCtrl1 = new wxHyperlinkCtrl(this, ID_HYPERLINKCTRL1, _("Click here for more information."), _("https://www.armresearch.com/Documentation/QA/mdaemon_plugin-238282018.jsp"), wxDefaultPosition, wxDefaultSize, wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE|wxNO_BORDER, _T("ID_HYPERLINKCTRL1"));
FlexGridSizer5->Add(HyperlinkCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2->Add(FlexGridSizer5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer1->Add(FlexGridSizer2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StdDialogButtonSizer1 = new wxStdDialogButtonSizer();
StdDialogButtonSizer1->AddButton(new wxButton(this, wxID_OK, wxEmptyString));
StdDialogButtonSizer1->Realize();
FlexGridSizer1->Add(StdDialogButtonSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer10 = new wxFlexGridSizer(0, 3, 0, 0);
FlexGridSizer1->Add(FlexGridSizer10, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);

Connect(ID_HYPERLINKCTRL2,wxEVT_COMMAND_HYPERLINK,(wxObjectEventFunction)&configdialog::OnHyperlinkCtrl2Click);
Connect(ID_HYPERLINKCTRL1,wxEVT_COMMAND_HYPERLINK,(wxObjectEventFunction)&configdialog::OnHyperlinkCtrl1Click);
//*)

//install_path = utf8_encode(install_pathW);
std::string license_path = install_path + "\\identity.xml";
if (fileExists(license_path)) {
std::ifstream identity; // Grab the input file.
identity.open(license_path.c_str(), // Open it in binary mode
std::ios::in | std::ios::binary); // to avoid corruption issues.
std::string line;
std::string license_tag = "licenseid=\'";
while (getline(identity, line)) // read in line
{
std::size_t found = line.find(license_tag);
if (found!=std::string::npos){
std::cout << "first 'needle' found at: " << found << '\n';
StaticText3->SetLabel("License ID: " + line.substr(found+11, 8));
}
}
}
}

configdialog::~configdialog()
{
//(*Destroy(configdialog)
//*)
}


void configdialog::OnHyperlinkCtrl1Click(wxCommandEvent& event)
{
wxLaunchDefaultBrowser("https://www.armresearch.com/Documentation/QA/mdaemon_plugin-238282018.jsp");
}

void configdialog::OnHyperlinkCtrl2Click(wxCommandEvent& event)
{
wxLaunchDefaultApplication(install_path + "\\snfmdplugin.xml");
}

+ 58
- 0
SNFMDaemonDLL/configdialog.h Näytä tiedosto

@@ -0,0 +1,58 @@
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H

#include <string>
#include <fstream>
#include <iostream>
#include <stdlib.h>

//(*Headers(configdialog)
#include <wx/dialog.h>
#include <wx/hyperlink.h>
#include <wx/sizer.h>
#include <wx/statbmp.h>
#include <wx/stattext.h>
//*)

class configdialog: public wxDialog
{
public:

configdialog(wxWindow* parent,wxWindowID id=wxID_ANY);
virtual ~configdialog();

//(*Declarations(configdialog)
wxHyperlinkCtrl* HyperlinkCtrl1;
wxHyperlinkCtrl* HyperlinkCtrl2;
wxStaticBitmap* StaticBitmap1;
wxStaticText* StaticText1;
wxStaticText* StaticText2;
wxStaticText* StaticText3;
//*)

protected:

//(*Identifiers(configdialog)
static const long ID_STATICBITMAP1;
static const long ID_STATICTEXT2;
static const long ID_STATICTEXT3;
static const long ID_STATICTEXT1;
static const long ID_HYPERLINKCTRL2;
static const long ID_HYPERLINKCTRL1;
//*)

private:

std::string install_path;
//(*Handlers(configdialog)
std::string utf8_encode(const std::wstring &wstr);
void OnQuit(wxCommandEvent& event);
void OnHyperlinkCtrl1Click(wxCommandEvent& event);
void OnHyperlinkCtrl2Click(wxCommandEvent& event);
//*)

DECLARE_EVENT_TABLE()
};

#endif

+ 26
- 0
SNFMDaemonDLL/dialogapp.cpp Näytä tiedosto

@@ -0,0 +1,26 @@
#include "dialogapp.h"

//(*AppHeaders
#include "configdialog.h"
#include <wx/image.h>
//*)

IMPLEMENT_APP_NO_MAIN(dialogapp);

bool dialogapp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
configdialog Dlg(0);
SetTopWindow(&Dlg);
Dlg.ShowModal();
wxsOK = false;
}
//*)
return wxsOK;
}



+ 14
- 0
SNFMDaemonDLL/dialogapp.h Näytä tiedosto

@@ -0,0 +1,14 @@

#ifndef DIALOGAPP_H
#define DIALOGAPP_H

#include <wx/app.h>

class dialogapp : public wxApp
{
public:
virtual bool OnInit();
};

//wxDECLARE_APP(dialogapp);
#endif

+ 94
- 69
SNFMDaemonDLL/main.cpp Näytä tiedosto

@@ -2,10 +2,31 @@
// SNF MDaemon Plugin
// Copyright (C) 2007-2008, ARM Research Labs, LLC.
#include <wx/app.h>
#include <wx/window.h>
#include <wx/dialog.h>
#include <wx/toplevel.h>
#include "dialogapp.h"
#include "configdialog.h"
#include <winsock2.h>
#include <windows.h>
#include "mdconfiguration.hpp"
#include "../SNF_Service/SNFMulti.hpp"
#define DLL_EXPORT __declspec(dllexport)
#include "SNFMulti/SNFMulti.hpp"
#ifndef _UNICODE
#define _UNICODE
#endif
#ifndef UNICODE
#define UNICODE
#endif
#define GX_STANDARD_CALL __attribute__((stdcall))
#define _stdcall __attribute__((stdcall))
//IMPLEMENT_APP_NO_MAIN(dialogapp);
//IMPLEMENT_WX_THEME_SUPPORT;
////////////////////////////////////////////////////////////////////////////////
// Constants And Tweaks
@@ -14,7 +35,7 @@
const int MDPLUGIN_MSG = 22000;
const int MDPLUGIN_DISPLAY = 22001;
const char* PLUGIN_VERSION_INFO = "SNF MDaemon Plugin Version 3.0 Build: " __DATE__ " " __TIME__;
const char* PLUGIN_VERSION_INFO = "SNF MDaemon Plugin Version 4.0 Build: " __DATE__ " " __TIME__;
////////////////////////////////////////////////////////////////////////////////
// SNF MDaemon Plugin DLL Interface Setup.
@@ -22,17 +43,17 @@ const char* PLUGIN_VERSION_INFO = "SNF MDaemon Plugin Version 3.0 Build: " __DAT
extern "C" { // All of these "C" functions for export.
BOOL WINAPI DllMain ( HINSTANCE hInst, DWORD wDataSeg, LPVOID lpvReserved ); // The DllMain starup/shutdown function.
DLL_EXPORT void _stdcall Startup(HWND Parent); // Startup Function.
DLL_EXPORT void _stdcall ConfigFunc(HWND Parent); // Configuration function.
DLL_EXPORT void _stdcall MessageFunc(HWND Parent, const char* File); // Message Scan Function.
DLL_EXPORT void _stdcall MessageIPFunc(HWND Parent, const char* File); // IP Scan Function.
DLL_EXPORT void _stdcall Shutdown(HWND Parent); // Shutdown Function.
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD wDataSeg, LPVOID lpvReserved ); // The DllMain starup/shutdown function.
void _stdcall StartupFunc(HWND Parent); // Startup Function.
void _stdcall ConfigFunc(HWND Parent); // Configuration function.
void _stdcall PreMessageFunc(HWND Parent, const char* File); // Message Scan Function.
void _stdcall SMTPMessageFunc(HWND Parent, const char* File); // IP Scan Function.
void _stdcall ShutdownFunc(HWND Parent); // Shutdown Function.
}
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { // Thread attach/detach functions.
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { // Thread attach/detach functions.
switch (fdwReason) { // Switch on the reason for the call.
case DLL_PROCESS_ATTACH: // Attach to process.
/*** Startup function moved to API ***/
@@ -52,7 +73,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
}
return true; // Be happy by default.
}
////////////////////////////////////////////////////////////////////////////////
// SNF MDaemon Plugin Engine Code
////////////////////////////////////////////////////////////////////////////////
@@ -66,8 +86,8 @@ void sayToScreen(const string StuffToSay) {
MessageBox ( // Use a message box.
GetFocus(), // Take the user's focus.
StuffToSay.c_str(), // This is what to say.
"Message Sniffer Plug-In", // This is how to title the box.
(LPCWSTR) StuffToSay.c_str(), // This is what to say.
(LPCWSTR) "Message Sniffer Plug-In", // This is how to title the box.
MB_OK|MB_SYSTEMMODAL ); // This makes it modal with a button.
}
@@ -93,47 +113,45 @@ void sayToLog(const string Msg) {
// from snf_engine.xml. If we don't get what we want then we return nothing.
string ConfigurationFilePath() { // Get the config file path.
char data[256]; // Create a buffer.
DWORD dwType = 0; // Type holder.
DWORD dwCount = sizeof(data); // Data counter.
HKEY rkey; // Key handle.
string KeyLocation("SOFTWARE\\Alt-N Technologies\\MDaemon"); // Key location.
string KeyValueName("AppPath"); // Value name.
// Open the key and if successful read it's value.
string ReadValue = ""; // We'll put the answer here.
if(ERROR_SUCCESS == // Try to open the registry
RegOpenKeyEx(HKEY_LOCAL_MACHINE, KeyLocation.c_str(), 0, KEY_READ, &rkey)
) { // If it opened successfully:
RegQueryValueEx( // Read the MDaemon AppPath key.
rkey,
KeyValueName.c_str(),
NULL,
&dwType,
(LPBYTE)&data,
&dwCount
);
ReadValue = data; // Convert the results to a string.
RegCloseKey(rkey); // Close the registry key.
std::wstring install_pathW;
HKEY hKey;
WCHAR szBuffer[512];
DWORD dwBufferSize = sizeof(szBuffer);
std::wstring regValue = L"";
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Alt-N Technologies\\MDaemon", 0, KEY_READ, &hKey)){
if(ERROR_SUCCESS == RegQueryValueEx(hKey, (LPCWSTR) L"AppPath", NULL, NULL, (LPBYTE) &szBuffer, &dwBufferSize)){
RegCloseKey(hKey);
regValue = std::wstring(szBuffer);
std::wstring termCheck;
for(auto val: regValue){
if(val != L'\0'){
termCheck += val;
}
}
if(termCheck.size() == 512){
regValue = L""; // RegValue wasn't null terminated
}
else{
int PathEnd = regValue.length(); // Grab the length.
if(PathEnd > 0) { regValue.erase(PathEnd-1,1); } // Eat the stroke at the end.
PathEnd = regValue.find_last_of(L"\\"); // Find the next stroke in.
int PathLength = regValue.length(); // Grab the path length.
int EraseSpan = PathLength - (PathEnd+1); // Calculate the amount to erase.
regValue.erase(PathEnd+1,EraseSpan); // Erase it to get the root path.
regValue.append(L"SNF\\snfmdplugin.xml");
}
}
}
// Now we must convert the APP path to our SNFMDPlugin path.
//convert wstring to utf8
size_t buffer_size = WideCharToMultiByte(CP_UTF8, 0, &regValue[0], (int)regValue.size(), NULL, 0, NULL, NULL);
std::string strFilePath(buffer_size, '\0');
WideCharToMultiByte(CP_UTF8, 0, &regValue[0], (int)regValue.size(), &strFilePath[0], buffer_size, NULL, NULL);
int PathEnd = ReadValue.length(); // Grab the length.
if(PathEnd > 0) { ReadValue.erase(PathEnd-1,1); } // Eat the stroke at the end.
PathEnd = ReadValue.find_last_of("\\"); // Find the next stroke in.
int PathLength = ReadValue.length(); // Grab the path length.
int EraseSpan = PathLength - (PathEnd+1); // Calculate the amount to erase.
ReadValue.erase(PathEnd+1,EraseSpan); // Erase it to get the root path.
ReadValue.append("SNF\\SNFMDPlugin.xml");
}
// Return either the empty string or the configuration file path.
return ReadValue; // Return what we have.
return strFilePath; // Return what we have.
}
// Here are out engine components, startup, and shutdown logic. The actual
@@ -151,7 +169,8 @@ int Generation = -1;
string Configuration; // Configuration file path.
MDConfiguration* PlatformConfig = 0; // Platform config interpreter.
DLL_EXPORT void _stdcall Startup(HWND Parent) { // How to get all this started.
extern "C" void _stdcall StartupFunc(HWND Parent){ // How to get all this started.
LatestParent = Parent;
EngineIsGood = false; // Start off pessimistically.
try { // Be sure to catch any exceptions.
@@ -229,7 +248,8 @@ DLL_EXPORT void _stdcall Startup(HWND Parent) {
***** deadlocking on their stop() functions (join()).
****/
DLL_EXPORT void _stdcall Shutdown(HWND Parent) { // How to get all this stopped.
extern "C" void _stdcall ShutdownFunc(HWND Parent){ // How to get all this stopped.
LatestParent = Parent;
if(EngineIsGood) { // If the engine is good:
try {
@@ -269,15 +289,20 @@ DLL_EXPORT void _stdcall Shutdown(HWND Parent) {
// 20080311 _M Adjusted ConfigFunc to use Platform Configuration Parameters.
DLL_EXPORT void _stdcall ConfigFunc(HWND Parent) { // Configuration function.
LatestParent = Parent; // Capture the parent for logging.
string ConfiguratorString = PlatformConfig->ConfiguratorCommand(); // Get Configurator launch command.
if(0 < ConfiguratorString.length()) system(ConfiguratorString.c_str()); // If we have a launch command use it.
//DLL_EXPORT void __stdcall ConfigFunc(HWND Parent) { // Configuration function.
extern "C" void _stdcall ConfigFunc(HWND Parent) {
// Initialize application.
wxApp::SetInstance(new dialogapp());
wxEntryStart(0, NULL);
wxTheApp->CallOnInit();
wxTheApp->OnRun();
wxTheApp->OnExit();
wxEntryCleanup();
}
// MessageFunc() scans a message file and injects headers.
DLL_EXPORT void _stdcall MessageFunc(HWND Parent, const char* File) { // Message Scan Function.
extern "C" void _stdcall PreMessageFunc(HWND Parent, const char* File){ // Message Scan Function.
LatestParent = Parent; // Capture the parent for logging.
string LogMessage = "SNF MessageScan: "; // Start a plugin log entry.
LogMessage.append(File); // add the file name.
@@ -390,7 +415,7 @@ string ControlFilePath(string MessageFilePath) {
// MessageIPFunc() looks at the control file for a message, extracts the
// source IP, and deletes the message if the IP is in the truncate range.
DLL_EXPORT void _stdcall MessageIPFunc(HWND Parent, const char* File) { // IP Scan Function.
extern "C" void _stdcall SMTPMessageFunc(HWND Parent, const char* File){ // IP Scan Function.
LatestParent = Parent; // Capture the parent for logging.
if(false == PlatformConfig->MessageIPFuncOn()) { // If the IP func is off:
return; // We're done.
@@ -461,18 +486,18 @@ DLL_EXPORT void _stdcall MessageIPFunc(HWND Parent, const char* File) {
<< "c=" << IPAnalysis.G.Confidence() << ", ";
switch(IPAnalysis.R) { // The Range analysis.
case Unknown: { Happy << " Unknown}"; break; } // Unknown - not defined.
case White: { Happy << " White}"; break; } // This is a good guy.
case Normal: { Happy << " Normal}"; break; } // Benefit of the doubt.
case New: { Happy << " New}"; break; } // It is new to us.
case Caution: { Happy << " Caution}"; break; } // This is suspicious.
case Black: { Happy << " Black}"; break; } // This is bad.
case Truncate: { Happy << " Truncate}"; break; } // This is bad unless we ignore it.
case snfIPRange::Unknown: { Happy << " Unknown}"; break; } // Unknown - not defined.
case snfIPRange::White: { Happy << " White}"; break; } // This is a good guy.
case snfIPRange::Normal: { Happy << " Normal}"; break; } // Benefit of the doubt.
case snfIPRange::New: { Happy << " New}"; break; } // It is new to us.
case snfIPRange::Caution: { Happy << " Caution}"; break; } // This is suspicious.
case snfIPRange::Black: { Happy << " Black}"; break; } // This is bad.
case snfIPRange::Truncate: { Happy << " Truncate}"; break; } // This is bad unless we ignore it.
}
string WhatWeDid; // So, what do we do?
if( // Are we in Truncate land?
(Truncate == IPAnalysis.R && Ugly == IPAnalysis.G.Flag()) || // If the IP is Truncate & Ugly, or
(snfIPRange::Truncate == IPAnalysis.R && Ugly == IPAnalysis.G.Flag()) || // If the IP is Truncate & Ugly, or
Bad == IPAnalysis.G.Flag() // If the IP is just plain bad then
) { // we are in truncate land so we
Happy << " Rejected!"; WhatWeDid = "Rejected"; // mark the message Rejected! and

+ 15
- 0
SNFMDaemonDLL/makefile Näytä tiedosto

@@ -0,0 +1,15 @@
MICRONEILLIBS = -LC:\Users\Dylan\Documents\Microneil\MDaemon\SNFMDaemon\SNFMDaemonDLL\SNFMulti -lSNFMulti -LC:\Users\Dylan\Documents\Microneil\MDaemon\SNFMDaemon\SNFMDaemonDLL\CodeDweller -lCodedweller
MICROINC = -IC:\Users\Dylan\Documents\Microneil\MDaemon\SNFMDaemon\SNFMDaemonDLL\SNFMulti -IC:\Users\Dylan\Documents\Microneil\MDaemon\SNFMDaemon\SNFMDaemonDLL\CodeDweller
WXLIBS = -LC:\wxWidgets-3.0.4\lib\gcc_dll64
WXINC = -IC:\wxWidgets-3.0.4\include -IC:\wxWidgets-3.0.4\lib\gcc_dll64\mswu
WXFLAGS = -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE

resource:
windres.exe ${WXINC} -J rc -O coff -i C:\Users\Dylan\DOCUME~1\MICRON~1\SPWXDI~2\resource.rc -o resource.res

wx:
g++.exe -pipe -std=c++11 -mthreads ${WXFLAGS} -Wall -O2 ${WXINC} -c configdialog.cpp -o configdialog.o
g++.exe -pipe -std=c++11 -mthreads ${WXFLAGS} -Wall -O2 ${WXINC} -c dialogapp.cpp -o dialogapp.o
g++.exe -pipe -std=c++11 -mthreads -g -DDEBUG -O2 ${MICRONEILLIBS} ${MICROINC} -c mdconfiguration.cpp -o mdconfiguration.o
g++.exe -pipe -std=c++11 -mthreads -g -DDEBUG -Wall -O2 ${MICRONEILLIBS} ${MICROINC} ${WXINC} -c main.cpp -o main.o
g++.exe -std=c++11 -shared -o bin\snfmdplugin.dll main.o mdconfiguration.o configdialog.o dialogapp.o ${MICROINC} ${MICRONEILLIBS} ${WXINC} ${WXLIBS} -lws2_32 -lwxmsw30u -s -mthreads -mwindows

+ 6
- 3
SNFMDaemonDLL/mdconfiguration.hpp Näytä tiedosto

@@ -12,10 +12,13 @@
#ifndef included_mdconfiguration_hpp
#define included_mdconfiguration_hpp
#include <winsock2.h>
#include <windows.h>
#include "../SNF_Service/SNFMulti.hpp"
#include "../SNF_Service/configuration.hpp"
#include "../SNF_Service/threading.hpp"
#include "SNFMulti/SNFMulti.hpp"
#include "CodeDweller/configuration.hpp"
#include "CodeDweller/threading.hpp"
class MDConfiguration {
private:

Loading…
Peruuta
Tallenna