Add editors/imhex, hex editor for reverse engineers and programmers.

This commit is contained in:
MANTANI Nobutaka 2020-12-12 12:57:29 +00:00
parent 82ea353a54
commit 670fd73c4f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=557818
11 changed files with 221 additions and 0 deletions

View File

@ -64,6 +64,7 @@
SUBDIR += hexpert
SUBDIR += hnb
SUBDIR += hte
SUBDIR += imhex
SUBDIR += impress
SUBDIR += jed
SUBDIR += jedit

43
editors/imhex/Makefile Normal file
View File

@ -0,0 +1,43 @@
# $FreeBSD$
PORTNAME= imhex
PORTVERSION= 1.5.0
CATEGORIES= editors
MAINTAINER= nobutaka@FreeBSD.org
COMMENT= Hex editor for reverse engineers and programmers
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
BUILD_DEPENDS= c++10:lang/gcc10 \
glm>0:math/glm \
nlohmann-json>0:devel/nlohmann-json
LIB_DEPENDS= libcapstone.so:devel/capstone4 \
libglfw.so:graphics/glfw \
libstdc++.so:lang/gcc10 \
libtre.so:textproc/libtre
USES= cmake pkgconfig python:3.8+ ssl xorg
USE_XORG= x11 xcb xau xdmcp
USE_GITHUB= yes
GH_ACCOUNT= WerWolv
GH_PROJECT= ImHex
GH_TAGNAME= v1.5.0
CXX= ${LOCALBASE}/bin/c++10
PLIST_FILES= bin/imhex
PORTDOCS= README.md
OPTIONS_DEFINE= DOCS NLS
NLS_USES= gettext
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/.build/imhex ${STAGEDIR}${PREFIX}/bin
post-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
.include <bsd.port.mk>

3
editors/imhex/distinfo Normal file
View File

@ -0,0 +1,3 @@
TIMESTAMP = 1607336763
SHA256 (WerWolv-ImHex-1.5.0-v1.5.0_GH0.tar.gz) = 211cca3a22d9c0d8a7a3bfa2a3aa7c29cd954c207979632fe9b9a08cf9b8444b
SIZE (WerWolv-ImHex-1.5.0-v1.5.0_GH0.tar.gz) = 848041

View File

