working multithreading

finally managed to multithread folder scanner and rtp. it may still have some bugs. but it works
This commit is contained in:
jakani24
2023-12-26 21:17:39 +01:00
parent f069abeb7b
commit c3f3fb85af
82 changed files with 2006 additions and 173 deletions

View File

@@ -137,25 +137,36 @@ int check_scan_dir(char*dirpath,char*dirname) {
} }
*/ */
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) { void process_changes(const FILE_NOTIFY_INFORMATION* pInfo) {
// Allocate a buffer for the file name and copy the content // Allocate a buffer for the file name and copy the content
std::wstring fileName(pInfo->FileName, pInfo->FileNameLength / sizeof(wchar_t)); std::wstring fileName(pInfo->FileName, pInfo->FileNameLength / sizeof(wchar_t));
// Print information about the changed file or directory
//convert wstring to string //convert wstring to string
std::string filename_str(fileName.begin(), fileName.end()); std::string filename_str(fileName.begin(), fileName.end());
filename_str = "c:\\" + filename_str; filename_str = "c:\\" + filename_str;
//scan the file and send it to virus_ctrl if it is a virus and then process it //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); std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower);
if (is_folder_excluded(filename_str.c_str())) { if (is_folder_excluded(filename_str.c_str()) or is_directory(filename_str.c_str())) {
//dont scan excluded files //dont scan excluded files or folders
return; return;
}else }
// action_scanfile(filename_str.c_str()); else {
std::thread scan_thread(action_scanfile_t, filename_str);
scan_thread.detach();
}
log(LOGLEVEL::INFO, "[process_changes()]: File change: ", filename_str.c_str(), " while monitoring directory for changes"); log(LOGLEVEL::INFO, "[process_changes()]: File change: ", filename_str.c_str(), " while monitoring directory for changes");
} }
/* /* this was the old algorithm. it was slower and used up more resources, because it used a database to track which files have been modified instead of using the windows internal functions
void monitor_directory(LPCSTR directory) { void monitor_directory(LPCSTR directory) {
// Open the directory for monitoring // Open the directory for monitoring
HANDLE hDir = CreateFile( HANDLE hDir = CreateFile(
@@ -262,7 +273,7 @@ void monitor_directory(LPCSTR directory) {
); );
if (hDir == INVALID_HANDLE_VALUE) { if (hDir == INVALID_HANDLE_VALUE) {
std::cerr << "[monitor_directory()]: Error opening directory: " << directory << " while monitoring directory for changes" << std::endl; log(LOGLEVEL::ERR, "[monitor_directory()]: Error opening directory: ", directory, " while monitoring directory for changes");
return; return;
} }
@@ -273,6 +284,7 @@ void monitor_directory(LPCSTR directory) {
// Monitor the directory for changes // Monitor the directory for changes
OVERLAPPED overlapped; OVERLAPPED overlapped;
memset(&overlapped, 0, sizeof(overlapped)); memset(&overlapped, 0, sizeof(overlapped));
memset(buffer, 0, bufferSize);
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (ReadDirectoryChangesW( if (ReadDirectoryChangesW(
@@ -280,19 +292,19 @@ void monitor_directory(LPCSTR directory) {
buffer, buffer,
bufferSize, bufferSize,
TRUE, TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE,
NULL, NULL,
&overlapped, &overlapped,
NULL) == 0) { NULL) == 0) {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl; log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes");
CloseHandle(hDir); CloseHandle(hDir);
return; return;
} }
std::cout << "[monitor_directory()]: Monitoring directory: " << directory << " for changes" << std::endl; log(LOGLEVEL::INFO, "[monitor_directory()]: Monitoring directory: ", directory, " for changes");
// Wait for changes // Wait for changes
while (true) { while (!app_stop()) {
DWORD bytesReturned; DWORD bytesReturned;
DWORD waitStatus = WaitForSingleObject(overlapped.hEvent, INFINITE); DWORD waitStatus = WaitForSingleObject(overlapped.hEvent, INFINITE);
@@ -311,6 +323,7 @@ void monitor_directory(LPCSTR directory) {
// Reset the event for the next wait // Reset the event for the next wait
ResetEvent(overlapped.hEvent); ResetEvent(overlapped.hEvent);
memset(buffer, 0, bufferSize);
// Continue monitoring // Continue monitoring
if (ReadDirectoryChangesW( if (ReadDirectoryChangesW(
@@ -322,17 +335,17 @@ void monitor_directory(LPCSTR directory) {
NULL, NULL,
&overlapped, &overlapped,
NULL) == 0) { NULL) == 0) {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl; log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes");
break; break;
} }
} }
else { else {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl; log(LOGLEVEL::ERR, "[monitor_directory()]: GetOverlappedResult failed: ", GetLastError());
break; break;
} }
} }
else { else {
std::cerr << "[monitor_directory()]: WaitForSingleObject failed: " << GetLastError() << std::endl; log(LOGLEVEL::ERR, "[monitor_directory()]: WaitForSingleObject failed: ", GetLastError());
break; break;
} }
} }

View File

@@ -0,0 +1,370 @@
#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 "scan.h"
#include "settings.h"
/* old implementation. used up a lot of resource and did not work properly.
void add_to_temp_db(const char*hash) {
//PERIODIC_FOLDER_SCAN_TEMP_DB
FILE*fp;
if (fopen_s(&fp, PERIODIC_FOLDER_SCAN_TEMP_DB, "a") != 0) {
log(LOGLEVEL::ERR, "[add_to_temp_db()]: Error opening temp db: ", PERIODIC_FOLDER_SCAN_TEMP_DB);
return;
}
else {
//log(LOGLEVEL::INFO, "[add_to_temp_db()]: Adding hash: ", hash, " to temp db: ", PERIODIC_FOLDER_SCAN_TEMP_DB);
fprintf_s(fp, "%s\n", hash);
fclose(fp);
}
}
void scan_folder_recursive(const std::string& directory, int thread_id,const std::string&db_file) {
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) {
//std::cerr << "Error opening directory: " << directory << std::endl;
log(LOGLEVEL::ERR, "[scan_folder_recursive()]: Error opening directory: ", directory ," while scanning folder for new files");
return;
}
do {
if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) {
continue; // Skip the current and parent directories
}
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_recursive(full_path, thread_id,db_file);
}
else {
// If it's a file, check if it is in db, else scan it and add it to db
char*hash = new char[300];
md5_file(full_path.c_str(), hash);
//now find hash in db
if (scan_hash(db_file.c_str(), hash)==1) {
//file is allready in db, skipping
//in order to not keep hashes that are not present anymore in the db, we have to write this hash into a temp dir, which is at the end copied into the main db
add_to_temp_db(hash);
}
else {
//scan the file and add it to db
//scan for virus
switch (scan_hash(hash)) {
case 1:
//virus found
//log it
log(LOGLEVEL::VIRUS, "[scan_folder_recursive()]: Virus found in file: ", full_path, " while scanning ", directory, " for new files");
//virus_ctrl_store(full_path.c_str(), hash, "fs");
break;
case 2:
//error
log(LOGLEVEL::ERR, "[scan_folder_recursive()]: Error while scanning file: ", full_path, " while scanning ", directory, " for new files");
break;
default:
//not a virus
add_to_temp_db(hash);
break;
}
}
}
} while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind);
}
int check_scan_dir(char*dirpath,char*dirname) {
if (can_scan_folder()) {
scan_folder_init();
//FOLDER_DATABASE_DIR <= the folder where the database for folder checking is stored
//the database is stored in the following format:
/* a file per folder (and its subfolders)
in this db file the hashes of all the files in the folder (and its subfolders) are stored
If a file is detected, which hash is not known, it gets scanned and added to the db. if a hash is inside the db, which is not present in the folder, the hash is rempved from the db
*/
/*
FILE* fp;
char* path = new char[300];
path[0] = '\0';
//build up the path for the db file.
strcpy_s(path, 295, FOLDER_DATABASE_DIR);
strcat_s(path, 295, "\\");
strcat_s(path, 295, dirname);
strcat_s(path, 295, ".jdbf");
//check if the file exists. else we cannot scan the folder
if ((fopen_s(&fp, path, "r")) != 0) {
log(LOGLEVEL::ERR, "[check_scan_dir()]: Error opening database: ", path, " while scanning folder for new files; aborting");
//try to create the file
if (fopen_s(&fp, path, "w") != 0) {
log(LOGLEVEL::ERR, "[check_scan_dir()]: Error creating new database: ", path, " while scanning folder for new files; aborting");
}
else {
fprintf_s(fp, "%s\n", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");//write A 32 times A into the file. So the algorithm ha ssomething to map into memory. else it might throw an error
fclose(fp);
}
scan_folder_shutdown();
return 1;
}
else {
fclose(fp);
//process the files of the folder.
//first: calculate hash of file
//second: check if hash is in db
//if not, scan file and add it to db (only add it if it is not detected as a virus)
scan_folder_recursive(dirpath, 0,path);
//process the found viruses
virus_ctrl_process("fs");
}
delete[] path;
scan_folder_shutdown();
return 0;
}
else {
//there is already a folder scan happening
}
}
*/
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
std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower);
if (is_folder_excluded(filename_str.c_str()) or is_directory(filename_str.c_str())) {
//dont scan excluded files
return;
}else
action_scanfile(filename_str.c_str());
log(LOGLEVEL::INFO, "[process_changes()]: File change: ", filename_str.c_str(), " while monitoring directory for changes");
}
/*
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));
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE,
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");
//print_exclusions();
// Wait for changes
while (true) {
DWORD bytesReturned;
if (GetOverlappedResult(hDir, &overlapped, &bytesReturned, TRUE)) {
// Process the changes in the buffer
FILE_NOTIFY_INFORMATION* pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer);
do {
process_changes(pInfo);
pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(
reinterpret_cast<BYTE*>(pInfo) + pInfo->NextEntryOffset);
} while (pInfo->NextEntryOffset != 0);
// Reset the event for the next wait
ResetEvent(overlapped.hEvent);
// Continue monitoring
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE,
NULL,
&overlapped,
NULL) == 0) {
log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes");
break;
}
}
else {
DWORD error = GetLastError();
if (error != ERROR_IO_PENDING) {
log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", error, " while monitoring directory for changes");
break;
}
}
// Wait for the event to be signaled (infinite timeout)
WaitForSingleObject(overlapped.hEvent, INFINITE);
}
// Cleanup
CloseHandle(overlapped.hEvent);
CloseHandle(hDir);
}
*/
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;
}
std::cout << "[monitor_directory()]: Monitoring directory: " << directory << " for changes" << std::endl;
// 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<FILE_NOTIFY_INFORMATION*>(buffer);
do {
process_changes(pInfo);
pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(
reinterpret_cast<BYTE*>(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,
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() {
//we are in a completely seperate thread then the main thread; unlimited resources wuhuii
FILE*fp;
char* path = new char[300];
char* foldername = new char[300];
//start the watch dir function used to monitor the dir for new files
monitor_directory("C:\\");
delete[] path;
delete[] foldername;
}
#endif // !CHECK_DIR_CPP

View File

@@ -0,0 +1,360 @@
#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 "scan.h"
#include "settings.h"
/* old implementation. used up a lot of resource and did not work properly.
void add_to_temp_db(const char*hash) {
//PERIODIC_FOLDER_SCAN_TEMP_DB
FILE*fp;
if (fopen_s(&fp, PERIODIC_FOLDER_SCAN_TEMP_DB, "a") != 0) {
log(LOGLEVEL::ERR, "[add_to_temp_db()]: Error opening temp db: ", PERIODIC_FOLDER_SCAN_TEMP_DB);
return;
}
else {
//log(LOGLEVEL::INFO, "[add_to_temp_db()]: Adding hash: ", hash, " to temp db: ", PERIODIC_FOLDER_SCAN_TEMP_DB);
fprintf_s(fp, "%s\n", hash);
fclose(fp);
}
}
void scan_folder_recursive(const std::string& directory, int thread_id,const std::string&db_file) {
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) {
//std::cerr << "Error opening directory: " << directory << std::endl;
log(LOGLEVEL::ERR, "[scan_folder_recursive()]: Error opening directory: ", directory ," while scanning folder for new files");
return;
}
do {
if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) {
continue; // Skip the current and parent directories
}
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_recursive(full_path, thread_id,db_file);
}
else {
// If it's a file, check if it is in db, else scan it and add it to db
char*hash = new char[300];
md5_file(full_path.c_str(), hash);
//now find hash in db
if (scan_hash(db_file.c_str(), hash)==1) {
//file is allready in db, skipping
//in order to not keep hashes that are not present anymore in the db, we have to write this hash into a temp dir, which is at the end copied into the main db
add_to_temp_db(hash);
}
else {
//scan the file and add it to db
//scan for virus
switch (scan_hash(hash)) {
case 1:
//virus found
//log it
log(LOGLEVEL::VIRUS, "[scan_folder_recursive()]: Virus found in file: ", full_path, " while scanning ", directory, " for new files");
//virus_ctrl_store(full_path.c_str(), hash, "fs");
break;
case 2:
//error
log(LOGLEVEL::ERR, "[scan_folder_recursive()]: Error while scanning file: ", full_path, " while scanning ", directory, " for new files");
break;
default:
//not a virus
add_to_temp_db(hash);
break;
}
}
}
} while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind);
}
int check_scan_dir(char*dirpath,char*dirname) {
if (can_scan_folder()) {
scan_folder_init();
//FOLDER_DATABASE_DIR <= the folder where the database for folder checking is stored
//the database is stored in the following format:
/* a file per folder (and its subfolders)
in this db file the hashes of all the files in the folder (and its subfolders) are stored
If a file is detected, which hash is not known, it gets scanned and added to the db. if a hash is inside the db, which is not present in the folder, the hash is rempved from the db
*/
/*
FILE* fp;
char* path = new char[300];
path[0] = '\0';
//build up the path for the db file.
strcpy_s(path, 295, FOLDER_DATABASE_DIR);
strcat_s(path, 295, "\\");
strcat_s(path, 295, dirname);
strcat_s(path, 295, ".jdbf");
//check if the file exists. else we cannot scan the folder
if ((fopen_s(&fp, path, "r")) != 0) {
log(LOGLEVEL::ERR, "[check_scan_dir()]: Error opening database: ", path, " while scanning folder for new files; aborting");
//try to create the file
if (fopen_s(&fp, path, "w") != 0) {
log(LOGLEVEL::ERR, "[check_scan_dir()]: Error creating new database: ", path, " while scanning folder for new files; aborting");
}
else {
fprintf_s(fp, "%s\n", "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");//write A 32 times A into the file. So the algorithm ha ssomething to map into memory. else it might throw an error
fclose(fp);
}
scan_folder_shutdown();
return 1;
}
else {
fclose(fp);
//process the files of the folder.
//first: calculate hash of file
//second: check if hash is in db
//if not, scan file and add it to db (only add it if it is not detected as a virus)
scan_folder_recursive(dirpath, 0,path);
//process the found viruses
virus_ctrl_process("fs");
}
delete[] path;
scan_folder_shutdown();
return 0;
}
else {
//there is already a folder scan happening
}
}
*/
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));
// Print information about the changed file or directory
//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
std::transform(filename_str.begin(), filename_str.end(), filename_str.begin(), ::tolower);
if (is_folder_excluded(filename_str.c_str())) {
//dont scan excluded files
return;
}else
action_scanfile(filename_str.c_str());
log(LOGLEVEL::INFO, "[process_changes()]: File change: ", filename_str.c_str(), " while monitoring directory for changes");
}
/*
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));
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE,
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");
//print_exclusions();
// Wait for changes
while (true) {
DWORD bytesReturned;
if (GetOverlappedResult(hDir, &overlapped, &bytesReturned, TRUE)) {
// Process the changes in the buffer
FILE_NOTIFY_INFORMATION* pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer);
do {
process_changes(pInfo);
pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(
reinterpret_cast<BYTE*>(pInfo) + pInfo->NextEntryOffset);
} while (pInfo->NextEntryOffset != 0);
// Reset the event for the next wait
ResetEvent(overlapped.hEvent);
// Continue monitoring
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE,
NULL,
&overlapped,
NULL) == 0) {
log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", GetLastError(), " while monitoring directory for changes");
break;
}
}
else {
DWORD error = GetLastError();
if (error != ERROR_IO_PENDING) {
log(LOGLEVEL::ERR, "[monitor_directory()]: Error reading directory changes: ", error, " while monitoring directory for changes");
break;
}
}
// Wait for the event to be signaled (infinite timeout)
WaitForSingleObject(overlapped.hEvent, INFINITE);
}
// Cleanup
CloseHandle(overlapped.hEvent);
CloseHandle(hDir);
}
*/
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) {
std::cerr << "[monitor_directory()]: Error opening directory: " << directory << " while monitoring directory for changes" << std::endl;
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));
overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE,
NULL,
&overlapped,
NULL) == 0) {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl;
CloseHandle(hDir);
return;
}
std::cout << "[monitor_directory()]: Monitoring directory: " << directory << " for changes" << std::endl;
// 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<FILE_NOTIFY_INFORMATION*>(buffer);
do {
process_changes(pInfo);
pInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(
reinterpret_cast<BYTE*>(pInfo) + pInfo->NextEntryOffset);
} while (pInfo->NextEntryOffset != 0);
// Reset the event for the next wait
ResetEvent(overlapped.hEvent);
// Continue monitoring
if (ReadDirectoryChangesW(
hDir,
buffer,
bufferSize,
TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE,
NULL,
&overlapped,
NULL) == 0) {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl;
break;
}
}
else {
std::cerr << "[monitor_directory()]: Error reading directory changes: " << GetLastError() << " while monitoring directory for changes" << std::endl;
break;
}
}
else {
std::cerr << "[monitor_directory()]: WaitForSingleObject failed: " << GetLastError() << std::endl;
break;
}
}
// Cleanup
CloseHandle(overlapped.hEvent);
CloseHandle(hDir);
}
void folder_scanner() {
//we are in a completely seperate thread then the main thread; unlimited resources wuhuii
FILE*fp;
char* path = new char[300];
char* foldername = new char[300];
//start the watch dir function used to monitor the dir for new files
monitor_directory("C:\\");
delete[] path;
delete[] foldername;
}
#endif // !CHECK_DIR_CPP

