Skip to content

Commit

Permalink
Show warning if DyKnow installation is too large
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Jan 23, 2025
1 parent 5dcac85 commit 2061893
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const char* FOLDER_PATH = "C:\\Program Files\\DyKnow\\Cloud";
// Probably subject to change, will have to be updated often
const char* DYK_CLASS_NAME = "WindowsForms10.Window.8.app.0.9fe31_r7_ad1";

const int MAX_DYKNOW_SIZE = 50;

KillMethod default_kill_method = KillMethod::WIN32_API;


Expand Down Expand Up @@ -181,7 +183,7 @@ DK_API void validate() {
std::string color;
if (size_in_mb < 30) {
color = "\033[32m"; // Green
} else if (size_in_mb >= 30 && size_in_mb <= 50) {
} else if (size_in_mb >= 30 && size_in_mb <= MAX_DYKNOW_SIZE) {
color = "\033[0m"; // Normal (default)
} else {
color = "\033[31m"; // Red
Expand Down
2 changes: 2 additions & 0 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extern const char* FOLDER_PATH;

extern const char* DYK_CLASS_NAME;

extern const int MAX_DYKNOW_SIZE;


std::filesystem::path get_directory();

Expand Down
43 changes: 28 additions & 15 deletions src/dieknow.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,29 @@
function_name = parts[1] if len(parts) > 1 else "unknown"
raise OSError(f"Function '{function_name}' name or ordinal missing!") from exc

get_kill_method = lib.get_kill_method
set_kill_method = lib.set_kill_method

validate = lib.validate
for func_name in dir(lib):
if not func_name.startswith("_"):
globals()[func_name] = getattr(lib, func_name)

folder_path = lib.get_folder_path()
start_monitoring = lib.start_monitoring
stop_monitoring = lib.stop_monitoring
monitor_executables = lib.monitor_executables
get_killed_count = lib.get_killed_count
close_application_by_exe = lib.close_application_by_exe
get_executables_in_folder = lib.get_executables_in_folder
is_running = lib.is_running
is_monitoring = lib.is_monitoring
bsod = lib.bsod
dialog = lib.dialog
#get_kill_method = lib.get_kill_method
#set_kill_method = lib.set_kill_method

#validate = lib.validate
#
#start_monitoring = lib.start_monitoring
#stop_monitoring = lib.stop_monitoring
#monitor_executables = lib.monitor_executables
#get_killed_count = lib.get_killed_count
#close_application_by_exe = lib.close_application_by_exe
#get_executables_in_folder = lib.get_executables_in_folder
#is_running = lib.is_running
#is_monitoring = lib.is_monitoring
#bsod = lib.bsod
#dialog = lib.dialog

del func_name

doc.doc(os.path.join(os.path.dirname(__file__), "api.cpp"), lib, markdown=md)

Expand All @@ -96,7 +104,7 @@

# Aliases
gui = create_window
directory = get_executables_in_folder
dir = get_executables_in_folder
start = start_monitoring
stop = stop_monitoring
status = is_running
Expand All @@ -110,6 +118,11 @@ def __init__(self):
"close_application_by_exe",
"ctypes",
"doc",
"get_executables_in_folder",
"get_folder_path",
"get_killed_count",
"create_window",
"folder_path",
"gui_dll_path",
"guilib",
"is_running",
Expand All @@ -132,7 +145,7 @@ def __init__(self):
if var_name not in exclude and not var_name.startswith("__"):
setattr(self, var_name, value)

self.dir = get_executables_in_folder
self.folder = folder_path


shell = Shell()
10 changes: 10 additions & 0 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,16 @@ Application::Application() {
LVS_EX_FULLROWSELECT
);

uint64_t size = dyknow_size();
uint64_t size_in_mb = size / (1024 * 1024);

if (size_in_mb > MAX_DYKNOW_SIZE) {
std::string message = "Your DyKnow folder size was detected as "
+ comma_separated(size_in_mb) + "! If this continues, restart your "
+ "computer.";
MessageBox(hwnd, message.c_str(), "Warning", MB_ICONWARNING);
}

// In ms -- set update rate to 10 ticks per second
SetTimer(hwnd, 1, settings.get<int>("update", 100), nullptr);

Expand Down

0 comments on commit 2061893

Please sign in to comment.