diff --git a/src/client_backend/.vs/client_backend/v17/.suo b/src/client_backend/.vs/client_backend/v17/.suo index 18efdf9..e8bb0c8 100644 Binary files a/src/client_backend/.vs/client_backend/v17/.suo and b/src/client_backend/.vs/client_backend/v17/.suo differ diff --git a/src/client_backend/.vs/client_backend/v17/Browse.VC.db b/src/client_backend/.vs/client_backend/v17/Browse.VC.db index cd459ab..9e4fe29 100644 Binary files a/src/client_backend/.vs/client_backend/v17/Browse.VC.db and b/src/client_backend/.vs/client_backend/v17/Browse.VC.db differ diff --git a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json index 746efff..ac1d25d 100644 --- a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json +++ b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json @@ -6,10 +6,18 @@ "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_process.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -19,13 +27,17 @@ "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -42,22 +54,10 @@ "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:scan.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, { "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" @@ -102,58 +102,164 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 7, + "SelectedChildIndex": 2, "Children": [ { "$type": "Document", - "DocumentIndex": 7, - "Title": "connect.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", - "RelativeDocumentMoniker": "connect.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", - "RelativeToolTip": "connect.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABMAAAAdAAAA", + "DocumentIndex": 19, + "Title": "settings.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeDocumentMoniker": "settings.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeToolTip": "settings.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAiAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:44:13.879Z", - "EditorCaption": "" + "WhenOpened": "2024-03-13T06:42:03.328Z" }, { "$type": "Document", - "DocumentIndex": 20, - "Title": "queue_ctrl.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", - "RelativeDocumentMoniker": "queue_ctrl.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", - "RelativeToolTip": "queue_ctrl.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAAYAAAA", + "DocumentIndex": 13, + "Title": "scan.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", + "RelativeDocumentMoniker": "scan.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", + "RelativeToolTip": "scan.h", + "ViewState": "AQIAAAkAAAAAAAAAAABRwBMAAAAPAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:43:48.22Z", - "EditorCaption": "" + "WhenOpened": "2024-03-13T06:41:43.701Z" }, { "$type": "Document", - "DocumentIndex": 18, - "Title": "queue _ctrl.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", - "RelativeDocumentMoniker": "queue _ctrl.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", - "RelativeToolTip": "queue _ctrl.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAACAAAAArAAAA", + "DocumentIndex": 0, + "Title": "scan.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", + "RelativeDocumentMoniker": "scan.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", + "RelativeToolTip": "scan.cpp", + "ViewState": "AQIAAMwAAAAAAAAAAAAkwNgAAAA0AAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.295Z", + "WhenOpened": "2024-01-28T20:40:06.248Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 16, - "Title": "update.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", - "RelativeDocumentMoniker": "update.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", - "RelativeToolTip": "update.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAUAAAA", + "DocumentIndex": 9, + "Title": "connect.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", + "RelativeDocumentMoniker": "connect.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", + "RelativeToolTip": "connect.cpp", + "ViewState": "AQIAAKcAAAAAAAAAAAAIwNsAAAAeAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.315Z" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "client_backend.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", + "RelativeDocumentMoniker": "client_backend.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", + "RelativeToolTip": "client_backend.cpp", + "ViewState": "AQIAAEIAAAAAAAAAAAAAAGkAAAAJAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.279Z" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "thread_ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", + "RelativeDocumentMoniker": "thread_ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", + "RelativeToolTip": "thread_ctrl.cpp", + "ViewState": "AQIAAAYAAAAAAAAAAAAAADUAAABGAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-13T06:52:01.533Z" + }, + { + "$type": "Document", + "DocumentIndex": 7, + "Title": "local_com.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", + "RelativeDocumentMoniker": "local_com.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", + "RelativeToolTip": "local_com.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAXAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-17T16:34:14.678Z" + }, + { + "$type": "Document", + "DocumentIndex": 8, + "Title": "virus_ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", + "RelativeDocumentMoniker": "virus_ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", + "RelativeToolTip": "virus_ctrl.cpp", + "ViewState": "AQIAAEsAAAAAAAAAAAAIwHYAAAARAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-02-18T12:49:41.861Z" + }, + { + "$type": "Document", + "DocumentIndex": 22, + "Title": "virus_ctrl.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", + "RelativeDocumentMoniker": "virus_ctrl.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", + "RelativeToolTip": "virus_ctrl.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAuAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:42:28.196Z", + "WhenOpened": "2024-03-13T06:45:51.845Z" + }, + { + "$type": "Document", + "DocumentIndex": 12, + "Title": "log.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeDocumentMoniker": "log.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeToolTip": "log.h", + "ViewState": "AQIAAEwAAAAAAAAAAABBwG4AAAA2AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:47:02.038Z" + }, + { + "$type": "Document", + "DocumentIndex": 21, + "Title": "local_com.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", + "RelativeDocumentMoniker": "local_com.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", + "RelativeToolTip": "local_com.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAABSAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:49:41.823Z" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "check_dir.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeDocumentMoniker": "check_dir.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeToolTip": "check_dir.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-13T06:48:31.009Z" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "utils.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", + "RelativeDocumentMoniker": "utils.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", + "RelativeToolTip": "utils.cpp", + "ViewState": "AQIAAD8AAAAAAAAAAAAAABgAAAAFAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-14T15:55:22.469Z", "EditorCaption": "" }, { @@ -166,164 +272,7 @@ "RelativeToolTip": "settings.cpp", "ViewState": "AQIAAAAAAAAAAAAAAAAAAD0AAAA1AAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-13T06:48:40.364Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 19, - "Title": "settings.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", - "RelativeDocumentMoniker": "settings.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", - "RelativeToolTip": "settings.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAiAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:42:03.328Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 11, - "Title": "scan.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", - "RelativeDocumentMoniker": "scan.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", - "RelativeToolTip": "scan.h", - "ViewState": "AQIAAAkAAAAAAAAAAABRwBMAAAAPAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:41:43.701Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 0, - "Title": "scan.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", - "RelativeDocumentMoniker": "scan.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", - "RelativeToolTip": "scan.cpp", - "ViewState": "AQIAAKYAAAAAAAAAAAAkwMsAAAAOAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.248Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 6, - "Title": "connect.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", - "RelativeDocumentMoniker": "connect.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", - "RelativeToolTip": "connect.cpp", - "ViewState": "AQIAAKcAAAAAAAAAAAAIwNsAAAAeAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.315Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "client_backend.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", - "RelativeDocumentMoniker": "client_backend.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", - "RelativeToolTip": "client_backend.cpp", - "ViewState": "AQIAADMAAAAAAAAAAAAkwE8AAAA6AAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.279Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 3, - "Title": "thread_ctrl.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", - "RelativeDocumentMoniker": "thread_ctrl.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", - "RelativeToolTip": "thread_ctrl.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABwAAAAsAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-13T06:52:01.533Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 5, - "Title": "local_com.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", - "RelativeDocumentMoniker": "local_com.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", - "RelativeToolTip": "local_com.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAXAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-17T16:34:14.678Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 4, - "Title": "virus_ctrl.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", - "RelativeDocumentMoniker": "virus_ctrl.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", - "RelativeToolTip": "virus_ctrl.cpp", - "ViewState": "AQIAAEsAAAAAAAAAAAAIwHYAAAARAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-02-18T12:49:41.861Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 22, - "Title": "virus_ctrl.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", - "RelativeDocumentMoniker": "virus_ctrl.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", - "RelativeToolTip": "virus_ctrl.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAuAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:45:51.845Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 9, - "Title": "log.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", - "RelativeDocumentMoniker": "log.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", - "RelativeToolTip": "log.h", - "ViewState": "AQIAAEwAAAAAAAAAAABBwG4AAAA2AAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:47:02.038Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 21, - "Title": "local_com.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", - "RelativeDocumentMoniker": "local_com.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", - "RelativeToolTip": "local_com.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAABSAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-13T06:49:41.823Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 10, - "Title": "check_dir.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", - "RelativeDocumentMoniker": "check_dir.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", - "RelativeToolTip": "check_dir.cpp", - "ViewState": "AQIAAAQAAAAAAAAAAABBwC0AAAA7AAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-13T06:48:31.009Z", - "EditorCaption": "" + "WhenOpened": "2024-03-13T06:48:40.364Z" }, { "$type": "Document", @@ -335,47 +284,80 @@ "RelativeToolTip": "well_known.h", "ViewState": "AQIAAAAAAAAAAAAAAAAAAC0AAAAZAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-14T13:20:06.953Z", - "EditorCaption": "" + "WhenOpened": "2024-03-14T13:20:06.953Z" }, { "$type": "Document", - "DocumentIndex": 1, + "DocumentIndex": 16, + "Title": "update.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", + "RelativeDocumentMoniker": "update.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", + "RelativeToolTip": "update.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAUAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:42:28.196Z" + }, + { + "$type": "Document", + "DocumentIndex": 18, + "Title": "queue _ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", + "RelativeDocumentMoniker": "queue _ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", + "RelativeToolTip": "queue _ctrl.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAACAAAAArAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.295Z" + }, + { + "$type": "Document", + "DocumentIndex": 20, + "Title": "queue_ctrl.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", + "RelativeDocumentMoniker": "queue_ctrl.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", + "RelativeToolTip": "queue_ctrl.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAAYAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:43:48.22Z" + }, + { + "$type": "Document", + "DocumentIndex": 10, + "Title": "connect.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeDocumentMoniker": "connect.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeToolTip": "connect.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABMAAAAdAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:44:13.879Z" + }, + { + "$type": "Document", + "DocumentIndex": 2, "Title": "check_process.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp", "RelativeDocumentMoniker": "check_process.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp", "RelativeToolTip": "check_process.cpp", - "ViewState": "AQIAABUAAAAAAAAAAAAAADcAAABCAAAA", + "ViewState": "AQIAABIAAAAAAAAAAAAAADgAAABGAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-03-14T13:35:33.369Z", "EditorCaption": "" }, { "$type": "Document", - "DocumentIndex": 13, - "Title": "utils.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", - "RelativeDocumentMoniker": "utils.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", - "RelativeToolTip": "utils.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAAAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-14T15:55:22.469Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 12, + "DocumentIndex": 3, "Title": "utils.h", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h", "RelativeDocumentMoniker": "utils.h", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h", "RelativeToolTip": "utils.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAMAAAAUAAAA", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAoAAAAuAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-14T15:55:30.524Z", - "EditorCaption": "" + "WhenOpened": "2024-03-14T15:55:30.524Z" }, { "$type": "Document", @@ -387,12 +369,11 @@ "RelativeToolTip": "update.cpp", "ViewState": "AQIAAAAAAAAAAAAAAIBZwAkAAAARAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.248Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.248Z" }, { "$type": "Document", - "DocumentIndex": 8, + "DocumentIndex": 11, "Title": "local_schedule.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp", "RelativeDocumentMoniker": "local_schedule.cpp", @@ -400,8 +381,7 @@ "RelativeToolTip": "local_schedule.cpp", "ViewState": "AQIAAAAAAAAAAAAAAAAAAEIAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-01-28T20:40:06.279Z", - "EditorCaption": "" + "WhenOpened": "2024-01-28T20:40:06.279Z" } ] } diff --git a/src/client_backend/.vs/client_backend/v17/DocumentLayout.json~RF25e78d6.TMP b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json~RF25e78d6.TMP new file mode 100644 index 0000000..5d3b501 --- /dev/null +++ b/src/client_backend/.vs/client_backend/v17/DocumentLayout.json~RF25e78d6.TMP @@ -0,0 +1,396 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:scan.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_dir.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:check_process.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:thread_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:client_backend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:utils.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:virus_ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_schedule.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:log.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:scan.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:update.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:queue _ctrl.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:settings.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:queue_ctrl.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:local_com.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + }, + { + "AbsoluteMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{56E65283-AAC9-43F6-9613-72BE8D648AC4}|client_backend.vcxproj|solutionrelative:virus_ctrl.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 7, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 10, + "Title": "connect.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeDocumentMoniker": "connect.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.h", + "RelativeToolTip": "connect.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABMAAAAdAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:44:13.879Z" + }, + { + "$type": "Document", + "DocumentIndex": 20, + "Title": "queue_ctrl.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", + "RelativeDocumentMoniker": "queue_ctrl.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue_ctrl.h", + "RelativeToolTip": "queue_ctrl.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAAYAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:43:48.22Z" + }, + { + "$type": "Document", + "DocumentIndex": 18, + "Title": "queue _ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", + "RelativeDocumentMoniker": "queue _ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\queue _ctrl.cpp", + "RelativeToolTip": "queue _ctrl.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAACAAAAArAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.295Z" + }, + { + "$type": "Document", + "DocumentIndex": 16, + "Title": "update.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", + "RelativeDocumentMoniker": "update.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.h", + "RelativeToolTip": "update.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAUAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:42:28.196Z" + }, + { + "$type": "Document", + "DocumentIndex": 17, + "Title": "settings.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", + "RelativeDocumentMoniker": "settings.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.cpp", + "RelativeToolTip": "settings.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAD0AAAA1AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-13T06:48:40.364Z" + }, + { + "$type": "Document", + "DocumentIndex": 19, + "Title": "settings.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeDocumentMoniker": "settings.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\settings.h", + "RelativeToolTip": "settings.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABEAAAAiAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:42:03.328Z" + }, + { + "$type": "Document", + "DocumentIndex": 13, + "Title": "scan.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", + "RelativeDocumentMoniker": "scan.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.h", + "RelativeToolTip": "scan.h", + "ViewState": "AQIAAAkAAAAAAAAAAABRwBMAAAAPAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:41:43.701Z" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "scan.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", + "RelativeDocumentMoniker": "scan.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\scan.cpp", + "RelativeToolTip": "scan.cpp", + "ViewState": "AQIAALkAAAAAAAAAAAAkwNsAAAApAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.248Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 9, + "Title": "connect.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", + "RelativeDocumentMoniker": "connect.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\connect.cpp", + "RelativeToolTip": "connect.cpp", + "ViewState": "AQIAAKcAAAAAAAAAAAAIwNsAAAAeAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.315Z" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "client_backend.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", + "RelativeDocumentMoniker": "client_backend.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\client_backend.cpp", + "RelativeToolTip": "client_backend.cpp", + "ViewState": "AQIAAEUAAAAAAAAAAAAkwGcAAAAcAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.279Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "thread_ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", + "RelativeDocumentMoniker": "thread_ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\thread_ctrl.cpp", + "RelativeToolTip": "thread_ctrl.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAAqAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-13T06:52:01.533Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "local_com.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", + "RelativeDocumentMoniker": "local_com.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.cpp", + "RelativeToolTip": "local_com.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAsAAAAXAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-17T16:34:14.678Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 8, + "Title": "virus_ctrl.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", + "RelativeDocumentMoniker": "virus_ctrl.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.cpp", + "RelativeToolTip": "virus_ctrl.cpp", + "ViewState": "AQIAAEsAAAAAAAAAAAAIwHYAAAARAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-02-18T12:49:41.861Z" + }, + { + "$type": "Document", + "DocumentIndex": 22, + "Title": "virus_ctrl.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", + "RelativeDocumentMoniker": "virus_ctrl.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\virus_ctrl.h", + "RelativeToolTip": "virus_ctrl.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAuAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:45:51.845Z" + }, + { + "$type": "Document", + "DocumentIndex": 12, + "Title": "log.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeDocumentMoniker": "log.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\log.h", + "RelativeToolTip": "log.h", + "ViewState": "AQIAAEwAAAAAAAAAAABBwG4AAAA2AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:47:02.038Z" + }, + { + "$type": "Document", + "DocumentIndex": 21, + "Title": "local_com.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", + "RelativeDocumentMoniker": "local_com.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_com.h", + "RelativeToolTip": "local_com.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAYAAABSAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-13T06:49:41.823Z" + }, + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "check_dir.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeDocumentMoniker": "check_dir.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_dir.cpp", + "RelativeToolTip": "check_dir.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-13T06:48:31.009Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 15, + "Title": "well_known.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\well_known.h", + "RelativeDocumentMoniker": "well_known.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\well_known.h", + "RelativeToolTip": "well_known.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAC0AAAAZAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-14T13:20:06.953Z" + }, + { + "$type": "Document", + "DocumentIndex": 3, + "Title": "check_process.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp", + "RelativeDocumentMoniker": "check_process.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\check_process.cpp", + "RelativeToolTip": "check_process.cpp", + "ViewState": "AQIAAAMAAAAAAAAAAAAAAAoAAAASAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-14T13:35:33.369Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "utils.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", + "RelativeDocumentMoniker": "utils.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.cpp", + "RelativeToolTip": "utils.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABUAAAAsAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-14T15:55:22.469Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 7, + "Title": "utils.h", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h", + "RelativeDocumentMoniker": "utils.h", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\utils.h", + "RelativeToolTip": "utils.h", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAwAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", + "WhenOpened": "2024-03-14T15:55:30.524Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 14, + "Title": "update.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp", + "RelativeDocumentMoniker": "update.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\update.cpp", + "RelativeToolTip": "update.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAIBZwAkAAAARAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.248Z" + }, + { + "$type": "Document", + "DocumentIndex": 11, + "Title": "local_schedule.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp", + "RelativeDocumentMoniker": "local_schedule.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\local_schedule.cpp", + "RelativeToolTip": "local_schedule.cpp", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAEIAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-01-28T20:40:06.279Z" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/client_backend/check_dir.cpp b/src/client_backend/check_dir.cpp index bd18dcf..fcdda24 100644 --- a/src/client_backend/check_dir.cpp +++ b/src/client_backend/check_dir.cpp @@ -12,6 +12,7 @@ #include // Include the algorithm header #include // Include the string header #include // Include the iostream header +#include "utils.h" // Define a mutex for thread synchronization std::mutex monitorMutex; @@ -36,15 +37,17 @@ void process_changes(const FILE_NOTIFY_INFORMATION* pInfo) { filename_str = "c:\\" + filename_str; // Scan the file and send it to virus_ctrl if it is a virus and then process it - std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower); - if (!is_folder_included(filename_str.c_str()) || is_directory(filename_str) || is_folder_excluded(filename_str.c_str())) { - // Don't scan excluded files or folders - return; - } - else { - //log(LOGLEVEL::INFO_NOSEND, "[process_changes()]: File ", filename_str, " has been changed. Scanning it for viruses"); - std::thread scan_thread(scan_file_t, filename_str); - scan_thread.detach(); + if (is_valid_path(filename_str)) { //filter out invalid paths and paths with weird characters + std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower); + if (!is_folder_included(filename_str.c_str()) || is_directory(filename_str) || is_folder_excluded(filename_str.c_str())) { + // Don't scan excluded files or folders + return; + } + else { + //log(LOGLEVEL::INFO_NOSEND, "[process_changes()]: File ", filename_str, " has been changed. Scanning it for viruses"); + std::thread scan_thread(scan_file_t, filename_str); + scan_thread.detach(); + } } } diff --git a/src/client_backend/check_dir.cpp~RF21c4a54.TMP b/src/client_backend/check_dir.cpp~RF21c4a54.TMP new file mode 100644 index 0000000..e69de29 diff --git a/src/client_backend/check_dir.cpp~RF21c703b.TMP b/src/client_backend/check_dir.cpp~RF21c703b.TMP new file mode 100644 index 0000000..0aa34ff --- /dev/null +++ b/src/client_backend/check_dir.cpp~RF21c703b.TMP @@ -0,0 +1,157 @@ +#ifndef CHECK_DIR_CPP +#define CHECK_DIR_CPP +#include "check_dir.h" +#include "well_known.h" +#include "log.h" +#include "md5hash.h" +#include "scan.h" +#include "app_ctrl.h" +#include "virus_ctrl.h" +#include "settings.h" +#include // Include the mutex header +#include // Include the algorithm header +#include // Include the string header +#include // Include the iostream header + +// Define a mutex for thread synchronization +std::mutex monitorMutex; + +bool is_directory(const std::string& path) { + DWORD attributes = GetFileAttributes(path.c_str()); + + if (attributes == INVALID_FILE_ATTRIBUTES) { + // Handle the error, e.g., by printing an error message + return false; + } + + return (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; +} + +void process_changes(const FILE_NOTIFY_INFORMATION* pInfo) { + // Allocate a buffer for the file name and copy the content + std::wstring fileName(pInfo->FileName, pInfo->FileNameLength / sizeof(wchar_t)); + + // Convert wstring to string + std::string filename_str(fileName.begin(), fileName.end()); + filename_str = "c:\\" + filename_str; + + // Scan the file and send it to virus_ctrl if it is a virus and then process it + if (is_valid_path(filename_str)) { //filter out invalid paths and paths with weird characters + std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower); + if (!is_folder_included(filename_str.c_str()) || is_directory(filename_str) || is_folder_excluded(filename_str.c_str())) { + // Don't scan excluded files or folders + return; + } + else { + //log(LOGLEVEL::INFO_NOSEND, "[process_changes()]: File ", filename_str, " has been changed. Scanning it for viruses"); + std::thread scan_thread(scan_file_t, filename_str); + scan_thread.detach(); + } + } +} + +void monitor_directory(LPCSTR directory) { + // Open the directory for monitoring + HANDLE hDir = CreateFile( + directory, + FILE_LIST_DIRECTORY, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + NULL, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, + NULL + ); + + if (hDir == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::ERR, "[monitor_directory()]: Error opening directory: ", directory, " while monitoring directory for changes"); + return; + } + + // Create a buffer for file change notifications + constexpr DWORD bufferSize = 4096; + BYTE buffer[bufferSize]; + + // Monitor the directory for changes + OVERLAPPED overlapped; + memset(&overlapped, 0, sizeof(overlapped)); + memset(buffer, 0, bufferSize); + overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + + if (ReadDirectoryChangesW( + hDir, + buffer, + bufferSize, + TRUE, + FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE, + NULL, + &overlapped, + NULL) == 0) { + log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes"); + CloseHandle(hDir); + return; + } + + log(LOGLEVEL::INFO, "[monitor_directory()]: Monitoring directory: ", directory, " for changes"); + + // Wait for changes + while (!app_stop()) { + DWORD bytesReturned; + DWORD waitStatus = WaitForSingleObject(overlapped.hEvent, INFINITE); + + if (waitStatus == WAIT_OBJECT_0) { + if (GetOverlappedResult(hDir, &overlapped, &bytesReturned, FALSE)) { + // Process the changes in the buffer + FILE_NOTIFY_INFORMATION* pInfo = reinterpret_cast(buffer); + + do { + process_changes(pInfo); + + pInfo = reinterpret_cast( + reinterpret_cast(pInfo) + pInfo->NextEntryOffset); + + } while (pInfo->NextEntryOffset != 0); + + // Reset the event for the next wait + ResetEvent(overlapped.hEvent); + memset(buffer, 0, bufferSize); + + // Continue monitoring + if (ReadDirectoryChangesW( + hDir, + buffer, + bufferSize, + TRUE, + FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_CREATION, + NULL, + &overlapped, + NULL) == 0) { + log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes"); + break; + } + } + else { + log(LOGLEVEL::ERR, "[monitor_directory()]: GetOverlappedResult failed: ", GetLastError()); + break; + } + } + else { + log(LOGLEVEL::ERR, "[monitor_directory()]: WaitForSingleObject failed: ", GetLastError()); + break; + } + } + + // Cleanup + CloseHandle(overlapped.hEvent); + CloseHandle(hDir); +} + +void folder_scanner() { + // Lock access to the monitor function + std::lock_guard lock(monitorMutex); + + // We are in a completely separate thread than the main thread; unlimited resources wuhuii + // Start the watch dir function used to monitor the dir for new files + monitor_directory("C:\\"); +} + +#endif // !CHECK_DIR_CPP diff --git a/src/client_backend/check_process.cpp b/src/client_backend/check_process.cpp index fe04614..f726c27 100644 --- a/src/client_backend/check_process.cpp +++ b/src/client_backend/check_process.cpp @@ -8,6 +8,7 @@ #include // Include the mutex header #include // Include the thread header #include // Include the Windows header +#include "utils.h" std::mutex mtx; // Declare a mutex for thread synchronization @@ -48,13 +49,14 @@ void monitor_processes() { strcpy_s(path, MAX_PATH, exePath); for (size_t z = 0; z < strlen(path); z++) path[z] = tolower(path[z]); - - if (!is_folder_included(path) || is_folder_excluded(path)) { - // Don't scan excluded files or folders - } - else { - std::thread scan_thread(scan_process_t, path); - scan_thread.detach(); + if (is_valid_path(path)) { //filter out invalid paths and paths with weird characters + if (!is_folder_included(path) || is_folder_excluded(path)) { + // Don't scan excluded files or folders + } + else { + std::thread scan_thread(scan_process_t, path); + scan_thread.detach(); + } } } CloseHandle(hProcess); diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.ilk b/src/client_backend/client_backend/x64/Debug/client_backend.ilk index d242544..d9fa679 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.ilk and b/src/client_backend/client_backend/x64/Debug/client_backend.ilk differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.log b/src/client_backend/client_backend/x64/Debug/client_backend.log index f2d8804..648c73e 100644 --- a/src/client_backend/client_backend/x64/Debug/client_backend.log +++ b/src/client_backend/client_backend/x64/Debug/client_backend.log @@ -1,3 +1,2 @@  Quellen werden auf Modulabhängigkeiten überprüft... - scan.cpp client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog index 1b8a4c9..abccc2a 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.command.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog index 5a289ae..af0f582 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.read.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog index 0c06ba3..19b6b88 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/CL.write.1.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog index fb63d9c..b64e6a5 100644 Binary files a/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog and b/src/client_backend/client_backend/x64/Debug/client_backend.tlog/client_backend.write.1u.tlog differ diff --git a/src/client_backend/client_backend/x64/Debug/vc143.idb b/src/client_backend/client_backend/x64/Debug/vc143.idb index f209da2..be535f2 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.idb and b/src/client_backend/client_backend/x64/Debug/vc143.idb differ diff --git a/src/client_backend/client_backend/x64/Debug/vc143.pdb b/src/client_backend/client_backend/x64/Debug/vc143.pdb index 6bf5739..8d51d34 100644 Binary files a/src/client_backend/client_backend/x64/Debug/vc143.pdb and b/src/client_backend/client_backend/x64/Debug/vc143.pdb differ diff --git a/src/client_backend/gbcloezb.4o0~ b/src/client_backend/gbcloezb.4o0~ new file mode 100644 index 0000000..b9bc449 --- /dev/null +++ b/src/client_backend/gbcloezb.4o0~ @@ -0,0 +1,299 @@ +#ifndef SCAN_CPP +#define SCAN_CPP +#include "scan.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "md5hash.h" +#include +#include "well_known.h" +#include "log.h" +#include "virus_ctrl.h" +#include "app_ctrl.h" +#include // Include the mutex header + +// Define mutexes for thread synchronization +std::mutex fileHandlesMutex; +std::mutex mappingHandlesMutex; +std::mutex fileDataMutex; +std::mutex cntMutex; +std::mutex numThreadsMutex; + +std::unordered_map fileHandles; +std::unordered_map mappingHandles; +std::unordered_map fileData; + +int cnt = 0; +int num_threads = 0; + +//load all the db files into memory +int initialize(const std::string& folderPath) { + for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) { + for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) { + // Ensure that the characters are valid hexadecimal digits + if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) { + continue; + } + + // Create the filename based on the naming convention + std::string filename = folderPath + "\\" + firstChar + secondChar + ".jdbf"; + //printf("Loading %s\n", filename.c_str()); + + // Open the file + HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + //log(LOGLEVEL::ERR, "[initialize()]: Error opening database file: ", filename); + return 1; + } + + // Create the file mapping + HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) { + // log(LOGLEVEL::ERR, "[initialize()]: Error creating database file mapping: ", filename); + CloseHandle(hFile); + return 2; + } + + // Map the file into memory + char* fileDataPtr = static_cast(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); + if (fileDataPtr == NULL) { + //log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename); + CloseHandle(hMapping); + CloseHandle(hFile); + return 3; + } + + // Store the handles in the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles[filename] = hFile; + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles[filename] = hMapping; + } + { + std::lock_guard lock(fileDataMutex); + fileData[filename] = fileDataPtr; + } + } + } + return 0; +} + +// Call this function when you are done using the file mappings +void cleanup() { + for (const auto& entry : fileHandles) { + UnmapViewOfFile(fileData[entry.first]); + CloseHandle(mappingHandles[entry.first]); + CloseHandle(entry.second); + } + + // Clear the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles.clear(); + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles.clear(); + } + { + std::lock_guard lock(fileDataMutex); + fileData.clear(); + } +} + +//the latest and fastest version of searching a hash by now +int search_hash(const std::string& dbname_, const std::string& hash_, const std::string& filepath_) { + // Check if the file mapping is already open for the given filename + std::string dbname; + std::string hash; + std::string filepath; + { + std::lock_guard lock(fileHandlesMutex); + dbname = dbname_; + } + { + std::lock_guard lock(fileDataMutex); + hash = hash_; + } + { + std::lock_guard lock(mappingHandlesMutex); + filepath = filepath_; + } + + auto fileIter = fileHandles.find(dbname); + if (fileIter == fileHandles.end() && dbname_.find("c:.jdbf") == std::string::npos) { + log(LOGLEVEL::ERR_NOSEND, "[search_hash()]: File mapping not initialized for ", dbname); + return 2; + } + else if (fileIter == fileHandles.end()) { + return 2; + } + + // Use fileData for subsequent searches + DWORD fileSize; + std::string fileContent; + { + std::lock_guard lock(fileDataMutex); + fileSize = GetFileSize(fileHandles[dbname], NULL); + fileContent = std::string(fileData[dbname], fileSize); + } + + // Search for the specific string in the file content + size_t foundPos = fileContent.find(hash); + if (foundPos != std::string::npos) { + //log(LOGLEVEL::VIRUS, "[search_hash()]: Found virus: ", hash, " in file: ", filepath); + virus_ctrl_store(filepath.c_str(), hash.c_str(), hash.c_str()); + //afterwards do the processing with that file + virus_ctrl_process(hash.c_str()); + return 1; // Found + } + return 0; // Not found +} + + +bool file_exists(const std::string& filePath) { + DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + + if (fileAttributes == INVALID_FILE_ATTRIBUTES) { + // The file does not exist or there was an error + return false; + } + + // Check if it's a regular file and not a directory + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; +} + +//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings +void scan_folder(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::WARN, "[scan_folder()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + scan_folder(full_path); + } + else { + //action scanfile_t will start the trheads for scanning the hashes + //action_scanfile_t(full_path.c_str()); + + //do multithreading here + int cnt = 0; + while (num_threads >= std::thread::hardware_concurrency()) { + Sleep(10); + cnt++; + if(cnt==100*60)//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + } + //log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path, "threads: ",num_threads); + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + //Sleep(1); + + cnt++; + if (cnt % 100 == 0) { + printf("Processed %d files;\n", cnt); + //printf("Number of threads: %d\n", num_threads); + } + if(num_threads<0) + printf("Number of threads: %d\n", num_threads); + } + } while (FindNextFile(hFind, &find_file_data) != 0); + + FindClose(hFind); +} + + + +//for singlethreaded scans +void action_scanfile(const std::string& filepath_) { + thread_init(); + const std::string filepath(filepath_); + char* db_path = new char[300]; + char* hash = new char[300]; + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH,std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } + } + thread_shutdown(); +} +void action_scanfolder(const std::string& folderpath) { + thread_init(); + cnt = 0; + thread_local std::string folderpath_(folderpath); + scan_folder(folderpath_); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "end " << "\"" << "nothing" << "\"" << " " << "nothing" << " " << "nothing" << "\n"; + answer_com.close(); + } + thread_shutdown(); +} + +void scan_file_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + thread_local std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else{ + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + search_hash(db_path, hash, filepath); + num_threads--; +} +void scan_process_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + strcpy_s(hash, 295, md5_file_t(filepath).c_str()); + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) == 1) { + //check if need to kill process + if (get_setting("virus_ctrl:virus_process_found:kill") == 1) { + //kill the process + kill_process(filepath.c_str()); + log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); + } + } + num_threads--; +} +#endif \ No newline at end of file diff --git a/src/client_backend/nfr2zydi.cgj~ b/src/client_backend/nfr2zydi.cgj~ new file mode 100644 index 0000000..08ca9c7 --- /dev/null +++ b/src/client_backend/nfr2zydi.cgj~ @@ -0,0 +1,103 @@ +#include "utils.h" +#include +#include +#include +#include "log.h" +#include +#include +#include + +void split(const std::string& input, char delimiter, std::string& out1, std::string& out2) { + // Split a string at the delimiter. The delimiter only occurs once. + // The first part is stored in out1 and the second part in out2. + size_t pos = input.find(delimiter); + if (pos != std::string::npos) { + out1 = input.substr(0, pos); + out2 = input.substr(pos + 1); + } +} +bool is_valid_path(const std::string& filename) { + // Regular expression to match Windows path name criteria and illegal characters + std::regex pattern(R"(^(?:[a-zA-Z]:)?(?:\\[^<>:"/\\|?*]*)*$)"); + + // Check if the path matches the pattern + return std::regex_match(path, pattern); +} + + +void startup(LPCTSTR lpApplicationName) +{ + // additional information + STARTUPINFO si; + PROCESS_INFORMATION pi; + + // set the size of the structures + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + // start the program up + CreateProcess(lpApplicationName, // the path + NULL, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi // Pointer to PROCESS_INFORMATION structure + ); + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + + +std::string get_filename(const std::string& path) { + auto pos = path.find_last_of("\\"); + if (pos == std::string::npos) { + // No directory separator found, return the original path + return path; + } + else { + // Return the substring after the last directory separator + return path.substr(pos + 1); + } +} + +int strcasecmp(const std::string& s1, const std::string& s2) { + auto it1 = s1.begin(); + auto it2 = s2.begin(); + while (it1 != s1.end() && it2 != s2.end()) { + int diff = std::tolower(*it1) - std::tolower(*it2); + if (diff != 0) + return diff; + ++it1; + ++it2; + } + return 0; +} + +void kill_process(const std::string& path) { + HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL); + PROCESSENTRY32 pEntry; + pEntry.dwSize = sizeof(pEntry); + BOOL hRes = Process32First(hSnapShot, &pEntry); + while (hRes) + { + if (strcasecmp(pEntry.szExeFile, get_filename(path).c_str()) == 0) + { + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, static_cast(pEntry.th32ProcessID)); + if (hProcess != NULL) + { + TerminateProcess(hProcess, 9); + CloseHandle(hProcess); + } + else + log(LOGLEVEL::ERR, "[kill_process()]: Error while killing process: ", path); + } + hRes = Process32Next(hSnapShot, &pEntry); + } + CloseHandle(hSnapShot); +} \ No newline at end of file diff --git a/src/client_backend/scan.cpp b/src/client_backend/scan.cpp index eb9da33..56c7145 100644 --- a/src/client_backend/scan.cpp +++ b/src/client_backend/scan.cpp @@ -16,6 +16,8 @@ #include "virus_ctrl.h" #include "app_ctrl.h" #include // Include the mutex header +#include +#include "utils.h" // Define mutexes for thread synchronization std::mutex fileHandlesMutex; @@ -29,7 +31,8 @@ std::unordered_map mappingHandles; std::unordered_map fileData; int cnt = 0; -unsigned int num_threads = 0; +int num_threads = 0; +int all_files = 0; //load all the db files into memory int initialize(const std::string& folderPath) { @@ -158,17 +161,33 @@ int search_hash(const std::string& dbname_, const std::string& hash_, const std: return 0; // Not found } +//function to get num of files in idr and its subdirs etc +int get_num_files(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + int num_files = 0; + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::ERR_NOSEND, "[get_num_files()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return 0; + } -bool file_exists(const std::string& filePath) { - DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } - if (fileAttributes == INVALID_FILE_ATTRIBUTES) { - // The file does not exist or there was an error - return false; - } - - // Check if it's a regular file and not a directory - return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + num_files += get_num_files(full_path); + } + else { + num_files++; + } + } while (FindNextFile(hFind, &find_file_data) != 0); + FindClose(hFind); + return num_files; } //this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings @@ -196,21 +215,40 @@ void scan_folder(const std::string& directory) { else { //action scanfile_t will start the trheads for scanning the hashes //action_scanfile_t(full_path.c_str()); - //do multithreading here + int thread_timeout = 0; while (num_threads >= std::thread::hardware_concurrency()) { Sleep(10); + thread_timeout++; + if (thread_timeout == 100 * 60) {//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + } } - //log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path, "threads: ",num_threads); - std::thread scan_thread(scan_file_t, full_path); - scan_thread.detach(); - //Sleep(1); + if (is_valid_path(full_path)) { //filter out invalid paths and paths with weird characters + std::uintmax_t fileSize = std::filesystem::file_size(full_path); + if (fileSize > 4000000000) {//4gb + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", full_path); + } + else { + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + } + }else + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Invalid path: ", full_path); cnt++; if (cnt % 100 == 0) { printf("Processed %d files;\n", cnt); //printf("Number of threads: %d\n", num_threads); } + if (cnt % 1000 == 0) { + //send progress to com file + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "progress " << (cnt*100/(all_files+1)) << "\n"; + answer_com.close(); + } + } } } while (FindNextFile(hFind, &find_file_data) != 0); @@ -225,29 +263,40 @@ void action_scanfile(const std::string& filepath_) { const std::string filepath(filepath_); char* db_path = new char[300]; char* hash = new char[300]; - std::string hash_(md5_file_t(filepath)); - if (strlen(hash_.c_str()) < 290) - strcpy_s(hash, 295, hash_.c_str()); - else { - strcpy_s(hash, 295, ""); - log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); - } - sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); - if (search_hash(db_path, hash, filepath) != 1) { - //notify desktop client by writing to answer_com file - //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function - std::ofstream answer_com(ANSWER_COM_PATH,std::ios::app); - if (answer_com.is_open()) { - answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; - answer_com.close(); + if (is_valid_path(filepath_)) { //filter out invalid paths and paths with weird characters + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } } } + else + log(LOGLEVEL::INFO_NOSEND, "[action_scanfile()]: Invalid path: ", filepath_); thread_shutdown(); } void action_scanfolder(const std::string& folderpath) { thread_init(); - cnt = 0; thread_local std::string folderpath_(folderpath); + cnt = 0; + all_files = get_num_files(folderpath_); + //tell the desktop client that the scan has started + std::ofstream answer_com1(ANSWER_COM_PATH, std::ios::app); + if (answer_com1.is_open()) { + answer_com1 << "start " << all_files << "\n"; + answer_com1.close(); + } scan_folder(folderpath_); std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); if (answer_com.is_open()) { @@ -274,7 +323,6 @@ void scan_file_t(const std::string& filepath_) { num_threads--; } void scan_process_t(const std::string& filepath_) { - num_threads++; thread_local const std::string filepath(filepath_); thread_local char* db_path = new char[300]; thread_local char* hash = new char[300]; @@ -288,6 +336,5 @@ void scan_process_t(const std::string& filepath_) { log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); } } - num_threads--; } #endif \ No newline at end of file diff --git a/src/client_backend/scan.cpp~RF215ad27.TMP b/src/client_backend/scan.cpp~RF215ad27.TMP new file mode 100644 index 0000000..532f470 --- /dev/null +++ b/src/client_backend/scan.cpp~RF215ad27.TMP @@ -0,0 +1,312 @@ +#ifndef SCAN_CPP +#define SCAN_CPP +#include "scan.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "md5hash.h" +#include +#include "well_known.h" +#include "log.h" +#include "virus_ctrl.h" +#include "app_ctrl.h" +#include // Include the mutex header +#include +#include "utils.h" + +// Define mutexes for thread synchronization +std::mutex fileHandlesMutex; +std::mutex mappingHandlesMutex; +std::mutex fileDataMutex; +std::mutex cntMutex; +std::mutex numThreadsMutex; + +std::unordered_map fileHandles; +std::unordered_map mappingHandles; +std::unordered_map fileData; + +int cnt = 0; +int num_threads = 0; + +//load all the db files into memory +int initialize(const std::string& folderPath) { + for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) { + for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) { + // Ensure that the characters are valid hexadecimal digits + if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) { + continue; + } + + // Create the filename based on the naming convention + std::string filename = folderPath + "\\" + firstChar + secondChar + ".jdbf"; + //printf("Loading %s\n", filename.c_str()); + + // Open the file + HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + //log(LOGLEVEL::ERR, "[initialize()]: Error opening database file: ", filename); + return 1; + } + + // Create the file mapping + HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) { + // log(LOGLEVEL::ERR, "[initialize()]: Error creating database file mapping: ", filename); + CloseHandle(hFile); + return 2; + } + + // Map the file into memory + char* fileDataPtr = static_cast(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); + if (fileDataPtr == NULL) { + //log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename); + CloseHandle(hMapping); + CloseHandle(hFile); + return 3; + } + + // Store the handles in the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles[filename] = hFile; + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles[filename] = hMapping; + } + { + std::lock_guard lock(fileDataMutex); + fileData[filename] = fileDataPtr; + } + } + } + return 0; +} + +// Call this function when you are done using the file mappings +void cleanup() { + for (const auto& entry : fileHandles) { + UnmapViewOfFile(fileData[entry.first]); + CloseHandle(mappingHandles[entry.first]); + CloseHandle(entry.second); + } + + // Clear the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles.clear(); + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles.clear(); + } + { + std::lock_guard lock(fileDataMutex); + fileData.clear(); + } +} + +//the latest and fastest version of searching a hash by now +int search_hash(const std::string& dbname_, const std::string& hash_, const std::string& filepath_) { + // Check if the file mapping is already open for the given filename + std::string dbname; + std::string hash; + std::string filepath; + { + std::lock_guard lock(fileHandlesMutex); + dbname = dbname_; + } + { + std::lock_guard lock(fileDataMutex); + hash = hash_; + } + { + std::lock_guard lock(mappingHandlesMutex); + filepath = filepath_; + } + + auto fileIter = fileHandles.find(dbname); + if (fileIter == fileHandles.end() && dbname_.find("c:.jdbf") == std::string::npos) { + log(LOGLEVEL::ERR_NOSEND, "[search_hash()]: File mapping not initialized for ", dbname); + return 2; + } + else if (fileIter == fileHandles.end()) { + return 2; + } + + // Use fileData for subsequent searches + DWORD fileSize; + std::string fileContent; + { + std::lock_guard lock(fileDataMutex); + fileSize = GetFileSize(fileHandles[dbname], NULL); + fileContent = std::string(fileData[dbname], fileSize); + } + + // Search for the specific string in the file content + size_t foundPos = fileContent.find(hash); + if (foundPos != std::string::npos) { + //log(LOGLEVEL::VIRUS, "[search_hash()]: Found virus: ", hash, " in file: ", filepath); + virus_ctrl_store(filepath.c_str(), hash.c_str(), hash.c_str()); + //afterwards do the processing with that file + virus_ctrl_process(hash.c_str()); + return 1; // Found + } + return 0; // Not found +} + + +bool file_exists(const std::string& filePath) { + DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + + if (fileAttributes == INVALID_FILE_ATTRIBUTES) { + // The file does not exist or there was an error + return false; + } + + // Check if it's a regular file and not a directory + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; +} + +//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings +void scan_folder(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::WARN, "[scan_folder()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + scan_folder(full_path); + } + else { + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path, "threads: ", num_threads); + //action scanfile_t will start the trheads for scanning the hashes + //action_scanfile_t(full_path.c_str()); + + //do multithreading here + int thread_timeout = 0; + while (num_threads >= std::thread::hardware_concurrency()) { + Sleep(10); + thread_timeout++; + if (thread_timeout == 100 * 60) {//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + printf("Number of threads_max: %d\n", num_threads); + } + } + //log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path, "threads: ",num_threads); + if (is_valid_path(full_path)==0) { + std::uintmax_t fileSize = std::filesystem::file_size(full_path); + if (fileSize > 4000000000) {//4gb + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", full_path); + } + else { + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + //Sleep(1); + } + }else + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Invalid path: ", full_path); + cnt++; + if (cnt % 100 == 0) { + printf("Processed %d files;\n", cnt); + //printf("Number of threads: %d\n", num_threads); + } + if(num_threads<0) + printf("Number of threads_min: %d\n", num_threads); + } + } while (FindNextFile(hFind, &find_file_data) != 0); + + FindClose(hFind); +} + + + +//for singlethreaded scans +void action_scanfile(const std::string& filepath_) { + thread_init(); + const std::string filepath(filepath_); + char* db_path = new char[300]; + char* hash = new char[300]; + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH,std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } + } + thread_shutdown(); +} +void action_scanfolder(const std::string& folderpath) { + thread_init(); + cnt = 0; + thread_local std::string folderpath_(folderpath); + scan_folder(folderpath_); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "end " << "\"" << "nothing" << "\"" << " " << "nothing" << " " << "nothing" << "\n"; + answer_com.close(); + } + thread_shutdown(); +} + +void scan_file_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + thread_local std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else{ + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + search_hash(db_path, hash, filepath); + num_threads--; +} +void scan_process_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + strcpy_s(hash, 295, md5_file_t(filepath).c_str()); + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) == 1) { + //check if need to kill process + if (get_setting("virus_ctrl:virus_process_found:kill") == 1) { + //kill the process + kill_process(filepath.c_str()); + log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); + } + } + num_threads--; +} +#endif \ No newline at end of file diff --git a/src/client_backend/scan.cpp~RF21b5556.TMP b/src/client_backend/scan.cpp~RF21b5556.TMP new file mode 100644 index 0000000..2f3c23b --- /dev/null +++ b/src/client_backend/scan.cpp~RF21b5556.TMP @@ -0,0 +1,311 @@ +#ifndef SCAN_CPP +#define SCAN_CPP +#include "scan.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "md5hash.h" +#include +#include "well_known.h" +#include "log.h" +#include "virus_ctrl.h" +#include "app_ctrl.h" +#include // Include the mutex header +#include +#include "utils.h" + +// Define mutexes for thread synchronization +std::mutex fileHandlesMutex; +std::mutex mappingHandlesMutex; +std::mutex fileDataMutex; +std::mutex cntMutex; +std::mutex numThreadsMutex; + +std::unordered_map fileHandles; +std::unordered_map mappingHandles; +std::unordered_map fileData; + +int cnt = 0; +int num_threads = 0; + +//load all the db files into memory +int initialize(const std::string& folderPath) { + for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) { + for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) { + // Ensure that the characters are valid hexadecimal digits + if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) { + continue; + } + + // Create the filename based on the naming convention + std::string filename = folderPath + "\\" + firstChar + secondChar + ".jdbf"; + //printf("Loading %s\n", filename.c_str()); + + // Open the file + HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + //log(LOGLEVEL::ERR, "[initialize()]: Error opening database file: ", filename); + return 1; + } + + // Create the file mapping + HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) { + // log(LOGLEVEL::ERR, "[initialize()]: Error creating database file mapping: ", filename); + CloseHandle(hFile); + return 2; + } + + // Map the file into memory + char* fileDataPtr = static_cast(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); + if (fileDataPtr == NULL) { + //log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename); + CloseHandle(hMapping); + CloseHandle(hFile); + return 3; + } + + // Store the handles in the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles[filename] = hFile; + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles[filename] = hMapping; + } + { + std::lock_guard lock(fileDataMutex); + fileData[filename] = fileDataPtr; + } + } + } + return 0; +} + +// Call this function when you are done using the file mappings +void cleanup() { + for (const auto& entry : fileHandles) { + UnmapViewOfFile(fileData[entry.first]); + CloseHandle(mappingHandles[entry.first]); + CloseHandle(entry.second); + } + + // Clear the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles.clear(); + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles.clear(); + } + { + std::lock_guard lock(fileDataMutex); + fileData.clear(); + } +} + +//the latest and fastest version of searching a hash by now +int search_hash(const std::string& dbname_, const std::string& hash_, const std::string& filepath_) { + // Check if the file mapping is already open for the given filename + std::string dbname; + std::string hash; + std::string filepath; + { + std::lock_guard lock(fileHandlesMutex); + dbname = dbname_; + } + { + std::lock_guard lock(fileDataMutex); + hash = hash_; + } + { + std::lock_guard lock(mappingHandlesMutex); + filepath = filepath_; + } + + auto fileIter = fileHandles.find(dbname); + if (fileIter == fileHandles.end() && dbname_.find("c:.jdbf") == std::string::npos) { + log(LOGLEVEL::ERR_NOSEND, "[search_hash()]: File mapping not initialized for ", dbname); + return 2; + } + else if (fileIter == fileHandles.end()) { + return 2; + } + + // Use fileData for subsequent searches + DWORD fileSize; + std::string fileContent; + { + std::lock_guard lock(fileDataMutex); + fileSize = GetFileSize(fileHandles[dbname], NULL); + fileContent = std::string(fileData[dbname], fileSize); + } + + // Search for the specific string in the file content + size_t foundPos = fileContent.find(hash); + if (foundPos != std::string::npos) { + //log(LOGLEVEL::VIRUS, "[search_hash()]: Found virus: ", hash, " in file: ", filepath); + virus_ctrl_store(filepath.c_str(), hash.c_str(), hash.c_str()); + //afterwards do the processing with that file + virus_ctrl_process(hash.c_str()); + return 1; // Found + } + return 0; // Not found +} + + +bool file_exists(const std::string& filePath) { + DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + + if (fileAttributes == INVALID_FILE_ATTRIBUTES) { + // The file does not exist or there was an error + return false; + } + + // Check if it's a regular file and not a directory + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; +} + +//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings +void scan_folder(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::WARN, "[scan_folder()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + scan_folder(full_path); + } + else { + //action scanfile_t will start the trheads for scanning the hashes + //action_scanfile_t(full_path.c_str()); + + //do multithreading here + int thread_timeout = 0; + while (num_threads >= std::thread::hardware_concurrency()) { + Sleep(10); + thread_timeout++; + if (thread_timeout == 100 * 60) {//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + printf("Number of threads_max: %d\n", num_threads); + } + } + + if (is_valid_path(full_path)) { //filter out invalid paths and paths with weird characters + std::uintmax_t fileSize = std::filesystem::file_size(full_path); + if (fileSize > 4000000000) {//4gb + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", full_path); + } + else { + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + Sleep(10); + } + }else + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Invalid path: ", full_path); + cnt++; + if (cnt % 100 == 0) { + printf("Processed %d files;\n", cnt); + //printf("Number of threads: %d\n", num_threads); + } + if(num_threads<0) + printf("Number of threads_min: %d\n", num_threads); + } + } while (FindNextFile(hFind, &find_file_data) != 0); + + FindClose(hFind); +} + + + +//for singlethreaded scans +void action_scanfile(const std::string& filepath_) { + thread_init(); + const std::string filepath(filepath_); + char* db_path = new char[300]; + char* hash = new char[300]; + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH,std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } + } + thread_shutdown(); +} +void action_scanfolder(const std::string& folderpath) { + thread_init(); + cnt = 0; + thread_local std::string folderpath_(folderpath); + scan_folder(folderpath_); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "end " << "\"" << "nothing" << "\"" << " " << "nothing" << " " << "nothing" << "\n"; + answer_com.close(); + } + thread_shutdown(); +} + +void scan_file_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + thread_local std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else{ + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + search_hash(db_path, hash, filepath); + num_threads--; +} +void scan_process_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + strcpy_s(hash, 295, md5_file_t(filepath).c_str()); + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) == 1) { + //check if need to kill process + if (get_setting("virus_ctrl:virus_process_found:kill") == 1) { + //kill the process + kill_process(filepath.c_str()); + log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); + } + } + num_threads--; +} +#endif \ No newline at end of file diff --git a/src/client_backend/scan.cpp~RF94003e.TMP b/src/client_backend/scan.cpp~RF94003e.TMP new file mode 100644 index 0000000..217d8c5 --- /dev/null +++ b/src/client_backend/scan.cpp~RF94003e.TMP @@ -0,0 +1,323 @@ +#ifndef SCAN_CPP +#define SCAN_CPP +#include "scan.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "md5hash.h" +#include +#include "well_known.h" +#include "log.h" +#include "virus_ctrl.h" +#include "app_ctrl.h" +#include // Include the mutex header +#include +#include "utils.h" + +// Define mutexes for thread synchronization +std::mutex fileHandlesMutex; +std::mutex mappingHandlesMutex; +std::mutex fileDataMutex; +std::mutex cntMutex; +std::mutex numThreadsMutex; + +std::unordered_map fileHandles; +std::unordered_map mappingHandles; +std::unordered_map fileData; + +int cnt = 0; +int num_threads = 0; + +//load all the db files into memory +int initialize(const std::string& folderPath) { + for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) { + for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) { + // Ensure that the characters are valid hexadecimal digits + if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) { + continue; + } + + // Create the filename based on the naming convention + std::string filename = folderPath + "\\" + firstChar + secondChar + ".jdbf"; + //printf("Loading %s\n", filename.c_str()); + + // Open the file + HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + //log(LOGLEVEL::ERR, "[initialize()]: Error opening database file: ", filename); + return 1; + } + + // Create the file mapping + HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) { + // log(LOGLEVEL::ERR, "[initialize()]: Error creating database file mapping: ", filename); + CloseHandle(hFile); + return 2; + } + + // Map the file into memory + char* fileDataPtr = static_cast(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); + if (fileDataPtr == NULL) { + //log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename); + CloseHandle(hMapping); + CloseHandle(hFile); + return 3; + } + + // Store the handles in the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles[filename] = hFile; + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles[filename] = hMapping; + } + { + std::lock_guard lock(fileDataMutex); + fileData[filename] = fileDataPtr; + } + } + } + return 0; +} + +// Call this function when you are done using the file mappings +void cleanup() { + for (const auto& entry : fileHandles) { + UnmapViewOfFile(fileData[entry.first]); + CloseHandle(mappingHandles[entry.first]); + CloseHandle(entry.second); + } + + // Clear the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles.clear(); + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles.clear(); + } + { + std::lock_guard lock(fileDataMutex); + fileData.clear(); + } +} + +//the latest and fastest version of searching a hash by now +int search_hash(const std::string& dbname_, const std::string& hash_, const std::string& filepath_) { + // Check if the file mapping is already open for the given filename + std::string dbname; + std::string hash; + std::string filepath; + { + std::lock_guard lock(fileHandlesMutex); + dbname = dbname_; + } + { + std::lock_guard lock(fileDataMutex); + hash = hash_; + } + { + std::lock_guard lock(mappingHandlesMutex); + filepath = filepath_; + } + + auto fileIter = fileHandles.find(dbname); + if (fileIter == fileHandles.end() && dbname_.find("c:.jdbf") == std::string::npos) { + log(LOGLEVEL::ERR_NOSEND, "[search_hash()]: File mapping not initialized for ", dbname); + return 2; + } + else if (fileIter == fileHandles.end()) { + return 2; + } + + // Use fileData for subsequent searches + DWORD fileSize; + std::string fileContent; + { + std::lock_guard lock(fileDataMutex); + fileSize = GetFileSize(fileHandles[dbname], NULL); + fileContent = std::string(fileData[dbname], fileSize); + } + + // Search for the specific string in the file content + size_t foundPos = fileContent.find(hash); + if (foundPos != std::string::npos) { + //log(LOGLEVEL::VIRUS, "[search_hash()]: Found virus: ", hash, " in file: ", filepath); + virus_ctrl_store(filepath.c_str(), hash.c_str(), hash.c_str()); + //afterwards do the processing with that file + virus_ctrl_process(hash.c_str()); + return 1; // Found + } + return 0; // Not found +} + + +bool file_exists(const std::string& filePath) { + DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + + if (fileAttributes == INVALID_FILE_ATTRIBUTES) { + // The file does not exist or there was an error + return false; + } + + // Check if it's a regular file and not a directory + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; +} + +//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings +void scan_folder(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::WARN, "[scan_folder()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + scan_folder(full_path); + } + else { + //action scanfile_t will start the trheads for scanning the hashes + //action_scanfile_t(full_path.c_str()); + + //do multithreading here + int thread_timeout = 0; + while (num_threads >= std::thread::hardware_concurrency()) { + Sleep(10); + thread_timeout++; + if (thread_timeout == 100 * 60) {//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + printf("Number of threads_max: %d\n", num_threads); + } + } + + if (is_valid_path(full_path)) { //filter out invalid paths and paths with weird characters + std::uintmax_t fileSize = std::filesystem::file_size(full_path); + if (fileSize > 4000000000) {//4gb + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", full_path); + } + else { + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + } + }else + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Invalid path: ", full_path); + cnt++; + if (cnt % 100 == 0) { + printf("Processed %d files;\n", cnt); + //printf("Number of threads: %d\n", num_threads); + } + if (cnt % 1000 == 0) { + //send progress to com file + printf("Processed %d files; Sending to frontend\n", cnt); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "progress " << 50 << "\n"; + answer_com.close(); + } + } + if(num_threads<0) + printf("Number of threads_min: %d\n", num_threads); + } + } while (FindNextFile(hFind, &find_file_data) != 0); + + FindClose(hFind); +} + + + +//for singlethreaded scans +void action_scanfile(const std::string& filepath_) { + thread_init(); + const std::string filepath(filepath_); + char* db_path = new char[300]; + char* hash = new char[300]; + if (is_valid_path(filepath_)) { //filter out invalid paths and paths with weird characters + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } + } + } + else + log(LOGLEVEL::INFO_NOSEND, "[action_scanfile()]: Invalid path: ", filepath_); + thread_shutdown(); +} +void action_scanfolder(const std::string& folderpath) { + thread_init(); + cnt = 0; + thread_local std::string folderpath_(folderpath); + scan_folder(folderpath_); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "end " << "\"" << "nothing" << "\"" << " " << "nothing" << " " << "nothing" << "\n"; + answer_com.close(); + } + thread_shutdown(); +} + +void scan_file_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + thread_local std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else{ + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + search_hash(db_path, hash, filepath); + num_threads--; +} +void scan_process_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + strcpy_s(hash, 295, md5_file_t(filepath).c_str()); + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) == 1) { + //check if need to kill process + if (get_setting("virus_ctrl:virus_process_found:kill") == 1) { + //kill the process + kill_process(filepath.c_str()); + log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); + } + } + num_threads--; +} +#endif \ No newline at end of file diff --git a/src/client_backend/scan.cpp~RFe042c4.TMP b/src/client_backend/scan.cpp~RFe042c4.TMP new file mode 100644 index 0000000..5f4af28 --- /dev/null +++ b/src/client_backend/scan.cpp~RFe042c4.TMP @@ -0,0 +1,344 @@ +#ifndef SCAN_CPP +#define SCAN_CPP +#include "scan.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "md5hash.h" +#include +#include "well_known.h" +#include "log.h" +#include "virus_ctrl.h" +#include "app_ctrl.h" +#include // Include the mutex header +#include +#include "utils.h" + +// Define mutexes for thread synchronization +std::mutex fileHandlesMutex; +std::mutex mappingHandlesMutex; +std::mutex fileDataMutex; +std::mutex cntMutex; +std::mutex numThreadsMutex; + +std::unordered_map fileHandles; +std::unordered_map mappingHandles; +std::unordered_map fileData; + +int cnt = 0; +int num_threads = 0; +int all_files = 0; + +//load all the db files into memory +int initialize(const std::string& folderPath) { + for (char firstChar = '0'; firstChar <= 'f'; ++firstChar) { + for (char secondChar = '0'; secondChar <= 'f'; ++secondChar) { + // Ensure that the characters are valid hexadecimal digits + if (!std::isxdigit(firstChar) || !std::isxdigit(secondChar) or std::isupper(firstChar) or std::isupper(secondChar)) { + continue; + } + + // Create the filename based on the naming convention + std::string filename = folderPath + "\\" + firstChar + secondChar + ".jdbf"; + //printf("Loading %s\n", filename.c_str()); + + // Open the file + HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) { + //log(LOGLEVEL::ERR, "[initialize()]: Error opening database file: ", filename); + return 1; + } + + // Create the file mapping + HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) { + // log(LOGLEVEL::ERR, "[initialize()]: Error creating database file mapping: ", filename); + CloseHandle(hFile); + return 2; + } + + // Map the file into memory + char* fileDataPtr = static_cast(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0)); + if (fileDataPtr == NULL) { + //log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename); + CloseHandle(hMapping); + CloseHandle(hFile); + return 3; + } + + // Store the handles in the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles[filename] = hFile; + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles[filename] = hMapping; + } + { + std::lock_guard lock(fileDataMutex); + fileData[filename] = fileDataPtr; + } + } + } + return 0; +} + +// Call this function when you are done using the file mappings +void cleanup() { + for (const auto& entry : fileHandles) { + UnmapViewOfFile(fileData[entry.first]); + CloseHandle(mappingHandles[entry.first]); + CloseHandle(entry.second); + } + + // Clear the global maps + { + std::lock_guard lock(fileHandlesMutex); + fileHandles.clear(); + } + { + std::lock_guard lock(mappingHandlesMutex); + mappingHandles.clear(); + } + { + std::lock_guard lock(fileDataMutex); + fileData.clear(); + } +} + +//the latest and fastest version of searching a hash by now +int search_hash(const std::string& dbname_, const std::string& hash_, const std::string& filepath_) { + // Check if the file mapping is already open for the given filename + std::string dbname; + std::string hash; + std::string filepath; + { + std::lock_guard lock(fileHandlesMutex); + dbname = dbname_; + } + { + std::lock_guard lock(fileDataMutex); + hash = hash_; + } + { + std::lock_guard lock(mappingHandlesMutex); + filepath = filepath_; + } + + auto fileIter = fileHandles.find(dbname); + if (fileIter == fileHandles.end() && dbname_.find("c:.jdbf") == std::string::npos) { + log(LOGLEVEL::ERR_NOSEND, "[search_hash()]: File mapping not initialized for ", dbname); + return 2; + } + else if (fileIter == fileHandles.end()) { + return 2; + } + + // Use fileData for subsequent searches + DWORD fileSize; + std::string fileContent; + { + std::lock_guard lock(fileDataMutex); + fileSize = GetFileSize(fileHandles[dbname], NULL); + fileContent = std::string(fileData[dbname], fileSize); + } + + // Search for the specific string in the file content + size_t foundPos = fileContent.find(hash); + if (foundPos != std::string::npos) { + //log(LOGLEVEL::VIRUS, "[search_hash()]: Found virus: ", hash, " in file: ", filepath); + virus_ctrl_store(filepath.c_str(), hash.c_str(), hash.c_str()); + //afterwards do the processing with that file + virus_ctrl_process(hash.c_str()); + return 1; // Found + } + return 0; // Not found +} + +//function to get num of files in idr and its subdirs etc +int get_num_files(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + int num_files = 0; + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::ERR_NOSEND, "[get_num_files()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return 0; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + num_files += get_num_files(full_path); + } + else { + num_files++; + } + } while (FindNextFile(hFind, &find_file_data) != 0); + FindClose(hFind); + return num_files; +} + +//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings +void scan_folder(const std::string& directory) { + std::string search_path = directory + "\\*.*"; + WIN32_FIND_DATA find_file_data; + HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); + + if (hFind == INVALID_HANDLE_VALUE) { + log(LOGLEVEL::WARN, "[scan_folder()]: Could not open directory: ", search_path.c_str(), " while scanning files inside directory."); + return; + } + + do { + if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) { + continue; // Skip the current and parent directories + } + + + const std::string full_path = directory + "\\" + find_file_data.cFileName; + if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // If it's a directory, recurse into it + scan_folder(full_path); + } + else { + //action scanfile_t will start the trheads for scanning the hashes + //action_scanfile_t(full_path.c_str()); + if (cnt > 47400) { + //say which file we are scanning now + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path); + } + //do multithreading here + int thread_timeout = 0; + while (num_threads >= std::thread::hardware_concurrency()) { + Sleep(10); + thread_timeout++; + if (thread_timeout == 100 * 60) {//if there is for more than 30 seconds no thread available, chances are high, that the threads did not temrinate correctly but aren t running anymore. so set the counter to 0 because else it might just stop the scan. + num_threads = 0; + } + } + + if (is_valid_path(full_path)) { //filter out invalid paths and paths with weird characters + std::uintmax_t fileSize = std::filesystem::file_size(full_path); + if (fileSize > 4000000000) {//4gb + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", full_path); + } + else { + std::thread scan_thread(scan_file_t, full_path); + scan_thread.detach(); + } + }else + log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Invalid path: ", full_path); + cnt++; + if (cnt % 100 == 0) { + printf("Processed %d files;\n", cnt); + //printf("Number of threads: %d\n", num_threads); + } + if (cnt % 1000 == 0) { + //send progress to com file + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "progress " << (cnt*100/(all_files+1)) << "\n"; + answer_com.close(); + } + } + } + } while (FindNextFile(hFind, &find_file_data) != 0); + + FindClose(hFind); +} + + + +//for singlethreaded scans +void action_scanfile(const std::string& filepath_) { + thread_init(); + const std::string filepath(filepath_); + char* db_path = new char[300]; + char* hash = new char[300]; + if (is_valid_path(filepath_)) { //filter out invalid paths and paths with weird characters + std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else { + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) != 1) { + //notify desktop client by writing to answer_com file + //if there is now virus, we notify here. if there is a virus we only notify in the virus_ctrl_process function + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "not_found " << "\"" << filepath_ << "\"" << " " << hash << " " << "no_action_taken" << "\n"; + answer_com.close(); + } + } + } + else + log(LOGLEVEL::INFO_NOSEND, "[action_scanfile()]: Invalid path: ", filepath_); + thread_shutdown(); +} +void action_scanfolder(const std::string& folderpath) { + thread_init(); + thread_local std::string folderpath_(folderpath); + cnt = 0; + all_files = get_num_files(folderpath_); + //tell the desktop client that the scan has started + std::ofstream answer_com1(ANSWER_COM_PATH, std::ios::app); + if (answer_com1.is_open()) { + answer_com1 << "start " << all_files << "\n"; + answer_com1.close(); + } + scan_folder(folderpath_); + std::ofstream answer_com(ANSWER_COM_PATH, std::ios::app); + if (answer_com.is_open()) { + answer_com << "end " << "\"" << "nothing" << "\"" << " " << "nothing" << " " << "nothing" << "\n"; + answer_com.close(); + } + thread_shutdown(); +} + +void scan_file_t(const std::string& filepath_) { + num_threads++; + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + thread_local std::string hash_(md5_file_t(filepath)); + if (strlen(hash_.c_str()) < 290) + strcpy_s(hash, 295, hash_.c_str()); + else{ + strcpy_s(hash, 295, ""); + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not calculate hash for file: ", filepath); + } + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + search_hash(db_path, hash, filepath); + num_threads--; +} +void scan_process_t(const std::string& filepath_) { + thread_local const std::string filepath(filepath_); + thread_local char* db_path = new char[300]; + thread_local char* hash = new char[300]; + strcpy_s(hash, 295, md5_file_t(filepath).c_str()); + sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]); + if (search_hash(db_path, hash, filepath) == 1) { + //check if need to kill process + if (get_setting("virus_ctrl:virus_process_found:kill") == 1) { + //kill the process + kill_process(filepath.c_str()); + log(LOGLEVEL::VIRUS, "[scan_process_t()]: Killing process: ", filepath); + } + } +} +#endif \ No newline at end of file diff --git a/src/client_backend/thread_ctrl.cpp b/src/client_backend/thread_ctrl.cpp index 2bc0c2f..644f096 100644 --- a/src/client_backend/thread_ctrl.cpp +++ b/src/client_backend/thread_ctrl.cpp @@ -51,12 +51,7 @@ int start_thread(const std::string& command) { t1.detach(); has_run = 1; } - if (has_run) { - while (can_run_thread()) { - // Delay a bit to wait until the thread is started - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - } + Sleep(10); // Sleep for 10 ms to give the thread time to start } return 0; } diff --git a/src/client_backend/utils.cpp b/src/client_backend/utils.cpp index a55f7d4..7a7307f 100644 --- a/src/client_backend/utils.cpp +++ b/src/client_backend/utils.cpp @@ -4,6 +4,9 @@ #include #include "log.h" #include +#include +#include +#include void split(const std::string& input, char delimiter, std::string& out1, std::string& out2) { // Split a string at the delimiter. The delimiter only occurs once. @@ -14,6 +17,17 @@ void split(const std::string& input, char delimiter, std::string& out1, std::str out2 = input.substr(pos + 1); } } +bool is_valid_path(const std::string& filename) { + for (char c : filename) { + if (c == '<' || c == '>' || c == '"' || c == '|' || c == '?' || c == '*' || c > 126 || c < 32 ) { + return 0; // Special character found + } + } + if (!std::filesystem::exists(filename)) { + return 0; // File does not exist + } + return 1; // No special character found +} void startup(LPCTSTR lpApplicationName) @@ -91,4 +105,17 @@ void kill_process(const std::string& path) { hRes = Process32Next(hSnapShot, &pEntry); } CloseHandle(hSnapShot); +} + + +bool file_exists(const std::string& filePath) { + DWORD fileAttributes = GetFileAttributes(filePath.c_str()); + + if (fileAttributes == INVALID_FILE_ATTRIBUTES) { + // The file does not exist or there was an error + return false; + } + + // Check if it's a regular file and not a directory + return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; } \ No newline at end of file diff --git a/src/client_backend/utils.cpp~RF2156205.TMP b/src/client_backend/utils.cpp~RF2156205.TMP new file mode 100644 index 0000000..5828e1c --- /dev/null +++ b/src/client_backend/utils.cpp~RF2156205.TMP @@ -0,0 +1,102 @@ +#include "utils.h" +#include +#include +#include +#include "log.h" +#include +#include + +void split(const std::string& input, char delimiter, std::string& out1, std::string& out2) { + // Split a string at the delimiter. The delimiter only occurs once. + // The first part is stored in out1 and the second part in out2. + size_t pos = input.find(delimiter); + if (pos != std::string::npos) { + out1 = input.substr(0, pos); + out2 = input.substr(pos + 1); + } +} +bool is_valid_path(const std::string& filename) { + // Define a regular expression pattern for allowed characters + // This pattern allows letters (upper and lower case), numbers, underscores, and hyphens + std::regex pattern("[^<>:\"/\\\\|?*]+"); + // Check if the filename matches the pattern + return std::regex_match(filename, pattern); +} + + +void startup(LPCTSTR lpApplicationName) +{ + // additional information + STARTUPINFO si; + PROCESS_INFORMATION pi; + + // set the size of the structures + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + // start the program up + CreateProcess(lpApplicationName, // the path + NULL, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi // Pointer to PROCESS_INFORMATION structure + ); + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + + +std::string get_filename(const std::string& path) { + auto pos = path.find_last_of("\\"); + if (pos == std::string::npos) { + // No directory separator found, return the original path + return path; + } + else { + // Return the substring after the last directory separator + return path.substr(pos + 1); + } +} + +int strcasecmp(const std::string& s1, const std::string& s2) { + auto it1 = s1.begin(); + auto it2 = s2.begin(); + while (it1 != s1.end() && it2 != s2.end()) { + int diff = std::tolower(*it1) - std::tolower(*it2); + if (diff != 0) + return diff; + ++it1; + ++it2; + } + return 0; +} + +void kill_process(const std::string& path) { + HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL); + PROCESSENTRY32 pEntry; + pEntry.dwSize = sizeof(pEntry); + BOOL hRes = Process32First(hSnapShot, &pEntry); + while (hRes) + { + if (strcasecmp(pEntry.szExeFile, get_filename(path).c_str()) == 0) + { + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, static_cast(pEntry.th32ProcessID)); + if (hProcess != NULL) + { + TerminateProcess(hProcess, 9); + CloseHandle(hProcess); + } + else + log(LOGLEVEL::ERR, "[kill_process()]: Error while killing process: ", path); + } + hRes = Process32Next(hSnapShot, &pEntry); + } + CloseHandle(hSnapShot); +} \ No newline at end of file diff --git a/src/client_backend/utils.cpp~RF2277854.TMP b/src/client_backend/utils.cpp~RF2277854.TMP new file mode 100644 index 0000000..e69de29 diff --git a/src/client_backend/utils.cpp~RF2277864.TMP b/src/client_backend/utils.cpp~RF2277864.TMP new file mode 100644 index 0000000..e69de29 diff --git a/src/client_backend/utils.cpp~RF27f7ad9.TMP b/src/client_backend/utils.cpp~RF27f7ad9.TMP new file mode 100644 index 0000000..4a05a71 --- /dev/null +++ b/src/client_backend/utils.cpp~RF27f7ad9.TMP @@ -0,0 +1,105 @@ +#include "utils.h" +#include +#include +#include +#include "log.h" +#include +#include +#include +#include + +void split(const std::string& input, char delimiter, std::string& out1, std::string& out2) { + // Split a string at the delimiter. The delimiter only occurs once. + // The first part is stored in out1 and the second part in out2. + size_t pos = input.find(delimiter); + if (pos != std::string::npos) { + out1 = input.substr(0, pos); + out2 = input.substr(pos + 1); + } +} +bool is_valid_path(const std::string& filename) { + for (char c : filename) { + if (c == '<' || c == '>' || c == '"' || c == '|' || c == '?' || c == '*') { + return 0; // Special character found + } + } + return 1; // No special character found +} + + +void startup(LPCTSTR lpApplicationName) +{ + // additional information + STARTUPINFO si; + PROCESS_INFORMATION pi; + + // set the size of the structures + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + // start the program up + CreateProcess(lpApplicationName, // the path + NULL, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi // Pointer to PROCESS_INFORMATION structure + ); + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + + +std::string get_filename(const std::string& path) { + auto pos = path.find_last_of("\\"); + if (pos == std::string::npos) { + // No directory separator found, return the original path + return path; + } + else { + // Return the substring after the last directory separator + return path.substr(pos + 1); + } +} + +int strcasecmp(const std::string& s1, const std::string& s2) { + auto it1 = s1.begin(); + auto it2 = s2.begin(); + while (it1 != s1.end() && it2 != s2.end()) { + int diff = std::tolower(*it1) - std::tolower(*it2); + if (diff != 0) + return diff; + ++it1; + ++it2; + } + return 0; +} + +void kill_process(const std::string& path) { + HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL); + PROCESSENTRY32 pEntry; + pEntry.dwSize = sizeof(pEntry); + BOOL hRes = Process32First(hSnapShot, &pEntry); + while (hRes) + { + if (strcasecmp(pEntry.szExeFile, get_filename(path).c_str()) == 0) + { + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, static_cast(pEntry.th32ProcessID)); + if (hProcess != NULL) + { + TerminateProcess(hProcess, 9); + CloseHandle(hProcess); + } + else + log(LOGLEVEL::ERR, "[kill_process()]: Error while killing process: ", path); + } + hRes = Process32Next(hSnapShot, &pEntry); + } + CloseHandle(hSnapShot); +} \ No newline at end of file diff --git a/src/client_backend/utils.cpp~RF94bc89.TMP b/src/client_backend/utils.cpp~RF94bc89.TMP new file mode 100644 index 0000000..c1a3f4d --- /dev/null +++ b/src/client_backend/utils.cpp~RF94bc89.TMP @@ -0,0 +1,105 @@ +#include "utils.h" +#include +#include +#include +#include "log.h" +#include +#include +#include +#include + +void split(const std::string& input, char delimiter, std::string& out1, std::string& out2) { + // Split a string at the delimiter. The delimiter only occurs once. + // The first part is stored in out1 and the second part in out2. + size_t pos = input.find(delimiter); + if (pos != std::string::npos) { + out1 = input.substr(0, pos); + out2 = input.substr(pos + 1); + } +} +bool is_valid_path(const std::string& filename) { + for (char c : filename) { + if (c == '<' || c == '>' || c == '"' || c == '|' || c == '?' || c == '*' || c > 126 || c < 32 ) { + return 0; // Special character found + } + } + return 1; // No special character found +} + + +void startup(LPCTSTR lpApplicationName) +{ + // additional information + STARTUPINFO si; + PROCESS_INFORMATION pi; + + // set the size of the structures + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + // start the program up + CreateProcess(lpApplicationName, // the path + NULL, // Command line + NULL, // Process handle not inheritable + NULL, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + 0, // No creation flags + NULL, // Use parent's environment block + NULL, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi // Pointer to PROCESS_INFORMATION structure + ); + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + + +std::string get_filename(const std::string& path) { + auto pos = path.find_last_of("\\"); + if (pos == std::string::npos) { + // No directory separator found, return the original path + return path; + } + else { + // Return the substring after the last directory separator + return path.substr(pos + 1); + } +} + +int strcasecmp(const std::string& s1, const std::string& s2) { + auto it1 = s1.begin(); + auto it2 = s2.begin(); + while (it1 != s1.end() && it2 != s2.end()) { + int diff = std::tolower(*it1) - std::tolower(*it2); + if (diff != 0) + return diff; + ++it1; + ++it2; + } + return 0; +} + +void kill_process(const std::string& path) { + HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL); + PROCESSENTRY32 pEntry; + pEntry.dwSize = sizeof(pEntry); + BOOL hRes = Process32First(hSnapShot, &pEntry); + while (hRes) + { + if (strcasecmp(pEntry.szExeFile, get_filename(path).c_str()) == 0) + { + HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, static_cast(pEntry.th32ProcessID)); + if (hProcess != NULL) + { + TerminateProcess(hProcess, 9); + CloseHandle(hProcess); + } + else + log(LOGLEVEL::ERR, "[kill_process()]: Error while killing process: ", path); + } + hRes = Process32Next(hSnapShot, &pEntry); + } + CloseHandle(hSnapShot); +} \ No newline at end of file diff --git a/src/client_backend/utils.h b/src/client_backend/utils.h index 2f1e1bd..f87edc7 100644 --- a/src/client_backend/utils.h +++ b/src/client_backend/utils.h @@ -6,4 +6,6 @@ std::string get_filename(const std::string& path); int strcasecmp(const std::string& s1, const std::string& s2); void kill_process(const std::string& path); void startup(LPCTSTR lpApplicationName); -void split(const std::string& input, char delimiter, std::string& out1, std::string& out2); \ No newline at end of file +void split(const std::string& input, char delimiter, std::string& out1, std::string& out2); +bool is_valid_path(const std::string& filename); +bool file_exists(const std::string& filename); \ No newline at end of file diff --git a/src/client_backend/utils.h~RF950e34.TMP b/src/client_backend/utils.h~RF950e34.TMP new file mode 100644 index 0000000..e69de29 diff --git a/src/client_backend/utils.h~RF950e43.TMP b/src/client_backend/utils.h~RF950e43.TMP new file mode 100644 index 0000000..e69de29 diff --git a/src/client_backend/x64/Debug/client_backend.pdb b/src/client_backend/x64/Debug/client_backend.pdb index 0fe365e..02c347b 100644 Binary files a/src/client_backend/x64/Debug/client_backend.pdb and b/src/client_backend/x64/Debug/client_backend.pdb differ diff --git a/src/client_frontend/.vs/client_frontend/v17/.suo b/src/client_frontend/.vs/client_frontend/v17/.suo index ff74e78..587de65 100644 Binary files a/src/client_frontend/.vs/client_frontend/v17/.suo and b/src/client_frontend/.vs/client_frontend/v17/.suo differ diff --git a/src/client_frontend/.vs/client_frontend/v17/Browse.VC.db b/src/client_frontend/.vs/client_frontend/v17/Browse.VC.db index 80550ea..8666e90 100644 Binary files a/src/client_frontend/.vs/client_frontend/v17/Browse.VC.db and b/src/client_frontend/.vs/client_frontend/v17/Browse.VC.db differ diff --git a/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json b/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json index ab70a06..15d304d 100644 --- a/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json +++ b/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json @@ -3,28 +3,8 @@ "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\", "Documents": [ { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:ui.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:choose_element.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:choose_element.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\id.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:id.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{644C9824-2298-46C6-9A62-7E080C98A0BB}|client_frontend.vcxproj|solutionrelative:ui.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + "AbsoluteMoniker": "D:0:0:{4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}|client_frontend.vcxproj|solutionrelative:client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" } ], "DocumentGroupContainers": [ @@ -34,84 +14,19 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 4, + "SelectedChildIndex": 0, "Children": [ - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "choose_element.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.h", - "RelativeDocumentMoniker": "choose_element.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.h", - "RelativeToolTip": "choose_element.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAUAAAAGAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-14T17:06:27.941Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 1, - "Title": "choose_element.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.cpp", - "RelativeDocumentMoniker": "choose_element.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\choose_element.cpp", - "RelativeToolTip": "choose_element.cpp", - "ViewState": "AQIAAAAAAAAAAAAAAAAAABcAAABJAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-14T17:06:16.884Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 4, - "Title": "id.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\id.h", - "RelativeDocumentMoniker": "id.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\id.h", - "RelativeToolTip": "id.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAEAAAAQAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-14T16:31:43.692Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 5, - "Title": "ui.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.h", - "RelativeDocumentMoniker": "ui.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.h", - "RelativeToolTip": "ui.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAMAAAAQAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-14T16:28:38.361Z", - "EditorCaption": "" - }, { "$type": "Document", "DocumentIndex": 0, - "Title": "ui.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.cpp", - "RelativeDocumentMoniker": "ui.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\ui.cpp", - "RelativeToolTip": "ui.cpp", - "ViewState": "AQIAACoAAAAAAAAAAAAwwC8AAAAwAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-14T16:28:29.863Z", - "EditorCaption": "" - }, - { - "$type": "Document", - "DocumentIndex": 3, "Title": "client_frontend.cpp", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp", "RelativeDocumentMoniker": "client_frontend.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp", "RelativeToolTip": "client_frontend.cpp", - "ViewState": "AQIAAHsAAAAAAAAAAAAAAJwAAAA3AAAA", + "ViewState": "AQIAAA4BAAAAAAAAAAAAADYBAAAQAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-14T16:22:29.931Z", + "WhenOpened": "2024-03-23T13:52:32.121Z", "EditorCaption": "" } ] diff --git a/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json~RFa547b4.TMP b/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json~RFa547b4.TMP new file mode 100644 index 0000000..242f319 --- /dev/null +++ b/src/client_frontend/.vs/client_frontend/v17/DocumentLayout.json~RFa547b4.TMP @@ -0,0 +1,37 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}|client_frontend.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", + "RelativeMoniker": "D:0:0:{4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}|client_frontend.vcxproj|solutionrelative:client_frontend.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 200, + "SelectedChildIndex": 0, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "client_frontend.cpp", + "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp", + "RelativeDocumentMoniker": "client_frontend.cpp", + "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend\\client_frontend.cpp", + "RelativeToolTip": "client_frontend.cpp", + "ViewState": "AQIAAIQAAAAAAAAAAAAAALAAAAA7AAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", + "WhenOpened": "2024-03-23T13:52:32.121Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/client_frontend/choose_element.cpp b/src/client_frontend/choose_element.cpp deleted file mode 100644 index 7826566..0000000 --- a/src/client_frontend/choose_element.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "choose_element.h" -#include -#include -#include -std::wstring open_file(HWND hWnd) -{ - OPENFILENAME ofn; - WCHAR szFile[MAX_PATH] = L""; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hWnd; - ofn.lpstrFile = szFile; - ofn.lpstrFile[0] = '\0'; - ofn.nMaxFile = sizeof(szFile); - ofn.lpstrFilter = L"All Files\0*.*\0"; // Filter for all files - ofn.nFilterIndex = 1; - ofn.lpstrFileTitle = NULL; - ofn.nMaxFileTitle = 0; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - if (GetOpenFileName(&ofn) == TRUE) - { - // User selected a file, 'szFile' contains the selected file path - return std::wstring(szFile); - } - else - { - // User canceled the dialog - //MessageBox(hWnd, L"File selection canceled.", L"Canceled", MB_OK | MB_ICONEXCLAMATION); - return L"cancel"; - } -} \ No newline at end of file diff --git a/src/client_frontend/choose_element.h b/src/client_frontend/choose_element.h deleted file mode 100644 index b19aca4..0000000 --- a/src/client_frontend/choose_element.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include "id.h" -#include -#include -#include -std::wstring open_file(HWND hWnd); \ No newline at end of file diff --git a/src/client_frontend/client_frontend.cpp b/src/client_frontend/client_frontend.cpp index f5a4abf..c57fdaf 100644 --- a/src/client_frontend/client_frontend.cpp +++ b/src/client_frontend/client_frontend.cpp @@ -1,210 +1,380 @@ -// client_frontend.cpp : Definiert den Einstiegspunkt für die Anwendung. -// -#include -#include "framework.h" -#include "client_frontend.h" -#include "ui.h" -#include "id.h" -#include "choose_element.h" -#define MAX_LOADSTRING 100 +#include +#include +#include +#include +#include +#include +#include +#include "../client_backend/well_known.h" + +#define IDM_SCAN_FILE 101 +#define IDM_SCAN_FOLDER 102 -// Globale Variablen: -HINSTANCE hInst; // Aktuelle Instanz -WCHAR szTitle[MAX_LOADSTRING]; // Titelleistentext -WCHAR szWindowClass[MAX_LOADSTRING]; // Der Klassenname des Hauptfensters. - -// Vorwärtsdeklarationen der in diesem Codemodul enthaltenen Funktionen: -ATOM frontend_class(HINSTANCE hInstance); -BOOL InitInstance(HINSTANCE, int); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); - -int APIENTRY wWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPWSTR lpCmdLine, - _In_ int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - - // TODO: Hier Code einfügen. - - // Globale Zeichenfolgen initialisieren - LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); - LoadStringW(hInstance, IDC_CLIENTFRONTEND, szWindowClass, MAX_LOADSTRING); - frontend_class(hInstance); - - // Anwendungsinitialisierung ausführen: - if (!InitInstance (hInstance, nCmdShow)) - { - return FALSE; +std::wstring string_to_widestring(const std::string& str) { + std::wstring_convert> converter; + return converter.from_bytes(str); +} +void send_command(const std::string& command) { + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << command; + outputFile.close(); } +} - HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CLIENTFRONTEND)); +// 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); - MSG msg; + // Set the selection to the end of the text field + SendMessage(hWndTextField, EM_SETSEL, textLength, textLength); - // Hauptnachrichtenschleife: - while (GetMessage(&msg, nullptr, 0, 0)) - { - if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); + // Append the new text + SendMessage(hWndTextField, EM_REPLACESEL, FALSE, (LPARAM)string_to_widestring(text).c_str()); +} + +void scan_file(HWND hWndTextField, const std::string& filePath) { + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned file path in the window + update_textfield(hWndTextField, "Scanning file: " + filePath + "\r\n"); + bool answered = false; + // Write command into com file + //printf("%d\n",send_to_pipe("scanfile \"" + filePath + "\"")); + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfile \"" << filePath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + if (inputFile >> status) { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + if (status == "found" || status == "not_found") { + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + } + else { + answered = true; + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + update_textfield(hWndTextField, "------------------------------------------\n"); + } + inputFile.close(); + std::remove(ANSWER_COM_PATH); + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + +// Function to simulate folder scanning +void scan_folder(HWND hProgressBar,HWND hWndTextField, const std::string& folderPath) { + //set progress bar to 0 + SendMessage(hProgressBar, PBM_SETPOS, 0, 0); + int num_of_found = 0; + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned folder path in the window + update_textfield(hWndTextField, "Scanning folder: " + folderPath + "\r\n"); + bool answered = false; + // Write command into com file + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfolder \"" << folderPath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + while (!inputFile.eof()) { + if (inputFile >> status) { + if (status == "found" || status == "not_found") { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + //answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + num_of_found++; + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + else if (status == "progress") { + std::string progress; + inputFile.ignore(1); // Ignore space + inputFile >> progress; + SendMessage(hProgressBar, PBM_SETPOS, std::stoi(progress), 0); + + } + else if (status == "start") { + std::string all_files; + inputFile.ignore(1); // Ignore space + inputFile >> all_files; + update_textfield(hWndTextField, "Folder scan started with "+ all_files +" files queued for scan\r\n"); + } + else if (status == "end") { + answered = true; + } + } + } + inputFile.close(); + std::ofstream(ANSWER_COM_PATH);//clear the file + Sleep(1000);//only see for new entrys ~ once a second + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + update_textfield(hWndTextField, "Folder scan completed\r\n"); + update_textfield(hWndTextField, "Number of infected files: " + std::to_string(num_of_found) + "\r\n"); + update_textfield(hWndTextField, "------------------------------------------\r\n"); + SendMessage(hProgressBar, PBM_SETPOS, 100, 0); + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + + + +std::string getFolderPath(HWND hWnd) { + std::wstring selectedFolderPath; + + // Initialize COM + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + // Display the folder picker dialog + BROWSEINFO browseInfo = { 0 }; + TCHAR selectedPath[MAX_PATH]; + browseInfo.hwndOwner = hWnd; // Set the owner window + browseInfo.pidlRoot = NULL; // Start from the desktop + browseInfo.pszDisplayName = selectedPath; + browseInfo.lpszTitle = TEXT("Select a folder"); + browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + + LPITEMIDLIST pidlSelected = SHBrowseForFolder(&browseInfo); + if (pidlSelected != NULL) { + SHGetPathFromIDList(pidlSelected, selectedPath); + + // Convert TCHAR array to std::string + std::wstring_convert> converter; + selectedFolderPath = selectedPath; + + // Free the PIDL + IMalloc* pMalloc; + if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + pMalloc->Free(pidlSelected); + pMalloc->Release(); } } - return (int) msg.wParam; + // Uninitialize COM + CoUninitialize(); + + return std::string(selectedFolderPath.begin(), selectedFolderPath.end()); } - - -// -// FUNKTION: MyRegisterClass() -// -// ZWECK: Registriert die Fensterklasse. -// -ATOM frontend_class(HINSTANCE hInstance) -{ - WNDCLASSEXW wcex; - - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CLIENTFRONTEND)); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_CLIENTFRONTEND); - wcex.lpszClassName = szWindowClass; - wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); - - return RegisterClassExW(&wcex); -} - -// -// FUNKTION: InitInstance(HINSTANCE, int) -// -// ZWECK: Speichert das Instanzenhandle und erstellt das Hauptfenster. -// -// KOMMENTARE: -// -// In dieser Funktion wird das Instanzenhandle in einer globalen Variablen gespeichert, und das -// Hauptprogrammfenster wird erstellt und angezeigt. -// -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - hInst = hInstance; // Instanzenhandle in der globalen Variablen speichern - - HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); - - if (!hWnd) - { - return FALSE; - } - - ShowWindow(hWnd, nCmdShow); - UpdateWindow(hWnd); - - return TRUE; -} - -// -// FUNKTION: WndProc(HWND, UINT, WPARAM, LPARAM) -// -// ZWECK: Verarbeitet Meldungen für das Hauptfenster. -// -// WM_COMMAND - Verarbeiten des Anwendungsmenüs -// WM_PAINT - Darstellen des Hauptfensters -// WM_DESTROY - Ausgeben einer Beendenmeldung und zurückkehren -// -// -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int windowWidth=0; - int windowHeight=0; - RECT clientRect; - GetClientRect(hWnd, &clientRect); - windowWidth = clientRect.right - clientRect.left; - windowHeight = clientRect.bottom - clientRect.top; - switch (message) +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: { + + // Create the "Scan File" button + CreateWindowEx(NULL, L"BUTTON", L"Scan File", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 10, 100, 30, hWnd, (HMENU)IDM_SCAN_FILE, GetModuleHandle(NULL), NULL); + + // Create the "Scan Folder" button + CreateWindowEx(NULL, L"BUTTON", L"Scan Folder", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 50, 100, 30, hWnd, (HMENU)IDM_SCAN_FOLDER, GetModuleHandle(NULL), NULL); + + // 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, + 140, 10, width-140-20, height-10-50, hWnd, NULL, NULL, NULL); + update_textfield(hWndTextField, "Welcome to Cyberhex endpoint protection!\r\n"); + + hProgressBar = CreateWindowEx(0, PROGRESS_CLASS, NULL, + WS_CHILD | WS_VISIBLE | PBS_SMOOTH, + 140, height-40, 200, 20, hWnd, NULL, NULL, NULL); + SendMessage(hProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); + SendMessage(hProgressBar, PBM_SETSTEP, 1, 0); + } + break; + case WM_SIZE: + { + // Resize the text field to fit the window + MoveWindow(hWndTextField, 140, 10, width - 140 - 20, height - 10 - 50, TRUE); + MoveWindow(hProgressBar, 140, height - 40, 200, 20, TRUE); + break; + } case WM_COMMAND: { int wmId = LOWORD(wParam); - // Menüauswahl analysieren: - switch (wmId) + // Parse the menu selections: + switch (wmId) { + case IDM_SCAN_FILE: { - case IDM_ABOUT: - DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); - break; - case IDM_EXIT: - DestroyWindow(hWnd); - break; - case ID_HOME_BUTTON: // Handle the home button click - //set page to 0 - ui_clear(); - ui_display_page(0, windowWidth, windowHeight, hWnd); - break; - case ID_SCAN_FILE_BUTTON: // Handle the scan file button click - //set page to 1 - ui_clear(); - ui_display_page(1, windowWidth, windowHeight, hWnd); - break; + // Open file dialog to select a file + // Call scan_file function in a separate thread + OPENFILENAME ofn; + WCHAR szFile[MAX_PATH] = L""; // Use WCHAR for Unicode compatibility + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hWnd; + ofn.lpstrFile = szFile; + ofn.lpstrFile[0] = L'\0'; // Use wide character constant L'\0' + ofn.nMaxFile = sizeof(szFile); + ofn.lpstrFilter = L"All Files\0*.*\0"; // Use wide character string literal L"" + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = NULL; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + if (GetOpenFileName(&ofn) == TRUE) { + std::wstring selectedFile = ofn.lpstrFile; // Use std::wstring for wide characters + std::string narrowSelectedFile(selectedFile.begin(), selectedFile.end()); + std::thread(scan_file, hWndTextField, narrowSelectedFile).detach(); + } + } + break; + case IDM_SCAN_FOLDER: + { + // Open folder picker dialog + // Call scan_folder function in a separate thread + std::string selected_folder = getFolderPath(hWnd); + if(selected_folder!="") + std::thread(scan_folder,hProgressBar, hWndTextField, selected_folder).detach(); + } + break; default: return DefWindowProc(hWnd, message, wParam, lParam); } } break; + case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); - // TODO: Zeichencode, der hdc verwendet, hier einfügen... + RECT rect; + GetClientRect(hWnd, &rect); + FillRect(hdc, &rect, hBackgroundBrush); // Fill the entire client area with white color EndPaint(hWnd, &ps); } break; - case WM_CREATE: - { - //ui_create(); - ui_display_page(0, windowWidth, windowHeight, hWnd); - } - break; case WM_DESTROY: PostQuitMessage(0); break; - case WM_SIZE: - //ui_resize(); - ui_clear(); - ui_display_page(0, windowWidth, windowHeight, hWnd); - break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } -// Meldungshandler für Infofeld. -INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - UNREFERENCED_PARAMETER(lParam); - switch (message) - { - case WM_INITDIALOG: - return (INT_PTR)TRUE; +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + const wchar_t CLASS_NAME[] = L"Cyberhex endpoint protection frontend"; - case WM_COMMAND: - if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) - { - EndDialog(hDlg, LOWORD(wParam)); - return (INT_PTR)TRUE; - } - break; + WNDCLASS wc = { }; + + wc.lpfnWndProc = WndProc; + wc.hInstance = hInstance; + wc.lpszClassName = CLASS_NAME; + + RegisterClass(&wc); + + HWND hWnd = CreateWindowEx( + 0, + CLASS_NAME, + L"Cyberhex endpoint protection", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 640, + 480, + NULL, + NULL, + hInstance, + NULL + ); + + + if (hWnd == NULL) { + return 0; } - return (INT_PTR)FALSE; + + ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + MSG msg = { }; + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return 0; } diff --git a/src/client_frontend/client_frontend.cpp~RF8ecc27.TMP b/src/client_frontend/client_frontend.cpp~RF8ecc27.TMP new file mode 100644 index 0000000..a7be702 --- /dev/null +++ b/src/client_frontend/client_frontend.cpp~RF8ecc27.TMP @@ -0,0 +1,368 @@ +#include +#include +#include +#include +#include +#include +#include +#include "../client_backend/well_known.h" + +#define IDM_SCAN_FILE 101 +#define IDM_SCAN_FOLDER 102 + + +std::wstring string_to_widestring(const std::string& str) { + std::wstring_convert> converter; + return converter.from_bytes(str); +} +void send_command(const std::string& command) { + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << command; + outputFile.close(); + } +} + +// 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()); +} + +void scan_file(HWND hWndTextField, const std::string& filePath) { + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned file path in the window + update_textfield(hWndTextField, "Scanning file: " + filePath + "\r\n"); + bool answered = false; + // Write command into com file + //printf("%d\n",send_to_pipe("scanfile \"" + filePath + "\"")); + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfile \"" << filePath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + if (inputFile >> status) { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + if (status == "found" || status == "not_found") { + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + } + else { + answered = true; + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + update_textfield(hWndTextField, "------------------------------------------\n"); + } + inputFile.close(); + std::remove(ANSWER_COM_PATH); + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + +// Function to simulate folder scanning +void scan_folder(HWND hProgressBar,HWND hWndTextField, const std::string& folderPath) { + int num_of_found = 0; + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned folder path in the window + update_textfield(hWndTextField, "Scanning folder: " + folderPath + "\r\n"); + bool answered = false; + // Write command into com file + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfolder \"" << folderPath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + while (!inputFile.eof()) { + if (inputFile >> status) { + if (status == "found" || status == "not_found") { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + //answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + num_of_found++; + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + else if (status == "progress") { + std::string progress; + inputFile.ignore(1); // Ignore space + inputFile >> progress; + MessageBox(NULL, string_to_widestring(progress).c_str(), L"Progress", MB_OK); + SendMessage(hProgressBar, PBM_SETPOS, atoi(progress.c_str()), 0); + } + else if (status == "end") + answered = true; + } + } + inputFile.close(); + Sleep(1000);//only see for new entrys ~ once a second + std::ofstream(ANSWER_COM_PATH);//clear the file + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + update_textfield(hWndTextField, "Folder scan completed\r\n"); + update_textfield(hWndTextField, "Number of infected files: " + std::to_string(num_of_found) + "\r\n"); + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + + + +std::string getFolderPath(HWND hWnd) { + std::wstring selectedFolderPath; + + // Initialize COM + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + // Display the folder picker dialog + BROWSEINFO browseInfo = { 0 }; + TCHAR selectedPath[MAX_PATH]; + browseInfo.hwndOwner = hWnd; // Set the owner window + browseInfo.pidlRoot = NULL; // Start from the desktop + browseInfo.pszDisplayName = selectedPath; + browseInfo.lpszTitle = TEXT("Select a folder"); + browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + + LPITEMIDLIST pidlSelected = SHBrowseForFolder(&browseInfo); + if (pidlSelected != NULL) { + SHGetPathFromIDList(pidlSelected, selectedPath); + + // Convert TCHAR array to std::string + std::wstring_convert> converter; + selectedFolderPath = selectedPath; + + // Free the PIDL + IMalloc* pMalloc; + if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + pMalloc->Free(pidlSelected); + pMalloc->Release(); + } + } + + // Uninitialize COM + CoUninitialize(); + + return std::string(selectedFolderPath.begin(), selectedFolderPath.end()); +} + +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: + { + + // Create the "Scan File" button + CreateWindowEx(NULL, L"BUTTON", L"Scan File", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 10, 100, 30, hWnd, (HMENU)IDM_SCAN_FILE, GetModuleHandle(NULL), NULL); + + // Create the "Scan Folder" button + CreateWindowEx(NULL, L"BUTTON", L"Scan Folder", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 50, 100, 30, hWnd, (HMENU)IDM_SCAN_FOLDER, GetModuleHandle(NULL), NULL); + + // 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, + 140, 10, width-140-20, height-10-50, hWnd, NULL, NULL, NULL); + update_textfield(hWndTextField, "Welcome to Cyberhex endpoint protection!\r\n"); + + hProgressBar = CreateWindowEx(0, PROGRESS_CLASS, NULL, + WS_CHILD | WS_VISIBLE | PBS_SMOOTH, + 140, height-40, 200, 20, hWnd, NULL, NULL, NULL); + SendMessage(hProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); + SendMessage(hProgressBar, PBM_SETSTEP, 1, 0); + } + break; + case WM_SIZE: + { + // Resize the text field to fit the window + MoveWindow(hWndTextField, 140, 10, width - 140 - 20, height - 10 - 50, TRUE); + MoveWindow(hProgressBar, 140, height - 40, 200, 20, TRUE); + break; + } + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Parse the menu selections: + switch (wmId) { + case IDM_SCAN_FILE: + { + // Open file dialog to select a file + // Call scan_file function in a separate thread + OPENFILENAME ofn; + WCHAR szFile[MAX_PATH] = L""; // Use WCHAR for Unicode compatibility + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hWnd; + ofn.lpstrFile = szFile; + ofn.lpstrFile[0] = L'\0'; // Use wide character constant L'\0' + ofn.nMaxFile = sizeof(szFile); + ofn.lpstrFilter = L"All Files\0*.*\0"; // Use wide character string literal L"" + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = NULL; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + if (GetOpenFileName(&ofn) == TRUE) { + std::wstring selectedFile = ofn.lpstrFile; // Use std::wstring for wide characters + std::string narrowSelectedFile(selectedFile.begin(), selectedFile.end()); + std::thread(scan_file, hWndTextField, narrowSelectedFile).detach(); + } + } + break; + case IDM_SCAN_FOLDER: + { + // Open folder picker dialog + // Call scan_folder function in a separate thread + std::string selectedFolder = getFolderPath(hWnd); + std::thread(scan_folder,hProgressBar, hWndTextField, selectedFolder).detach(); + } + break; + 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 frontend"; + + WNDCLASS wc = { }; + + wc.lpfnWndProc = WndProc; + wc.hInstance = hInstance; + wc.lpszClassName = CLASS_NAME; + + RegisterClass(&wc); + + HWND hWnd = CreateWindowEx( + 0, + CLASS_NAME, + L"Cyberhex endpoint protection", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 640, + 480, + NULL, + NULL, + hInstance, + NULL + ); + + + 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/client_frontend/client_frontend.cpp~RF8fd450.TMP b/src/client_frontend/client_frontend.cpp~RF8fd450.TMP new file mode 100644 index 0000000..99a4d8b --- /dev/null +++ b/src/client_frontend/client_frontend.cpp~RF8fd450.TMP @@ -0,0 +1,367 @@ +#include +#include +#include +#include +#include +#include +#include +#include "../client_backend/well_known.h" + +#define IDM_SCAN_FILE 101 +#define IDM_SCAN_FOLDER 102 + + +std::wstring string_to_widestring(const std::string& str) { + std::wstring_convert> converter; + return converter.from_bytes(str); +} +void send_command(const std::string& command) { + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << command; + outputFile.close(); + } +} + +// 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()); +} + +void scan_file(HWND hWndTextField, const std::string& filePath) { + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned file path in the window + update_textfield(hWndTextField, "Scanning file: " + filePath + "\r\n"); + bool answered = false; + // Write command into com file + //printf("%d\n",send_to_pipe("scanfile \"" + filePath + "\"")); + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfile \"" << filePath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + if (inputFile >> status) { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + if (status == "found" || status == "not_found") { + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + } + else { + answered = true; + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + update_textfield(hWndTextField, "------------------------------------------\n"); + } + inputFile.close(); + std::remove(ANSWER_COM_PATH); + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + +// Function to simulate folder scanning +void scan_folder(HWND hProgressBar,HWND hWndTextField, const std::string& folderPath) { + int num_of_found = 0; + // Remove the answer file + std::remove(ANSWER_COM_PATH); + // Display the scanned folder path in the window + update_textfield(hWndTextField, "Scanning folder: " + folderPath + "\r\n"); + bool answered = false; + // Write command into com file + std::ofstream outputFile(MAIN_COM_PATH); + if (outputFile.is_open()) { + outputFile << "scanfolder \"" << folderPath << "\""; + outputFile.close(); + } + else { + update_textfield(hWndTextField, "Error: Unable to talk to daemon!\n"); + return; + } + while (!answered) { + // Wait for answer in file + std::ifstream inputFile(ANSWER_COM_PATH); + // The structure of the answer file is as follows: + // found/not_found + // filepath + // hash + // action_taken/no_action_taken + if (inputFile.is_open()) { + std::string status, scannedFilePath, hash, action; + while (!inputFile.eof()) { + if (inputFile >> status) { + if (status == "found" || status == "not_found") { + inputFile.ignore(1); // Ignore space + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, scannedFilePath, '\"'); // Read until closing double quote + inputFile.ignore(1); // Ignore space between filepath and hash + inputFile.ignore(1); // Ignore starting double quote + std::getline(inputFile, hash, ' '); // Read until space + std::getline(inputFile, action); // Read until end of line + + //answered = true; + + if (status == "found") { + update_textfield(hWndTextField, "Virus found in file: " + scannedFilePath + "\r\n"); + update_textfield(hWndTextField, "File: " + scannedFilePath + " is infected\r\n"); + update_textfield(hWndTextField, "Hash: " + hash + "\r\n"); + update_textfield(hWndTextField, "Action taken: " + action + "\r\n"); + num_of_found++; + } + else { + update_textfield(hWndTextField, "No virus found in file: " + scannedFilePath + "\r\n"); + } + update_textfield(hWndTextField, "------------------------------------------\r\n"); + } + else if (status == "progress") { + std::string progress; + inputFile.ignore(1); // Ignore space + inputFile >> progress; + SendMessage(hProgressBar, PBM_SETPOS, atoi(progress.c_str()), 0); + } + else if (status == "end") + answered = true; + } + } + inputFile.close(); + Sleep(1000);//only see for new entrys ~ once a second + std::ofstream(ANSWER_COM_PATH);//clear the file + } + // Wait for 1 second before checking again + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + update_textfield(hWndTextField, "Folder scan completed\r\n"); + update_textfield(hWndTextField, "Number of infected files: " + std::to_string(num_of_found) + "\r\n"); + // Remove the answer file + std::remove(ANSWER_COM_PATH); +} + + + +std::string getFolderPath(HWND hWnd) { + std::wstring selectedFolderPath; + + // Initialize COM + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + // Display the folder picker dialog + BROWSEINFO browseInfo = { 0 }; + TCHAR selectedPath[MAX_PATH]; + browseInfo.hwndOwner = hWnd; // Set the owner window + browseInfo.pidlRoot = NULL; // Start from the desktop + browseInfo.pszDisplayName = selectedPath; + browseInfo.lpszTitle = TEXT("Select a folder"); + browseInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + + LPITEMIDLIST pidlSelected = SHBrowseForFolder(&browseInfo); + if (pidlSelected != NULL) { + SHGetPathFromIDList(pidlSelected, selectedPath); + + // Convert TCHAR array to std::string + std::wstring_convert> converter; + selectedFolderPath = selectedPath; + + // Free the PIDL + IMalloc* pMalloc; + if (SUCCEEDED(SHGetMalloc(&pMalloc))) { + pMalloc->Free(pidlSelected); + pMalloc->Release(); + } + } + + // Uninitialize COM + CoUninitialize(); + + return std::string(selectedFolderPath.begin(), selectedFolderPath.end()); +} + +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: + { + + // Create the "Scan File" button + CreateWindowEx(NULL, L"BUTTON", L"Scan File", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 10, 100, 30, hWnd, (HMENU)IDM_SCAN_FILE, GetModuleHandle(NULL), NULL); + + // Create the "Scan Folder" button + CreateWindowEx(NULL, L"BUTTON", L"Scan Folder", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, + 20, 50, 100, 30, hWnd, (HMENU)IDM_SCAN_FOLDER, GetModuleHandle(NULL), NULL); + + // 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, + 140, 10, width-140-20, height-10-50, hWnd, NULL, NULL, NULL); + update_textfield(hWndTextField, "Welcome to Cyberhex endpoint protection!\r\n"); + + hProgressBar = CreateWindowEx(0, PROGRESS_CLASS, NULL, + WS_CHILD | WS_VISIBLE | PBS_SMOOTH, + 140, height-40, 200, 20, hWnd, NULL, NULL, NULL); + SendMessage(hProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); + SendMessage(hProgressBar, PBM_SETSTEP, 1, 0); + } + break; + case WM_SIZE: + { + // Resize the text field to fit the window + MoveWindow(hWndTextField, 140, 10, width - 140 - 20, height - 10 - 50, TRUE); + MoveWindow(hProgressBar, 140, height - 40, 200, 20, TRUE); + break; + } + case WM_COMMAND: + { + int wmId = LOWORD(wParam); + // Parse the menu selections: + switch (wmId) { + case IDM_SCAN_FILE: + { + // Open file dialog to select a file + // Call scan_file function in a separate thread + OPENFILENAME ofn; + WCHAR szFile[MAX_PATH] = L""; // Use WCHAR for Unicode compatibility + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hWnd; + ofn.lpstrFile = szFile; + ofn.lpstrFile[0] = L'\0'; // Use wide character constant L'\0' + ofn.nMaxFile = sizeof(szFile); + ofn.lpstrFilter = L"All Files\0*.*\0"; // Use wide character string literal L"" + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = NULL; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + if (GetOpenFileName(&ofn) == TRUE) { + std::wstring selectedFile = ofn.lpstrFile; // Use std::wstring for wide characters + std::string narrowSelectedFile(selectedFile.begin(), selectedFile.end()); + std::thread(scan_file, hWndTextField, narrowSelectedFile).detach(); + } + } + break; + case IDM_SCAN_FOLDER: + { + // Open folder picker dialog + // Call scan_folder function in a separate thread + std::string selectedFolder = getFolderPath(hWnd); + std::thread(scan_folder,hProgressBar, hWndTextField, selectedFolder).detach(); + } + break; + 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 frontend"; + + WNDCLASS wc = { }; + + wc.lpfnWndProc = WndProc; + wc.hInstance = hInstance; + wc.lpszClassName = CLASS_NAME; + + RegisterClass(&wc); + + HWND hWnd = CreateWindowEx( + 0, + CLASS_NAME, + L"Cyberhex endpoint protection", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 640, + 480, + NULL, + NULL, + hInstance, + NULL + ); + + + 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/client_frontend/client_frontend.sln b/src/client_frontend/client_frontend.sln index e75fda4..dde2a32 100644 --- a/src/client_frontend/client_frontend.sln +++ b/src/client_frontend/client_frontend.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34701.34 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client_frontend", "client_frontend.vcxproj", "{644C9824-2298-46C6-9A62-7E080C98A0BB}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client_frontend", "client_frontend.vcxproj", "{4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,19 +13,19 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Debug|x64.ActiveCfg = Debug|x64 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Debug|x64.Build.0 = Debug|x64 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Debug|x86.ActiveCfg = Debug|Win32 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Debug|x86.Build.0 = Debug|Win32 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Release|x64.ActiveCfg = Release|x64 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Release|x64.Build.0 = Release|x64 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Release|x86.ActiveCfg = Release|Win32 - {644C9824-2298-46C6-9A62-7E080C98A0BB}.Release|x86.Build.0 = Release|Win32 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Debug|x64.ActiveCfg = Debug|x64 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Debug|x64.Build.0 = Debug|x64 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Debug|x86.ActiveCfg = Debug|Win32 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Debug|x86.Build.0 = Debug|Win32 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Release|x64.ActiveCfg = Release|x64 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Release|x64.Build.0 = Release|x64 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Release|x86.ActiveCfg = Release|Win32 + {4A82AA44-A521-4B6B-99F1-F8F32D7AC57B}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F67EF8DC-E0C4-4EE3-9BBA-D7BD7AC687A9} + SolutionGuid = {47A5DC0C-22B2-47B0-8C56-FB80E8C063AE} EndGlobalSection EndGlobal diff --git a/src/client_frontend/client_frontend.vcxproj b/src/client_frontend/client_frontend.vcxproj index 34e54f1..cf8efc0 100644 --- a/src/client_frontend/client_frontend.vcxproj +++ b/src/client_frontend/client_frontend.vcxproj @@ -21,7 +21,7 @@ 17.0 Win32Proj - {644c9824-2298-46c6-9a62-7e080c98a0bb} + {4a82aa44-a521-4b6b-99f1-f8f32d7ac57b} clientfrontend 10.0 @@ -127,18 +127,13 @@ - - - - - diff --git a/src/client_frontend/client_frontend.vcxproj.filters b/src/client_frontend/client_frontend.vcxproj.filters index dee5a9f..a3c6340 100644 --- a/src/client_frontend/client_frontend.vcxproj.filters +++ b/src/client_frontend/client_frontend.vcxproj.filters @@ -27,26 +27,11 @@ Headerdateien - - Headerdateien - - - Headerdateien - - - Headerdateien - Quelldateien - - Headerdateien - - - Headerdateien - diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.ilk b/src/client_frontend/client_frontend/x64/Debug/client_frontend.ilk index 9057ca3..550ba68 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.ilk and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.ilk differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.log b/src/client_frontend/client_frontend/x64/Debug/client_frontend.log index c299e1b..2eb302f 100644 --- a/src/client_frontend/client_frontend/x64/Debug/client_frontend.log +++ b/src/client_frontend/client_frontend/x64/Debug/client_frontend.log @@ -1,2 +1 @@ - ui.cpp - client_frontend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\x64\Debug\client_frontend.exe + client_frontend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\x64\Debug\client_frontend.exe diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.command.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.command.1.tlog index 9e008c3..4ddfbf4 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.command.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.command.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.read.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.read.1.tlog index 84cdf16..2c93015 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.read.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.read.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.write.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.write.1.tlog index 37057b1..2fe7b80 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.write.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/CL.write.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/Cl.items.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/Cl.items.tlog index 90a40bf..d5365df 100644 --- a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/Cl.items.tlog +++ b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/Cl.items.tlog @@ -1,3 +1 @@ -C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\choose_element.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\client_frontend\x64\Debug\choose_element.obj C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\client_frontend.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\client_frontend\x64\Debug\client_frontend.obj -C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\ui.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\client_frontend\x64\Debug\ui.obj diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.command.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.command.1.tlog index 5a41b57..54ae4d5 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.command.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.command.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.read.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.read.1.tlog index 5670a98..eb26de6 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.read.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.read.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.secondary.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.secondary.1.tlog index 9edfbe3..f9aa07e 100644 --- a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.secondary.1.tlog +++ b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.secondary.1.tlog @@ -1,2 +1,2 @@ -^C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\CHOOSE_ELEMENT.OBJ|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\CLIENT_FRONTEND.OBJ|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\CLIENT_FRONTEND.RES|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\UI.OBJ +^C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\CLIENT_FRONTEND.OBJ|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND\CLIENT_FRONTEND\X64\DEBUG\CLIENT_FRONTEND.RES C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\client_frontend\x64\Debug\client_frontend.ilk diff --git a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.write.1.tlog b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.write.1.tlog index dac96c2..268f89c 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.write.1.tlog and b/src/client_frontend/client_frontend/x64/Debug/client_frontend.tlog/link.write.1.tlog differ diff --git a/src/client_frontend/client_frontend/x64/Debug/vc143.idb b/src/client_frontend/client_frontend/x64/Debug/vc143.idb index 406354d..db8b7b9 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/vc143.idb and b/src/client_frontend/client_frontend/x64/Debug/vc143.idb differ diff --git a/src/client_frontend/client_frontend/x64/Debug/vc143.pdb b/src/client_frontend/client_frontend/x64/Debug/vc143.pdb index a3842f4..dcfd1c2 100644 Binary files a/src/client_frontend/client_frontend/x64/Debug/vc143.pdb and b/src/client_frontend/client_frontend/x64/Debug/vc143.pdb differ diff --git a/src/client_frontend/id.h b/src/client_frontend/id.h deleted file mode 100644 index eea2e1f..0000000 --- a/src/client_frontend/id.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#define ID_HOME_BUTTON 0 -#define ID_STARTUP_BUTTON 1 -#define ID_SCAN_FILE_BUTTON 2 -#define ID_SCAN_FOLDER_BUTTON 3 -#define ID_SETTINGS_BUTTON 4 - -#define ID_WELCOME_TEXT 1000 \ No newline at end of file diff --git a/src/client_frontend/ui.cpp b/src/client_frontend/ui.cpp deleted file mode 100644 index cb7a7cf..0000000 --- a/src/client_frontend/ui.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "ui.h" -#include "id.h" -#include -#include "choose_element.h" -HWND hwnd_[100]; -int num_hwnd = 0; - -void draw_main_page(int window_width, int window_height, HWND hwnd); -void draw_scan_file_page(int window_width, int window_height, HWND hwnd); - -void ui_display_page(int page_id,int window_width, int window_height, HWND hwnd) { - //create one button in middle of screen - //hwnd_[num_hwnd] = CreateWindowW(L"BUTTON", L"OK", WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,(window_width-50)/2,(window_height-15)/2, 100, 30, hwnd, (HMENU)ID_STARTUP_BUTTON, NULL, NULL); - //num_hwnd++; - switch (page_id) { - case 0: //main page - draw_main_page(window_width,window_height,hwnd); - break; - case 1: //scan file page - draw_scan_file_page(window_width, window_height, hwnd); - break; - } -} - -void ui_clear() { - //clear all windows - for (int i = 0; i < num_hwnd; i++) { - if (hwnd_[i] != NULL) { - DestroyWindow(hwnd_[i]); - } - } - num_hwnd = 0; -} - -void draw_main_page(int window_width, int window_height, HWND hwnd) { - //draw main page - hwnd_[num_hwnd] = CreateWindow(L"EDIT", - L"Welcome to cyberhex\r\n\r\nPlease select an option:\r\n\r\n", - WS_VISIBLE | WS_CHILD | ES_READONLY | ES_MULTILINE, - 10, 10, window_width - 30, window_height - 200, - hwnd, (HMENU)0, NULL, NULL); - num_hwnd++; - - hwnd_[num_hwnd]= CreateWindow(L"BUTTON", - L"Scan a file", - WS_VISIBLE | WS_CHILD | WS_BORDER, - (window_width)/4-100, window_height - 150, 200, 30, - hwnd, (HMENU)ID_SCAN_FILE_BUTTON, NULL, NULL); - num_hwnd++; - hwnd_[num_hwnd] = CreateWindow(L"BUTTON", - L"Scan a folder", - WS_VISIBLE | WS_CHILD | WS_BORDER, - (2* window_width) / 4-100, window_height - 150, 200, 30, - hwnd, (HMENU)ID_SCAN_FOLDER_BUTTON, NULL, NULL); - num_hwnd++; - hwnd_[num_hwnd] = CreateWindow(L"BUTTON", - L"Settings", - WS_VISIBLE | WS_CHILD | WS_BORDER, - (3* window_width) / 4-100, window_height - 150, 200, 30, - hwnd, (HMENU)ID_SETTINGS_BUTTON, NULL, NULL); - num_hwnd++; -} - -void draw_scan_file_page(int window_width, int window_height, HWND hwnd) { - //draw scan file page - std::wstring message = L"File to scan: "; - std::wstring path=open_file(hwnd); - if (path == L"cancel") { - ui_clear(); - ui_display_page(0, window_width, window_height, hwnd); - return; - } - message += path; - hwnd_[num_hwnd] = CreateWindow(L"EDIT", - message.c_str(), - WS_VISIBLE | WS_CHILD | ES_READONLY | ES_MULTILINE, - 10, 10, window_width - 30, window_height - 200, - hwnd, (HMENU)0, NULL, NULL); - num_hwnd++; - - hwnd_[num_hwnd] = CreateWindow(L"BUTTON", - L"Home", - WS_VISIBLE | WS_CHILD | WS_BORDER, - 10, window_height - 50, 200, 30, - hwnd, (HMENU)ID_HOME_BUTTON, NULL, NULL); - num_hwnd++; -} - -void update_scan_results(int window_width, int window_height, HWND hwnd,std::wstring& message) { - //draw scan results - //get value from the text field of draw_scan_file_page - //add to thetextfield the string message - - -} \ No newline at end of file diff --git a/src/client_frontend/ui.h b/src/client_frontend/ui.h deleted file mode 100644 index b8693a7..0000000 --- a/src/client_frontend/ui.h +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once -#include -void ui_display_page(int page_id, int window_width, int window_height, HWND hwnd); -void ui_clear(); \ No newline at end of file diff --git a/src/client_frontend/x64/Debug/client_frontend.pdb b/src/client_frontend/x64/Debug/client_frontend.pdb index 8624171..d2b5d69 100644 Binary files a/src/client_frontend/x64/Debug/client_frontend.pdb and b/src/client_frontend/x64/Debug/client_frontend.pdb differ diff --git a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/.suo b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/.suo index ac54862..ab5ce10 100644 Binary files a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/.suo and b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/.suo differ diff --git a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/Browse.VC.db b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/Browse.VC.db index c8713a2..7122f31 100644 Binary files a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/Browse.VC.db and b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/Browse.VC.db differ diff --git a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/DocumentLayout.json b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/DocumentLayout.json index df08f2c..6778328 100644 --- a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/DocumentLayout.json +++ b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/DocumentLayout.json @@ -6,14 +6,6 @@ "AbsoluteMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "RelativeMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|solutionrelative:main.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" }, - { - "AbsoluteMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|solutionrelative:connect.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, - { - "AbsoluteMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", - "RelativeMoniker": "D:0:0:{C434E5CA-752E-4D35-9986-BECF1CC34A98}|client_frontend_guilite.vcxproj|solutionrelative:connect.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" - }, { "AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\well_known.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" } @@ -25,35 +17,11 @@ "DocumentGroups": [ { "DockedWidth": 200, - "SelectedChildIndex": 3, + "SelectedChildIndex": 1, "Children": [ { "$type": "Document", "DocumentIndex": 1, - "Title": "connect.cpp", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.cpp", - "RelativeDocumentMoniker": "connect.cpp", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.cpp", - "RelativeToolTip": "connect.cpp", - "ViewState": "AQIAACEAAAAAAAAAAAAIwC0AAAArAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", - "WhenOpened": "2024-03-19T18:03:49.536Z" - }, - { - "$type": "Document", - "DocumentIndex": 2, - "Title": "connect.h", - "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.h", - "RelativeDocumentMoniker": "connect.h", - "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\connect.h", - "RelativeToolTip": "connect.h", - "ViewState": "AQIAAAAAAAAAAAAAAAAAAAcAAAAAAAAA", - "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|", - "WhenOpened": "2024-03-19T18:03:42.761Z" - }, - { - "$type": "Document", - "DocumentIndex": 3, "Title": "well_known.h", "DocumentMoniker": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\well_known.h", "RelativeDocumentMoniker": "..\\client_backend\\well_known.h", @@ -71,7 +39,7 @@ "RelativeDocumentMoniker": "main.cpp", "ToolTip": "C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_frontend_guilite\\main.cpp", "RelativeToolTip": "main.cpp", - "ViewState": "AQIAAGYAAAAAAAAAAAAAAJEAAAA0AAAA", + "ViewState": "AQIAAGwAAAAAAAAAAAAAAJYAAAABAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-03-14T19:45:55.142Z", "EditorCaption": "" diff --git a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/fileList.bin b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/fileList.bin index f55d7c9..89117ee 100644 Binary files a/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/fileList.bin and b/src/client_frontend_guilite/.vs/client_frontend_guilite/v17/fileList.bin differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.read.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.read.1.tlog index 5e20d03..06ffe71 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.read.1.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.read.1.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.write.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.write.1.tlog index ad66cb0..d06da3e 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.write.1.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/CL.write.1.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/Cl.items.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/Cl.items.tlog index 494cbea..3290d00 100644 --- a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/Cl.items.tlog +++ b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/Cl.items.tlog @@ -1,2 +1 @@ -C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\connect.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\client_f.c434e5ca\x64\Debug\connect.obj C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\main.cpp;C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\client_f.c434e5ca\x64\Debug\main.obj diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/client_frontend_guilite.write.1u.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/client_frontend_guilite.write.1u.tlog index 1ee9ead..3592055 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/client_frontend_guilite.write.1u.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/client_frontend_guilite.write.1u.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.command.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.command.1.tlog index e2382df..2185688 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.command.1.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.command.1.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.read.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.read.1.tlog index 00279a3..8ebc0f1 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.read.1.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.read.1.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.secondary.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.secondary.1.tlog index f651fc8..c81bc17 100644 --- a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.secondary.1.tlog +++ b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.secondary.1.tlog @@ -1,2 +1,2 @@ -^C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND_GUILITE\CLIENT_F.C434E5CA\X64\DEBUG\CONNECT.OBJ|C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND_GUILITE\CLIENT_F.C434E5CA\X64\DEBUG\MAIN.OBJ +^C:\USERS\JANIS\DOCUMENTS\PROJEKTE_MIT_C\MA\MA\SRC\CLIENT_FRONTEND_GUILITE\CLIENT_F.C434E5CA\X64\DEBUG\MAIN.OBJ C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\client_f.c434e5ca\x64\Debug\client_frontend_guilite.ilk diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.write.1.tlog b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.write.1.tlog index c3d3cd0..b4257de 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.write.1.tlog and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_f.c434e5ca.tlog/link.write.1.tlog differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.ilk b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.ilk index 9bb3132..764cd17 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.ilk and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.ilk differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.log b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.log index dc99186..88d7fbc 100644 --- a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.log +++ b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/client_frontend_guilite.log @@ -4,5 +4,6 @@ C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(1 C:\vcpkg\vcpkg-2023.08.09\installed\x64-windows\include\GLFW\glfw3.h(123,1): Siehe vorherige Definition von "APIENTRY" +LINK : warning LNK4044: Nicht erkannte Option /lOpenGL; wird ignoriert. LINK : warning LNK4044: Nicht erkannte Option /lOpenGL; wird ignoriert. client_frontend_guilite.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend_guilite\x64\Debug\client_frontend_guilite.exe diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.idb b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.idb index e9794a1..7bd990f 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.idb and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.idb differ diff --git a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.pdb b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.pdb index ae21549..9ab55c3 100644 Binary files a/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.pdb and b/src/client_frontend_guilite/client_f.c434e5ca/x64/Debug/vc143.pdb differ diff --git a/src/client_frontend_guilite/client_frontend_guilite.vcxproj b/src/client_frontend_guilite/client_frontend_guilite.vcxproj index 6264e7c..c288454 100644 --- a/src/client_frontend_guilite/client_frontend_guilite.vcxproj +++ b/src/client_frontend_guilite/client_frontend_guilite.vcxproj @@ -134,12 +134,8 @@ - - - - diff --git a/src/client_frontend_guilite/client_frontend_guilite.vcxproj.filters b/src/client_frontend_guilite/client_frontend_guilite.vcxproj.filters index c844216..87acf48 100644 --- a/src/client_frontend_guilite/client_frontend_guilite.vcxproj.filters +++ b/src/client_frontend_guilite/client_frontend_guilite.vcxproj.filters @@ -18,13 +18,5 @@ Quelldateien - - Headerdateien - - - - - Headerdateien - \ No newline at end of file diff --git a/src/client_frontend_guilite/connect.cpp b/src/client_frontend_guilite/connect.cpp deleted file mode 100644 index 6288dc3..0000000 --- a/src/client_frontend_guilite/connect.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#pragma warning(disable:4996) -#ifndef CONNECT_CPP -#define CONNECT_CPP -#include -#include -#include -#include "../client_backend/well_known.h" -int send_to_pipe(const std::string& message) { - HANDLE hPipe; - DWORD dwWritten; - std::ofstream (MAIN_COM_PATH);//enshure the file exists - hPipe = CreateFile(TEXT(MAIN_COM_PATH), - GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL); - - if (hPipe != INVALID_HANDLE_VALUE) { - if (WriteFile(hPipe, - message.c_str(), - static_cast(message.size()), // Size of the message - &dwWritten, - NULL)) { - CloseHandle(hPipe); - return 0; // Success - } - else { - // Failed to write to pipe - CloseHandle(hPipe); - return 2; // Error writing to pipe - } - } - else { - // Failed to open pipe - DWORD dwError = GetLastError(); - return dwError; // Return the error code - } -} -std::string read_from_pipe() { - HANDLE hPipe; - DWORD dwRead; - DWORD dwWritten; - char buffer[1000]; - hPipe = CreateFile(TEXT(MAIN_COM_PATH), - GENERIC_READ | GENERIC_WRITE, - 0, - NULL, - OPEN_EXISTING, - 0, - NULL); - if (hPipe != INVALID_HANDLE_VALUE) - { - ReadFile(hPipe, buffer, sizeof(buffer), &dwRead, NULL); - CloseHandle(hPipe); - buffer[strlen(buffer) + 1] = '\0'; - return std::string(buffer); - } - else { - return "Error"; - } -} -#endif diff --git a/src/client_frontend_guilite/connect.h b/src/client_frontend_guilite/connect.h deleted file mode 100644 index 2cb8fa5..0000000 --- a/src/client_frontend_guilite/connect.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include - -int send_to_pipe(const std::string& message); -std::string read_from_pipe(); diff --git a/src/client_frontend_guilite/main.cpp b/src/client_frontend_guilite/main.cpp index d2fcfc7..3e181fe 100644 --- a/src/client_frontend_guilite/main.cpp +++ b/src/client_frontend_guilite/main.cpp @@ -10,7 +10,6 @@ #include #include "../client_backend/well_known.h" -#include "connect.h" // Function to simulate file scanning void scan_file(nanogui::Screen* screen, nanogui::Widget* contentWidget, const std::string& filePath) { // Remove the answer file @@ -61,7 +60,6 @@ void scan_file(nanogui::Screen* screen, nanogui::Widget* contentWidget, const st } else { nanogui::Label* lineLabel7 = new nanogui::Label(contentWidget, "No virus found in file: " + scannedFilePath + "\n"); - nanogui::Label* lineLabel8 = new nanogui::Label(contentWidget, "File: " + scannedFilePath + " is not infected\n"); } nanogui::Label* lineLabel9 = new nanogui::Label(contentWidget, "------------------------------------------"); screen->performLayout(); @@ -133,7 +131,6 @@ void scan_folder(nanogui::Screen* screen, nanogui::Widget* contentWidget, const } else { nanogui::Label* lineLabel7 = new nanogui::Label(contentWidget, "No virus found in file: " + scannedFilePath + "\n"); - nanogui::Label* lineLabel8 = new nanogui::Label(contentWidget, "File: " + scannedFilePath + " is not infected\n"); } nanogui::Label* lineLabel9 = new nanogui::Label(contentWidget, "------------------------------------------"); screen->performLayout(); diff --git a/src/client_frontend_guilite/x64/Debug/client_frontend_guilite.pdb b/src/client_frontend_guilite/x64/Debug/client_frontend_guilite.pdb index f6dc9a6..2fc2d3b 100644 Binary files a/src/client_frontend_guilite/x64/Debug/client_frontend_guilite.pdb and b/src/client_frontend_guilite/x64/Debug/client_frontend_guilite.pdb differ