From 70b71324e5ea7447abb0fa9e60a1d81b89a2abfb Mon Sep 17 00:00:00 2001 From: Jsu <165079500+vincere-mori@users.noreply.github.com> Date: Fri, 22 May 2026 18:33:49 +0300 Subject: [PATCH 1/2] add cli help and version flags --- src/main.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main.c b/src/main.c index 06ef95d..ccf9e9e 100644 --- a/src/main.c +++ b/src/main.c @@ -14,9 +14,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see https://www.gnu.org/licenses/. +#include +#include +#include #include #include "../include/gui.h" +#include "../include/version.h" /* Force NVIDIA Optimus and AMD switchable-graphics systems to use the * high-performance discrete GPU for this process. @@ -25,11 +29,51 @@ __declspec(dllexport) unsigned long NvOptimusEnablement = 1; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +static void attach_output_console(void) +{ + FILE *stream; + + if (!AttachConsole(ATTACH_PARENT_PROCESS)) { + AllocConsole(); + } + + freopen_s(&stream, "CONOUT$", "w", stdout); + freopen_s(&stream, "CONOUT$", "w", stderr); +} + +static int handle_command_line_flags(void) +{ + int argc = 0; + int handled = 0; + LPWSTR *argv = CommandLineToArgvW(GetCommandLineW(), &argc); + + if (argv == NULL) { + return 0; + } + + if (argc == 2 && wcscmp(argv[1], L"--version") == 0) { + attach_output_console(); + printf("FSP.DMRCrack %s\n", DMRCRACK_VERSION); + handled = 1; + } else if (argc == 2 && wcscmp(argv[1], L"--help") == 0) { + attach_output_console(); + printf("Usage: dmrcrack.exe [--help] [--version]\n"); + handled = 1; + } + + LocalFree(argv); + return handled; +} + int WINAPI WinMain(HINSTANCE h_instance, HINSTANCE h_prev, LPSTR lp_cmd_line, int n_cmd_show) { (void)h_prev; (void)lp_cmd_line; + if (handle_command_line_flags()) { + return 0; + } + /* Enable per-monitor DPI awareness for crisp rendering on high-DPI displays */ SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); From 405795d7473f1b6769b278445ec7ca7d508155d5 Mon Sep 17 00:00:00 2001 From: whoami Date: Sat, 23 May 2026 20:51:15 +0300 Subject: [PATCH 2/2] Move before so its types are defined --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index ccf9e9e..b41f288 100644 --- a/src/main.c +++ b/src/main.c @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see https://www.gnu.org/licenses/. +#include #include #include #include -#include #include "../include/gui.h" #include "../include/version.h"