Skip to content

Commit

Permalink
Create basic functionality and remove folder_path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Nov 3, 2024
1 parent 84438a8 commit 549fa56
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
22 changes: 17 additions & 5 deletions api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@ Compile with g++ -shared -o api.dll api.cpp -Ofast -fPIC -shared
using namespace std;
namespace fs = std::filesystem;

const char* FOLDER_PATH = "C:/Program Files/DyKnow/Cloud/7.10.22.9";

namespace Widgets {
enum Button {
START = 1,
STOP = 2
};
}

extern "C"
{
bool running = false;
int killed = 0;

__declspec(dllexport) void start_monitoring(const char* folder_path);
__declspec(dllexport) void start_monitoring();
__declspec(dllexport) void stop_monitoring();
__declspec(dllexport) int get_killed_count();
__declspec(dllexport) bool is_running();
Expand Down Expand Up @@ -94,7 +103,7 @@ void monitor_executables(const string& folder_path)
}
}

void start_monitoring(const char* folder_path)
void start_monitoring()
{
if (!running)
{
Expand Down Expand Up @@ -162,8 +171,11 @@ __declspec(dllexport) int __stdcall bsod()
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_COMMAND:
if (LOWORD(wParam) == 1) {
MessageBox(hwnd, "Button Clicked!", "Info", MB_OK);
if (LOWORD(wParam) == Widgets::START) {
start_monitoring(FOLDER_PATH);
}
else if (LOWORD(wParam) == Widgets::STOP) {
stop_monitoring();
}
break;
case WM_DESTROY:
Expand Down Expand Up @@ -198,7 +210,7 @@ void create_window() {

CreateWindow(
"BUTTON",
"Click Me",
"Start application",
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
10,
10,
Expand Down
1 change: 0 additions & 1 deletion dieknow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

lib = ctypes.CDLL("./api.dll")

lib.start_monitoring.argtypes = [ctypes.c_char_p]
lib.stop_monitoring.restype = None
lib.get_killed_count.restype = ctypes.c_int
lib.get_executables_in_folder.argtypes = [ctypes.c_char_p]
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def main():

if user_input == "start":
if not dieknow.is_running():
dieknow.start_monitoring(folder_path)
dieknow.start_monitoring()
print("Monitoring started...")
else:
dieknow.dialog(
Expand Down

0 comments on commit 549fa56

Please sign in to comment.