mirror of
https://github.com/bitdefender/bddisasm.git
synced 2024-11-26 09:28:07 +00:00
commit
8528de2d98
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -28,7 +28,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Build bddisasm and bdshemu
|
- name: Build bddisasm and bdshemu
|
||||||
run: make -j$(nproc)
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
cd -
|
||||||
- name: Install rapidjson
|
- name: Install rapidjson
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
with:
|
with:
|
||||||
@ -88,5 +93,5 @@ jobs:
|
|||||||
- name: Run cppcheck
|
- name: Run cppcheck
|
||||||
run: cppcheck --error-exitcode=1 --language=c \
|
run: cppcheck --error-exitcode=1 --language=c \
|
||||||
--enable=all --suppress=missingIncludeSystem --suppress=unusedStructMember --suppress=unusedFunction \
|
--enable=all --suppress=missingIncludeSystem --suppress=unusedStructMember --suppress=unusedFunction \
|
||||||
-I inc/ -I inc/bdshemu -I bddisasm/include bddisasm/ bdshemu/ \
|
-I inc/ -I bddisasm/include bddisasm/ bdshemu/ \
|
||||||
/
|
/
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -63,3 +63,7 @@ bdshemu_fuzz/shfuzz
|
|||||||
bdshemu_fuzz/out-32
|
bdshemu_fuzz/out-32
|
||||||
bdshemu_fuzz/out-64
|
bdshemu_fuzz/out-64
|
||||||
docs/build
|
docs/build
|
||||||
|
libbddisasm.pc
|
||||||
|
build
|
||||||
|
.vscode
|
||||||
|
disasmtool_lix/_build
|
||||||
|
135
CMakeLists.txt
Normal file
135
CMakeLists.txt
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/project-meta-info.in")
|
||||||
|
|
||||||
|
set(disasm_version_file ${CMAKE_CURRENT_LIST_DIR}/inc/version.h)
|
||||||
|
|
||||||
|
file(STRINGS ${disasm_version_file} disasm_ver_major REGEX "DISASM_VERSION_MAJOR")
|
||||||
|
file(STRINGS ${disasm_version_file} disasm_ver_minor REGEX "DISASM_VERSION_MINOR")
|
||||||
|
file(STRINGS ${disasm_version_file} disasm_ver_patch REGEX "DISASM_VERSION_REVISION")
|
||||||
|
|
||||||
|
string(REGEX REPLACE "#define DISASM_VERSION_MAJOR[ \t\r\n]*" "" disasm_ver_major ${disasm_ver_major})
|
||||||
|
string(REGEX REPLACE "#define DISASM_VERSION_MINOR[ \t\r\n]*" "" disasm_ver_minor ${disasm_ver_minor})
|
||||||
|
string(REGEX REPLACE "#define DISASM_VERSION_REVISION[ \t\r\n]*" "" disasm_ver_patch ${disasm_ver_patch})
|
||||||
|
|
||||||
|
message(STATUS "Extracted version from ${disasm_version_file}: ${disasm_ver_major}.${disasm_ver_minor}.${disasm_ver_patch}")
|
||||||
|
|
||||||
|
project(bddisasm
|
||||||
|
VERSION ${disasm_ver_major}.${disasm_ver_minor}.${disasm_ver_patch}
|
||||||
|
DESCRIPTION ${project_description}
|
||||||
|
LANGUAGES C
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
|
message(STATUS "No build type given. Will use 'Release'")
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/x64/${CMAKE_BUILD_TYPE})
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/x64/${CMAKE_BUILD_TYPE})
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/x64/${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
|
message(STATUS "Output directory set to: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
|
||||||
|
|
||||||
|
set(bddisasm_src
|
||||||
|
bddisasm/crt.c
|
||||||
|
bddisasm/bddisasm.c
|
||||||
|
)
|
||||||
|
add_library(bddisasm STATIC ${bddisasm_src})
|
||||||
|
set_target_properties(bddisasm PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
C_STANDARD 11
|
||||||
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(bdshemu_src
|
||||||
|
bdshemu/bdshemu.c
|
||||||
|
)
|
||||||
|
add_library(bdshemu STATIC ${bdshemu_src})
|
||||||
|
set_target_properties(bdshemu PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
C_STANDARD 11
|
||||||
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||||
|
)
|
||||||
|
add_dependencies(bdshemu bddisasm)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
inc
|
||||||
|
inc/bdshemu
|
||||||
|
bddisasm/include
|
||||||
|
)
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE EQUAL "Release")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -DNDEBUG")
|
||||||
|
else ()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -D_DEBUG -DDEBUG")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
"$<$<CONFIG:Release>:-U_FORTIFY_SOURCE>"
|
||||||
|
"$<$<CONFIG:Release>:-D_FORTIFY_SOURCE=2>"
|
||||||
|
-Wall
|
||||||
|
-Wno-unknown-pragmas
|
||||||
|
-Wextra
|
||||||
|
-Wshadow
|
||||||
|
-Wformat-security
|
||||||
|
-Wstrict-overflow=2
|
||||||
|
-Wstrict-prototypes
|
||||||
|
-Wwrite-strings
|
||||||
|
-Wshadow
|
||||||
|
-Winit-self
|
||||||
|
-Wswitch-default
|
||||||
|
-Wmissing-variable-declarations
|
||||||
|
-Wused-but-marked-unused
|
||||||
|
-Wswitch-enum
|
||||||
|
-Wno-unused-function
|
||||||
|
-Wno-multichar
|
||||||
|
-Wno-incompatible-pointer-types
|
||||||
|
-Wcast-qual
|
||||||
|
-Wnull-dereference
|
||||||
|
-Wduplicated-cond
|
||||||
|
-Werror=format-security
|
||||||
|
-Werror=implicit-function-declaration
|
||||||
|
-pipe
|
||||||
|
-fwrapv
|
||||||
|
-fno-strict-aliasing
|
||||||
|
-fstack-protector-strong
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
-ffunction-sections
|
||||||
|
-fdata-sections
|
||||||
|
-g3
|
||||||
|
-gdwarf-4
|
||||||
|
-grecord-gcc-switches
|
||||||
|
-march=nehalem
|
||||||
|
)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||||
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
|
get_filename_component(public_header_path "${PROJECT_SOURCE_DIR}/inc" REALPATH)
|
||||||
|
file(GLOB_RECURSE public_headers "${public_header_path}/*.h")
|
||||||
|
set_target_properties(bddisasm PROPERTIES PUBLIC_HEADER "${public_headers}")
|
||||||
|
|
||||||
|
set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(INC_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
set(PRIVATE_LIBS "-lbdshemu -lbddisasm")
|
||||||
|
set(DATA_DIR "${CMAKE_INSTALL_DATADIR}")
|
||||||
|
|
||||||
|
CONFIGURE_FILE("${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc.in"
|
||||||
|
"${PROJECT_SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(TARGETS bddisasm bdshemu
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/bddisasm"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES "${PROJECT_SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||||
|
)
|
29
README.md
29
README.md
@ -27,7 +27,7 @@ The main objectives of this disassembler are:
|
|||||||
4. Easy to work with - just include the main header file, bddisasm.h, link with the bddisasm library, and call the NdDecode API!
|
4. Easy to work with - just include the main header file, bddisasm.h, link with the bddisasm library, and call the NdDecode API!
|
||||||
5. Complete - support every x86 instruction to date, and provide as much information as possible.
|
5. Complete - support every x86 instruction to date, and provide as much information as possible.
|
||||||
|
|
||||||
## Build
|
## Build and install
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
@ -54,6 +54,31 @@ In order to build the projects on Linux you need:
|
|||||||
|
|
||||||
* gcc
|
* gcc
|
||||||
* make
|
* make
|
||||||
|
* cmake 3.12 or newer (optional)
|
||||||
|
|
||||||
|
#### Building and installing with make
|
||||||
|
|
||||||
|
In order to build bddisasm and bdshemu run `make` in the root of the repository. The results will be placed in the bin directory.
|
||||||
|
|
||||||
|
In order to install bddisasm and bdshemu run `make install`.
|
||||||
|
|
||||||
|
#### Building and installing with cmake
|
||||||
|
|
||||||
|
```console
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
|
||||||
|
cmake ..
|
||||||
|
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
```
|
||||||
|
|
||||||
|
The default build type is Release.
|
||||||
|
|
||||||
|
Note that the current install behavior differs based on how the installation is done. When using make, the `bdshemu.h` header is placed by default in `include/bddisasm/bdshemu` in your install location, while the cmake method will place it in `include/bddisasm`. Using cmake also provides support for pkg-config.
|
||||||
|
|
||||||
|
### Building disasmtool_lix
|
||||||
|
|
||||||
For disasmtool_lix you also need:
|
For disasmtool_lix you also need:
|
||||||
|
|
||||||
@ -61,8 +86,6 @@ For disasmtool_lix you also need:
|
|||||||
* cmake 3.12 or newer
|
* cmake 3.12 or newer
|
||||||
* [RapidJSON](https://github.com/Tencent/rapidjson/)
|
* [RapidJSON](https://github.com/Tencent/rapidjson/)
|
||||||
|
|
||||||
In order to build bddisasm and bdshemu run `make` in the root of the repository. The results will be placed in the bin directory.
|
|
||||||
|
|
||||||
In order to build disasmtool_lix go to the disasmtool_lix directory and run `make`. The results will be in the bin directory in the disasmtool_lix/build directory.
|
In order to build disasmtool_lix go to the disasmtool_lix directory and run `make`. The results will be in the bin directory in the disasmtool_lix/build directory.
|
||||||
|
|
||||||
## Decoding instructions
|
## Decoding instructions
|
||||||
|
@ -4,7 +4,7 @@ SRC_FILES := bdshemu.c
|
|||||||
|
|
||||||
OBJECTS := $(SRC_FILES:.c=.o)
|
OBJECTS := $(SRC_FILES:.c=.o)
|
||||||
|
|
||||||
INCLUDES := -I. -I../inc -I../bddisasm/include -I../inc/bdshemu
|
INCLUDES := -I. -I../inc -I../bddisasm/include
|
||||||
|
|
||||||
ifeq ($(PLATFORM),)
|
ifeq ($(PLATFORM),)
|
||||||
PLATFORM := x64
|
PLATFORM := x64
|
||||||
@ -119,5 +119,5 @@ clean: clean_lib_file clean_int_dir clean_dep_dir
|
|||||||
install: all
|
install: all
|
||||||
install -d $(DESTDIR)$(PREFIX)/lib/
|
install -d $(DESTDIR)$(PREFIX)/lib/
|
||||||
install -m 644 $(OUT_DIR)/$(LIB_NAME) $(DESTDIR)$(PREFIX)/lib/
|
install -m 644 $(OUT_DIR)/$(LIB_NAME) $(DESTDIR)$(PREFIX)/lib/
|
||||||
install -d $(DESTDIR)$(PREFIX)/include/bddisasm/bdshemu/
|
install -d $(DESTDIR)$(PREFIX)/include/bddisasm/
|
||||||
cp -r ../inc/bdshemu/* $(DESTDIR)$(PREFIX)/include/bddisasm/bdshemu/
|
cp -r ../inc/bdshemu.h $(DESTDIR)$(PREFIX)/include/bddisasm/
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "nd_crt.h"
|
#include "nd_crt.h"
|
||||||
#include "bddisasm.h"
|
#include "bddisasm.h"
|
||||||
#include "bdshemu/bdshemu.h"
|
#include "bdshemu.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -405,7 +405,7 @@
|
|||||||
<ClCompile Include="bdshemu.c" />
|
<ClCompile Include="bdshemu.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\inc\bdshemu\bdshemu.h" />
|
<ClInclude Include="..\inc\bdshemu.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\inc\bdshemu\bdshemu.h">
|
<ClInclude Include="..\inc\bdshemu.h">
|
||||||
<Filter>Header Files\public</Filter>
|
<Filter>Header Files\public</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
typedef uint64_t QWORD, *PQWORD;
|
typedef uint64_t QWORD, *PQWORD;
|
||||||
|
|
||||||
// Main disasm header file.
|
// Main disasm header file.
|
||||||
#include "bdshemu\bdshemu.h"
|
#include "bdshemu.h"
|
||||||
#include "bddisasm.h"
|
#include "bddisasm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,7 +253,6 @@ endif()
|
|||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${DISASM_DIRECTORY}/inc
|
${DISASM_DIRECTORY}/inc
|
||||||
${DISASM_DIRECTORY}/inc/bdshemu
|
|
||||||
${DISASM_DIRECTORY}/bddisasm/include
|
${DISASM_DIRECTORY}/bddisasm/include
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define BDSHEMU_H
|
#define BDSHEMU_H
|
||||||
|
|
||||||
|
|
||||||
#include "../bddisasm.h"
|
#include "bddisasm.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
19
libbddisasm.pc.in
Normal file
19
libbddisasm.pc.in
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
dir_prefix=@DEST_DIR@
|
||||||
|
lib=@LIB_DIR@
|
||||||
|
include=@INC_DIR@
|
||||||
|
data_dir=@DATA_DIR@
|
||||||
|
|
||||||
|
prefix=${dir_prefix}
|
||||||
|
lib_dir=${dir_prefix}/${lib}
|
||||||
|
include_dir=${dir_prefix}/${include}
|
||||||
|
|
||||||
|
datarootdir=${dir_prefix}/${data_dir}
|
||||||
|
pkgdatadir=${datarootdir}/bddisasm
|
||||||
|
|
||||||
|
Name: bddisasm
|
||||||
|
Description: "Bitdefender x86 instruction decoder and shellcode emulator"
|
||||||
|
URL: https://github.com/bitdefender/bddisasm
|
||||||
|
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
|
||||||
|
|
||||||
|
Libs: -L${lib_dir} @PRIVATE_LIBS@
|
||||||
|
Cflags: -I${include_dir}
|
3
project-meta-info.in
Normal file
3
project-meta-info.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# project-meta-info.in
|
||||||
|
|
||||||
|
set(project_description "Bitdefender x86 instruction decoder and emulator")
|
Loading…
Reference in New Issue
Block a user