View File

@@ -16,13 +16,19 @@
#include "thread_ctrl.h" #include "thread_ctrl.h"
#include "settings.h" #include "settings.h"
#include "check_dir.h" #include "check_dir.h"
#include "virus_ctrl.h"
int main() { int main() {
log(LOGLEVEL::INFO, "[main()]:Starting main thread.");
printf("welcome to the jakach security tool main thread\n"); printf("welcome to the jakach security tool main thread\n");
load_settings(); load_settings();
initialize(DB_DIR);
//start a second thread which will scan for new files //start a second thread which will scan for new files
std::thread folder_scannner_thread(folder_scanner); if (get_setting("rtp:status") == 1) {
// log(LOGLEVEL::INFO, "[main()]:Starting real time protection.");
// std::thread folder_scannner_thread(folder_scanner);
folder_scannner_thread.detach();
}
//main thread: //main thread:
/* watches for notifications on bus /* watches for notifications on bus
* start threads (scans etc); only one at a time may run * start threads (scans etc); only one at a time may run
@@ -31,7 +37,6 @@ int main() {
*/ */
while (!app_stop()) { while (!app_stop()) {
//run all the tasks described above //run all the tasks described above
//check for tasks in com //check for tasks in com
@@ -40,6 +45,8 @@ int main() {
//call_srv("8.8.8.8","",""); //call_srv("8.8.8.8","","");
auto start = std::chrono::high_resolution_clock::now(); auto start = std::chrono::high_resolution_clock::now();
// printf("check_from_com:%d\n",check_for_com_tasks(MAIN_COM, MAIN_COM_PATH)); // printf("check_from_com:%d\n",check_for_com_tasks(MAIN_COM, MAIN_COM_PATH));
check_for_com_tasks(MAIN_COM, MAIN_COM_PATH);
check_for_sched_tasks(SCHED, SCHED_PATH);
// printf("check_from_task:%d\n", check_for_sched_tasks(SCHED,SCHED_PATH)); // printf("check_from_task:%d\n", check_for_sched_tasks(SCHED,SCHED_PATH));
//unlock_task("tsk1"); else it will only be executed once. but this function has to be called at the end of the task. else it will nvr be executed again. this would be bad :( //unlock_task("tsk1"); else it will only be executed once. but this function has to be called at the end of the task. else it will nvr be executed again. this would be bad :(
//start a thread that executes check_scan_dir to scan folders for new files. this thread then should start a ock so only one scanfolder thread runs at a time //start a thread that executes check_scan_dir to scan folders for new files. this thread then should start a ock so only one scanfolder thread runs at a time
@@ -67,8 +74,6 @@ int main() {
//ListFilesRecursive("C:\\", 0); //ListFilesRecursive("C:\\", 0);
/*char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator /*char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator
printf("Hash of the executable: "); printf("Hash of the executable: ");

View File

@@ -0,0 +1,106 @@
#pragma warning(disable:4996)
#include <iostream>
#include <thread>
#include <curl/curl.h>
#include <openssl/md5.h>
//#include <yara.h>
#include "app_ctrl.h"
#include "md5hash.h"
#include "connect.h"
#include "scan.h"
#include "queue_ctrl.h"
#include "well_known.h"
#include "local_com.h"
#include "local_schedule.h"
#include "log.h"
#include "thread_ctrl.h"
#include "settings.h"
#include "check_dir.h"
#include "virus_ctrl.h"
int main() {
log(LOGLEVEL::INFO, "[main()]:Starting main thread.");
printf("welcome to the jakach security tool main thread\n");
load_settings();
initialize(DB_DIR);
//start a second thread which will scan for new files
if (get_setting("rtp:status") == 1) {
log(LOGLEVEL::INFO, "[main()]:Starting real time protection.");
std::thread folder_scannner_thread(folder_scanner);
folder_scannner_thread.detach();
}
//main thread:
/* watches for notifications on bus
* start threads (scans etc); only one at a time may run
* updates settings etc
* start scheduled tasks
*/
while (!app_stop()) {
//run all the tasks described above
//check for tasks in com
//check for scheduled tasks
//execute tasks
//call_srv("8.8.8.8","","");
auto start = std::chrono::high_resolution_clock::now();
// printf("check_from_com:%d\n",check_for_com_tasks(MAIN_COM, MAIN_COM_PATH));
check_for_com_tasks(MAIN_COM, MAIN_COM_PATH);
check_for_sched_tasks(SCHED, SCHED_PATH);
// printf("check_from_task:%d\n", check_for_sched_tasks(SCHED,SCHED_PATH));
//unlock_task("tsk1"); else it will only be executed once. but this function has to be called at the end of the task. else it will nvr be executed again. this would be bad :(
//start a thread that executes check_scan_dir to scan folders for new files. this thread then should start a ock so only one scanfolder thread runs at a time
//Sleep(1000);
if (can_run_thread()) {
int queue_size = get_queue_size();
for (int i = 0; i < queue_size; i++) {
char* queue_entry = new char[300 * 2 + 5];
queue_entry[0] = '\0';
queue_pop(queue_entry);
//execute the function which starts the threads
// printf("%s\n", queue_entry);
start_thread(queue_entry);
delete[] queue_entry;
}
}
//to ensure that the loop takes at least 1 second else it will run too fast nd destroy you CPU :)
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start);
if (duration.count() < 1000)
Sleep(1000 - duration.count());
// printf("\n\n\n");
}
//ListFilesRecursive("C:\\", 0);
/*char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator
printf("Hash of the executable: ");
md5_file("C:\\Users\\janis\\Documents\\Projekte_mit_c\\ma\\ma\\src\\client_backend\\x64\\Debug\\client_backend.exe", md5Hash);
printf("%s", md5Hash);
char a_[2000];
printf("\nerror:%d\n",connect_to_srv("https://self-signed.badssl.com/", a_, 2000,1)); //error 60: self signed => option f<>r self-signed ignorieren aktivieren (bool ignore_invalid=true)
printf("%s", a_); //error 6: not reachable
download_file_from_srv("https://jakach.duckdns.org/php/login/v3/login.php", "c:\\programdata\\jakach\\out12.txt");
/*
const int numThreads = 12;
std::thread threads[numThreads];
for (int i = 0; i < numThreads; ++i) {
threads[i] = std::thread(ListFilesRecursive, "C:\\Users\\janis\\Documents\\ma_av_tests",i);
}
// Join threads to wait for them to finish
for (int i = 0; i < numThreads; ++i) {
threads[i].join();
}
std::cout << "All threads have finished." << std::endl;
*/
//printf("code:%d",scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", "1fddc13c02a79442c911a44b02ee0f58"));
return 0;
}

View File

@@ -1,27 +1,27 @@
#pragma warning(disable:4996) #pragma warning(disable:4996)
#include "md5hash.h" #include "md5hash.h"
#include "log.h"
int md5_file(const char*path,char*md5Hash) { int md5_file( const char*path, char*md5Hash) {
std::ifstream file(path, std::ios::binary); std::ifstream file(path, std::ios::binary);
if (!file) { if (!file) {
std::cerr << "Error opening file." << std::endl; log(LOGLEVEL::ERR, "[md5_file()]: Could not open file for scanning ",path);
return 1; return 1;
} }
// Initialize OpenSSL's MD5 context // Initialize OpenSSL's MD5 context
MD5_CTX md5Context; MD5_CTX md5Context;
MD5_Init(&md5Context); MD5_Init(&md5Context);
// Read and update the context with the file's content // Read and update the context with the file's content
char buffer[1024]; char buffer[1024];
while (file.good()) { while (file.good()) {
file.read(buffer, sizeof(buffer)); file.read(buffer, sizeof(buffer));
MD5_Update(&md5Context, buffer, file.gcount()); MD5_Update(&md5Context, buffer, file.gcount());
} }
// Finalize the MD5 hash and store it in result // Finalize the MD5 hash and store it in result
unsigned char result[MD5_DIGEST_LENGTH]; unsigned char result[MD5_DIGEST_LENGTH];
MD5_Final(result, &md5Context); MD5_Final(result, &md5Context);
// Close the file // Close the file
@@ -34,3 +34,86 @@ int md5_file(const char*path,char*md5Hash) {
snprintf(&md5Hash[i * 2], 3, "%02x", result[i]); snprintf(&md5Hash[i * 2], 3, "%02x", result[i]);
} }
} }
//thread save implementation
/*
char* md5_file_t(const char*path) {
//log(LOGLEVEL::INFO, "[md5_file_t()]: Calculating MD5 hash of file ", path_);
FILE* fp = fopen(path, "rb");
if (!fp) {
log(LOGLEVEL::ERR, "[md5_file_t()]: Could not open file for scanning ", path);
return nullptr;
}
// Initialize OpenSSL's MD5 context
MD5_CTX md5Context;
MD5_Init(&md5Context);
// Read and update the context with the file's content
char buffer[1024];
size_t bytesRead;
while ((bytesRead = fread(buffer, 1,1024, fp)) > 0) {
MD5_Update(&md5Context, buffer, bytesRead);
}
// Finalize the MD5 hash and store it in result
unsigned char result[MD5_DIGEST_LENGTH];
MD5_Final(result, &md5Context);
// Close the file
fclose(fp);
// Convert the MD5 hash to a string using snprintf
char* md5Hash = (char*)malloc(2 * MD5_DIGEST_LENGTH + 1);
if (!md5Hash) {
return nullptr; // Allocation failure
}
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
snprintf(&md5Hash[i * 2], 3, "%02x", result[i]);
}
//log(LOGLEVEL::INFO, "[md5_file_t()]: MD5 hash of file ", path, " is ", md5Hash);
return md5Hash;
}
*/
//thread save implementation
std::string md5_file_t(const std::string& path_) {
//log(LOGLEVEL::INFO, "[md5_file_t()]: Calculating MD5 hash of file ", path_);
thread_local std::string path (path_);
thread_local FILE* fp = fopen(path.c_str(), "rb");
if (!fp) {
log(LOGLEVEL::ERR, "[md5_file_t()]: Could not open file for scanning ", path.c_str());
return path; //we return the path because else it moight crash ()if we sen da nullptr
}
// Initialize OpenSSL's MD5 context
thread_local MD5_CTX md5Context;
MD5_Init(&md5Context);
// Read and update the context with the file's content
thread_local char buffer[1024];
thread_local size_t bytesRead;
while ((bytesRead = fread(buffer, 1, 1024, fp)) > 0) {
MD5_Update(&md5Context, buffer, bytesRead);
}
// Finalize the MD5 hash and store it in result
thread_local unsigned char result[MD5_DIGEST_LENGTH];
MD5_Final(result, &md5Context);
// Close the file
fclose(fp);
// Convert the MD5 hash to a string using snprintf
thread_local char* md5Hash = (char*)malloc(2 * MD5_DIGEST_LENGTH + 1);
if (!md5Hash) {
return path; // Allocation failure
}
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
snprintf(&md5Hash[i * 2], 3, "%02x", result[i]);
}
//log(LOGLEVEL::INFO, "[md5_file_t()]: MD5 hash of file ", path, " is ", md5Hash);
return md5Hash;
}

View File

@@ -0,0 +1,36 @@
#pragma warning(disable:4996)
#include "md5hash.h"
#include "log.h"
int md5_file(const char*path,char*md5Hash) {
std::ifstream file(path, std::ios::binary);
if (!file) {
log(LOGLEVEL::ERR, "[md5_file()]: Could not open file for scanning ",path);
return 1;
}
// Initialize OpenSSL's MD5 context
MD5_CTX md5Context;
MD5_Init(&md5Context);
// Read and update the context with the file's content
char buffer[1024];
while (file.good()) {
file.read(buffer, sizeof(buffer));
MD5_Update(&md5Context, buffer, file.gcount());
}
// Finalize the MD5 hash and store it in result
unsigned char result[MD5_DIGEST_LENGTH];
MD5_Final(result, &md5Context);
// Close the file
file.close();
// Store the MD5 hash in a char array
//char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; // +1 for null-terminator
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
snprintf(&md5Hash[i * 2], 3, "%02x", result[i]);
}
}

View File

@@ -5,3 +5,5 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
int md5_file(const char* path, char* md5Hash); int md5_file(const char* path, char* md5Hash);
//char* md5_file_t(const char* path_);
std::string md5_file_t(const std::string& path_);

View File

@@ -4,6 +4,9 @@
#include <openssl/md5.h> #include <openssl/md5.h>
#include <windows.h> #include <windows.h>
#include <iostream> #include <iostream>
#include <thread>
#include <chrono>
#include <time.h>
#include "md5hash.h" #include "md5hash.h"
#include <string> #include <string>
#include "well_known.h" #include "well_known.h"
@@ -11,7 +14,100 @@
#include "virus_ctrl.h" #include "virus_ctrl.h"
#ifndef SCAN_CPP #ifndef SCAN_CPP
#define SCAN_CPP #define SCAN_CPP
std::unordered_map<std::string, HANDLE> fileHandles;
std::unordered_map<std::string, HANDLE> mappingHandles;
std::unordered_map<std::string, char*> fileData;
int cnt = 0; int cnt = 0;
int num_threads=0;
//load all the db files into memory
void 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);
continue; // Move on to the next file if there's an error
}
// 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);
continue; // Move on to the next file if there's an error
}
// Map the file into memory
char* fileDataPtr = static_cast<char*>(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0));
if (fileDataPtr == NULL) {
log(LOGLEVEL::ERR, "[initialize()]: Error mapping database file: ", filename);
CloseHandle(hMapping);
CloseHandle(hFile);
continue; // Move on to the next file if there's an error
}
// Store the handles in the global maps
fileHandles[filename] = hFile;
mappingHandles[filename] = hMapping;
fileData[filename] = fileDataPtr;
}
}
}
// 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
fileHandles.clear();
mappingHandles.clear();
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
thread_local std::string dbname (dbname_);
thread_local std::string hash (hash_);
thread_local std::string filepath (filepath_);
thread_local auto fileIter = fileHandles.find(dbname);
if (fileIter == fileHandles.end()) {
log(LOGLEVEL::ERR, "[search_hash()]: File mapping not initialized for ", dbname);
return 2;
}
// Use fileData for subsequent searches
thread_local DWORD fileSize = GetFileSize(fileHandles[dbname], NULL);
thread_local std::string fileContent(fileData[dbname], fileSize);
// Search for the specific string in the file content
thread_local 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) { bool file_exists(const std::string& filePath) {
DWORD fileAttributes = GetFileAttributes(filePath.c_str()); DWORD fileAttributes = GetFileAttributes(filePath.c_str());
@@ -23,7 +119,9 @@ bool file_exists(const std::string& filePath) {
// Check if it's a regular file and not a directory // Check if it's a regular file and not a directory
return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0; return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
} }
void ListFilesRecursive(const std::string& directory, int thread_id) {
//this is the main function to scan folders. it will then start multuiple threads based on the number of cores / settings
void scan_folder_recursive(const std::string& directory) {
std::string search_path = directory + "\\*.*"; std::string search_path = directory + "\\*.*";
WIN32_FIND_DATA find_file_data; WIN32_FIND_DATA find_file_data;
HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data); HANDLE hFind = FindFirstFile(search_path.c_str(), &find_file_data);
@@ -39,92 +137,88 @@ void ListFilesRecursive(const std::string& directory, int thread_id) {
} }
std::string full_path = directory + "\\" + find_file_data.cFileName; const std::string full_path = directory + "\\" + find_file_data.cFileName;
if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// If it's a directory, recurse into it // If it's a directory, recurse into it
ListFilesRecursive(full_path,thread_id); scan_folder_recursive(full_path);
} }
else { else {
// If it's a file, print its name //action scanfile_t will start the trheads for scanning the hashes
/*char md5Hash[2 * MD5_DIGEST_LENGTH + 1]; //action_scanfile_t(full_path.c_str());
md5_file(full_path.c_str(), md5Hash); //do multithreading here
printf("%s\n", md5Hash); while (num_threads >= std::thread::hardware_concurrency()) {
printf("%d\n", scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", "96be95b122c2b9b8bb5765c312ca4f73")); Sleep(10);
if (scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", md5Hash) == 1) { }
printf("virus found"); num_threads++;
std::thread scan_thread(action_scanfile_t, full_path);
scan_thread.detach();
}*/
cnt++; cnt++;
if (cnt % 1000 == 0) { if (cnt % 100 == 0) {
printf("Processed %d files; sent from thread %d\n", cnt,thread_id); printf("Processed %d files;\n", cnt);
//printf("Number of threads: %d\n", num_threads);
} }
} }
} while (FindNextFile(hFind, &find_file_data) != 0); } while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind); FindClose(hFind);
} }
int scan_hash(const std::string& filename, const std::string& searchString) {//!!!! does not work with e.g. utf-16 or something like that. either ascii or utf8!!
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, "[scan_hash()]: Error opening database file: ", filename, " while searching for hash.", searchString);
return 2;
}
HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapping == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error creating database file mapping: ", filename, " while searching for hash.");
CloseHandle(hFile);
return 2;
}
char* fileData = static_cast<char*>(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0));
if (fileData == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error mapping database file: ", filename, " while searching for hash.");
CloseHandle(hMapping);
CloseHandle(hFile);
return 2;
}
DWORD fileSize = GetFileSize(hFile, NULL);
std::string fileContent(fileData, fileSize);
// Search for the specific string in the file content
size_t foundPos = fileContent.find(searchString);
if (foundPos != std::string::npos) {
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 1;//found
}
// Unmap the memory and close the handles
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 0;
}
int scan_hash(const char* hash) {
char* path = new char[600];
path[0] = '\0';
sprintf_s(path, 595, "%s\\%c%c.jdbf", DB_DIR, hash[0],hash[1]);
return scan_hash(path,hash);
}
//for singlethreaded scans
void action_scanfile(const char*filepath) { void action_scanfile(const char*filepath) {
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath)==false) { char* db_path = new char[300];
log(LOGLEVEL::ERR, "[action_scanfile()]: Error opening file: ", filepath, " while scanning file for viruses.");
return; //no filepath given //log(LOGLEVEL::INFO, "[action_scanfile_t()]: Scanning file: ", filepath);
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath) == false) {
return; //no filepath given or file not accessible
} }
char*hash = new char[300]; else {
md5_file(filepath, hash); char* hash = new char[300];
if (scan_hash(hash)==1) { //virus found hash[0] = '\0';
log(LOGLEVEL::VIRUS, "[action_scanfile()]: Virus found in file: ", filepath); strcpy_s(hash, 295, md5_file_t(filepath).c_str());
//add it to a database which stores filepaths of infected files sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]);
virus_ctrl_store(filepath,hash,"sf"); search_hash(db_path, hash, filepath);
//afterwards do the processing with that file delete[] hash;
virus_ctrl_process("sf");
} }
delete[] hash; delete[] db_path;
}
/*
void action_scanfile_t( const char*filepath) {
char* db_path = new char[300];
int max_threads = std::thread::hardware_concurrency();
//log(LOGLEVEL::INFO, "[action_scanfile_t()]: Scanning file: ", filepath);
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath) == false) {
return; //no filepath given or file not accessible
}
else {
char* hash = new char[300];
hash[0] = '\0';
hash = md5_file_t(filepath);
sprintf_s(db_path, 295, "%s\\%c%c.jdbf", DB_DIR, hash[0], hash[1]);
while (num_threads >= max_threads) {
Sleep(10);
}
num_threads++;
std::thread search_thread(search_hash,db_path, hash, filepath);
search_thread.detach();
std::this_thread::sleep_for(std::chrono::microseconds(50));
delete[] hash;
}
delete[] db_path;
}*/
void action_scanfile_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]);
search_hash(db_path, hash, filepath);
num_threads--;
} }
#endif #endif

