From f1ae0e0bb0adeebd712b2bf44e65223091d5b368 Mon Sep 17 00:00:00 2001 From: suut Date: Mon, 2 Feb 2026 20:34:39 +0100 Subject: [PATCH 1/4] Disable the "deprecated declaration" warning for MSVC build --- CHANGELOG.md | 2 +- software/src/CMakeLists.txt | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e8caaa..289814e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fix the issue where some reader cause CU to enter a strange state (@xianglin1998) - The transmission performance of USB has been improved (@xianglin1998) - Added cmd for set mf1 config 'field_off_do_reset' (@xianglin1998) - + - Fix Windows build (@suut) ## [v2.1.0][2025-09-02] - Added UV, formatter and linter. Contribution guidelines. (@GameTec-live) diff --git a/software/src/CMakeLists.txt b/software/src/CMakeLists.txt index f33c8d6..5f77f17 100644 --- a/software/src/CMakeLists.txt +++ b/software/src/CMakeLists.txt @@ -221,16 +221,18 @@ endif() add_executable(mfulc_des_brute mfulc_des_brute.c) target_include_directories(mfulc_des_brute PRIVATE ${SRC_DIR}) target_link_libraries(mfulc_des_brute PRIVATE ${LIBTHREAD} OpenSSL::Crypto) -target_compile_options(mfulc_des_brute PRIVATE -Wno-deprecated-declarations) +if (MSVC) + target_compile_options(mfulc_des_brute PRIVATE /Wd4996) # disable "deprecated declaration" warning +else() + target_compile_options(mfulc_des_brute PRIVATE -Wno-deprecated-declarations) +endif() if (CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Android" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") target_compile_definitions(mfulc_des_brute PRIVATE _GNU_SOURCE) - find_package(OpenSSL REQUIRED) endif() if (CMAKE_SYSTEM_NAME MATCHES "Windows") target_compile_definitions(mfulc_des_brute PRIVATE HAVE_STRUCT_TIMESPEC) - find_package(OpenSSL REQUIRED) endif() - +find_package(OpenSSL REQUIRED) # --- hardnested Executable --- add_executable(hardnested ${COMMON_FILES} ${HARDNESTED_SOURCES}) From f6ac86cc1979f73c714511b2a9d611d0a0abf81d Mon Sep 17 00:00:00 2001 From: suut Date: Mon, 2 Feb 2026 21:22:01 +0100 Subject: [PATCH 2/4] Fix missing bswap64 on Windows --- software/src/mfulc_des_brute.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/software/src/mfulc_des_brute.c b/software/src/mfulc_des_brute.c index 7d7b307..1357c10 100644 --- a/software/src/mfulc_des_brute.c +++ b/software/src/mfulc_des_brute.c @@ -10,6 +10,12 @@ #include #include +#ifdef _MSC_VER +# define bswap64 _byteswap_uint64 +#else +# define bswap64 __builtin_bswap64 +#endif + #define BLOCK_SIZE 8 // DES (and 3DES) block size in bytes #define KEY_SIZE 16 // Full 2TDEA key size (K1 || K2) #define BENCHMARK_FULL_KEYSPACE 0 @@ -57,7 +63,7 @@ static void print_hex(const unsigned char *buf, size_t len) { } static bool valid_lfsr_ulcg(uint64_t x64) { - x64 = __builtin_bswap64(x64); + x64 = bswap64(x64); uint16_t x16 = x64 >> 48; x16 = x16 << 15 | ((x16 >> 1) ^ ((x16 >> 3 ^ x16 >> 4 ^ x16 >> 6) & 1)); if (x16 != ((x64 >> 32) & 0xFFFF)) return false; @@ -69,7 +75,7 @@ static bool valid_lfsr_ulcg(uint64_t x64) { } static bool valid_lfsr_uscuidul(uint64_t x64) { - x64 = __builtin_bswap64(x64); + x64 = bswap64(x64); uint16_t x16 = x64 & 0xFFFF; for (int i = 0; i < 16; i++) x16 = x16 >> 1 | (x16 ^ x16 >> 2 ^ x16 >> 3 ^ x16 >> 5) << 15; if (x16 != ((x64 >> 16) & 0xFFFF)) return false; @@ -193,9 +199,9 @@ static void *worker(void *arg) { // Check if out is 8-bit (1-byte) left rotated version of init_out // Need to convert to big-endian for byte rotation, then back to little-endian - uint64_t init_be = __builtin_bswap64(init_out); + uint64_t init_be = bswap64(init_out); uint64_t rotated_be = (init_be << 8) | (init_be >> 56); - uint64_t rotated = __builtin_bswap64(rotated_be); + uint64_t rotated = bswap64(rotated_be); match = (out == rotated); } else { // In counterfeit mode, check the resulting plaintext against LFSR From 6e4a5644179ed3d2f0808c712a890c33032ebc1a Mon Sep 17 00:00:00 2001 From: suut Date: Mon, 2 Feb 2026 21:25:14 +0100 Subject: [PATCH 3/4] Fix typo in CMakeLists.txt --- software/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/src/CMakeLists.txt b/software/src/CMakeLists.txt index 5f77f17..d137251 100644 --- a/software/src/CMakeLists.txt +++ b/software/src/CMakeLists.txt @@ -222,7 +222,7 @@ add_executable(mfulc_des_brute mfulc_des_brute.c) target_include_directories(mfulc_des_brute PRIVATE ${SRC_DIR}) target_link_libraries(mfulc_des_brute PRIVATE ${LIBTHREAD} OpenSSL::Crypto) if (MSVC) - target_compile_options(mfulc_des_brute PRIVATE /Wd4996) # disable "deprecated declaration" warning + target_compile_options(mfulc_des_brute PRIVATE /wd4996) # disable "deprecated declaration" warning else() target_compile_options(mfulc_des_brute PRIVATE -Wno-deprecated-declarations) endif() From 23181d84f1f0dba571042d01a2c36106e9a516e9 Mon Sep 17 00:00:00 2001 From: suut Date: Tue, 3 Feb 2026 00:34:05 +0100 Subject: [PATCH 4/4] Run GitHub actions