From 5737355985e28af306a8566e12fce69a3cff12cd Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 16 Oct 2019 14:46:57 +0200 Subject: [PATCH] chg renable win ansi test. trying turning offlogging. @doegox can refacor this away when we get a prefs.json settings file --- client/cmdparser.c | 6 +++-- client/proxmark3.c | 65 ++++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/client/cmdparser.c b/client/cmdparser.c index 52d4e805e..72628f2fb 100644 --- a/client/cmdparser.c +++ b/client/cmdparser.c @@ -154,9 +154,11 @@ void CmdsHelp(const command_t Commands[]) { if (Commands[0].Name == NULL) return; int i = 0; while (Commands[i].Name) { - if (Commands[i].IsAvailable()) -// PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); + if (Commands[i].IsAvailable()) { + g_printAndLog = PRINTANDLOG_PRINT; PrintAndLogEx(NORMAL, _GREEN_("%-16s")" %s", Commands[i].Name, Commands[i].Help); + g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; + } ++i; } } diff --git a/client/proxmark3.c b/client/proxmark3.c index ceabbc6f3..fb02396bd 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -29,6 +29,8 @@ static void showBanner(void) { + g_printAndLog = PRINTANDLOG_PRINT; + PrintAndLogEx(NORMAL, "\n"); #if defined(__linux__) || (__APPLE__) || (_WIN32) PrintAndLogEx(NORMAL, _BLUE_("██████╗ ███╗ ███╗ ████╗ ") " ...iceman fork"); @@ -50,6 +52,8 @@ static void showBanner(void) { // printf("\nMonero: 43mNJLpgBVaTvyZmX9ajcohpvVkaRy1kbZPm8tqAb7itZgfuYecgkRF36rXrKFUkwEGeZedPsASRxgv4HPBHvJwyJdyvQuP"); PrintAndLogEx(NORMAL, "\n"); fflush(stdout); + + g_printAndLog = PRINTANDLOG_PRINT | PRINTANDLOG_LOG; } int check_comm(void) { @@ -466,6 +470,35 @@ finish2: return ret; } +// Check if windows AnsiColor Support is enabled in the registery +// [HKEY_CURRENT_USER\Console] +// "VirtualTerminalLevel"=dword:00000001 +static bool DetectWindowsAnsiSupport(void) { + bool ret = false; +#if defined(_WIN32) + HKEY hKey = NULL; + + if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) { + DWORD dwType = REG_SZ; + BYTE KeyValue[sizeof(dwType)]; + DWORD len = sizeof(KeyValue); + + if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) { + uint8_t i; + uint32_t Data = 0; + for (i = 0; i < 4; i++) + Data += KeyValue[i] << (8 * i); + + if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled + ret = true; + } + } + RegCloseKey(hKey); + } +#endif + return ret; +} + int main(int argc, char *argv[]) { srand(time(0)); @@ -683,37 +716,7 @@ int main(int argc, char *argv[]) { return 1; } - session.supports_colors = false; -/* - // Removed color on windows until a better option can be implemented. - -#if defined(_WIN32) - // Check if windows AnsiColor Support is enabled in the registery - // [HKEY_CURRENT_USER\Console] - // "VirtualTerminalLevel"=dword:00000001 - - HKEY hKey = NULL; - - if (RegOpenKeyA(HKEY_CURRENT_USER, "Console", &hKey) == ERROR_SUCCESS) { - DWORD dwType = REG_SZ; - BYTE KeyValue[sizeof(dwType)]; - DWORD len = sizeof(KeyValue); - - if (RegQueryValueEx(hKey, "VirtualTerminalLevel", NULL, &dwType, KeyValue, &len) != ERROR_FILE_NOT_FOUND) { - uint8_t i; - uint32_t Data = 0; - for (i = 0; i < 4; i++) - Data += KeyValue[i] << (8 * i); - - if (Data == 1) { // Reg key is set to 1, Ansi Color Enabled - session.supports_colors = true; - } - } - RegCloseKey(hKey); - } - -#endif -*/ + session.supports_colors = DetectWindowsAnsiSupport(); session.stdinOnTTY = isatty(STDIN_FILENO); session.stdoutOnTTY = isatty(STDOUT_FILENO);