View File

@@ -0,0 +1,132 @@
#include "scan.h"
#include <windows.h>
#include <iostream>
#include <openssl/md5.h>
#include <windows.h>
#include <iostream>
#include "md5hash.h"
#include <string>
#include "well_known.h"
#include "log.h"
#include "virus_ctrl.h"
#ifndef SCAN_CPP
#define SCAN_CPP
int cnt = 0;
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;
}
void scan_files_recursive(const std::string& directory, int thread_id) {
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::ERR, "[ListFilesRecursive()]: Error opening directory: ", directory, " while scanning files inside folder.");
return;
}
do {
if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) {
continue; // Skip the current and parent directories
}
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_files_recursive(full_path,thread_id);
}
else {
// If it's a file, print its name
/*char md5Hash[2 * MD5_DIGEST_LENGTH + 1];
md5_file(full_path.c_str(), md5Hash);
printf("%s\n", md5Hash);
printf("%d\n", scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", "96be95b122c2b9b8bb5765c312ca4f73"));
if (scan_hash("C:\\Users\\janis\\Documents\\ma_av_tests\\OutputFile.txt", md5Hash) == 1) {
printf("virus found");
}*/
cnt++;
if (cnt % 1000 == 0) {
printf("Processed %d files; sent from thread %d\n", cnt,thread_id);
}
}
} while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind);
}
int scan_hash(const std::string& filename, const std::string& hash) {//!!!! does not work with e.g. utf-16 or something like that. either ascii or utf8!!
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, "[scan_hash()]: Error opening database file: ", filename, " while searching for hash.", hash);
return 2;
}
HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapping == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error creating database file mapping: ", filename, " while searching for hash.");
CloseHandle(hFile);
return 2;
}
char* fileData = static_cast<char*>(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0));
if (fileData == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error mapping database file: ", filename, " while searching for hash.");
CloseHandle(hMapping);
CloseHandle(hFile);
return 2;
}
DWORD fileSize = GetFileSize(hFile, NULL);
std::string fileContent(fileData, fileSize);
// Search for the specific string in the file content
size_t foundPos = fileContent.find(hash);
if (foundPos != std::string::npos) {
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 1;//found
}
// Unmap the memory and close the handles
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 0;
}
int scan_hash(const char* hash) {
char* path = new char[600];
path[0] = '\0';
sprintf_s(path, 595, "%s\\%c%c.jdbf", DB_DIR, hash[0],hash[1]);
return scan_hash(path,hash);
}
void action_scanfile(const char*filepath) {
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath) == false) {
//log(LOGLEVEL::ERR, "[action_scanfile()]: Error opening file: ", filepath, " while scanning file for viruses.");
return; //no filepath given or file not accessible
}
else {
char* hash = new char[300];
md5_file(filepath, hash);
if (scan_hash(hash) == 1) { //virus found
log(LOGLEVEL::VIRUS, "[action_scanfile()]: Virus found in file: ", filepath);
//add it to a database which stores filepaths of infected files
virus_ctrl_store(filepath, hash, "sf");
//afterwards do the processing with that file
virus_ctrl_process("sf");
}
delete[] hash;
}
}
#endif

