Skip to content

Commit

Permalink
Inital commit.
Browse files Browse the repository at this point in the history
Initial implementation can dissassmeble a target function in a specific
section with some support for relocatable symbols in place of absolute
or relative addresses.
  • Loading branch information
OmniBlade committed Jul 11, 2023
0 parents commit 5e13356
Show file tree
Hide file tree
Showing 22 changed files with 2,522 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ColumnLimit: 125
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: []
IncludeCategories:
- Regex: 'always.h'
Priority: -1
- Regex: '^<'
Priority: 2
- Regex: '^"'
Priority: 1
FixNamespaceComments: true
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never

...
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
*.user
*.ncb
/build*
nbproject/
project/
doxygen/
*.a
*.o
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
*.so*
CPackConfig.cmake
CPackSourceConfig.cmake
*.spec
*.ncb
*.sdf
*.suo
*.sln
*.vcxproj*
*.vcproj
.cproject
.project
*~
!*.exe
*.lastbuildstate
*.unsuccessfulbuild
*.tlog
*.idb
*.cd
*.tmp
*.bak
thumbs.db
/CMakeUserPresets.json
75 changes: 75 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
cmake_minimum_required(VERSION 3.24)

# Use packagename_ROOT for FindPackage.
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

# Disable default MSVC warning level so we can set it ourselves.
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()

# Disable default MSVC runtime hardcoding.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")

project(unassemblize LANGUAGES C CXX)

# Set up a format target to do automated clang format checking.
find_package(ClangFormat)
include(ClangFormat)

if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows")
set(WINDOWS TRUE)
endif()

include(FetchContent)

FetchContent_Declare(
zydis
GIT_REPOSITORY https://github.com/zyantific/zydis.git
GIT_TAG 1ba75aeefae37094c7be8eba07ff81d4fe0f1f20
)
set(ZYDIS_BUILD_EXAMPLES OFF)
set(ZYDIS_FEATURE_ENCODER OFF)
FetchContent_MakeAvailable(zydis)

FetchContent_Declare(
lief
GIT_REPOSITORY https://github.com/lief-project/LIEF.git
GIT_TAG 2d9855fc7f9d4ce6325245f8b75c98eb7663db60
)
set(LEIF_EXAMPLES OFF)
set(LEIF_INSTALL OFF)
set(LIEF_C_API OFF)
set(LIEF_PYTHON_API OFF)
set(LIEF_TESTS OFF)
FetchContent_MakeAvailable(lief)

set(GIT_PRE_CONFIGURE_FILE "gitinfo.cpp.in")
set(GIT_POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gitinfo.cpp")
include(GitWatcher)

add_executable(unassemblize)

target_sources(unassemblize PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/gitinfo.cpp
gitinfo.h
executable.cpp
executable.h
function.cpp
function.h
main.cpp
symbols.cpp
symbols.h)
target_link_libraries(unassemblize PRIVATE Zydis LIEF::LIEF)
target_include_directories(unassemblize PRIVATE .)

if(WINDOWS)
target_sources(unassemblize PRIVATE wincompat/getopt.c wincompat/getopt.h wincompat/strings.h)
target_include_directories(unassemblize PRIVATE wincompat)
endif()
Loading

0 comments on commit 5e13356

Please sign in to comment.