Skip to content

Commit

Permalink
Merge pull request #16 from quarkslab/fix_imports
Browse files Browse the repository at this point in the history
Fix compatibility with IDA 8.{1,2} and cleanup
  • Loading branch information
RobinDavid committed Jul 18, 2023
2 parents c2e1a13 + 3e26ce7 commit cdc0a78
Show file tree
Hide file tree
Showing 30 changed files with 121 additions and 83 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
30 changes: 27 additions & 3 deletions cmake/FindIdaSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down Expand Up @@ -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 ()
Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion include/quokka/Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include <cassert>
#include <vector>

#include "Compatibility.h"
#include <pro.h>

#include <gdl.hpp>
#include <ida.hpp>

Expand Down
4 changes: 3 additions & 1 deletion include/quokka/Comment.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@
#include <utility>
#include <vector>

#include "Compatibility.h"
#include <bytes.hpp>
#include <enum.hpp>
#include <funcs.hpp>
#include <ida.hpp>
#include <struct.hpp>

#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 {

Expand Down
31 changes: 9 additions & 22 deletions include/quokka/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <idp.hpp>
#include <ua.hpp>
#include <pro.h>

#include "Windows.h"
// Workaround for fixing IDA SDK missing header
#if IDA_SDK_VERSION == 810 || IDA_SDK_VERSION == 820
#include <cstdint>
#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
4 changes: 2 additions & 2 deletions include/quokka/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <cassert>
#include <cstdint>

#include "Compatibility.h"
#include <bytes.hpp>
#include <enum.hpp>
#include <kernwin.hpp>
Expand All @@ -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 {

/**
Expand Down
4 changes: 2 additions & 2 deletions include/quokka/FileMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef FILEMETADATA_H
#define FILEMETADATA_H

#include "Compatibility.h"
#include <pro.h>
#include <ida.hpp>
#include <kernwin.hpp>
Expand All @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion include/quokka/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <utility>
#include <vector>

#include "Compatibility.h"
#include <pro.h>

#include <funcs.hpp>
#include <gdl.hpp>
#include <graph.hpp>
Expand Down
5 changes: 3 additions & 2 deletions include/quokka/Imports.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
#ifndef QUOKKA_IMPORTS_H
#define QUOKKA_IMPORTS_H

#include <absl/container/flat_hash_map.h>

#include "Compatibility.h"
#include <pro.h>
#include <nalt.hpp>
#include <utility>
#include <vector>

#include <absl/container/flat_hash_map.h>

#include "Windows.h"

namespace quokka {
Expand Down
1 change: 1 addition & 0 deletions include/quokka/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <utility>
#include <vector>

#include "Compatibility.h"
#include <ida.hpp>
#include <idp.hpp>
#include <lines.hpp>
Expand Down
4 changes: 2 additions & 2 deletions include/quokka/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <cstdint>
#include <unordered_set>

#include "Compatibility.h"
#include <pro.h>
#include <bytes.hpp>
#include <funcs.hpp>
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions include/quokka/Localization.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <memory>
#include <variant>

#include "Compatibility.h"
#include <pro.h>

#include "Windows.h"

namespace quokka {
Expand Down
2 changes: 1 addition & 1 deletion include/quokka/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include <ctime>
#include <utility>

#include "Compatibility.h"
#include <pro.h>

#include <kernwin.hpp>

#include "absl/strings/str_cat.h"
Expand Down
4 changes: 2 additions & 2 deletions include/quokka/Quokka.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <fstream>
#include <string>

#include "Compatibility.h"
#include <auto.hpp>
#include <entry.hpp>
#include <expr.hpp>
Expand All @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions include/quokka/Reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <variant>
#include <vector>

#include "Compatibility.h"
#include <pro.h>
#include <bytes.hpp>
#include <funcs.hpp>
Expand Down
4 changes: 2 additions & 2 deletions include/quokka/Segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
#ifndef QUOKKA_SEGMENT_H
#define QUOKKA_SEGMENT_H

#include "Compatibility.h"
#include <loader.hpp>
#include <name.hpp>
#include <segment.hpp>

#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;
Expand Down
2 changes: 2 additions & 0 deletions include/quokka/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef QUOKKA_SETTINGS_H
#define QUOKKA_SETTINGS_H

#include <cassert>

#include "Version.h"
#include "Windows.h"

Expand Down
25 changes: 24 additions & 1 deletion include/quokka/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
#define QUOKKA_UTIL_H

#include <cstdint>
#include <string>
#include <unordered_map>

#include "Compatibility.h"
#include <pro.h>
#include <bytes.hpp>
#include <idp.hpp>
#include <name.hpp>
#include <unordered_map>
#include <ua.hpp>

#include "absl/container/btree_map.h"
#include "absl/container/flat_hash_map.h"
Expand Down Expand Up @@ -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
Loading

0 comments on commit cdc0a78

Please sign in to comment.