View File

@@ -0,0 +1,147 @@
#include "scan.h"
#include <windows.h>
#include <iostream>
#include <openssl/md5.h>
#include <windows.h>
#include <iostream>
#include "md5hash.h"
#include <string>
#include "well_known.h"
#include "log.h"
#include "virus_ctrl.h"
#ifndef SCAN_CPP
#define SCAN_CPP
int cnt = 0;
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_files_recursive(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::ERR, "[ListFilesRecursive()]: Error opening directory: ", directory, " while scanning files inside folder.");
return;
}
do {
if (strcmp(find_file_data.cFileName, ".") == 0 || strcmp(find_file_data.cFileName, "..") == 0) {
continue; // Skip the current and parent directories
}
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_files_recursive(full_path);
}
else {
//we can use a modified version of action_scanfile for this
//action_scanfile_t(full_path.c_str());
cnt++;
if (cnt % 1000 == 0) {
printf("Processed %d files;\n", cnt);
}
}
} while (FindNextFile(hFind, &find_file_data) != 0);
FindClose(hFind);
}
int scan_hash(thread_local const std::string& filename, thread_local const std::string& hash) {//!!!! does not work with e.g. utf-16 or something like that. either ascii or utf8!!
thread_local 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, "[scan_hash()]: Error opening database file: ", filename, " while searching for hash.", hash);
return 2;
}
thread_local HANDLE hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapping == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error creating database file mapping: ", filename, " while searching for hash.");
CloseHandle(hFile);
return 2;
}
char* fileData = static_cast<char*>(MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0));
if (fileData == NULL) {
log(LOGLEVEL::ERR, "[scan_hash()]: Error mapping database file: ", filename, " while searching for hash.");
CloseHandle(hMapping);
CloseHandle(hFile);
return 2;
}
DWORD fileSize = GetFileSize(hFile, NULL);
std::string fileContent(fileData, fileSize);
// Search for the specific string in the file content
size_t foundPos = fileContent.find(hash);
if (foundPos != std::string::npos) {
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 1;//found
}
// Unmap the memory and close the handles
UnmapViewOfFile(fileData);
CloseHandle(hMapping);
CloseHandle(hFile);
return 0;
}
int scan_hash(thread_local const char* hash) {
thread_local char* path = new char[600];
path[0] = '\0';
sprintf_s(path, 595, "%s\\%c%c.jdbf", DB_DIR, hash[0],hash[1]);
return scan_hash(path,hash);
}
//for singlethreaded scans
void action_scanfile(const char*filepath) {
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath) == false) {
//log(LOGLEVEL::ERR, "[action_scanfile()]: Error opening file: ", filepath, " while scanning file for viruses.");
return; //no filepath given or file not accessible
}
else {
char* hash = new char[300];
md5_file(filepath, hash);
if (scan_hash(hash) == 1) { //virus found
log(LOGLEVEL::VIRUS, "[action_scanfile()]: Virus found in file: ", filepath);
//add it to a database which stores filepaths of infected files
virus_ctrl_store(filepath, hash, "sf");
//afterwards do the processing with that file
virus_ctrl_process("sf");
}
delete[] hash;
}
}
//for multithreaded scans
void action_scanfile_t(thread_local const char* filepath) {
if (strlen(filepath) == 0 or strcmp("", filepath) == 0 or file_exists(filepath) == false) {
return; //no filepath given or file not accessible
}
else {
thread_local char* hash = new char[300];
md5_file(filepath, hash);
if (scan_hash(hash) == 1) { //virus found
log(LOGLEVEL::VIRUS, "[action_scanfile()]: Virus found in file: ", filepath);
//add it to a database which stores filepaths of infected files
virus_ctrl_store(filepath, hash, "sft");
//we do the processing at the end of the scan in order to not slow down the scan !!i have to remember to do this!!
//virus_ctrl_process("sft");
}
delete[] hash;
}
}
#endif