@ -0,0 +1,55 @@
--- CMakeLists.txt.orig 2020-12-06 20:40:57 UTC
+++ CMakeLists.txt
@@ -10,23 +10,21 @@ set(CMAKE_CXX_STANDARD 20)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
pkg_search_module(GLM REQUIRED glm)
-pkg_search_module(CRYPTO REQUIRED libcrypto)
pkg_search_module(CAPSTONE REQUIRED capstone)
find_package(OpenGL REQUIRED)
-find_package(LLVM REQUIRED CONFIG)
find_package(nlohmann_json REQUIRED)
find_package(Python COMPONENTS Interpreter Development)
+include(CheckCXXSymbolExists)
+check_cxx_symbol_exists(abi::__cxa_demangle "cxxabi.h" HAVE_CXXABI)
+
if(Python_VERSION LESS 3)
message(STATUS ${PYTHON_VERSION_MAJOR_MINOR})
message(FATAL_ERROR "No valid version of Python 3 was found.")
endif()
-llvm_map_components_to_libnames(_llvm_libs demangle)
-llvm_expand_dependencies(llvm_libs ${_llvm_libs})
+include_directories(include ${GLFW_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} libs/ImGui/include libs/glad/include ${Python_INCLUDE_DIRS})
-include_directories(include ${GLFW_INCLUDE_DIRS} ${CAPSTONE_INCLUDE_DIRS} ${LLVM_INCLUDE_DIRS} libs/ImGui/include libs/glad/include ${Python_INCLUDE_DIRS})
-
# Get Python major and minor
string(REPLACE "." ";" PYTHON_VERSION_MAJOR_MINOR ${Python_VERSION})
list(REMOVE_AT PYTHON_VERSION_MAJOR_MINOR 2)
@@ -42,7 +40,7 @@ endif (WIN32)
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DRELEASE")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
-add_executable(ImHex
+add_executable(imhex
source/main.cpp
source/window.cpp
@@ -88,12 +86,10 @@ add_executable(ImHex
resource.rc
)
-target_link_directories(ImHex PRIVATE ${LLVM_LIBRARY_DIR})
-
if (WIN32)
target_link_libraries(ImHex libglfw3.a libgcc.a libstdc++.a libmagic.a libgnurx.a libtre.a libintl.a libiconv.a shlwapi.lib libcrypto.a libwinpthread.a libcapstone.a ${llvm_libs} ${Python_LIBRARIES} nlohmann_json::nlohmann_json)
endif (WIN32)
if (UNIX)
- target_link_libraries(ImHex libglfw.so libmagic.so libcrypto.so libdl.so libcapstone.so ${llvm_libs} ${Python_LIBRARIES} nlohmann_json::nlohmann_json)
-endif (UNIX)
\ No newline at end of file
+ target_link_libraries(imhex libglfw.so libmagic.so libcrypto.so libdl.so libcapstone.so ${Python_LIBRARIES} nlohmann_json::nlohmann_json)
+endif (UNIX)

View File

@ -0,0 +1,10 @@
--- include/helpers/utils.hpp.orig 2020-12-06 20:40:57 UTC
+++ include/helpers/utils.hpp
@@ -61,6 +61,7 @@ namespace hex {
std::string toByteString(u64 bytes);
std::string makePrintable(char c);
+ std::string demangle(const std::string &mangled_name);
template<typename T>
struct always_false : std::false_type {};

View File

@ -0,0 +1,29 @@
--- source/helpers/utils.cpp.orig 2020-12-06 20:40:57 UTC
+++ source/helpers/utils.cpp
@@ -3,6 +3,8 @@
#include <cstdio>
#include <codecvt>
#include <locale>
+#include <iostream>
+#include <cxxabi.h>
namespace hex {
@@ -90,4 +92,16 @@ namespace hex {
return result;
}
+ std::string demangle(const std::string &mangled_name) {
+ int status = 0;
+ int skip_underscore = mangled_name.find("__") == 0;
+ char *realname = abi::__cxa_demangle(mangled_name.c_str() + skip_underscore,
+ 0, 0, &status);
+ std::string result{mangled_name};
+ if (status == 0 && realname) {
+ result = realname;
+ std::free(realname);
+ }
+ return result;
+ }
}
\ No newline at end of file

View File

@ -0,0 +1,11 @@
--- source/providers/file_provider.cpp.orig 2020-12-06 20:40:57 UTC
+++ source/providers/file_provider.cpp
@@ -10,7 +10,7 @@
#include "helpers/project_file_handler.hpp"
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
#define off64_t off_t
#define fopen64 fopen
#define fseeko64 fseek

View File

@ -0,0 +1,13 @@
--- source/views/view_hexeditor.cpp.orig 2020-12-06 20:40:57 UTC
+++ source/views/view_hexeditor.cpp
@@ -13,6 +13,10 @@
#undef __STRICT_ANSI__
#include <cstdio>
+#if defined(__APPLE__) || defined(__FreeBSD__)
+ #define ftello64 ftell
+#endif
+
namespace hex {
ViewHexEditor::ViewHexEditor(prv::Provider* &dataProvider, std::vector<lang::PatternData*> &patternData)

View File

@ -0,0 +1,20 @@
--- source/views/view_strings.cpp.orig 2020-12-06 20:40:57 UTC
+++ source/views/view_strings.cpp
@@ -5,8 +5,6 @@
#include <cstring>
-#include <llvm/Demangle/Demangle.h>
-
using namespace std::literals::string_literals;
namespace hex {
@@ -37,7 +35,7 @@ namespace hex {
}
ImGui::Separator();
if (ImGui::MenuItem("Demangle")) {
- this->m_demangledName = llvm::demangle(this->m_selectedString);
+ this->m_demangledName = demangle(this->m_selectedString);
if (!this->m_demangledName.empty())
View::doLater([]{ ImGui::OpenPopup("Demangled Name"); });
}

View File

@ -0,0 +1,20 @@
--- source/views/view_tools.cpp.orig 2020-12-06 20:40:57 UTC
+++ source/views/view_tools.cpp
@@ -7,8 +7,6 @@
#include "providers/provider.hpp"
#include "helpers/utils.hpp"
-#include <llvm/Demangle/Demangle.h>
-
namespace hex {
ViewTools::ViewTools(hex::prv::Provider* &provider) : View("Tools"), m_dataProvider(provider) {
@@ -76,7 +74,7 @@ namespace hex {
void ViewTools::drawDemangler() {
if (ImGui::CollapsingHeader("Itanium/MSVC demangler")) {
if (ImGui::InputText("Mangled name", this->m_mangledBuffer, 0xF'FFFF)) {
- this->m_demangledName = llvm::demangle(this->m_mangledBuffer);
+ this->m_demangledName = demangle(this->m_mangledBuffer);
}
ImGui::InputText("Demangled name", this->m_demangledName.data(), this->m_demangledName.size(), ImGuiInputTextFlags_ReadOnly);

16
editors/imhex/pkg-descr Normal file
View File

@ -0,0 +1,16 @@
ImHex is a hex editor for reverse engineers, programmers and people that value
their eye sight when working at 3 AM.
ImHex has many features including the following:
- Byte patching
- String and hex search
- Colorful highlighting
- Custom C++-like pattern language for parsing highlighting a file's content
- Data inspector allowing interpretation of data as many different types
(little and big endian)
- File hashing support
- Disassembler supporting many different architectures
- Bookmarks
- Data Analyzer
WWW: https://github.com/WerWolv/ImHex