diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9cfaccc..10822d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,12 +10,20 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ida_sdk: [77, 80] + ida_sdk: [74, 77, 80, 81, 82, 83] include: + - ida_sdk: 74 + sdk_password: IDA_SDK74_PASSWORD - ida_sdk: 77 sdk_password: IDA_SDK77_PASSWORD - ida_sdk: 80 sdk_password: IDA_SDK80_PASSWORD + - ida_sdk: 81 + sdk_password: IDA_SDK81_PASSWORD + - ida_sdk: 82 + sdk_password: IDA_SDK82_PASSWORD + - ida_sdk: 83 + sdk_password: IDA_SDK83_PASSWORD - os: ubuntu-latest ext: so - os: windows-latest @@ -84,7 +92,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ida_sdk: [77, 80] + ida_sdk: [74, 77, 80, 81, 82, 83] include: - os: windows-latest ext: dll diff --git a/README.md b/README.md index fccb31e..2f3103d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ $ pip install quokka-project Note: The IDA plugin is not needed to read a `Quokka` generated file. It is only used to generate them. +Quokka is currently compatible with IDA 7.3+ + The plugin is built on the CI and available in the [Release](https://github.com/quarkslab/quokka/releases/new) tab. diff --git a/cmake/FindIdaSdk.cmake b/cmake/FindIdaSdk.cmake index 0e77888..4d3d9d7 100644 --- a/cmake/FindIdaSdk.cmake +++ b/cmake/FindIdaSdk.cmake @@ -31,7 +31,10 @@ # IdaSdk_INCLUDE_DIRS - Include directories for the IDA Pro SDK. # IdaSdk_PLATFORM - IDA SDK platform, one of __LINUX__, __NT__ or # __MAC__. -# IDA_ROOT_DIR - IDA Binary +# IDA_ROOT_DIR - IDA Binary +# IdaSdk_LIB - Windows: path to ida.lib for 64-bit address sizes +# IdaSdk_LIB32 - Windows: full path to a suitable ida.lib for 32-bit +# address aware IDA. # # This module reads hints about search locations from variables: # @@ -76,7 +79,28 @@ if (UNIX) endif () elseif (WIN32) set(IdaSdk_PLATFORM __NT__) - set(IdaLib ${IdaSdk_DIR}/lib/x64_win_vc_64/ida.lib) + find_library(IdaSdk_LIB ida + PATHS ${IdaSdk_DIR}/lib + PATH_SUFFIXES x64_win_vc_64 + # IDA SDK 8.2 and later + x64_win_vc_64_teams + x64_win_vc_64_pro + x64_win_vc_64_home + NO_DEFAULT_PATH + ) + find_library(IdaSdk_LIB32 ida + PATHS ${IdaSdk_DIR}/lib + PATH_SUFFIXES x64_win_vc_32 + # IDA SDK 8.2 and later + x64_win_vc_32_teams + x64_win_vc_32_pro + x64_win_vc_32_home + NO_DEFAULT_PATH + ) + if(NOT IdaSdk_LIB OR NOT IdaSdk_LIB32) + message(FATAL_ERROR "Missing ida.lib from SDK lib dir") + endif() + set(IdaLib ${IdaSdk_LIB}) else () message(FATAL_ERROR "Unsupported system type: ${CMAKE_SYSTEM_NAME}") endif () @@ -117,7 +141,7 @@ function(_ida_plugin name link_script) # ARGN contains sources # TODO(cblichmann): This belongs in an interface library instead. target_compile_options(${name} PUBLIC -Wno-non-virtual-dtor) elseif (WIN32) - target_link_libraries(${name} ${IdaSdk_DIR}/lib/x64_win_vc_64/ida.lib) + target_link_libraries(${name} ${IdaSdk_LIB}) endif () endfunction() diff --git a/docs/installation.md b/docs/installation.md index 0b8b5c1..c25145c 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -74,8 +74,8 @@ To download the plugin, get the file named `quokka_plugin**.so`. - CMake (at least 3.13) - A reasonable modern compiler supporting at least Cxx17 -- IDA Sdk (version 7.7) 64 bits -- IDA (7.7 and higher) +- IDA Sdk (version 7.3 or higher) 64 bits +- IDA (7.3 or higher) #### Standard build diff --git a/include/quokka/Block.h b/include/quokka/Block.h index 456523d..1acf375 100644 --- a/include/quokka/Block.h +++ b/include/quokka/Block.h @@ -27,8 +27,8 @@ #include #include +#include "Compatibility.h" #include - #include #include diff --git a/include/quokka/Comment.h b/include/quokka/Comment.h index 4ae11ed..7b1b745 100644 --- a/include/quokka/Comment.h +++ b/include/quokka/Comment.h @@ -24,17 +24,19 @@ #include #include +#include "Compatibility.h" #include #include #include #include #include +#include "absl/container/flat_hash_map.h" + #include "Localization.h" //Kept for Location #include "Util.h" #include "Windows.h" -#include "absl/container/flat_hash_map.h" namespace quokka { diff --git a/include/quokka/Compatibility.h b/include/quokka/Compatibility.h index 7221ecd..e309f01 100644 --- a/include/quokka/Compatibility.h +++ b/include/quokka/Compatibility.h @@ -16,34 +16,21 @@ * @file Compatibility.h * Compatibility file * - * Proxy methods for IDA when some functions in the SDK changes. + * Keeps compatibility between different version of IDA. */ #ifndef QUOKKA_COMPATIBILITY_H #define QUOKKA_COMPATIBILITY_H -#include -#include +#include -#include "Windows.h" +// Workaround for fixing IDA SDK missing header +#if IDA_SDK_VERSION == 810 || IDA_SDK_VERSION == 820 +#include +#endif -/** - * Get the processor "ph" variable - * - * New for IDA SDK 7.5 - * - * @return A pointer to the processor object - */ -processor_t* GetProcessor(); - -/** - * Retrieve the mnemonic name - * - * New in IDA 7.5 - * - * @param instruction IDA instruction structure - * @return A string containing the mnemonic - */ -std::string GetMnemonic(const insn_t& instruction); +#if IDA_SDK_VERSION < 730 +#define BADADDR64 uint64(-1) +#endif #endif // QUOKKA_COMPATIBILITY_H diff --git a/include/quokka/Data.h b/include/quokka/Data.h index b8b46ac..2fe424e 100644 --- a/include/quokka/Data.h +++ b/include/quokka/Data.h @@ -24,6 +24,7 @@ #include #include +#include "Compatibility.h" #include #include #include @@ -36,11 +37,10 @@ #include "Logger.h" // Kept for logger #include "ProtoHelper.h" // Kept for ProtoHelper +#include "ProtoWrapper.h" #include "Util.h" #include "Windows.h" -#include "ProtoWrapper.h" - namespace quokka { /** diff --git a/include/quokka/FileMetadata.h b/include/quokka/FileMetadata.h index 13b6f66..7c26932 100644 --- a/include/quokka/FileMetadata.h +++ b/include/quokka/FileMetadata.h @@ -20,6 +20,7 @@ #ifndef FILEMETADATA_H #define FILEMETADATA_H +#include "Compatibility.h" #include #include #include @@ -31,9 +32,8 @@ #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" -#include "Windows.h" - #include "ProtoWrapper.h" +#include "Windows.h" namespace quokka { diff --git a/include/quokka/Function.h b/include/quokka/Function.h index f6be78f..e83abde 100644 --- a/include/quokka/Function.h +++ b/include/quokka/Function.h @@ -24,8 +24,8 @@ #include #include +#include "Compatibility.h" #include - #include #include #include diff --git a/include/quokka/Imports.h b/include/quokka/Imports.h index 940d9f6..f820ac1 100644 --- a/include/quokka/Imports.h +++ b/include/quokka/Imports.h @@ -15,13 +15,14 @@ #ifndef QUOKKA_IMPORTS_H #define QUOKKA_IMPORTS_H -#include - +#include "Compatibility.h" #include #include #include #include +#include + #include "Windows.h" namespace quokka { diff --git a/include/quokka/Instruction.h b/include/quokka/Instruction.h index 1781369..85b474c 100644 --- a/include/quokka/Instruction.h +++ b/include/quokka/Instruction.h @@ -25,6 +25,7 @@ #include #include +#include "Compatibility.h" #include #include #include diff --git a/include/quokka/Layout.h b/include/quokka/Layout.h index 12223d1..6bed67c 100644 --- a/include/quokka/Layout.h +++ b/include/quokka/Layout.h @@ -28,6 +28,7 @@ #include #include +#include "Compatibility.h" #include #include #include @@ -45,11 +46,10 @@ #include "absl/time/clock.h" #include "Logger.h" +#include "ProtoWrapper.h" #include "Util.h" #include "Windows.h" -#include "ProtoWrapper.h" - namespace quokka { class FuncChunk; diff --git a/include/quokka/Localization.h b/include/quokka/Localization.h index a1455b5..ff1c1de 100644 --- a/include/quokka/Localization.h +++ b/include/quokka/Localization.h @@ -26,6 +26,9 @@ #include #include +#include "Compatibility.h" +#include + #include "Windows.h" namespace quokka { diff --git a/include/quokka/Logger.h b/include/quokka/Logger.h index e796845..9fb08ab 100644 --- a/include/quokka/Logger.h +++ b/include/quokka/Logger.h @@ -23,8 +23,8 @@ #include #include +#include "Compatibility.h" #include - #include #include "absl/strings/str_cat.h" diff --git a/include/quokka/Quokka.h b/include/quokka/Quokka.h index edade65..94f4606 100644 --- a/include/quokka/Quokka.h +++ b/include/quokka/Quokka.h @@ -26,6 +26,7 @@ #include #include +#include "Compatibility.h" #include #include #include @@ -41,9 +42,8 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" -#include "Windows.h" - #include "ProtoWrapper.h" +#include "Windows.h" namespace quokka { diff --git a/include/quokka/Reference.h b/include/quokka/Reference.h index f048768..34a5a2d 100644 --- a/include/quokka/Reference.h +++ b/include/quokka/Reference.h @@ -26,6 +26,7 @@ #include #include +#include "Compatibility.h" #include #include #include diff --git a/include/quokka/Segment.h b/include/quokka/Segment.h index d460763..75d82bc 100644 --- a/include/quokka/Segment.h +++ b/include/quokka/Segment.h @@ -20,6 +20,7 @@ #ifndef QUOKKA_SEGMENT_H #define QUOKKA_SEGMENT_H +#include "Compatibility.h" #include #include #include @@ -27,11 +28,10 @@ #include "absl/strings/str_format.h" #include "Logger.h" +#include "ProtoWrapper.h" #include "Util.h" #include "Windows.h" -#include "ProtoWrapper.h" - namespace quokka { enum AddressSize : short; diff --git a/include/quokka/Settings.h b/include/quokka/Settings.h index 63c0989..2260f31 100644 --- a/include/quokka/Settings.h +++ b/include/quokka/Settings.h @@ -20,6 +20,8 @@ #ifndef QUOKKA_SETTINGS_H #define QUOKKA_SETTINGS_H +#include + #include "Version.h" #include "Windows.h" diff --git a/include/quokka/Util.h b/include/quokka/Util.h index 5220b69..350bef7 100644 --- a/include/quokka/Util.h +++ b/include/quokka/Util.h @@ -21,11 +21,15 @@ #define QUOKKA_UTIL_H #include +#include +#include +#include "Compatibility.h" #include #include +#include #include -#include +#include #include "absl/container/btree_map.h" #include "absl/container/flat_hash_map.h" @@ -296,6 +300,25 @@ std::string ReplaceFileExtension(absl::string_view path, */ bool StrToBoolean(const std::string& option); +/** + * Get the processor "ph" variable + * + * New for IDA SDK 7.5 + * + * @return A pointer to the processor object + */ +processor_t* GetProcessor(); + +/** + * Retrieve the mnemonic name + * + * New in IDA 7.5 + * + * @param instruction IDA instruction structure + * @return A string containing the mnemonic + */ +std::string GetMnemonic(const insn_t& instruction); + } // namespace quokka #endif // QUOKKA_UTIL_H diff --git a/include/quokka/Writer.h b/include/quokka/Writer.h index 1998a39..5caf3b8 100644 --- a/include/quokka/Writer.h +++ b/include/quokka/Writer.h @@ -24,6 +24,7 @@ #include #include +#include "Compatibility.h" #include #include "absl/container/btree_set.h" @@ -32,11 +33,10 @@ #include "Localization.h" #include "Logger.h" +#include "ProtoWrapper.h" #include "Util.h" #include "Windows.h" -#include "ProtoWrapper.h" - namespace quokka { class Operand; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b93906..6aa1094 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,7 +17,6 @@ endif () add_library(quokka_shared STATIC "Block.cpp" "Comment.cpp" - "Compatibility.cpp" "Data.cpp" "FileMetadata.cpp" "Function.cpp" diff --git a/src/Compatibility.cpp b/src/Compatibility.cpp deleted file mode 100644 index 6e6a6e9..0000000 --- a/src/Compatibility.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2022-2023 Quarkslab -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "quokka/Compatibility.h" - -processor_t* GetProcessor() { -#if IDA_SDK_VERSION >= 750 - return get_ph(); -#else - return &ph; -#endif -} - -std::string GetMnemonic(const insn_t& instruction) { -#if IDA_SDK_VERSION >= 750 - processor_t* processor = get_ph(); - return {instruction.get_canon_mnem(*processor)}; -#else - return {instruction.get_canon_mnem()}; -#endif -} \ No newline at end of file diff --git a/src/Instruction.cpp b/src/Instruction.cpp index 59a9589..912932d 100644 --- a/src/Instruction.cpp +++ b/src/Instruction.cpp @@ -14,8 +14,8 @@ #include "quokka/Instruction.h" -#include "quokka/Compatibility.h" #include "quokka/Settings.h" +#include "quokka/Util.h" namespace quokka { diff --git a/src/Quokka.cpp b/src/Quokka.cpp index a221cc6..780f6ce 100644 --- a/src/Quokka.cpp +++ b/src/Quokka.cpp @@ -14,12 +14,12 @@ #include "quokka/Quokka.h" -#include "quokka/Compatibility.h" #include "quokka/Data.h" #include "quokka/FileMetadata.h" #include "quokka/Layout.h" #include "quokka/Segment.h" #include "quokka/Settings.h" +#include "quokka/Util.h" #include "quokka/Version.h" #include "quokka/Writer.h" diff --git a/src/Util.cpp b/src/Util.cpp index bae509f..8f9a74e 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -37,4 +37,21 @@ std::string GetName(ea_t address, bool mangled) { bool StrToBoolean(const std::string& option) { return !option.empty(); } +processor_t* GetProcessor() { +#if IDA_SDK_VERSION >= 750 + return get_ph(); +#else + return &ph; +#endif +} + +std::string GetMnemonic(const insn_t& instruction) { +#if IDA_SDK_VERSION >= 750 + processor_t* processor = get_ph(); + return {instruction.get_canon_mnem(*processor)}; +#else + return {instruction.get_canon_mnem()}; +#endif +} + } // namespace quokka \ No newline at end of file diff --git a/third_party/idasdk74.zip b/third_party/idasdk74.zip new file mode 100644 index 0000000..1586ef5 Binary files /dev/null and b/third_party/idasdk74.zip differ diff --git a/third_party/idasdk81.zip b/third_party/idasdk81.zip new file mode 100644 index 0000000..0c1b9b3 Binary files /dev/null and b/third_party/idasdk81.zip differ diff --git a/third_party/idasdk82.zip b/third_party/idasdk82.zip new file mode 100644 index 0000000..2e13534 Binary files /dev/null and b/third_party/idasdk82.zip differ diff --git a/third_party/idasdk83.zip b/third_party/idasdk83.zip new file mode 100644 index 0000000..f968109 Binary files /dev/null and b/third_party/idasdk83.zip differ