View File

@@ -1,7 +1,18 @@
#pragma once #pragma once
#include <string> #include <string>
void ListFilesRecursive(const std::string& directory,int thread_id); #include <unordered_map>
int scan_hash(const std::string& filename, const std::string& searchString); #include <Windows.h>
int scan_hash(const char* hash); #include <string>
int scan_hash(const char* hash); #include <fstream>
#include <iostream>
#include <cctype> // for std::isxdigit
#include <iostream>
#include <future>
#include <vector>
#include <algorithm>
void scan_folder_recursive(const std::string& directory);
void action_scanfile(const char* filepath); void action_scanfile(const char* filepath);
//void action_scanfile_t(const char* filepath);
void action_scanfile_t(const std::string& filepath_);
void initialize(const std::string& folderPath);
void cleanup();

View File

@@ -7,7 +7,7 @@ int setting_virus_ctrl_virus_found_action = 0;
char*setting_server_server_url = new char[300]; char*setting_server_server_url = new char[300];
char exluded_folders[100][300]; char exluded_folders[100][300];
int excluded_folders_size = 0; int excluded_folders_size = 0;
bool setting_rtp_status = 1; //0=off, 1=on
void load_excluded_folders(); void load_excluded_folders();
int load_settings() { int load_settings() {
FILE* fp; FILE* fp;
@@ -41,6 +41,15 @@ int load_settings() {
fscanf_s(fp, "%s", settings_arg, 295); // get the argument fscanf_s(fp, "%s", settings_arg, 295); // get the argument
strcpy_s(setting_server_server_url, 295, settings_arg); strcpy_s(setting_server_server_url, 295, settings_arg);
} }
else if (strcmp(settings_cmd, "rtp:status") == 0) {
fscanf_s(fp, "%s", settings_arg, 295); // get the argument
if (strcmp(settings_arg, "on") == 0) {
setting_rtp_status = 1; //1=on
}
else if (strcmp(settings_arg, "off") == 0) {
setting_rtp_status = 0; //0=off
}
}
} }
@@ -58,6 +67,9 @@ int get_setting(const char*setting_name) {
if (strcmp(setting_name, "virus_ctrl:virus_found:action") == 0) { if (strcmp(setting_name, "virus_ctrl:virus_found:action") == 0) {
return setting_virus_ctrl_virus_found_action; return setting_virus_ctrl_virus_found_action;
} }
else if (strcmp(setting_name, "rtp:status") == 0) {
return setting_rtp_status;
}
return -1; return -1;
} }

