diff --git a/src/client_frontend/client_frontend.cpp b/src/client_frontend/client_frontend.cpp index ffb3f62..9f37a7a 100644 --- a/src/client_frontend/client_frontend.cpp +++ b/src/client_frontend/client_frontend.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "../client_backend/well_known.h" #define IDM_SCAN_FILE 101 diff --git a/src/ma_installer/service.cpp b/src/ma_installer/service.cpp index bec3a02..ce8b06d 100644 --- a/src/ma_installer/service.cpp +++ b/src/ma_installer/service.cpp @@ -148,6 +148,20 @@ int create_task() return 1; } + + hr = pSettings->put_StopIfGoingOnBatteries(VARIANT_FALSE); + pSettings->Release(); + if (FAILED(hr)) + { + cout << "Cannot set dont stop on batteries: " << hex << hr << endl; + pRootFolder->Release(); + pTask->Release(); + CoUninitialize(); + return 1; + } + + + ITriggerCollection* pTriggerCollection = NULL; hr = pTask->get_Triggers(&pTriggerCollection); if (FAILED(hr)) diff --git a/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.backup.json b/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.backup.json new file mode 100644 index 0000000..793b7d8 --- /dev/null +++ b/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.backup.json @@ -0,0 +1,37 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{85D8C5BA-ADFE-463B-A5E5-5016639400C0}|ma_notificator.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{85D8C5BA-ADFE-463B-A5E5-5016639400C0}|ma_notificator.vcxproj|solutionrelative:ma_notificator.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 0, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "ma_notificator.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp", + "RelativeDocumentMoniker": "ma_notificator.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp", + "RelativeToolTip": "ma_notificator.cpp", + "ViewState": "AgIAACEAAAAAAAAAAAAAADoAAAAYAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-11-09T08:16:16.921Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.json b/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.json new file mode 100644 index 0000000..b7d142a --- /dev/null +++ b/src/ma_notificator/.vs/ma_notificator/v17/DocumentLayout.json @@ -0,0 +1,37 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{85D8C5BA-ADFE-463B-A5E5-5016639400C0}|ma_notificator.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{85D8C5BA-ADFE-463B-A5E5-5016639400C0}|ma_notificator.vcxproj|solutionrelative:ma_notificator.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 0, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "ma_notificator.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp", + "RelativeDocumentMoniker": "ma_notificator.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\ma_notificator\\ma_notificator.cpp", + "RelativeToolTip": "ma_notificator.cpp", + "ViewState": "AgIAAGYAAAAAAAAAAAAAAIsAAAAGAAAAAAAAAA==", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-11-09T08:16:16.921Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/ma_notificator/Resource.h b/src/ma_notificator/Resource.h new file mode 100644 index 0000000..3ddbcec --- /dev/null +++ b/src/ma_notificator/Resource.h @@ -0,0 +1,30 @@ +//{{NO_DEPENDENCIES}} +// Von Microsoft Visual C++ generierte Includedatei. +// Verwendet von ma_notificator.rc + +#define IDS_APP_TITLE 103 + +#define IDR_MAINFRAME 128 +#define IDD_MANOTIFICATOR_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDI_MANOTIFICATOR 107 +#define IDI_SMALL 108 +#define IDC_MANOTIFICATOR 109 +#define IDC_MYICON 2 +#ifndef IDC_STATIC +#define IDC_STATIC -1 +#endif +// Nächste Standardwerte für neue Objekte +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NO_MFC 130 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/src/ma_notificator/framework.h b/src/ma_notificator/framework.h new file mode 100644 index 0000000..fbce5ca --- /dev/null +++ b/src/ma_notificator/framework.h @@ -0,0 +1,15 @@ +// header.h: Includedatei für Include-Standardsystemdateien +// oder projektspezifische Includedateien. +// + +#pragma once + +#include "targetver.h" +#define WIN32_LEAN_AND_MEAN // Selten verwendete Komponenten aus Windows-Headern ausschließen +// Windows-Headerdateien +#include +// C RunTime-Headerdateien +#include +#include +#include +#include diff --git a/src/ma_notificator/ma_notificator.cpp b/src/ma_notificator/ma_notificator.cpp new file mode 100644 index 0000000..891214c --- /dev/null +++ b/src/ma_notificator/ma_notificator.cpp @@ -0,0 +1,158 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "../client_backend/well_known.h" + +#define IDM_SCAN_FILE 101 +#define IDM_SCAN_FOLDER 102 +#define IDM_DEEP_SCAN_FILE 103 +#define IDM_DEEP_SCAN_FOLDER 104 +#define IDM_QUICK_SCAN 105 + + +std::wstring string_to_widestring(const std::string& str) { + std::wstring_convert> converter; + return converter.from_bytes(str); +} +std::string widestring_to_string(const std::wstring& wstr) { + std::wstring_convert> converter; + return converter.to_bytes(wstr); +} + + +// Function to update the content of the text field with the provided text +void update_textfield(HWND hWndTextField, const std::string& text) { + // Get the current text length + int textLength = GetWindowTextLength(hWndTextField); + + // Set the selection to the end of the text field + SendMessage(hWndTextField, EM_SETSEL, textLength, textLength); + + // Append the new text + SendMessage(hWndTextField, EM_REPLACESEL, FALSE, (LPARAM)string_to_widestring(text).c_str()); +} + + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { + static HWND hWndTextField; + static HWND hProgressBar; + static HBRUSH hBackgroundBrush = CreateSolidBrush(RGB(255, 255, 255)); // White color + RECT rect; + GetClientRect(hWnd, &rect); + int width = rect.right - rect.left; + int height = rect.bottom - rect.top; + switch (message) { + case WM_CREATE: + { + int argc; + LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); + // Create a multi-line edit control for displaying text + hWndTextField = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", NULL, + WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY, + 10, 10, width - 20, height - 20, hWnd, NULL, NULL, NULL); + + if (argc >= 2) { + for (int i = 1; i < argc; i++) { + update_textfield(hWndTextField, widestring_to_string(argv[i]) + "\r\n"); + } + } + else { + update_textfield(hWndTextField, "No notification to display."); + } + } + break; + case WM_SIZE: + { + // Resize the text field to fit the window + MoveWindow(hWndTextField, 10, 10, width - 20, height - 20 , TRUE); + break; + } + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Parse the menu selections: + switch (wmId) { + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + } + break; + + case WM_PAINT: + { + PAINTSTRUCT ps; + HDC hdc = BeginPaint(hWnd, &ps); + RECT rect; + GetClientRect(hWnd, &rect); + FillRect(hdc, &rect, hBackgroundBrush); // Fill the entire client area with white color + EndPaint(hWnd, &ps); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + + const wchar_t CLASS_NAME[] = L"Cyberhex endpoint protection notificator"; + + WNDCLASS wc = { }; + + wc.lpfnWndProc = WndProc; + wc.hInstance = hInstance; + wc.lpszClassName = CLASS_NAME; + + RegisterClass(&wc); + + int screenWidth = GetSystemMetrics(SM_CXSCREEN); + int screenHeight = GetSystemMetrics(SM_CYSCREEN); + + int windowWidth = 640; + int windowHeight = 480; + + // Calculate the center position + int xPos = (screenWidth - windowWidth) / 2; + int yPos = (screenHeight - windowHeight) / 2; + + HWND hWnd = CreateWindowEx( + WS_EX_TOPMOST, // Extended window style (TOPMOST) + CLASS_NAME, // Window class name + L"Cyberhex Endpoint Protection - Notificator", // Window title + WS_OVERLAPPEDWINDOW, // Window style + xPos, // X position + yPos, // Y position + windowWidth, // Width + windowHeight, // Height + NULL, // Parent window + NULL, // Menu + hInstance, // Instance handle + NULL // Additional application data + ); + + + if (hWnd == NULL) { + return 0; + } + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + + MSG msg = { }; + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return 0; +} diff --git a/src/ma_notificator/ma_notificator.h b/src/ma_notificator/ma_notificator.h new file mode 100644 index 0000000..d00d47e --- /dev/null +++ b/src/ma_notificator/ma_notificator.h @@ -0,0 +1,3 @@ +#pragma once + +#include "resource.h" diff --git a/src/ma_notificator/ma_notificator.ico b/src/ma_notificator/ma_notificator.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/src/ma_notificator/ma_notificator.ico differ diff --git a/src/ma_notificator/ma_notificator.sln b/src/ma_notificator/ma_notificator.sln new file mode 100644 index 0000000..437beaf --- /dev/null +++ b/src/ma_notificator/ma_notificator.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ma_notificator", "ma_notificator.vcxproj", "{85D8C5BA-ADFE-463B-A5E5-5016639400C0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Debug|x64.ActiveCfg = Debug|x64 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Debug|x64.Build.0 = Debug|x64 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Debug|x86.ActiveCfg = Debug|Win32 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Debug|x86.Build.0 = Debug|Win32 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Release|x64.ActiveCfg = Release|x64 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Release|x64.Build.0 = Release|x64 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Release|x86.ActiveCfg = Release|Win32 + {85D8C5BA-ADFE-463B-A5E5-5016639400C0}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8DD4FB36-2271-4771-9BA9-F59DFC5714E6} + EndGlobalSection +EndGlobal diff --git a/src/ma_notificator/ma_notificator.vcxproj b/src/ma_notificator/ma_notificator.vcxproj new file mode 100644 index 0000000..47e590f --- /dev/null +++ b/src/ma_notificator/ma_notificator.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {85d8c5ba-adfe-463b-a5e5-5016639400c0} + manotificator + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + true + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ma_notificator/ma_notificator.vcxproj.filters b/src/ma_notificator/ma_notificator.vcxproj.filters new file mode 100644 index 0000000..463a498 --- /dev/null +++ b/src/ma_notificator/ma_notificator.vcxproj.filters @@ -0,0 +1,49 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + Headerdateien + + + + + Quelldateien + + + + + Ressourcendateien + + + + + Ressourcendateien + + + Ressourcendateien + + + \ No newline at end of file diff --git a/src/ma_notificator/ma_notificator.vcxproj.user b/src/ma_notificator/ma_notificator.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/src/ma_notificator/ma_notificator.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.exe.recipe b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.exe.recipe new file mode 100644 index 0000000..544e6cc --- /dev/null +++ b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.exe.recipe @@ -0,0 +1,11 @@ + + + + + C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\ma_notificator\x64\Debug\ma_notificator.exe + + + + + + \ No newline at end of file diff --git a/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.ilk b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.ilk new file mode 100644 index 0000000..fce34e3 Binary files /dev/null and b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.ilk differ diff --git a/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.res b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.res new file mode 100644 index 0000000..6ff774f Binary files /dev/null and b/src/ma_notificator/ma_notificator/x64/Debug/ma_notificator.res differ diff --git a/src/ma_notificator/small.ico b/src/ma_notificator/small.ico new file mode 100644 index 0000000..b3ec03b Binary files /dev/null and b/src/ma_notificator/small.ico differ diff --git a/src/ma_notificator/targetver.h b/src/ma_notificator/targetver.h new file mode 100644 index 0000000..b522b5c --- /dev/null +++ b/src/ma_notificator/targetver.h @@ -0,0 +1,6 @@ +#pragma once + +// // Durch das Einschließen von "SDKDDKVer.h" wird die höchste verfügbare Windows-Plattform definiert. +// Wenn Sie Ihre Anwendung für eine frühere Windows-Plattform erstellen möchten, schließen Sie "WinSDKVer.h" ein, und +// legen Sie vor dem Einschließen von "SDKDDKVer.h" das _WIN32_WINNT-Makro auf die Plattform fest, die Sie unterstützen möchten. +#include