From 2abd7e08b42f278bfb07777fb81199ce09f69403 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 29 Jun 2020 22:23:46 +0200 Subject: [PATCH] chg: disable ctrl-c on mingw/ps --- client/src/proxmark3.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/proxmark3.c b/client/src/proxmark3.c index cb739df13..1bf08f1d3 100644 --- a/client/src/proxmark3.c +++ b/client/src/proxmark3.c @@ -146,6 +146,18 @@ static void flush_history(void) { } #ifdef HAVE_READLINE + +# if defined(_WIN32) +/* +static bool WINAPI terminate_handler(DWORD t) { + if (t == CTRL_C_EVENT) { + flush_history(); + return true; + } + return false; +} +*/ +# else struct sigaction old_action; static void terminate_handler(int signum) { sigaction(SIGINT, &old_action, NULL); @@ -154,6 +166,8 @@ static void terminate_handler(int signum) { } #endif +#endif + // first slot is always NULL, indicating absence of script when idx=0 static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0}; static uint8_t cmdscriptfile_idx = 0; @@ -236,11 +250,14 @@ main_loop(char *script_cmds_file, char *script_cmd, bool stayInCommandLoop) { session.history_path = NULL; } else { +# if defined(_WIN32) +// SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, true); +# else struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = &terminate_handler; sigaction(SIGINT, &action, &old_action); - +# endif rl_catch_signals = 1; rl_set_signals(); read_history(session.history_path); @@ -1054,7 +1071,7 @@ int main(int argc, char *argv[]) { #ifdef HAVE_GUI -# ifdef _WIN32 +# if defined(_WIN32) InitGraphics(argc, argv, script_cmds_file, script_cmd, stayInCommandLoop); MainGraphics(); # else