View File

@@ -1,7 +1,9 @@
#ifndef THREAD_CTRL_CPP #ifndef THREAD_CTRL_CPP
#define THREAD_CTRL_CPP #define THREAD_CTRL_CPP
#include "thread_ctrl.h" #include "thread_ctrl.h"
#include "log.h"
#include "well_known.h"
#include "scan.h"
void split(char* input,char*delimiter, char* out1, char* out2) { void split(char* input,char*delimiter, char* out1, char* out2) {
//split a string at the delimiter. the delimiter only occurs once. so the first part is out1 and the second part is out2 //split a string at the delimiter. the delimiter only occurs once. so the first part is out1 and the second part is out2
int i = 0; int i = 0;
@@ -36,7 +38,7 @@ int start_thread(const char*command) {
//determine what should be executed //determine what should be executed
if(strcmp(out1,"scanfile")==0){ if(strcmp(out1,"scanfile")==0){
//start a new thread with the scanfile function //start a new thread with the scanfile function
//std::thread t1(scanfile, out2); std::thread t1(action_scanfile, out2);
} }

View File

@@ -5,7 +5,7 @@
#include "log.h" #include "log.h"
#include "settings.h" #include "settings.h"
#include "connect.h" #include "connect.h"
int virus_ctrl_store(const char*path,const char*hash,const char*id) { int virus_ctrl_store( const char*path, const char*hash, const char*id) {
FILE* fp; FILE* fp;
char *db_path = new char[300]; char *db_path = new char[300];
strcpy_s(db_path, 295,VIRUS_CTRL_DB); strcpy_s(db_path, 295,VIRUS_CTRL_DB);
@@ -22,12 +22,12 @@ int virus_ctrl_store(const char*path,const char*hash,const char*id) {
return 0; return 0;
} }
} }
int virus_ctrl_process(const char* id) { int virus_ctrl_process( const char* id) {
//take actions based on settings. //take actions based on settings.
//eg delete infected files, quarantine them, etc //eg delete infected files, quarantine them, etc
FILE* fp; FILE* fp;
char* db_path = new char[300]; char* db_path = new char[300];
strcpy_s(db_path, 295, VIRUS_CTRL_DB); strcpy_s(db_path, 295, VIRUS_CTRL_DB);
strcat_s(db_path, 295, id); strcat_s(db_path, 295, id);
if (fopen_s(&fp, db_path, "r") != 0) { if (fopen_s(&fp, db_path, "r") != 0) {

View File

@@ -20,13 +20,13 @@
#define FOLDER_DATABASE_DIR "C:\\Program Files\\cyberhex\\secure\\database\\folder" #define FOLDER_DATABASE_DIR "C:\\Program Files\\cyberhex\\secure\\database\\folder"
#define DB_DIR "C:\\Program Files\\cyberhex\\secure\\database\\" #define DB_DIR "C:\\Program Files\\cyberhex\\secure\\database"
#define VIRUS_CTRL_DB "C:\\Program Files\\cyberhex\\secure\\database\\virus_ctrl_db.txt" #define VIRUS_CTRL_DB "C:\\Program Files\\cyberhex\\secure\\database\\virus_ctrl_db.txt"
#define SETTINGS_DB "C:\\Program Files\\cyberhex\\secure\\settings\\settings_db.txt" #define SETTINGS_DB "C:\\Program Files\\cyberhex\\secure\\settings\\settings_db.txt"
#define QUARANTINE_PATH "C:\\Program Files\\cyberhex\\secure\\quarantine\\" #define QUARANTINE_PATH "C:\\Program Files\\cyberhex\\secure\\quarantine"
#define PERIODIC_FOLDER_SCAN "C:\\Program Files\\cyberhex\\secure\\database\\folder\\periodic_folder_scan.txt" #define PERIODIC_FOLDER_SCAN "C:\\Program Files\\cyberhex\\secure\\database\\folder\\periodic_folder_scan.txt"
#define PERIODIC_FOLDER_SCAN_TEMP_DB "C:\\Program Files\\cyberhex\\secure\\database\\folder\\temp_db.txt" #define PERIODIC_FOLDER_SCAN_TEMP_DB "C:\\Program Files\\cyberhex\\secure\\database\\folder\\temp_db.txt"

View File

@@ -1 +0,0 @@
C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\TEAM TOOLS\STATIC ANALYSIS TOOLS\\RULE SETS\NATIVERECOMMENDEDRULES.RULESET

View File

@@ -1,60 +1,8 @@
 Quellen werden auf Modulabhängigkeiten überprüft...  Quellen werden auf Modulabhängigkeiten überprüft...
app_ctrl.h
Kompilieren...
app_ctrl.h
app_ctrl.cpp
check_dir.cpp
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(348,7): warning C4101: "fp": Unreferenzierte lokale Variable
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: "Argument": Konvertierung von "wchar_t" in "const _Elem", möglicher Datenverlust
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: with
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: [
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: _Elem=char
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53): warning C4244: ]
(Quelldatei „check_dir.cpp“ wird kompiliert)
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2749,53):
der Vorlageninstanziierungskontext (der älteste zuerst) ist
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(147,29):
Siehe Verweis auf die gerade kompilierte Instanziierung "std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string<std::_String_iterator<std::_String_val<std::_Simple_types<_Elem>>>,0>(_Iter,_Iter,const _Alloc &)" der Funktions-Vorlage.
with
[
_Elem=wchar_t,
_Iter=std::_String_iterator<std::_String_val<std::_Simple_types<wchar_t>>>,
_Alloc=std::allocator<char>
]
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(147,29):
Ersten Verweis auf "std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string" in "process_changes" anzeigen
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\include\xstring(2590,17):
Siehe Verweis auf die gerade kompilierte Instanziierung "void std::basic_string<char,std::char_traits<char>,std::allocator<char>>::_Construct_from_iter<wchar_t*,wchar_t*,_Size_type>(_Iter,const _Sent,_Size)" der Funktions-Vorlage.
with
[
_Size_type=unsigned __int64,
_Iter=wchar_t *,
_Sent=wchar_t *,
_Size=unsigned __int64
]
client_backend.cpp client_backend.cpp
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(63,24): warning C4244: "Argument": Konvertierung von "_Rep" in "DWORD", möglicher Datenverlust C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(70,24): warning C4244: "Argument": Konvertierung von "_Rep" in "DWORD", möglicher Datenverlust
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(63,24): warning C4244: with C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(70,24): warning C4244: with
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(63,24): warning C4244: [ C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(70,24): warning C4244: [
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(63,24): warning C4244: _Rep=__int64 C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(70,24): warning C4244: _Rep=__int64
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(63,24): warning C4244: ] C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\client_backend.cpp(70,24): warning C4244: ]
connect.cpp
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\connect.cpp(92,65): warning C4267: "Argument": Konvertierung von "size_t" nach "int", Datenverlust möglich
local_com.cpp
local_schedule.cpp
log.cpp
md5hash.cpp
permissions.cpp
queue _ctrl.cpp
scan.cpp
settings.cpp
thread_ctrl.cpp
virus_ctrl.cpp
Code Analysis für C/C++ wird ausgeführt...
Code wird generiert...
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\md5hash.cpp(36): warning C4715: "md5_file": Nicht alle Codepfade geben einen Wert zurück.
client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe client_backend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(297): warning C6387: "overlapped.hEvent" könnte "0" sein: dies entspricht nicht der Spezifikation für Funktion "WaitForSingleObject".
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(313): warning C6387: "overlapped.hEvent" könnte "0" sein: dies entspricht nicht der Spezifikation für Funktion "ResetEvent". In Zeile 297 finden Sie einen früheren Ort, an dem dies vorkommen kann.
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\check_dir.cpp(341): warning C6387: "overlapped.hEvent" könnte "0" sein: dies entspricht nicht der Spezifikation für Funktion "CloseHandle". In Zeile 297 finden Sie einen früheren Ort, an dem dies vorkommen kann.

Binary file not shown.

View File

@@ -1,5 +1,3 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\libcrypto-3-x64.dll C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\libcrypto-3-x64.dll
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.exe.lastcodeanalysissucceeded
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\NativeCodeAnalysis.read.1.tlog
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.vcxproj.CopyComplete C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_backend\x64\Debug\client_backend.vcxproj.CopyComplete

Binary file not shown.

View File

@@ -0,0 +1,30 @@
//{{NO_DEPENDENCIES}}
// Von Microsoft Visual C++ generierte Includedatei.
// Verwendet von client_frontend.rc
#define IDS_APP_TITLE 103
#define IDR_MAINFRAME 128
#define IDD_CLIENTFRONTEND_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_CLIENTFRONTEND 107
#define IDI_SMALL 108
#define IDC_CLIENTFRONTEND 109
#define IDC_MYICON 2
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// Nächste Standardwerte für neue Objekte
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 130
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

View File

@@ -0,0 +1,211 @@
// client_frontend.cpp : Definiert den Einstiegspunkt für die Anwendung.
//
#include "framework.h"
#include "client_frontend.h"
#define width 1000
#define height 700
#define MAX_LOADSTRING 100
// 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 MyRegisterClass(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);
MyRegisterClass(hInstance);
// Anwendungsinitialisierung ausführen:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CLIENTFRONTEND));
MSG msg;
// Hauptnachrichtenschleife:
while (GetMessage(&msg, nullptr, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNKTION: MyRegisterClass()
//
// ZWECK: Registriert die Fensterklasse.
//
ATOM MyRegisterClass(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, width,height, 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
//
//main loop
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// Menüauswahl analysieren:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
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...
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CREATE:
{
HWND textbox_, learn_button_, make_button_, settings_button_;
//for this text we need to get some data from the backend
//e.g. rtp
//database status
//infected files
//etc
textbox_ = 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, width - 30, height - 200,
hWnd, (HMENU)0, NULL, NULL);
learn_button_ = CreateWindow(L"BUTTON",
L"Learn a set of Voc",
WS_VISIBLE | WS_CHILD | WS_BORDER,
160, 550, 200, 30, //wo, xy // wie gross xy
hWnd, (HMENU)1, NULL, NULL);
make_button_ = CreateWindow(L"BUTTON",
L"Make a set of Voc",
WS_VISIBLE | WS_CHILD | WS_BORDER,
380, 550, 200, 30,
hWnd, (HMENU)2, NULL, NULL);
settings_button_ = CreateWindow(L"BUTTON",
L"Settings",
WS_VISIBLE | WS_CHILD | WS_BORDER,
600, 550, 200, 30,
hWnd, (HMENU)3, NULL, NULL);
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;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}

View File

@@ -0,0 +1,3 @@
#pragma once
#include "resource.h"

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client_frontend", "client_frontend.vcxproj", "{714B1F08-886A-4AB5-89D4-B9919264F524}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{714B1F08-886A-4AB5-89D4-B9919264F524}.Debug|x64.ActiveCfg = Debug|x64
{714B1F08-886A-4AB5-89D4-B9919264F524}.Debug|x64.Build.0 = Debug|x64
{714B1F08-886A-4AB5-89D4-B9919264F524}.Debug|x86.ActiveCfg = Debug|Win32
{714B1F08-886A-4AB5-89D4-B9919264F524}.Debug|x86.Build.0 = Debug|Win32
{714B1F08-886A-4AB5-89D4-B9919264F524}.Release|x64.ActiveCfg = Release|x64
{714B1F08-886A-4AB5-89D4-B9919264F524}.Release|x64.Build.0 = Release|x64
{714B1F08-886A-4AB5-89D4-B9919264F524}.Release|x86.ActiveCfg = Release|Win32
{714B1F08-886A-4AB5-89D4-B9919264F524}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D94BC215-E973-42E4-A7F3-33EFCC3C89C9}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{714b1f08-886a-4ab5-89d4-b9919264f524}</ProjectGuid>
<RootNamespace>clientfrontend</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="client_frontend.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="client_frontend.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="client_frontend.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="client_frontend.ico" />
<Image Include="small.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="client_frontend.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="client_frontend.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="client_frontend.rc">
<Filter>Ressourcendateien</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="small.ico">
<Filter>Ressourcendateien</Filter>
</Image>
<Image Include="client_frontend.ico">
<Filter>Ressourcendateien</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,15 @@
// header.h: Includedatei für Include-Standardsystemdateien
// oder projektspezifische Includedateien.
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Selten verwendete Komponenten aus Windows-Headern ausschließen
// Windows-Headerdateien
#include <windows.h>
// C RunTime-Headerdateien
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,6 @@
#pragma once
// // Durch das Einschließen von "SDKDDKVer.h" wird die höchste verfügbare Windows-Plattform definiert.
// Wenn Sie Ihre Anwendung für eine frühere Windows-Plattform erstellen möchten, schließen Sie "WinSDKVer.h" ein, und
// legen Sie vor dem Einschließen von "SDKDDKVer.h" das _WIN32_WINNT-Makro auf die Plattform fest, die Sie unterstützen möchten.
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\x64\Debug\client_frontend.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

Binary file not shown.

View File

@@ -0,0 +1,2 @@
 client_frontend.cpp
client_frontend.vcxproj -> C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\x64\Debug\client_frontend.exe

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
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\x64\Debug\client_frontend.obj

View File

@@ -0,0 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.38.33130:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows:
Debug|x64|C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\|

View File

@@ -0,0 +1 @@
C:\Users\janis\Documents\Projekte_mit_c\ma\ma\src\client_frontend\x64\Debug\client_frontend.exe

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@