From 37dd3875607a897de3a260196a61d08951440d42 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 31 May 2025 10:47:42 +0200 Subject: [PATCH] Fix more warnings --- cmake/sccache.cmake | 20 ++++---- src/analyzer/main.cpp | 67 ++++++++++++++------------ src/fuzzer/main.cpp | 69 ++++++++++++++------------- src/tools/dump-apiset/dump-apiset.cpp | 18 +++---- 4 files changed, 93 insertions(+), 81 deletions(-) diff --git a/cmake/sccache.cmake b/cmake/sccache.cmake index 732330d5..e0cdfdae 100644 --- a/cmake/sccache.cmake +++ b/cmake/sccache.cmake @@ -1,14 +1,16 @@ include_guard() -find_program(SCCACHE sccache) +if(CMAKE_GENERATOR STREQUAL "Ninja") + find_program(SCCACHE sccache) -if (SCCACHE) - file(TO_CMAKE_PATH "${SCCACHE}" SCCACHE) - set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE}) - set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE}) - set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) + if (SCCACHE) + file(TO_CMAKE_PATH "${SCCACHE}" SCCACHE) + set(CMAKE_C_COMPILER_LAUNCHER ${SCCACHE}) + set(CMAKE_CXX_COMPILER_LAUNCHER ${SCCACHE}) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT Embedded) - if(POLICY CMP0141) - cmake_policy(SET CMP0141 NEW) + if(POLICY CMP0141) + cmake_policy(SET CMP0141 NEW) + endif() endif() -endif() +endif() \ No newline at end of file diff --git a/src/analyzer/main.cpp b/src/analyzer/main.cpp index a9690f93..889e78be 100644 --- a/src/analyzer/main.cpp +++ b/src/analyzer/main.cpp @@ -473,45 +473,50 @@ namespace return options; } + + int run_main(const int argc, char** argv) + { + try + { + auto args = bundle_arguments(argc, argv); + if (args.empty()) + { + print_help(); + return 1; + } + + const auto options = parse_options(args); + + bool result{}; + + do + { + result = run(options, args); + } while (options.use_gdb); + + return result ? 0 : 1; + } + catch (std::exception& e) + { + puts(e.what()); + +#if defined(_WIN32) && 0 + MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR); +#endif + } + + return 1; + } } int main(const int argc, char** argv) { - try - { - auto args = bundle_arguments(argc, argv); - if (args.empty()) - { - print_help(); - return 1; - } - - const auto options = parse_options(args); - - bool result{}; - - do - { - result = run(options, args); - } while (options.use_gdb); - - return result ? 0 : 1; - } - catch (std::exception& e) - { - puts(e.what()); - -#if defined(_WIN32) && 0 - MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR); -#endif - } - - return 1; + return run_main(argc, argv); } #ifdef _WIN32 int WINAPI WinMain(HINSTANCE, HINSTANCE, PSTR, int) { - return main(__argc, __argv); + return run_main(__argc, __argv); } #endif diff --git a/src/fuzzer/main.cpp b/src/fuzzer/main.cpp index 2bb4cb5c..7af4ba2d 100644 --- a/src/fuzzer/main.cpp +++ b/src/fuzzer/main.cpp @@ -166,46 +166,51 @@ namespace forward_emulator(win_emu); run_fuzzer(win_emu); } + + int run_main(const int argc, char** argv) + { + if (argc <= 1) + { + puts("Application not specified!"); + return 1; + } + + // setvbuf(stdout, nullptr, _IOFBF, 0x10000); + if (argc > 2 && argv[1] == "-d"s) + { + use_gdb = true; + } + + try + { + do + { + run(argv[use_gdb ? 2 : 1]); + } while (use_gdb); + + return 0; + } + catch (std::exception& e) + { + puts(e.what()); + +#if defined(_WIN32) && 0 + MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR); +#endif + } + + return 1; + } } int main(const int argc, char** argv) { - if (argc <= 1) - { - puts("Application not specified!"); - return 1; - } - - // setvbuf(stdout, nullptr, _IOFBF, 0x10000); - if (argc > 2 && argv[1] == "-d"s) - { - use_gdb = true; - } - - try - { - do - { - run(argv[use_gdb ? 2 : 1]); - } while (use_gdb); - - return 0; - } - catch (std::exception& e) - { - puts(e.what()); - -#if defined(_WIN32) && 0 - MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR); -#endif - } - - return 1; + return run_main(argc, argv); } #ifdef _WIN32 int WINAPI WinMain(HINSTANCE, HINSTANCE, PSTR, int) { - return main(__argc, __argv); + return run_main(__argc, __argv); } #endif diff --git a/src/tools/dump-apiset/dump-apiset.cpp b/src/tools/dump-apiset/dump-apiset.cpp index 8b18741f..1b2c4ffa 100644 --- a/src/tools/dump-apiset/dump-apiset.cpp +++ b/src/tools/dump-apiset/dump-apiset.cpp @@ -24,14 +24,14 @@ int main() const auto peb = static_cast(GetCurrentProcessPeb()); const auto api_set_map = reinterpret_cast(peb->ApiSetMap); - printf("APISET: 0x%p\n", api_set_map); - printf("Version: %d\n", api_set_map->Version); - printf("Size: %08X\n", api_set_map->Size); - printf("Flags: %08X\n", api_set_map->Flags); - printf("Count: %d\n", api_set_map->Count); - printf("EntryOffset: %08X\n", api_set_map->EntryOffset); - printf("HashOffset: %08X\n", api_set_map->HashOffset); - printf("HashFactor: %08X\n", api_set_map->HashFactor); + printf("APISET: 0x%p\n", static_cast(api_set_map)); + printf("Version: %lu\n", api_set_map->Version); + printf("Size: %08lX\n", api_set_map->Size); + printf("Flags: %08lX\n", api_set_map->Flags); + printf("Count: %lu\n", api_set_map->Count); + printf("EntryOffset: %08lX\n", api_set_map->EntryOffset); + printf("HashOffset: %08lX\n", api_set_map->HashOffset); + printf("HashFactor: %08lX\n", api_set_map->HashFactor); // print_apiset(apiSetMap); // Compress the API-SET binary blob @@ -68,7 +68,7 @@ void print_apiset(PAPI_SET_NAMESPACE api_set_map) std::wstring name(reinterpret_cast(reinterpret_cast(api_set_map) + entry->NameOffset), entry->NameLength / sizeof(wchar_t)); - printf("-----------\n[%05d]: Contract Name: %ls\n", i, name.data()); + printf("-----------\n[%05lu]: Contract Name: %ls\n", i, name.data()); for (ULONG x = 0; x < entry->ValueCount; x++) {