Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b92db4c97 | ||
|
|
5b6eefbe9c | ||
|
|
65d6b150d6 | ||
|
|
9e9d26f70b | ||
|
|
3185d59870 | ||
|
|
73e23deb60 | ||
|
|
752ab8a3ce | ||
|
|
f70b2371b9 | ||
|
|
c6381bbcc1 | ||
|
|
f999ea6456 | ||
|
|
ac939a645f | ||
|
|
cc165d2aba | ||
|
|
5b8ef83022 | ||
|
|
6a90b3457f | ||
|
|
d34d20c198 | ||
|
|
22a6ffa0bd | ||
|
|
1781ba0f61 | ||
|
|
6e328569fb | ||
|
|
00d9cc7c25 | ||
|
|
bff5411884 | ||
|
|
c225890973 | ||
|
|
96193a0488 | ||
|
|
5936e85d02 | ||
|
|
e41c3280ec | ||
|
|
e4a7f679a8 | ||
|
|
97bf8b65ff |
+1
-1
@@ -1 +1 @@
|
||||
github: [romainthomas]
|
||||
github: [lief-project, romainthomas]
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
name: code-check
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: 'LIEF branch'
|
||||
default: master
|
||||
required: false
|
||||
type: string
|
||||
what:
|
||||
description: 'clang-tidy action'
|
||||
default: latest
|
||||
required: false
|
||||
type: string
|
||||
job:
|
||||
description: 'Job (e.g. coverage)'
|
||||
default: "all"
|
||||
required: false
|
||||
type: string
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: liefproject/code-check
|
||||
env:
|
||||
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
|
||||
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: lief-project/code-check
|
||||
token: ${{ secrets.LIEF_CLONE_TOKEN }}
|
||||
- name: Running LIEF coverage [workflow dispatch]
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.job == 'all' || github.event.inputs.job == 'coverage') }}
|
||||
run: ./lief-coverage --debug
|
||||
- name: Running LIEF coverage [regular]
|
||||
if: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
run: ./lief-coverage --debug
|
||||
clang-tidy:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: liefproject/code-check
|
||||
env:
|
||||
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
|
||||
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: lief-project/code-check
|
||||
token: ${{ secrets.LIEF_CLONE_TOKEN }}
|
||||
- name: Running LIEF coverage [workflow dispatch]
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.job == 'all' || github.event.inputs.job == 'clang-tidy') }}
|
||||
run: ./lief-tidy --branch ${{ github.event.inputs.branch }} ${{ github.event.inputs.what }}
|
||||
- name: Running LIEF coverage [regular]
|
||||
if: "github.event.name != 'workflow_dispatch'"
|
||||
run: ./lief-tidy latest
|
||||
memory-profiler:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: liefproject/code-check
|
||||
env:
|
||||
LIEF_S3_KEY: ${{ secrets.LIEF_S3_KEY }}
|
||||
LIEF_S3_SECRET: ${{ secrets.LIEF_S3_SECRET }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: lief-project/code-check
|
||||
token: ${{ secrets.LIEF_CLONE_TOKEN }}
|
||||
- name: Running LIEF memory profiler [workflow dispatch]
|
||||
if: ${{ github.event_name == 'workflow_dispatch' && (github.event.inputs.job == 'all' || github.event.inputs.job == 'memprof') }}
|
||||
run: ./lief-memory-profile --branch ${{ github.event.inputs.branch }}
|
||||
- name: Running LIEF memory profiler [regular]
|
||||
if: "github.event.name != 'workflow_dispatch'"
|
||||
run: ./lief-memory-profile
|
||||
+35
-210
@@ -33,9 +33,8 @@ endif()
|
||||
|
||||
# LIEF Project
|
||||
# ============
|
||||
project(
|
||||
LIEF
|
||||
VERSION ${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
|
||||
project(LIEF VERSION
|
||||
${LIEF_VERSION_MAJOR}.${LIEF_VERSION_MINOR}.${LIEF_VERSION_PATCH})
|
||||
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION}")
|
||||
|
||||
# Select the MSVC runtime based on the LIEF_USE_CRT_XXX variable
|
||||
@@ -111,6 +110,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS "CMAKE_CXX_LINK_EXECUTABLE: ${CMAKE_CXX_LINK_EXECUTABLE}")
|
||||
message(STATUS "CMAKE_CXX_LINK_FLAGS: ${CMAKE_CXX_LINK_FLAGS}")
|
||||
@@ -126,83 +127,8 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
# LIEF Source definition
|
||||
# ======================
|
||||
|
||||
set(LIEF_PRIVATE_INCLUDE_DIR)
|
||||
set(LIEF_PUBLIC_INCLUDE_DIR)
|
||||
|
||||
set(LIEF_PUBLIC_INCLUDE_FILES)
|
||||
set(LIEF_PRIVATE_INCLUDE_FILES)
|
||||
|
||||
set(LIBLIEF_SOURCE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/errors.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/iostream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/Object.tcc"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/Visitor.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/BinaryStream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/VectorStream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/FileStream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/MemoryStream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/SpanStream.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/BinaryStream/Convert.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/hash.cpp")
|
||||
|
||||
# Grouping basic headers together
|
||||
# ===============================
|
||||
set(LIEF_INC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/errors.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/span.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iostream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/iterators.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/LIEF.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/logging.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/MachO.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/PE.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/types.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visibility.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Object.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Visitor.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/visitor_macros.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/BinaryStream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/VectorStream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/FileStream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/MemoryStream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/SpanStream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/BinaryStream/Convert.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/internal_utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_stream.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/frozen.hpp"
|
||||
)
|
||||
|
||||
set(LIEF_VISITOR_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/hash.hpp")
|
||||
|
||||
set(LIEF_INCLUDE_FILES ${LIEF_INC_FILES} ${LIEF_VISITOR_INCLUDE_FILES})
|
||||
|
||||
set(LIEF_JSON_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/visitors/json.cpp")
|
||||
set(LIEF_JSON_HDR "${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/json.hpp")
|
||||
|
||||
list(APPEND LIEF_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/json.hpp")
|
||||
list(APPEND LIBLIEF_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/json_api.cpp")
|
||||
|
||||
if(LIEF_ENABLE_JSON)
|
||||
list(APPEND LIBLIEF_SOURCE_FILES "${LIEF_JSON_SRC}")
|
||||
list(APPEND LIEF_INC_FILES "${LIEF_JSON_HDR}")
|
||||
endif()
|
||||
|
||||
source_group("Header Files" FILES ${LIEF_INC_FILES})
|
||||
source_group("Source Files" FILES ${LIBLIEF_SOURCE_FILES})
|
||||
|
||||
source_group("Header Files\\visitors" FILES ${LIEF_VISITOR_INCLUDE_FILES})
|
||||
|
||||
add_library(LIB_LIEF ${LIBLIEF_SOURCE_FILES} ${LIEF_INCLUDE_FILES})
|
||||
add_library(LIB_LIEF src/Object.cpp)
|
||||
add_subdirectory(src)
|
||||
|
||||
if(NOT LIEF_PY_LIEF_EXT)
|
||||
add_library(LIEF::LIEF ALIAS LIB_LIEF)
|
||||
@@ -212,27 +138,20 @@ if(NOT LIEF_OPT_MBEDTLS_EXTERNAL)
|
||||
set_source_files_properties(${mbedtls_src_crypto} PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(${mbedtls_src_x509} PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(${mbedtls_src_tls} PROPERTIES GENERATED TRUE)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
"${mbedtls_src_crypto}"
|
||||
"${mbedtls_src_x509}"
|
||||
"${mbedtls_src_tls}")
|
||||
target_sources(LIB_LIEF PRIVATE ${mbedtls_src_crypto}
|
||||
${mbedtls_src_x509}
|
||||
${mbedtls_src_tls})
|
||||
|
||||
source_group("mbedtls\\crypto" FILES ${mbedtls_src_crypto})
|
||||
source_group("mbedtls\\x509" FILES ${mbedtls_src_x509})
|
||||
source_group("mbedtls\\tls" FILES ${mbedtls_src_tls})
|
||||
|
||||
target_include_directories(
|
||||
LIB_LIEF SYSTEM PRIVATE
|
||||
"${MBEDTLS_INCLUDE_DIRS}"
|
||||
"${MBEDTLS_SOURCE_DIR}/library"
|
||||
target_include_directories(LIB_LIEF SYSTEM PRIVATE
|
||||
${MBEDTLS_INCLUDE_DIRS}
|
||||
"${MBEDTLS_SOURCE_DIR}/library"
|
||||
)
|
||||
|
||||
add_dependencies(LIB_LIEF lief_mbed_tls)
|
||||
else()
|
||||
find_package(MbedTLS REQUIRED)
|
||||
target_link_libraries(LIB_LIEF PRIVATE
|
||||
MbedTLS::mbedcrypto
|
||||
MbedTLS::mbedx509)
|
||||
MbedTLS::mbedcrypto MbedTLS::mbedx509)
|
||||
endif()
|
||||
|
||||
if(WINDOWS AND BUILD_SHARED_LIBS)
|
||||
@@ -243,11 +162,6 @@ if(MSVC)
|
||||
add_compile_options(/bigobj)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug AND WINDOWS)
|
||||
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0 -D_SECURE_SCL=0
|
||||
-D_HAS_ITERATOR_DEBUGGING=0)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug AND UNIX)
|
||||
target_compile_options(LIB_LIEF PRIVATE -g -O0)
|
||||
endif()
|
||||
@@ -258,39 +172,8 @@ else()
|
||||
target_compile_definitions(LIB_LIEF PRIVATE -DLIEF_STATIC)
|
||||
endif()
|
||||
|
||||
# Abstract part
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/Abstract/CMakeLists.txt")
|
||||
|
||||
# ELF Part
|
||||
# ========
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/ELF/CMakeLists.txt")
|
||||
if(LIEF_ELF)
|
||||
set(ENABLE_ELF_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_ELF_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# PE Part
|
||||
# =======
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/PE/CMakeLists.txt")
|
||||
if(LIEF_PE)
|
||||
set(ENABLE_PE_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_PE_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# MachO part
|
||||
# ==========
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/src/MachO/CMakeLists.txt")
|
||||
if(LIEF_MACHO)
|
||||
set(ENABLE_MACHO_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_MACHO_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# Logging Configuration
|
||||
# =====================
|
||||
|
||||
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||
SPDLOG_NO_EXCEPTIONS
|
||||
SPDLOG_FUNCTION=)
|
||||
@@ -299,47 +182,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
target_compile_definitions(LIB_LIEF PRIVATE SPDLOG_NO_THREAD_ID)
|
||||
endif()
|
||||
|
||||
|
||||
# OAT part
|
||||
# ========
|
||||
if(LIEF_OAT)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/OAT/CMakeLists.txt)
|
||||
set(ENABLE_OAT_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_OAT_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# DEX part
|
||||
# ========
|
||||
if(LIEF_DEX)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/DEX/CMakeLists.txt)
|
||||
set(ENABLE_DEX_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_DEX_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# VDEX part
|
||||
# =========
|
||||
if(LIEF_VDEX)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/VDEX/CMakeLists.txt)
|
||||
set(ENABLE_VDEX_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_VDEX_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# ART part
|
||||
# ========
|
||||
if(LIEF_ART)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/ART/CMakeLists.txt)
|
||||
set(ENABLE_ART_SUPPORT 1)
|
||||
else()
|
||||
set(ENABLE_ART_SUPPORT 0)
|
||||
endif()
|
||||
|
||||
# Platforms
|
||||
# =========
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/CMakeLists.txt)
|
||||
|
||||
# LIEF includes
|
||||
# =============
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
|
||||
@@ -348,16 +190,18 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/version.h.in"
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/config.h.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/config.h" @ONLY)
|
||||
|
||||
list(APPEND LIEF_PUBLIC_INCLUDE_DIR
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/include/")
|
||||
set(LIEF_PUBLIC_INCLUDE_DIR
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api/c/include/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
|
||||
list(APPEND LIEF_PRIVATE_INCLUDE_DIR "${LIEF_PUBLIC_INCLUDE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set(LIEF_PRIVATE_INCLUDE_DIR
|
||||
${LIEF_PUBLIC_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in ${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc
|
||||
@ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEF.pc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEF.pc @ONLY)
|
||||
|
||||
target_include_directories(LIB_LIEF
|
||||
PUBLIC "$<BUILD_INTERFACE:${LIEF_PUBLIC_INCLUDE_DIR}>"
|
||||
@@ -468,22 +312,16 @@ endif()
|
||||
|
||||
# Flags definition
|
||||
# ----------------
|
||||
|
||||
# cmake-format: off
|
||||
set_target_properties(
|
||||
LIB_LIEF
|
||||
set_target_properties(LIB_LIEF
|
||||
PROPERTIES POSITION_INDEPENDENT_CODE ON
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_VISIBILITY_PRESET hidden
|
||||
C_VISIBILITY_PRESET hidden)
|
||||
# cmake-format: on
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
set_property(
|
||||
TARGET LIB_LIEF
|
||||
APPEND
|
||||
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
set_property(TARGET LIB_LIEF APPEND
|
||||
PROPERTY LINK_FLAGS "-Wl,--gc-sections -Wl,--exclude-libs,ALL")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(LIB_LIEF PUBLIC -D_GLIBCXX_USE_CXX11_ABI=1)
|
||||
@@ -539,7 +377,7 @@ endif()
|
||||
if(LIEF_SANITIZER)
|
||||
message("LIEF Sanitizer enabled: ${SANITIZER_FLAGS}")
|
||||
target_compile_options(LIB_LIEF PUBLIC ${SANITIZER_FLAGS})
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests/sanitizer")
|
||||
add_subdirectory(tests/sanitizer)
|
||||
endif()
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -553,13 +391,13 @@ if(LIEF_FUZZING)
|
||||
|
||||
target_compile_options(LIB_LIEF PRIVATE ${FUZZING_FLAGS})
|
||||
target_link_libraries(LIB_LIEF PUBLIC asan pthread)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/fuzzing")
|
||||
add_subdirectory(fuzzing)
|
||||
endif()
|
||||
|
||||
include(LIEFCompilerFlags)
|
||||
|
||||
if(LIEF_PROFILING)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/profiling")
|
||||
add_subdirectory(profiling)
|
||||
endif()
|
||||
|
||||
set_target_properties(LIB_LIEF PROPERTIES
|
||||
@@ -586,28 +424,19 @@ if(APPLE)
|
||||
set_target_properties(LIB_LIEF PROPERTIES MACOSX_RPATH ON)
|
||||
endif()
|
||||
|
||||
# API
|
||||
# ======================
|
||||
include(LIEFApi)
|
||||
|
||||
# Examples
|
||||
# ======================
|
||||
if(LIEF_EXAMPLES)
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# Tests
|
||||
# ======================
|
||||
|
||||
if(LIEF_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# Documentation
|
||||
# ======================
|
||||
if(LIEF_DOC)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
# Post-build operations
|
||||
@@ -638,10 +467,8 @@ if(LIEF_INSTALL)
|
||||
|
||||
# Find Package Config
|
||||
# ======================
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake
|
||||
@ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/LIEFConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfig.cmake @ONLY)
|
||||
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LIEFConfigVersion.cmake
|
||||
@@ -726,7 +553,5 @@ if(LIEF_INSTALL)
|
||||
NAMESPACE LIEF::
|
||||
FILE LIEFExport-${lib_type}.cmake)
|
||||
|
||||
# Package
|
||||
# ======================
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/package")
|
||||
add_subdirectory(package)
|
||||
endif()
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API_
|
||||
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API_
|
||||
#ifndef LIEF_PE_DATA_DIRECTORY_CPP_C_API
|
||||
#define LIEF_PE_DATA_DIRECTORY_CPP_C_API
|
||||
|
||||
#include "LIEF/PE/Binary.h"
|
||||
#include "LIEF/PE/Binary.hpp"
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace PE {
|
||||
void init_c_dos_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
const DosHeader& dos_header = binary->dos_header();
|
||||
c_binary->dos_header.magic = dos_header.magic();
|
||||
c_binary->dos_header.used_bytes_in_the_last_page = dos_header.used_bytes_in_the_last_page();
|
||||
c_binary->dos_header.used_bytes_in_last_page = dos_header.used_bytes_in_last_page();
|
||||
c_binary->dos_header.file_size_in_pages = dos_header.file_size_in_pages();
|
||||
c_binary->dos_header.numberof_relocation = dos_header.numberof_relocation();
|
||||
c_binary->dos_header.header_size_in_paragraphs = dos_header.header_size_in_paragraphs();
|
||||
|
||||
@@ -20,21 +20,10 @@
|
||||
#include "LIEF/PE/enums.h"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
|
||||
const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::PE_TYPE>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::MACHINE_TYPES>(e));
|
||||
}
|
||||
|
||||
|
||||
const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::SUBSYSTEM>(e));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+11
-4
@@ -32,11 +32,18 @@ void init_c_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
c_binary->header.sizeof_optional_header = header.sizeof_optional_header();
|
||||
c_binary->header.characteristics = static_cast<uint16_t>(header.characteristics());
|
||||
|
||||
std::copy(
|
||||
std::begin(signature),
|
||||
std::end(signature),
|
||||
c_binary->header.signature);
|
||||
std::copy(std::begin(signature), std::end(signature),
|
||||
c_binary->header.signature);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::MACHINE_TYPES>(e));
|
||||
}
|
||||
|
||||
const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::Header::CHARACTERISTICS>(e));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "OptionalHeader.hpp"
|
||||
#include "LIEF/PE/OptionalHeader.h"
|
||||
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
@@ -59,3 +60,8 @@ void init_c_optional_header(Pe_Binary_t* c_binary, Binary* binary) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e) {
|
||||
return LIEF::PE::to_string(static_cast<LIEF::PE::OptionalHeader::SUBSYSTEM>(e));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 2023 Quarkslab
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* 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
|
||||
*
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_DATA_DIRECTORY_H_
|
||||
#define C_LIEF_PE_DATA_DIRECTORY_H_
|
||||
#ifndef C_LIEF_PE_DATA_DIRECTORY_H
|
||||
#define C_LIEF_PE_DATA_DIRECTORY_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -31,6 +31,28 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
enum LIEF_PE_DATA_DIRECTORY {
|
||||
LIEF_PE_DATA_DIR_EXPORT_TABLE = 0,
|
||||
LIEF_PE_DATA_DIR_IMPORT_TABLE,
|
||||
LIEF_PE_DATA_DIR_RESOURCE_TABLE,
|
||||
LIEF_PE_DATA_DIR_EXCEPTION_TABLE,
|
||||
LIEF_PE_DATA_DIR_CERTIFICATE_TABLE,
|
||||
LIEF_PE_DATA_DIR_BASE_RELOCATION_TABLE,
|
||||
LIEF_PE_DATA_DIR_DEBUG,
|
||||
LIEF_PE_DATA_DIR_ARCHITECTURE,
|
||||
LIEF_PE_DATA_DIR_GLOBAL_PTR,
|
||||
LIEF_PE_DATA_DIR_TLS_TABLE,
|
||||
LIEF_PE_DATA_DIR_LOAD_CONFIG_TABLE,
|
||||
LIEF_PE_DATA_DIR_BOUND_IMPORT,
|
||||
LIEF_PE_DATA_DIR_IAT,
|
||||
LIEF_PE_DATA_DIR_DELAY_IMPORT_DESCRIPTOR,
|
||||
LIEF_PE_DATA_DIR_CLR_RUNTIME_HEADER,
|
||||
LIEF_PE_DATA_DIR_RESERVED,
|
||||
|
||||
LIEF_PE_DATA_DIR_NONE,
|
||||
};
|
||||
|
||||
struct Pe_DataDirectory_t {
|
||||
uint32_t rva;
|
||||
uint32_t size;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/ELF/enums.h"
|
||||
/** @defgroup pe_dos_header_c_api DosHeader
|
||||
/** @defgroup pe_dos_header_c_api DosHeader
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_dos_header_c_api
|
||||
* @brief Dos Header C API
|
||||
@@ -32,7 +32,7 @@ extern "C" {
|
||||
|
||||
struct Pe_DosHeader_t {
|
||||
uint16_t magic ;
|
||||
uint16_t used_bytes_in_the_last_page;
|
||||
uint16_t used_bytes_in_last_page;
|
||||
uint16_t file_size_in_pages;
|
||||
uint16_t numberof_relocation;
|
||||
uint16_t header_size_in_paragraphs;
|
||||
|
||||
@@ -24,10 +24,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
LIEF_API const char* PE_TYPES_to_string(enum LIEF_PE_PE_TYPES e);
|
||||
LIEF_API const char* MACHINE_TYPES_to_string(enum LIEF_PE_MACHINE_TYPES e);
|
||||
LIEF_API const char* SUBSYSTEM_to_string(enum LIEF_PE_SUBSYSTEM e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_HEADER_H_
|
||||
#define C_LIEF_PE_HEADER_H_
|
||||
#ifndef C_LIEF_PE_HEADER_H
|
||||
#define C_LIEF_PE_HEADER_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
/** @defgroup pe_header_c_api Header
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_header_c_api
|
||||
@@ -31,6 +32,53 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_MACHINE_TYPES {
|
||||
LIEF_PE_MACHINE_UNKNOWN = 0x0,
|
||||
LIEF_PE_MACHINE_AM33 = 0x1D3, /**< Matsushita AM33 */
|
||||
LIEF_PE_MACHINE_AMD64 = 0x8664, /**< AMD x64 */
|
||||
LIEF_PE_MACHINE_ARM = 0x1C0, /**< ARM little endian */
|
||||
LIEF_PE_MACHINE_ARMNT = 0x1C4, /**< ARMv7 Thumb mode only */
|
||||
LIEF_PE_MACHINE_ARM64 = 0xAA64, /**< ARMv8 in 64-bits mode */
|
||||
LIEF_PE_MACHINE_EBC = 0xEBC, /**< EFI byte code */
|
||||
LIEF_PE_MACHINE_I386 = 0x14C, /**< Intel 386 or later */
|
||||
LIEF_PE_MACHINE_IA64 = 0x200, /**< Intel Itanium processor family */
|
||||
LIEF_PE_MACHINE_M32R = 0x9041, /**< Mitsubishi M32R little endian */
|
||||
LIEF_PE_MACHINE_MIPS16 = 0x266, /**< MIPS16 */
|
||||
LIEF_PE_MACHINE_MIPSFPU = 0x366, /**< MIPS with FPU */
|
||||
LIEF_PE_MACHINE_MIPSFPU16 = 0x466, /**< MIPS16 with FPU */
|
||||
LIEF_PE_MACHINE_POWERPC = 0x1F0, /**< Power PC little endian */
|
||||
LIEF_PE_MACHINE_POWERPCFP = 0x1F1, /**< Power PC with floating point */
|
||||
LIEF_PE_MACHINE_R4000 = 0x166, /**< MIPS with little endian */
|
||||
LIEF_PE_MACHINE_RISCV32 = 0x5032, /**< RISC-V 32-bit address space */
|
||||
LIEF_PE_MACHINE_RISCV64 = 0x5064, /**< RISC-V 64-bit address space */
|
||||
LIEF_PE_MACHINE_RISCV128 = 0x5128, /**< RISC-V 128-bit address space */
|
||||
LIEF_PE_MACHINE_SH3 = 0x1A2, /**< Hitachi SH3 */
|
||||
LIEF_PE_MACHINE_SH3DSP = 0x1A3, /**< Hitachi SH3 DSP */
|
||||
LIEF_PE_MACHINE_SH4 = 0x1A6, /**< Hitachi SH4 */
|
||||
LIEF_PE_MACHINE_SH5 = 0x1A8, /**< Hitachi SH5 */
|
||||
LIEF_PE_MACHINE_THUMB = 0x1C2, /**< ARM or Thumb */
|
||||
LIEF_PE_MACHINE_WCEMIPSV2 = 0x169 /**< MIPS little-endian WCE v2 */
|
||||
};
|
||||
|
||||
enum LIEF_PE_HEADER_CHARACTERISTICS {
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_INVALID = 0x0000,
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_RELOCS_STRIPPED = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_EXECUTABLE_IMAGE = 0x0002, /**< The file is valid and can be run.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LINE_NUMS_STRIPPED = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LOCAL_SYMS_STRIPPED = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_AGGRESSIVE_WS_TRIM = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_LARGE_ADDRESS_AWARE = 0x0020, /**< Image can handle > 2GiB addresses. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_LO = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_32BIT_MACHINE = 0x0100, /**< Machine is based on a 32bit word architecture. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_DEBUG_STRIPPED = 0x0200, /**< Debugging info has been removed. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_REMOVABLE_RUN_FROM_SWAP = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_NET_RUN_FROM_SWAP = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_SYSTEM = 0x1000, /**< The image file is a system file, not a user program.*/
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_DLL = 0x2000, /**< The image file is a DLL. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_UP_SYSTEM_ONLY = 0x4000, /**< This file should only be run on a uniprocessor machine. */
|
||||
LIEF_PE_HEADER_CHARACTERISTICS_BYTES_REVERSED_HI = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
|
||||
};
|
||||
|
||||
struct Pe_Header_t {
|
||||
uint8_t signature[4];
|
||||
enum LIEF_PE_MACHINE_TYPES machine;
|
||||
@@ -44,6 +92,8 @@ struct Pe_Header_t {
|
||||
|
||||
typedef struct Pe_Header_t Pe_Header_t;
|
||||
|
||||
LIEF_API const char* lief_pe_header_machine_str(enum LIEF_PE_MACHINE_TYPES e);
|
||||
LIEF_API const char* lief_pe_header_characteristics_str(enum LIEF_PE_HEADER_CHARACTERISTICS e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H_
|
||||
#define C_LIEF_PE_OPTIONAL_HEADER_H_
|
||||
#ifndef C_LIEF_PE_OPTIONAL_HEADER_H
|
||||
#define C_LIEF_PE_OPTIONAL_HEADER_H
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "LIEF/PE/enums.h"
|
||||
#include "LIEF/visibility.h"
|
||||
/** @defgroup pe_optional_header_c_api OptionalHeader
|
||||
* @ingroup pe_c_api
|
||||
* @addtogroup pe_optional_header_c_api
|
||||
@@ -30,6 +31,37 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_DLL_CHARACTERISTICS {
|
||||
LIEF_PE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020, /**< ASLR with 64 bit address space. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, /**< DLL can be relocated at load time. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, /**< Code integrity checks are enforced. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, /**< Image is NX compatible. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200, /**< Isolation aware, but do not isolate the image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_SEH = 0x0400, /**< Does not use structured exception handling (SEH). No SEH handler may be called in this image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_NO_BIND = 0x0800, /**< Do not bind the image. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000, /**< Image should execute in an AppContainer. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000, /**< A WDM driver. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000, /**< Image supports Control Flow Guard. */
|
||||
LIEF_PE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000 /**< Terminal Server aware. */
|
||||
};
|
||||
|
||||
enum LIEF_PE_SUBSYSTEM {
|
||||
LIEF_PE_SUBSYSTEM_UNKNOWN = 0, /**< An unknown subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_NATIVE = 1, /**< Device drivers and native Windows processes */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_GUI = 2, /**< The Windows GUI subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_CUI = 3, /**< The Windows character subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_OS2_CUI = 5, /**< The OS/2 character subsytem. */
|
||||
LIEF_PE_SUBSYSTEM_POSIX_CUI = 7, /**< The POSIX character subsystem. */
|
||||
LIEF_PE_SUBSYSTEM_NATIVE_WINDOWS = 8, /**< Native Windows 9x driver. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_CE_GUI = 9, /**< Windows CE. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_APPLICATION = 10, /**< An EFI application. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, /**< An EFI driver with boot services. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, /**< An EFI driver with run-time services. */
|
||||
LIEF_PE_SUBSYSTEM_EFI_ROM = 13, /**< An EFI ROM image. */
|
||||
LIEF_PE_SUBSYSTEM_XBOX = 14, /**< XBOX. */
|
||||
LIEF_PE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 /**< A BCD application. */
|
||||
};
|
||||
|
||||
struct Pe_OptionalHeader_t {
|
||||
enum LIEF_PE_PE_TYPES magic;
|
||||
uint8_t major_linker_version;
|
||||
@@ -65,6 +97,7 @@ struct Pe_OptionalHeader_t {
|
||||
|
||||
typedef struct Pe_OptionalHeader_t Pe_OptionalHeader_t;
|
||||
|
||||
LIEF_API const char* lief_pe_subsytem_str(enum LIEF_PE_SUBSYSTEM e);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -31,6 +31,45 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum LIEF_PE_SECTION_CHARACTERISTICS {
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_TYPE_NO_PAD = 0x00000008,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_CODE = 0x00000020,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_INITIALIZED_DATA = 0x00000040,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_CNT_UNINITIALIZED_DATA = 0x00000080,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_OTHER = 0x00000100,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_INFO = 0x00000200,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_REMOVE = 0x00000800,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_COMDAT = 0x00001000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_GPREL = 0x00008000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PURGEABLE = 0x00010000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_16BIT = 0x00020000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_LOCKED = 0x00040000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_PRELOAD = 0x00080000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1BYTES = 0x00100000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2BYTES = 0x00200000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4BYTES = 0x00300000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8BYTES = 0x00400000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_16BYTES = 0x00500000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_32BYTES = 0x00600000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_64BYTES = 0x00700000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_128BYTES = 0x00800000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_256BYTES = 0x00900000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_512BYTES = 0x00A00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_1024BYTES = 0x00B00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_2048BYTES = 0x00C00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_4096BYTES = 0x00D00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_ALIGN_8192BYTES = 0x00E00000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_LNK_NRELOC_OVFL = 0x01000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_DISCARDABLE = 0x02000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_CACHED = 0x04000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_NOT_PAGED = 0x08000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_SHARED = 0x10000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_EXECUTE = 0x20000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_READ = 0x40000000,
|
||||
LIEF_PE_SECTION_CHARACTERISTICS_MEM_WRITE = 0x80000000
|
||||
};
|
||||
|
||||
|
||||
struct Pe_Section_t {
|
||||
const char* name;
|
||||
uint64_t virtual_address;
|
||||
@@ -50,7 +89,6 @@ struct Pe_Section_t {
|
||||
|
||||
typedef struct Pe_Section_t Pe_Section_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,7 @@ extern "C" {
|
||||
#undef _LIEF_EN_2
|
||||
#undef _LIEF_EI
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -58,7 +58,7 @@ def print_header(binary):
|
||||
|
||||
print("== Dos Header ==")
|
||||
print(format_str.format("Magic:", str((dos_header.magic))))
|
||||
print(format_dec.format("Used bytes in the last page:", dos_header.used_bytes_in_the_last_page))
|
||||
print(format_dec.format("Used bytes in the last page:", dos_header.used_bytes_in_last_page))
|
||||
print(format_dec.format("File size in pages:", dos_header.file_size_in_pages))
|
||||
print(format_dec.format("Number of relocations:", dos_header.numberof_relocation))
|
||||
print(format_dec.format("Header size in paragraphs:", dos_header.header_size_in_paragraphs))
|
||||
|
||||
+228
-225
@@ -312,7 +312,7 @@ class Binary(lief.Binary):
|
||||
def add_relocation(self, relocation: lief.PE.Relocation) -> lief.PE.Relocation: ...
|
||||
def add_section(self, section: lief.PE.Section, type: lief.PE.SECTION_TYPES = ...) -> lief.PE.Section: ...
|
||||
def authentihash(self, algorithm: lief.PE.ALGORITHMS) -> bytes: ...
|
||||
def data_directory(self, type: lief.PE.DATA_DIRECTORY) -> lief.PE.DataDirectory: ...
|
||||
def data_directory(self, type: lief.PE.DataDirectory.TYPES) -> lief.PE.DataDirectory: ...
|
||||
def get_delay_import(self, import_name: str) -> lief.PE.DelayImport: ...
|
||||
def get_export(self) -> lief.PE.Export: ...
|
||||
def get_import(self, import_name: str) -> lief.PE.Import: ...
|
||||
@@ -616,30 +616,6 @@ class ContentType(Attribute):
|
||||
@property
|
||||
def oid(self) -> str: ...
|
||||
|
||||
class DATA_DIRECTORY:
|
||||
ARCHITECTURE: ClassVar[DATA_DIRECTORY] = ...
|
||||
BASE_RELOCATION_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
BOUND_IMPORT: ClassVar[DATA_DIRECTORY] = ...
|
||||
CERTIFICATE_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
CLR_RUNTIME_HEADER: ClassVar[DATA_DIRECTORY] = ...
|
||||
DEBUG: ClassVar[DATA_DIRECTORY] = ...
|
||||
DELAY_IMPORT_DESCRIPTOR: ClassVar[DATA_DIRECTORY] = ...
|
||||
EXCEPTION_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
EXPORT_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
GLOBAL_PTR: ClassVar[DATA_DIRECTORY] = ...
|
||||
IAT: ClassVar[DATA_DIRECTORY] = ...
|
||||
IMPORT_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
LOAD_CONFIG_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
RESERVED: ClassVar[DATA_DIRECTORY] = ...
|
||||
RESOURCE_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
TLS_TABLE: ClassVar[DATA_DIRECTORY] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.DATA_DIRECTORY: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class DIALOG_BOX_STYLES:
|
||||
ABSALIGN: ClassVar[DIALOG_BOX_STYLES] = ...
|
||||
CENTER: ClassVar[DIALOG_BOX_STYLES] = ...
|
||||
@@ -663,40 +639,31 @@ class DIALOG_BOX_STYLES:
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class DLL_CHARACTERISTICS:
|
||||
APPCONTAINER: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
DYNAMIC_BASE: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
FORCE_INTEGRITY: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
GUARD_CF: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
HIGH_ENTROPY_VA: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
NO_BIND: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
NO_ISOLATION: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
NO_SEH: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
NX_COMPAT: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
TERMINAL_SERVER_AWARE: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
WDM_DRIVER: ClassVar[DLL_CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.DLL_CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class DataDirectory(lief.Object):
|
||||
class TYPES:
|
||||
ARCHITECTURE: ClassVar[DataDirectory.TYPES] = ...
|
||||
BASE_RELOCATION_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
BOUND_IMPORT: ClassVar[DataDirectory.TYPES] = ...
|
||||
CERTIFICATE_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
CLR_RUNTIME_HEADER: ClassVar[DataDirectory.TYPES] = ...
|
||||
DEBUG: ClassVar[DataDirectory.TYPES] = ...
|
||||
DELAY_IMPORT_DESCRIPTOR: ClassVar[DataDirectory.TYPES] = ...
|
||||
EXCEPTION_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
EXPORT_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
GLOBAL_PTR: ClassVar[DataDirectory.TYPES] = ...
|
||||
IAT: ClassVar[DataDirectory.TYPES] = ...
|
||||
IMPORT_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
LOAD_CONFIG_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
RESERVED: ClassVar[DataDirectory.TYPES] = ...
|
||||
RESOURCE_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
TLS_TABLE: ClassVar[DataDirectory.TYPES] = ...
|
||||
UNKNOWN: ClassVar[DataDirectory.TYPES] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.DataDirectory.TYPES: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
rva: int
|
||||
size: int
|
||||
def __init__(self) -> None: ...
|
||||
@@ -706,7 +673,7 @@ class DataDirectory(lief.Object):
|
||||
@property
|
||||
def section(self) -> lief.PE.Section: ...
|
||||
@property
|
||||
def type(self) -> lief.PE.DATA_DIRECTORY: ...
|
||||
def type(self) -> lief.PE.DataDirectory.TYPES: ...
|
||||
|
||||
class Debug(lief.Object):
|
||||
class TYPES:
|
||||
@@ -725,6 +692,7 @@ class Debug(lief.Object):
|
||||
OMAP_TO_SRC: ClassVar[Debug.TYPES] = ...
|
||||
POGO: ClassVar[Debug.TYPES] = ...
|
||||
REPRO: ClassVar[Debug.TYPES] = ...
|
||||
RESERVED: ClassVar[Debug.TYPES] = ...
|
||||
UNKNOWN: ClassVar[Debug.TYPES] = ...
|
||||
VC_FEATURE: ClassVar[Debug.TYPES] = ...
|
||||
__name__: Any
|
||||
@@ -796,9 +764,11 @@ class DosHeader(lief.Object):
|
||||
oem_id: int
|
||||
oem_info: int
|
||||
overlay_number: int
|
||||
used_bytes_in_the_last_page: int
|
||||
def __init__(self) -> None: ...
|
||||
used_bytes_in_last_page: int
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def copy(self) -> lief.PE.DosHeader: ...
|
||||
@staticmethod
|
||||
def create(arg: lief.PE.PE_TYPE, /) -> lief.PE.DosHeader: ...
|
||||
|
||||
class EXTENDED_WINDOW_STYLES:
|
||||
ACCEPTFILES: ClassVar[EXTENDED_WINDOW_STYLES] = ...
|
||||
@@ -975,59 +945,90 @@ class GenericType(Attribute):
|
||||
@property
|
||||
def raw_content(self) -> bytes: ...
|
||||
|
||||
class HEADER_CHARACTERISTICS:
|
||||
AGGRESSIVE_WS_TRIM: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
BYTES_REVERSED_HI: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
BYTES_REVERSED_LO: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
CHARA_32BIT_MACHINE: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
DEBUG_STRIPPED: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
DLL: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
EXECUTABLE_IMAGE: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
LARGE_ADDRESS_AWARE: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
LINE_NUMS_STRIPPED: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
LOCAL_SYMS_STRIPPED: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
NET_RUN_FROM_SWAP: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
RELOCS_STRIPPED: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
REMOVABLE_RUN_FROM_SWAP: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
SYSTEM: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
UP_SYSTEM_ONLY: ClassVar[HEADER_CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.HEADER_CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class Header(lief.Object):
|
||||
characteristics: lief.PE.HEADER_CHARACTERISTICS
|
||||
machine: lief.PE.MACHINE_TYPES
|
||||
class CHARACTERISTICS:
|
||||
AGGRESSIVE_WS_TRIM: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
BYTES_REVERSED_HI: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
BYTES_REVERSED_LO: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
DEBUG_STRIPPED: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
DLL: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
EXECUTABLE_IMAGE: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
LARGE_ADDRESS_AWARE: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
LINE_NUMS_STRIPPED: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
LOCAL_SYMS_STRIPPED: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
NEED_32BIT_MACHINE: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
NET_RUN_FROM_SWAP: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
RELOCS_STRIPPED: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
REMOVABLE_RUN_FROM_SWAP: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
SYSTEM: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
UP_SYSTEM_ONLY: ClassVar[Header.CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.Header.CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class MACHINE_TYPES:
|
||||
AM33: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
AMD64: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
ARM: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
ARM64: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
ARMNT: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
EBC: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
I386: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
IA64: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
M32R: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
MIPS16: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
MIPSFPU: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
MIPSFPU16: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
POWERPC: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
POWERPCFP: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
R4000: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
SH3: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
SH3DSP: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
SH4: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
SH5: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
THUMB: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
UNKNOWN: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
WCEMIPSV2: ClassVar[Header.MACHINE_TYPES] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.Header.MACHINE_TYPES: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
characteristics: int
|
||||
machine: lief.PE.Header.MACHINE_TYPES
|
||||
numberof_sections: int
|
||||
numberof_symbols: int
|
||||
pointerto_symbol_table: int
|
||||
signature: list[int]
|
||||
sizeof_optional_header: int
|
||||
time_date_stamps: int
|
||||
def __init__(self) -> None: ...
|
||||
def add_characteristic(self, characteristic: lief.PE.HEADER_CHARACTERISTICS) -> None: ...
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def add_characteristic(self, characteristic: lief.PE.Header.CHARACTERISTICS) -> None: ...
|
||||
def copy(self) -> lief.PE.Header: ...
|
||||
def has_characteristic(self, characteristic: lief.PE.HEADER_CHARACTERISTICS) -> bool: ...
|
||||
def remove_characteristic(self, characteristic: lief.PE.HEADER_CHARACTERISTICS) -> None: ...
|
||||
@staticmethod
|
||||
def create(type: lief.PE.PE_TYPE) -> lief.PE.Header: ...
|
||||
def has_characteristic(self, characteristic: lief.PE.Header.CHARACTERISTICS) -> bool: ...
|
||||
def remove_characteristic(self, characteristic: lief.PE.Header.CHARACTERISTICS) -> None: ...
|
||||
@property
|
||||
def characteristics_list(self) -> set[lief.PE.HEADER_CHARACTERISTICS]: ...
|
||||
def characteristics_list(self) -> list[lief.PE.Header.CHARACTERISTICS]: ...
|
||||
|
||||
class IMPHASH_MODE:
|
||||
DEFAULT: ClassVar[IMPHASH_MODE] = ...
|
||||
@@ -1212,37 +1213,6 @@ class LoadConfigurationV9(LoadConfigurationV8):
|
||||
def __init__(self) -> None: ...
|
||||
def copy(self) -> lief.PE.LoadConfigurationV9: ...
|
||||
|
||||
class MACHINE_TYPES:
|
||||
AM33: ClassVar[MACHINE_TYPES] = ...
|
||||
AMD64: ClassVar[MACHINE_TYPES] = ...
|
||||
ARM: ClassVar[MACHINE_TYPES] = ...
|
||||
ARM64: ClassVar[MACHINE_TYPES] = ...
|
||||
ARMNT: ClassVar[MACHINE_TYPES] = ...
|
||||
EBC: ClassVar[MACHINE_TYPES] = ...
|
||||
I386: ClassVar[MACHINE_TYPES] = ...
|
||||
IA64: ClassVar[MACHINE_TYPES] = ...
|
||||
INVALID: ClassVar[MACHINE_TYPES] = ...
|
||||
M32R: ClassVar[MACHINE_TYPES] = ...
|
||||
MIPS16: ClassVar[MACHINE_TYPES] = ...
|
||||
MIPSFPU: ClassVar[MACHINE_TYPES] = ...
|
||||
MIPSFPU16: ClassVar[MACHINE_TYPES] = ...
|
||||
POWERPC: ClassVar[MACHINE_TYPES] = ...
|
||||
POWERPCFP: ClassVar[MACHINE_TYPES] = ...
|
||||
R4000: ClassVar[MACHINE_TYPES] = ...
|
||||
SH3: ClassVar[MACHINE_TYPES] = ...
|
||||
SH3DSP: ClassVar[MACHINE_TYPES] = ...
|
||||
SH4: ClassVar[MACHINE_TYPES] = ...
|
||||
SH5: ClassVar[MACHINE_TYPES] = ...
|
||||
THUMB: ClassVar[MACHINE_TYPES] = ...
|
||||
UNKNOWN: ClassVar[MACHINE_TYPES] = ...
|
||||
WCEMIPSV2: ClassVar[MACHINE_TYPES] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.MACHINE_TYPES: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class MsSpcNestedSignature(Attribute):
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@property
|
||||
@@ -1254,6 +1224,60 @@ class MsSpcStatementType(Attribute):
|
||||
def oid(self) -> str: ...
|
||||
|
||||
class OptionalHeader(lief.Object):
|
||||
class DLL_CHARACTERISTICS:
|
||||
APPCONTAINER: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
DYNAMIC_BASE: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
FORCE_INTEGRITY: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
GUARD_CF: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
HIGH_ENTROPY_VA: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
NO_BIND: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
NO_ISOLATION: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
NO_SEH: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
NX_COMPAT: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
TERMINAL_SERVER_AWARE: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
WDM_DRIVER: ClassVar[OptionalHeader.DLL_CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.OptionalHeader.DLL_CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class SUBSYSTEM:
|
||||
EFI_APPLICATION: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
EFI_BOOT_SERVICE_DRIVER: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
EFI_ROM: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
EFI_RUNTIME_DRIVER: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
NATIVE: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
NATIVE_WINDOWS: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
OS2_CUI: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
POSIX_CUI: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
UNKNOWN: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
WINDOWS_BOOT_APPLICATION: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
WINDOWS_CE_GUI: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
WINDOWS_CUI: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
WINDOWS_GUI: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
XBOX: ClassVar[OptionalHeader.SUBSYSTEM] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.OptionalHeader.SUBSYSTEM: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
addressof_entrypoint: int
|
||||
baseof_code: int
|
||||
baseof_data: int
|
||||
@@ -1284,18 +1308,20 @@ class OptionalHeader(lief.Object):
|
||||
sizeof_uninitialized_data: int
|
||||
subsystem: Any
|
||||
win32_version_value: int
|
||||
def __init__(self) -> None: ...
|
||||
def add(self, characteristic: lief.PE.DLL_CHARACTERISTICS) -> None: ...
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def add(self, characteristic: lief.PE.OptionalHeader.DLL_CHARACTERISTICS) -> None: ...
|
||||
def copy(self) -> lief.PE.OptionalHeader: ...
|
||||
def has(self, characteristics: lief.PE.DLL_CHARACTERISTICS) -> bool: ...
|
||||
def remove(self, characteristic: lief.PE.DLL_CHARACTERISTICS) -> None: ...
|
||||
def __contains__(self, arg: lief.PE.DLL_CHARACTERISTICS, /) -> bool: ...
|
||||
def __iadd__(self, arg: lief.PE.DLL_CHARACTERISTICS, /) -> lief.PE.OptionalHeader: ...
|
||||
def __isub__(self, arg: lief.PE.DLL_CHARACTERISTICS, /) -> lief.PE.OptionalHeader: ...
|
||||
@staticmethod
|
||||
def create(type: lief.PE.PE_TYPE) -> lief.PE.OptionalHeader: ...
|
||||
def has(self, characteristics: lief.PE.OptionalHeader.DLL_CHARACTERISTICS) -> bool: ...
|
||||
def remove(self, characteristic: lief.PE.OptionalHeader.DLL_CHARACTERISTICS) -> None: ...
|
||||
def __contains__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> bool: ...
|
||||
def __iadd__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> lief.PE.OptionalHeader: ...
|
||||
def __isub__(self, arg: lief.PE.OptionalHeader.DLL_CHARACTERISTICS, /) -> lief.PE.OptionalHeader: ...
|
||||
@property
|
||||
def computed_checksum(self) -> int: ...
|
||||
@property
|
||||
def dll_characteristics_lists(self) -> set[lief.PE.DLL_CHARACTERISTICS]: ...
|
||||
def dll_characteristics_lists(self) -> list[lief.PE.OptionalHeader.DLL_CHARACTERISTICS]: ...
|
||||
|
||||
class PE_TYPE:
|
||||
PE32: ClassVar[PE_TYPE] = ...
|
||||
@@ -2122,63 +2148,6 @@ class RsaInfo:
|
||||
@property
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
class SECTION_CHARACTERISTICS:
|
||||
ALIGN_1024BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_128BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_16BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_1BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_2048BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_256BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_2BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_32BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_4096BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_4BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_512BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_64BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_8192BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
ALIGN_8BYTES: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
CNT_CODE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
CNT_INITIALIZED_DATA: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
CNT_UNINITIALIZED_DATA: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
GPREL: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
LNK_COMDAT: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
LNK_INFO: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
LNK_NRELOC_OVFL: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
LNK_OTHER: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
LNK_REMOVE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_16BIT: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_DISCARDABLE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_EXECUTE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_LOCKED: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_NOT_CACHED: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_NOT_PAGED: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_PRELOAD: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_PURGEABLE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_READ: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_SHARED: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
MEM_WRITE: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
TYPE_NO_PAD: ClassVar[SECTION_CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.SECTION_CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class SECTION_TYPES:
|
||||
BSS: ClassVar[SECTION_TYPES] = ...
|
||||
DATA: ClassVar[SECTION_TYPES] = ...
|
||||
@@ -2215,28 +2184,6 @@ class SIG_ATTRIBUTE_TYPES:
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class SUBSYSTEM:
|
||||
EFI_APPLICATION: ClassVar[SUBSYSTEM] = ...
|
||||
EFI_BOOT_SERVICE_DRIVER: ClassVar[SUBSYSTEM] = ...
|
||||
EFI_ROM: ClassVar[SUBSYSTEM] = ...
|
||||
EFI_RUNTIME_DRIVER: ClassVar[SUBSYSTEM] = ...
|
||||
NATIVE: ClassVar[SUBSYSTEM] = ...
|
||||
NATIVE_WINDOWS: ClassVar[SUBSYSTEM] = ...
|
||||
OS2_CUI: ClassVar[SUBSYSTEM] = ...
|
||||
POSIX_CUI: ClassVar[SUBSYSTEM] = ...
|
||||
UNKNOWN: ClassVar[SUBSYSTEM] = ...
|
||||
WINDOWS_BOOT_APPLICATION: ClassVar[SUBSYSTEM] = ...
|
||||
WINDOWS_CE_GUI: ClassVar[SUBSYSTEM] = ...
|
||||
WINDOWS_CUI: ClassVar[SUBSYSTEM] = ...
|
||||
WINDOWS_GUI: ClassVar[SUBSYSTEM] = ...
|
||||
XBOX: ClassVar[SUBSYSTEM] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.SUBSYSTEM: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
|
||||
class SYMBOL_BASE_TYPES:
|
||||
BYTE: ClassVar[SYMBOL_BASE_TYPES] = ...
|
||||
CHAR: ClassVar[SYMBOL_BASE_TYPES] = ...
|
||||
@@ -2318,6 +2265,62 @@ class SYMBOL_STORAGE_CLASS:
|
||||
def value(self) -> int: ...
|
||||
|
||||
class Section(lief.Section):
|
||||
class CHARACTERISTICS:
|
||||
ALIGN_1024BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_128BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_16BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_1BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_2048BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_256BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_2BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_32BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_4096BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_4BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_512BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_64BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_8192BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
ALIGN_8BYTES: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
CNT_CODE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
CNT_INITIALIZED_DATA: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
CNT_UNINITIALIZED_DATA: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
GPREL: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
LNK_COMDAT: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
LNK_INFO: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
LNK_NRELOC_OVFL: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
LNK_OTHER: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
LNK_REMOVE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_16BIT: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_DISCARDABLE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_EXECUTE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_LOCKED: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_NOT_CACHED: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_NOT_PAGED: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_PRELOAD: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_PURGEABLE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_READ: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_SHARED: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
MEM_WRITE: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
TYPE_NO_PAD: ClassVar[Section.CHARACTERISTICS] = ...
|
||||
__name__: Any
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
@staticmethod
|
||||
def from_value(arg: int, /) -> lief.PE.Section.CHARACTERISTICS: ...
|
||||
def __abs__(self) -> Any: ...
|
||||
def __add__(self, other) -> Any: ...
|
||||
def __floordiv__(self, other) -> Any: ...
|
||||
def __lshift__(self, other) -> Any: ...
|
||||
def __mul__(self, other) -> Any: ...
|
||||
def __neg__(self) -> Any: ...
|
||||
def __radd__(self, other) -> Any: ...
|
||||
def __rfloordiv__(self, other) -> Any: ...
|
||||
def __rlshift__(self, other) -> Any: ...
|
||||
def __rmul__(self, other) -> Any: ...
|
||||
def __rrshift__(self, other) -> Any: ...
|
||||
def __rshift__(self, other) -> Any: ...
|
||||
def __rsub__(self, other) -> Any: ...
|
||||
def __sub__(self, other) -> Any: ...
|
||||
@property
|
||||
def value(self) -> int: ...
|
||||
characteristics: int
|
||||
numberof_line_numbers: int
|
||||
numberof_relocations: int
|
||||
@@ -2333,9 +2336,9 @@ class Section(lief.Section):
|
||||
@overload
|
||||
def __init__(self, name: str) -> None: ...
|
||||
def copy(self) -> lief.PE.Section: ...
|
||||
def has_characteristic(self, characteristic: lief.PE.SECTION_CHARACTERISTICS) -> bool: ...
|
||||
def has_characteristic(self, characteristic: lief.PE.Section.CHARACTERISTICS) -> bool: ...
|
||||
@property
|
||||
def characteristics_lists(self) -> set[lief.PE.SECTION_CHARACTERISTICS]: ...
|
||||
def characteristics_lists(self) -> Any: ...
|
||||
@property
|
||||
def padding(self) -> bytes: ...
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "LIEF/MachO/SegmentCommand.hpp"
|
||||
#include "LIEF/MachO/Section.hpp"
|
||||
#include "LIEF/MachO/Relocation.hpp"
|
||||
#include "LIEF/MachO/LinkEdit.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -33,6 +34,7 @@ template<>
|
||||
void create<SegmentCommand>(nb::module_& m) {
|
||||
using namespace LIEF::py;
|
||||
|
||||
|
||||
nb::class_<SegmentCommand, LoadCommand> seg_cmd(m, "SegmentCommand",
|
||||
R"delim(
|
||||
Class which represents a LOAD_COMMAND_TYPES::LC_SEGMENT /
|
||||
@@ -142,6 +144,7 @@ void create<SegmentCommand>(nb::module_& m) {
|
||||
)delim"_doc, "name"_a, nb::rv_policy::reference_internal)
|
||||
|
||||
LIEF_DEFAULT_STR(SegmentCommand);
|
||||
nb::class_<LinkEdit, SegmentCommand>(m, "LinkEdit");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,133 +29,6 @@ void init_enums(nb::module_& m) {
|
||||
.value(PY_ENUM(PE_TYPE::PE32))
|
||||
.value(PY_ENUM(PE_TYPE::PE32_PLUS));
|
||||
|
||||
enum_<MACHINE_TYPES>(m, "MACHINE_TYPES")
|
||||
.value(PY_ENUM(MACHINE_TYPES::MT_Invalid))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_UNKNOWN))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_AM33))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_AMD64))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_ARM))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_ARMNT))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_ARM64))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_EBC))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_I386))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_IA64))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_M32R))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPS16))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPSFPU))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_MIPSFPU16))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_POWERPC))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_POWERPCFP))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_R4000))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_SH3))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_SH3DSP))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_SH4))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_SH5))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_THUMB))
|
||||
.value(PY_ENUM(MACHINE_TYPES::IMAGE_FILE_MACHINE_WCEMIPSV2));
|
||||
|
||||
enum_<HEADER_CHARACTERISTICS>(m, "HEADER_CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_RELOCS_STRIPPED))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_EXECUTABLE_IMAGE))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_LINE_NUMS_STRIPPED))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_LOCAL_SYMS_STRIPPED))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_AGGRESSIVE_WS_TRIM))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_LARGE_ADDRESS_AWARE))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_BYTES_REVERSED_LO))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_32BIT_MACHINE))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_DEBUG_STRIPPED))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_NET_RUN_FROM_SWAP))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_SYSTEM))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_DLL))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_UP_SYSTEM_ONLY))
|
||||
.value(PY_ENUM(HEADER_CHARACTERISTICS::IMAGE_FILE_BYTES_REVERSED_HI));
|
||||
|
||||
enum_<SUBSYSTEM>(m, "SUBSYSTEM")
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_UNKNOWN))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_NATIVE))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_GUI))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_CUI))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_OS2_CUI))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_POSIX_CUI))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_NATIVE_WINDOWS))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_CE_GUI))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_APPLICATION))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_EFI_ROM))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_XBOX))
|
||||
.value(PY_ENUM(SUBSYSTEM::IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION));
|
||||
|
||||
enum_<DATA_DIRECTORY>(m, "DATA_DIRECTORY")
|
||||
.value(PY_ENUM(DATA_DIRECTORY::EXPORT_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::IMPORT_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::RESOURCE_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::EXCEPTION_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::CERTIFICATE_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::BASE_RELOCATION_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::DEBUG))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::ARCHITECTURE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::GLOBAL_PTR))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::TLS_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::LOAD_CONFIG_TABLE))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::BOUND_IMPORT))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::IAT))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::DELAY_IMPORT_DESCRIPTOR))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::CLR_RUNTIME_HEADER))
|
||||
.value(PY_ENUM(DATA_DIRECTORY::RESERVED));
|
||||
|
||||
enum_<DLL_CHARACTERISTICS>(m, "DLL_CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NX_COMPAT))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_SEH))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_NO_BIND))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_APPCONTAINER))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_GUARD_CF))
|
||||
.value(PY_ENUM(DLL_CHARACTERISTICS::IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE));
|
||||
|
||||
|
||||
enum_<SECTION_CHARACTERISTICS>(m, "SECTION_CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_TYPE_NO_PAD))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_CODE))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_INITIALIZED_DATA))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_UNINITIALIZED_DATA))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_OTHER))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_INFO))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_REMOVE))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_COMDAT))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_GPREL))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_PURGEABLE))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_16BIT))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_LOCKED))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_PRELOAD))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_1BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_2BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_4BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_8BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_16BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_32BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_64BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_128BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_256BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_512BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_1024BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_2048BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_4096BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_ALIGN_8192BYTES))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_LNK_NRELOC_OVFL))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_DISCARDABLE))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_NOT_CACHED))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_NOT_PAGED))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_SHARED))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_EXECUTE))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_READ))
|
||||
.value(PY_ENUM(SECTION_CHARACTERISTICS::IMAGE_SCN_MEM_WRITE));
|
||||
|
||||
enum_<PE_SECTION_TYPES>(m, "SECTION_TYPES")
|
||||
.value(PY_ENUM(PE_SECTION_TYPES::TEXT))
|
||||
.value(PY_ENUM(PE_SECTION_TYPES::TLS))
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
#include "LIEF/PE/debug/PogoEntry.hpp"
|
||||
#include "LIEF/PE/resources/LangCodeItem.hpp"
|
||||
#include "LIEF/PE/signature/attributes.hpp"
|
||||
#include "LIEF/PE/signature/SpcIndirectData.hpp"
|
||||
#include "LIEF/PE/signature/GenericContent.hpp"
|
||||
|
||||
#define CREATE(X,Y) create<X>(Y)
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
@@ -85,6 +88,8 @@ void init_signature(nb::module_& m) {
|
||||
CREATE(RsaInfo, m);
|
||||
CREATE(x509, m);
|
||||
CREATE(ContentInfo, m);
|
||||
CREATE(GenericContent, m);
|
||||
CREATE(SpcIndirectData, m);
|
||||
CREATE(SignerInfo, m);
|
||||
CREATE(CodeIntegrity, m);
|
||||
CREATE(Attribute, m);
|
||||
|
||||
@@ -45,7 +45,7 @@ void create<CodeViewPDB>(nb::module_& m) {
|
||||
|
||||
.def_prop_rw("signature",
|
||||
nb::overload_cast<>(&CodeViewPDB::signature, nb::const_),
|
||||
nb::overload_cast<CodeViewPDB::signature_t>(&CodeViewPDB::signature))
|
||||
nb::overload_cast<const CodeViewPDB::signature_t&>(&CodeViewPDB::signature))
|
||||
|
||||
.def_prop_rw("age",
|
||||
nb::overload_cast<>(&CodeViewPDB::age, nb::const_),
|
||||
@@ -53,7 +53,7 @@ void create<CodeViewPDB>(nb::module_& m) {
|
||||
|
||||
.def_prop_rw("filename",
|
||||
nb::overload_cast<>(&CodeViewPDB::filename, nb::const_),
|
||||
nb::overload_cast<const std::string&>(&CodeViewPDB::filename),
|
||||
nb::overload_cast<std::string>(&CodeViewPDB::filename),
|
||||
"Original pdb path")
|
||||
|
||||
LIEF_DEFAULT_STR(CodeViewPDB);
|
||||
|
||||
@@ -316,8 +316,8 @@ void create<Binary>(nb::module_& m) {
|
||||
nb::keep_alive<0, 1>())
|
||||
|
||||
.def("data_directory",
|
||||
nb::overload_cast<DATA_DIRECTORY>(&Binary::data_directory),
|
||||
"Return the " RST_CLASS_REF(lief.PE.DataDirectory) " object from the given " RST_CLASS_REF(lief.PE.DATA_DIRECTORY) " type"_doc,
|
||||
nb::overload_cast<DataDirectory::TYPES>(&Binary::data_directory),
|
||||
"Return the " RST_CLASS_REF(lief.PE.DataDirectory) " object from the given " RST_CLASS_REF(lief.PE.DataDirectory.TYPES) " type"_doc,
|
||||
"type"_a,
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
@@ -374,6 +374,9 @@ void create<Binary>(nb::module_& m) {
|
||||
"Return the overlay content as a ``list`` of bytes"_doc,
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
.def_prop_ro("overlay_offset", &Binary::overlay_offset,
|
||||
"Return the original overlay offset")
|
||||
|
||||
.def_prop_rw("dos_stub",
|
||||
[] (Binary& self) {
|
||||
const span<const uint8_t> content = self.dos_stub();
|
||||
|
||||
@@ -17,19 +17,43 @@
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
|
||||
#include "enums_wrapper.hpp"
|
||||
#include "LIEF/PE/DataDirectory.hpp"
|
||||
#include "LIEF/PE/Section.hpp"
|
||||
|
||||
#include "PE/pyPE.hpp"
|
||||
|
||||
#define PY_ENUM(x) to_string(x), x
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<DataDirectory>(nb::module_& m) {
|
||||
nb::class_<DataDirectory, Object>(m, "DataDirectory",
|
||||
nb::class_<DataDirectory, Object> data_dir(m, "DataDirectory",
|
||||
R"delim(
|
||||
Class that represents a PE data directory entry
|
||||
)delim"_doc)
|
||||
)delim"_doc);
|
||||
|
||||
enum_<DataDirectory::TYPES>(data_dir, "TYPES")
|
||||
.value(PY_ENUM(DataDirectory::TYPES::EXPORT_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::IMPORT_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::RESOURCE_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::EXCEPTION_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::CERTIFICATE_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::BASE_RELOCATION_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::DEBUG))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::ARCHITECTURE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::GLOBAL_PTR))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::TLS_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::LOAD_CONFIG_TABLE))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::BOUND_IMPORT))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::IAT))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::DELAY_IMPORT_DESCRIPTOR))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::CLR_RUNTIME_HEADER))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::RESERVED))
|
||||
.value(PY_ENUM(DataDirectory::TYPES::UNKNOWN));
|
||||
|
||||
data_dir
|
||||
.def(nb::init<>())
|
||||
.def_prop_rw("rva",
|
||||
nb::overload_cast<>(&DataDirectory::RVA, nb::const_),
|
||||
@@ -48,7 +72,7 @@ void create<DataDirectory>(nb::module_& m) {
|
||||
|
||||
.def_prop_ro("type",
|
||||
&DataDirectory::type,
|
||||
"Type (" RST_CLASS_REF(lief.PE.DATA_DIRECTORY) ") of the current data directory"_doc,
|
||||
"Type (" RST_CLASS_REF(lief.PE.DataDirectory.TYPES) ") of the current data directory"_doc,
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
.def_prop_ro("has_section",
|
||||
|
||||
@@ -31,14 +31,15 @@ void create<DosHeader>(nb::module_& m) {
|
||||
|
||||
Most of the attributes of this structures are not relevant, except :attr:`~lief.PE.DosHeader.addressof_new_exeheader`
|
||||
)delim"_doc)
|
||||
.def(nb::init<>())
|
||||
.def_static("create", &DosHeader::create, nb::rv_policy::move)
|
||||
|
||||
.def_prop_rw("magic",
|
||||
nb::overload_cast<>(&DosHeader::magic, nb::const_),
|
||||
nb::overload_cast<uint16_t>(&DosHeader::magic))
|
||||
|
||||
.def_prop_rw("used_bytes_in_the_last_page",
|
||||
nb::overload_cast<>(&DosHeader::used_bytes_in_the_last_page, nb::const_),
|
||||
nb::overload_cast<uint16_t>(&DosHeader::used_bytes_in_the_last_page))
|
||||
.def_prop_rw("used_bytes_in_last_page",
|
||||
nb::overload_cast<>(&DosHeader::used_bytes_in_last_page, nb::const_),
|
||||
nb::overload_cast<uint16_t>(&DosHeader::used_bytes_in_last_page))
|
||||
|
||||
.def_prop_rw("file_size_in_pages",
|
||||
nb::overload_cast<>(&DosHeader::file_size_in_pages, nb::const_),
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "PE/pyPE.hpp"
|
||||
#include "enums_wrapper.hpp"
|
||||
|
||||
#include "LIEF/PE/Header.hpp"
|
||||
|
||||
@@ -21,17 +22,62 @@
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
#include <nanobind/stl/array.h>
|
||||
#include <nanobind/stl/set.h>
|
||||
#include <nanobind/stl/vector.h>
|
||||
|
||||
#define PY_ENUM(x) to_string(x), x
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<Header>(nb::module_& m) {
|
||||
nb::class_<Header, LIEF::Object>(m, "Header",
|
||||
nb::class_<Header, Object> hdr(m, "Header",
|
||||
R"delim(
|
||||
Class that represents the PE header (which follows the :class:`lief.PE.DosHeader`)
|
||||
)delim"_doc)
|
||||
.def(nb::init<>())
|
||||
)delim"_doc);
|
||||
|
||||
enum_<Header::MACHINE_TYPES>(hdr, "MACHINE_TYPES")
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::UNKNOWN))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::AM33))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::AMD64))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::ARM))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::ARMNT))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::ARM64))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::EBC))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::I386))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::IA64))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::M32R))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::MIPS16))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::MIPSFPU))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::MIPSFPU16))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::POWERPC))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::POWERPCFP))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::R4000))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::SH3))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::SH3DSP))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::SH4))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::SH5))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::THUMB))
|
||||
.value(PY_ENUM(Header::MACHINE_TYPES::WCEMIPSV2));
|
||||
|
||||
enum_<Header::CHARACTERISTICS>(hdr, "CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::RELOCS_STRIPPED))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::EXECUTABLE_IMAGE))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::LINE_NUMS_STRIPPED))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::LOCAL_SYMS_STRIPPED))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::AGGRESSIVE_WS_TRIM))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::LARGE_ADDRESS_AWARE))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::BYTES_REVERSED_LO))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::NEED_32BIT_MACHINE))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::DEBUG_STRIPPED))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::REMOVABLE_RUN_FROM_SWAP))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::NET_RUN_FROM_SWAP))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::SYSTEM))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::DLL))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::UP_SYSTEM_ONLY))
|
||||
.value(PY_ENUM(Header::CHARACTERISTICS::BYTES_REVERSED_HI));
|
||||
|
||||
hdr
|
||||
.def_static("create", &Header::create, "type"_a)
|
||||
|
||||
.def_prop_rw("signature",
|
||||
nb::overload_cast<>(&Header::signature, nb::const_),
|
||||
@@ -42,8 +88,8 @@ void create<Header>(nb::module_& m) {
|
||||
|
||||
.def_prop_rw("machine",
|
||||
nb::overload_cast<>(&Header::machine, nb::const_),
|
||||
nb::overload_cast<MACHINE_TYPES>(&Header::machine),
|
||||
"The target machine architecture (" RST_CLASS_REF(lief.PE.MACHINE_TYPES) ")"_doc)
|
||||
nb::overload_cast<Header::MACHINE_TYPES>(&Header::machine),
|
||||
"The target machine architecture (" RST_CLASS_REF(lief.PE.Header.MACHINE_TYPES) ")"_doc)
|
||||
|
||||
.def_prop_rw("numberof_sections",
|
||||
nb::overload_cast<>(&Header::numberof_sections, nb::const_),
|
||||
@@ -91,26 +137,26 @@ void create<Header>(nb::module_& m) {
|
||||
.def_prop_rw("characteristics",
|
||||
nb::overload_cast<>(&Header::characteristics, nb::const_),
|
||||
nb::overload_cast<>(&Header::characteristics, nb::const_),
|
||||
"The " RST_CLASS_REF(lief.PE.HEADER_CHARACTERISTICS) " that indicate the attributes of the file."_doc)
|
||||
"The " RST_CLASS_REF(lief.PE.Header.CHARACTERISTICS) " that indicate the attributes of the file."_doc)
|
||||
|
||||
.def("has_characteristic",
|
||||
&Header::has_characteristic,
|
||||
"``True`` if the header has the given " RST_CLASS_REF(lief.PE.HEADER_CHARACTERISTICS) ""_doc,
|
||||
"``True`` if the header has the given " RST_CLASS_REF(lief.PE.Header.CHARACTERISTICS) ""_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def("add_characteristic",
|
||||
&Header::add_characteristic,
|
||||
"Add the given " RST_CLASS_REF(lief.PE.HEADER_CHARACTERISTICS) " to the header"_doc,
|
||||
"Add the given " RST_CLASS_REF(lief.PE.Header.CHARACTERISTICS) " to the header"_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def("remove_characteristic",
|
||||
&Header::remove_characteristic,
|
||||
"Remove the given " RST_CLASS_REF(lief.PE.HEADER_CHARACTERISTICS) " from the header"_doc,
|
||||
"Remove the given " RST_CLASS_REF(lief.PE.Header.CHARACTERISTICS) " from the header"_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def_prop_ro("characteristics_list",
|
||||
&Header::characteristics_list,
|
||||
"Return the " RST_CLASS_REF(lief.PE.HEADER_CHARACTERISTICS) " as a ``list``"_doc)
|
||||
"Return the " RST_CLASS_REF(lief.PE.Header.CHARACTERISTICS) " as a ``list``"_doc)
|
||||
|
||||
LIEF_COPYABLE(Header)
|
||||
LIEF_DEFAULT_STR(Header);
|
||||
|
||||
@@ -76,7 +76,7 @@ void create<Import>(nb::module_& m) {
|
||||
R"delim(
|
||||
Return the :class:`~lief.PE.DataDirectory` associated with this import.
|
||||
|
||||
It should be the one at index :attr:`lief.PE.DATA_DIRECTORY.IMPORT_TABLE`.
|
||||
It should be the one at index :attr:`lief.PE.DataDirectory.TYPES.IMPORT_TABLE`.
|
||||
It can return None if the Import directory can't be resolved.
|
||||
)delim"_doc,
|
||||
nb::rv_policy::reference_internal)
|
||||
@@ -86,7 +86,7 @@ void create<Import>(nb::module_& m) {
|
||||
R"delim(
|
||||
Return the :class:`~lief.PE.DataDirectory` associated with the ``IAT`` table.
|
||||
|
||||
It should be the one at index :attr:`lief.PE.DATA_DIRECTORY.IAT`. It can
|
||||
It should be the one at index :attr:`lief.PE.DataDirectory.TYPES.IAT`. It can
|
||||
return None if the IAT directory can't be resolved.
|
||||
)delim"_doc,
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "PE/pyPE.hpp"
|
||||
#include "enums_wrapper.hpp"
|
||||
|
||||
#include "LIEF/PE/OptionalHeader.hpp"
|
||||
|
||||
@@ -21,18 +22,51 @@
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
#include <nanobind/stl/vector.h>
|
||||
#include <nanobind/stl/set.h>
|
||||
#include <nanobind/operators.h>
|
||||
|
||||
#define PY_ENUM(x) to_string(x), x
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<OptionalHeader>(nb::module_& m) {
|
||||
nb::class_<OptionalHeader, LIEF::Object>(m, "OptionalHeader",
|
||||
nb::class_<OptionalHeader, Object> opt_header(m, "OptionalHeader",
|
||||
R"delim(
|
||||
Class which represents the PE OptionalHeader structure..
|
||||
)delim"_doc)
|
||||
.def(nb::init<>())
|
||||
Class which represents the PE OptionalHeader structure.
|
||||
)delim"_doc);
|
||||
|
||||
enum_<OptionalHeader::SUBSYSTEM>(opt_header, "SUBSYSTEM")
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::UNKNOWN))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::NATIVE))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::WINDOWS_GUI))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::WINDOWS_CUI))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::OS2_CUI))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::POSIX_CUI))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::NATIVE_WINDOWS))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::WINDOWS_CE_GUI))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::EFI_APPLICATION))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::EFI_BOOT_SERVICE_DRIVER))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::EFI_RUNTIME_DRIVER))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::EFI_ROM))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::XBOX))
|
||||
.value(PY_ENUM(OptionalHeader::SUBSYSTEM::WINDOWS_BOOT_APPLICATION));
|
||||
|
||||
enum_<OptionalHeader::DLL_CHARACTERISTICS>(opt_header, "DLL_CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::HIGH_ENTROPY_VA))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::DYNAMIC_BASE))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::FORCE_INTEGRITY))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::NX_COMPAT))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::NO_ISOLATION))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::NO_SEH))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::NO_BIND))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::APPCONTAINER))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::WDM_DRIVER))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::GUARD_CF))
|
||||
.value(PY_ENUM(OptionalHeader::DLL_CHARACTERISTICS::TERMINAL_SERVER_AWARE));
|
||||
|
||||
opt_header
|
||||
.def_static("create", OptionalHeader::create, "type"_a)
|
||||
|
||||
.def_prop_rw("magic",
|
||||
nb::overload_cast<>(&OptionalHeader::magic, nb::const_),
|
||||
nb::overload_cast<PE_TYPE>(&OptionalHeader::magic),
|
||||
@@ -53,7 +87,8 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
nb::overload_cast<uint32_t>(&OptionalHeader::sizeof_code),
|
||||
R"delim(
|
||||
The size of the code ``.text`` section or the sum of
|
||||
all the sections that contain code (ie. :class:`~lief.PE.Section` with the flag :attr:`~lief.PE.SECTION_CHARACTERISTICS.CNT_CODE`)
|
||||
all the sections that contain code (ie. :class:`~lief.PE.Section` with
|
||||
the flag :attr:`~lief.PE.Section.CHARACTERISTICS.CNT_CODE`)
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("sizeof_initialized_data",
|
||||
@@ -64,7 +99,7 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
If the initialized data are split across multiple sections, it is the sum of the sections.
|
||||
|
||||
The sections associated with the initialized data are usually identified with the
|
||||
flag :attr:`~lief.PE.SECTION_CHARACTERISTICS.CNT_INITIALIZED_DATA`
|
||||
flag :attr:`~lief.PE.Section.CHARACTERISTICS.CNT_INITIALIZED_DATA`
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("sizeof_uninitialized_data",
|
||||
@@ -75,7 +110,7 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
If the uninitialized data are split across multiple sections, it is the sum of the sections.
|
||||
|
||||
The sections associated with the uninitialized data are usually identified with the
|
||||
flag :attr:`~lief.PE.SECTION_CHARACTERISTICS.CNT_UNINITIALIZED_DATA`
|
||||
flag :attr:`~lief.PE.Section.CHARACTERISTICS.CNT_UNINITIALIZED_DATA`
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("addressof_entrypoint",
|
||||
@@ -193,7 +228,6 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
time, and any **DLL** that is loaded into a **critical** Windows process.
|
||||
)delim"_doc)
|
||||
|
||||
|
||||
.def_prop_ro("computed_checksum",
|
||||
&OptionalHeader::computed_checksum,
|
||||
R"delim(
|
||||
@@ -206,38 +240,38 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
|
||||
.def_prop_rw("subsystem",
|
||||
nb::overload_cast<>(&OptionalHeader::subsystem, nb::const_),
|
||||
nb::overload_cast<SUBSYSTEM>(&OptionalHeader::subsystem),
|
||||
nb::overload_cast<OptionalHeader::SUBSYSTEM>(&OptionalHeader::subsystem),
|
||||
R"delim(
|
||||
Target subsystem (:class:`~lief.PE.SUBSYSTEM`) like Driver, XBox, Windows GUI, ..
|
||||
Target subsystem (:class:`~lief.PE.OptionalHeader.SUBSYSTEM`) like Driver, XBox, Windows GUI, ..
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("dll_characteristics",
|
||||
nb::overload_cast<>(&OptionalHeader::dll_characteristics, nb::const_),
|
||||
nb::overload_cast<uint32_t>(&OptionalHeader::dll_characteristics),
|
||||
R"delim(
|
||||
Some characteristics (:class:`~lief.PE.DLL_CHARACTERISTICS`) of the underlying binary like the support of the PIE.
|
||||
Some characteristics (:class:`~lief.PE.OptionalHeader.DLL_CHARACTERISTICS`) of the underlying binary like the support of the PIE.
|
||||
|
||||
The prefix ``dll`` comes from the official PE specifications but these characteristics
|
||||
are also used for **executables**
|
||||
)delim"_doc)
|
||||
|
||||
.def("add",
|
||||
nb::overload_cast<DLL_CHARACTERISTICS>(&OptionalHeader::add),
|
||||
"Add the given " RST_CLASS_REF(lief.PE.DLL_CHARACTERISTICS) ""_doc,
|
||||
nb::overload_cast<OptionalHeader::DLL_CHARACTERISTICS>(&OptionalHeader::add),
|
||||
"Add the given " RST_CLASS_REF(lief.PE.OptionalHeader.DLL_CHARACTERISTICS) ""_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def("remove",
|
||||
nb::overload_cast<DLL_CHARACTERISTICS>(&OptionalHeader::remove),
|
||||
"Remove the given " RST_CLASS_REF(lief.PE.DLL_CHARACTERISTICS) ""_doc,
|
||||
nb::overload_cast<OptionalHeader::DLL_CHARACTERISTICS>(&OptionalHeader::remove),
|
||||
"Remove the given " RST_CLASS_REF(lief.PE.OptionalHeader.DLL_CHARACTERISTICS) ""_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def_prop_ro("dll_characteristics_lists",
|
||||
&OptionalHeader::dll_characteristics_list,
|
||||
":attr:`~lief.PE.OptionalHeader.dll_characteristics` as a list of " RST_CLASS_REF(lief.PE.DLL_CHARACTERISTICS) ""_doc)
|
||||
":attr:`~lief.PE.OptionalHeader.dll_characteristics` as a list of " RST_CLASS_REF(lief.PE.OptionalHeader.DLL_CHARACTERISTICS) ""_doc)
|
||||
|
||||
.def("has",
|
||||
nb::overload_cast<DLL_CHARACTERISTICS>(&OptionalHeader::has, nb::const_),
|
||||
"``True`` if the given " RST_CLASS_REF(lief.PE.DLL_CHARACTERISTICS) " is in the "
|
||||
nb::overload_cast<OptionalHeader::DLL_CHARACTERISTICS>(&OptionalHeader::has, nb::const_),
|
||||
"``True`` if the given " RST_CLASS_REF(lief.PE.OptionalHeader.DLL_CHARACTERISTICS) " is in the "
|
||||
":attr:`~lief.PE.OptionalHeader.dll_characteristics`"_doc,
|
||||
"characteristics"_a)
|
||||
|
||||
@@ -281,12 +315,12 @@ void create<OptionalHeader>(nb::module_& m) {
|
||||
nb::overload_cast<uint32_t>(&OptionalHeader::numberof_rva_and_size),
|
||||
"The number of " RST_CLASS_REF(lief.PE.DataDirectory) " that follow this header"_doc)
|
||||
|
||||
.def(nb::self += DLL_CHARACTERISTICS(), nb::rv_policy::reference_internal)
|
||||
.def(nb::self -= DLL_CHARACTERISTICS(), nb::rv_policy::reference_internal)
|
||||
.def(nb::self += OptionalHeader::DLL_CHARACTERISTICS(), nb::rv_policy::reference_internal)
|
||||
.def(nb::self -= OptionalHeader::DLL_CHARACTERISTICS(), nb::rv_policy::reference_internal)
|
||||
|
||||
.def("__contains__",
|
||||
nb::overload_cast<DLL_CHARACTERISTICS>(&OptionalHeader::has, nb::const_),
|
||||
"Check if the given " RST_CLASS_REF(lief.PE.DLL_CHARACTERISTICS) " is present"_doc)
|
||||
nb::overload_cast<OptionalHeader::DLL_CHARACTERISTICS>(&OptionalHeader::has, nb::const_),
|
||||
"Check if the given " RST_CLASS_REF(lief.PE.OptionalHeader.DLL_CHARACTERISTICS) " is present"_doc)
|
||||
|
||||
LIEF_COPYABLE(OptionalHeader)
|
||||
LIEF_DEFAULT_STR(OptionalHeader);
|
||||
|
||||
@@ -16,22 +16,64 @@
|
||||
#include "PE/pyPE.hpp"
|
||||
|
||||
#include "LIEF/PE/Section.hpp"
|
||||
#include "enums_wrapper.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
#include <nanobind/stl/set.h>
|
||||
|
||||
#define PY_ENUM(x) to_string(x), x
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<Section>(nb::module_& m) {
|
||||
nb::class_<Section, LIEF::Section>(m, "Section",
|
||||
nb::class_<Section, LIEF::Section> sec(m, "Section",
|
||||
R"delim(
|
||||
Class which represents a PE section.
|
||||
|
||||
It extends the base class :class:`lief.Section`
|
||||
)delim"_doc)
|
||||
)delim"_doc);
|
||||
|
||||
enum_<Section::CHARACTERISTICS>(sec, "CHARACTERISTICS", nb::is_arithmetic())
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::TYPE_NO_PAD))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::CNT_CODE))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::CNT_INITIALIZED_DATA))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::CNT_UNINITIALIZED_DATA))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::LNK_OTHER))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::LNK_INFO))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::LNK_REMOVE))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::LNK_COMDAT))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::GPREL))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_PURGEABLE))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_16BIT))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_LOCKED))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_PRELOAD))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_1BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_2BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_4BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_8BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_16BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_32BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_64BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_128BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_256BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_512BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_1024BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_2048BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_4096BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::ALIGN_8192BYTES))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::LNK_NRELOC_OVFL))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_DISCARDABLE))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_NOT_CACHED))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_NOT_PAGED))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_SHARED))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_EXECUTE))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_READ))
|
||||
.value(PY_ENUM(Section::CHARACTERISTICS::MEM_WRITE));
|
||||
|
||||
sec
|
||||
.def(nb::init<>())
|
||||
.def(nb::init<const std::vector<uint8_t>&, const std::string&, uint32_t>(),
|
||||
"Constructor from "
|
||||
@@ -51,7 +93,8 @@ void create<Section>(nb::module_& m) {
|
||||
R"delim(
|
||||
The total size of the section when loaded into memory.
|
||||
|
||||
If this value is greater than :attr:`~lief.PE.Section.sizeof_raw_data`, the section is zero-padded.
|
||||
If this value is greater than :attr:`~lief.PE.Section.sizeof_raw_data`,
|
||||
the section is zero-padded.
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("sizeof_raw_data",
|
||||
@@ -68,8 +111,9 @@ void create<Section>(nb::module_& m) {
|
||||
nb::overload_cast<>(&Section::pointerto_relocation, nb::const_),
|
||||
nb::overload_cast<uint32_t>(&Section::pointerto_relocation),
|
||||
R"delim(
|
||||
The file pointer to the beginning of the COFF relocation entries for the section. This is set to zero for
|
||||
executable images or if there are no relocations.
|
||||
The file pointer to the beginning of the COFF relocation entries for
|
||||
the section. This is set to zero for executable images or if there are
|
||||
no relocations.
|
||||
|
||||
For modern PE binaries, this value is usually set to 0 as the relocations are managed by
|
||||
:class:`~lief.PE.Relocation`.
|
||||
@@ -80,8 +124,9 @@ void create<Section>(nb::module_& m) {
|
||||
nb::overload_cast<uint32_t>(&Section::pointerto_line_numbers),
|
||||
R"delim(
|
||||
The file pointer to the beginning of line-number entries for the section.
|
||||
This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF
|
||||
debugging information is deprecated and modern debug information relies on the PDB files.
|
||||
This is set to zero if there are no COFF line numbers. This value should
|
||||
be zero for an image because COFF debugging information is deprecated
|
||||
and modern debug information relies on the PDB files.
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_rw("numberof_relocations",
|
||||
@@ -108,7 +153,7 @@ void create<Section>(nb::module_& m) {
|
||||
.def_prop_rw("characteristics",
|
||||
nb::overload_cast<>(&Section::characteristics, nb::const_),
|
||||
nb::overload_cast<uint32_t>(&Section::characteristics),
|
||||
"The " RST_CLASS_REF(lief.PE.SECTION_CHARACTERISTICS) " that describe the characteristics of the section"_doc)
|
||||
"The " RST_CLASS_REF(lief.PE.Section.CHARACTERISTICS) " that describe the characteristics of the section"_doc)
|
||||
|
||||
.def_prop_ro("characteristics_lists",
|
||||
&Section::characteristics_list,
|
||||
@@ -116,7 +161,7 @@ void create<Section>(nb::module_& m) {
|
||||
|
||||
.def("has_characteristic",
|
||||
&Section::has_characteristic,
|
||||
"``True`` if the section has the given " RST_CLASS_REF(lief.PE.SECTION_CHARACTERISTICS) ""_doc,
|
||||
"``True`` if the section has the given " RST_CLASS_REF(lief.PE.Section.CHARACTERISTICS) ""_doc,
|
||||
"characteristic"_a)
|
||||
|
||||
.def_prop_ro("padding",
|
||||
|
||||
@@ -42,7 +42,7 @@ void create<TLS>(nb::module_& m) {
|
||||
|
||||
.def_prop_rw("callbacks",
|
||||
nb::overload_cast<>(&TLS::callbacks, nb::const_),
|
||||
nb::overload_cast<const std::vector<uint64_t>&>(&TLS::callbacks),
|
||||
nb::overload_cast<std::vector<uint64_t>>(&TLS::callbacks),
|
||||
R"delim(
|
||||
List of the callback associated with the current TLS.
|
||||
|
||||
@@ -110,7 +110,7 @@ void create<TLS>(nb::module_& m) {
|
||||
const span<const uint8_t> content = self.data_template();
|
||||
return nb::memoryview::from_memory(content.data(), content.size());
|
||||
},
|
||||
nb::overload_cast<const std::vector<uint8_t>&>(&TLS::data_template),
|
||||
nb::overload_cast<std::vector<uint8_t>>(&TLS::data_template),
|
||||
"The data template content"_doc)
|
||||
|
||||
.def_prop_ro("has_section",
|
||||
|
||||
@@ -4,7 +4,11 @@ set(LIEF_PYTHON_PE_SIG_SRC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pyRsaInfo.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pyx509.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pyContentInfo.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pyGenericContent.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pySpcIndirectData.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pySignature.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pySpcIndirectData.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pyGenericContent.cpp"
|
||||
)
|
||||
|
||||
target_sources(pyLIEF PRIVATE "${LIEF_PYTHON_PE_SIG_SRC}")
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace LIEF::PE::py {
|
||||
template<>
|
||||
void create<ContentInfo>(nb::module_& m) {
|
||||
|
||||
nb::class_<ContentInfo, LIEF::Object>(m, "ContentInfo",
|
||||
nb::class_<ContentInfo, Object> info(m, "ContentInfo",
|
||||
R"delim(
|
||||
ContentInfo as described in the `RFC 2315 <https://tools.ietf.org/html/rfc2315#section-7>`_
|
||||
|
||||
@@ -69,25 +69,22 @@ void create<ContentInfo>(nb::module_& m) {
|
||||
algorithm ObjectID,
|
||||
parameters [0] EXPLICIT ANY OPTIONAL
|
||||
}
|
||||
)delim"_doc)
|
||||
)delim"_doc);
|
||||
|
||||
nb::class_<ContentInfo::Content, Object>(info, "Content")
|
||||
.def_prop_ro("content_type",
|
||||
&ContentInfo::Content::content_type,
|
||||
"OID of the content type. This value should match ``SPC_INDIRECT_DATA_OBJID``"_doc)
|
||||
LIEF_CLONABLE(ContentInfo::Content);
|
||||
|
||||
info
|
||||
.def_prop_ro("content_type",
|
||||
&ContentInfo::content_type,
|
||||
"OID of the content type. This value should match ``SPC_INDIRECT_DATA_OBJID``"_doc)
|
||||
|
||||
.def_prop_ro("digest_algorithm",
|
||||
&ContentInfo::digest_algorithm,
|
||||
"Algorithm (" RST_CLASS_REF(lief.PE.ALGORITHMS) ") used to hash the file. "
|
||||
"This value should match " RST_ATTR_REF_FULL(SignerInfo.digest_algorithm) " and "
|
||||
"" RST_ATTR_REF_FULL(Signature.digest_algorithm) ""_doc)
|
||||
|
||||
.def_prop_ro("digest",
|
||||
[] (const ContentInfo& info) -> nb::bytes {
|
||||
const std::vector<uint8_t>& dg = info.digest();
|
||||
return nb::bytes(reinterpret_cast<const char*>(dg.data()), dg.size());
|
||||
},
|
||||
"The digest as ``bytes``. It should match the binary :meth:`~lief.PE.Binary.authentihash`"_doc)
|
||||
"An alias for :attr:`~.ContentInfo.content_type`"_doc)
|
||||
.def_prop_ro("value", nb::overload_cast<>(&ContentInfo::value),
|
||||
nb::rv_policy::reference_internal)
|
||||
|
||||
LIEF_COPYABLE(ContentInfo)
|
||||
LIEF_DEFAULT_STR(ContentInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 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
|
||||
*
|
||||
* http://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 "PE/pyPE.hpp"
|
||||
|
||||
#include "LIEF/PE/signature/GenericContent.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<GenericContent>(nb::module_& m) {
|
||||
nb::class_<GenericContent, ContentInfo::Content>(m, "GenericContent");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 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
|
||||
*
|
||||
* http://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 "PE/pyPE.hpp"
|
||||
|
||||
#include "LIEF/PE/signature/SpcIndirectData.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <nanobind/stl/string.h>
|
||||
#include <nanobind/extra/memoryview.hpp>
|
||||
|
||||
namespace LIEF::PE::py {
|
||||
|
||||
template<>
|
||||
void create<SpcIndirectData>(nb::module_& m) {
|
||||
nb::class_<SpcIndirectData, ContentInfo::Content>(m, "SpcIndirectData")
|
||||
.def_prop_ro("digest_algorithm", &SpcIndirectData::digest_algorithm,
|
||||
R"delim(
|
||||
Digest used to hash the file. This should match
|
||||
:attr:`~lief.PE.SignerInfo.digest_algorithm`
|
||||
)delim"_doc)
|
||||
|
||||
.def_prop_ro("digest", [] (const SpcIndirectData& sid) {
|
||||
const span<const uint8_t> digest = sid.digest();
|
||||
return nb::memoryview::from_memory(digest.data(), digest.size());
|
||||
})
|
||||
.def_prop_ro("file", &SpcIndirectData::file)
|
||||
LIEF_DEFAULT_STR(SpcIndirectData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,79 +69,74 @@ endif()
|
||||
#ADD_FLAG_IF_SUPPORTED("-Wduplicated-branches" HAS_DUPLICATED_BRANCHES)
|
||||
#ADD_FLAG_IF_SUPPORTED("-Wlogical-op" HAS_LOGICAL_OP)
|
||||
#ADD_FLAG_IF_SUPPORTED("-Wshadow" HAS_SHADOW)
|
||||
# =========================================
|
||||
# MSVC FLAGS
|
||||
# This part is inspired from LLVM:
|
||||
# https://github.com/llvm-mirror/llvm/blob/a86576d8771c89502d239f0b85a1a6992020aa47/cmake/modules/HandleLLVMOptions.cmake
|
||||
# =========================================
|
||||
set(msvc_warning_flags
|
||||
# Disabled warnings.
|
||||
-wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
|
||||
-wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
|
||||
-wd4180 # Suppress 'qualifier applied to function type has no meaning; ignored'
|
||||
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
|
||||
-wd4258 # Suppress ''var' : definition from the for loop is ignored; the definition from the enclosing scope is used'
|
||||
-wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
|
||||
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
|
||||
-wd4345 # Suppress 'behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized'
|
||||
-wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
|
||||
-wd4355 # Suppress ''this' : used in base member initializer list'
|
||||
-wd4456 # Suppress 'declaration of 'var' hides local variable'
|
||||
-wd4457 # Suppress 'declaration of 'var' hides function parameter'
|
||||
-wd4458 # Suppress 'declaration of 'var' hides class member'
|
||||
-wd4459 # Suppress 'declaration of 'var' hides global declaration'
|
||||
-wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
|
||||
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
|
||||
-wd4722 # Suppress 'function' : destructor never returns, potential memory leak
|
||||
-wd4800 # Suppress ''type' : forcing value to bool 'true' or 'false' (performance warning)'
|
||||
-wd4100 # Suppress 'unreferenced formal parameter'
|
||||
-wd4127 # Suppress 'conditional expression is constant'
|
||||
-wd4512 # Suppress 'assignment operator could not be generated'
|
||||
-wd4505 # Suppress 'unreferenced local function has been removed'
|
||||
-wd4610 # Suppress '<class> can never be instantiated'
|
||||
-wd4510 # Suppress 'default constructor could not be generated'
|
||||
-wd4702 # Suppress 'unreachable code'
|
||||
-wd4245 # Suppress 'signed/unsigned mismatch'
|
||||
-wd4706 # Suppress 'assignment within conditional expression'
|
||||
-wd4310 # Suppress 'cast truncates constant value'
|
||||
-wd4701 # Suppress 'potentially uninitialized local variable'
|
||||
-wd4703 # Suppress 'potentially uninitialized local pointer variable'
|
||||
-wd4389 # Suppress 'signed/unsigned mismatch'
|
||||
-wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
|
||||
-wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
|
||||
-wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
|
||||
-wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
|
||||
-wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
|
||||
# C4592 is disabled because of false positives in Visual Studio 2015
|
||||
# Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
|
||||
-wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
|
||||
-wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
|
||||
-wd4710 # Suppress 'function not inlined'
|
||||
-wd4820 # Suppress 'XXX bytes padding added after data member'
|
||||
-wd4514 # Suppress 'unreferenced inline function has been removed'
|
||||
if(MSVC AND NOT CLANG_CL)
|
||||
set(msvc_warning_flags
|
||||
# Disabled warnings.
|
||||
-wd4141 # Suppress ''modifier' : used more than once' (because of __forceinline combined with inline)
|
||||
-wd4146 # Suppress 'unary minus operator applied to unsigned type, result still unsigned'
|
||||
-wd4244 # Suppress ''argument' : conversion from 'type1' to 'type2', possible loss of data'
|
||||
-wd4267 # Suppress ''var' : conversion from 'size_t' to 'type', possible loss of data'
|
||||
-wd4291 # Suppress ''declaration' : no matching operator delete found; memory will not be freed if initialization throws an exception'
|
||||
-wd4351 # Suppress 'new behavior: elements of array 'array' will be default initialized'
|
||||
-wd4456 # Suppress 'declaration of 'var' hides local variable'
|
||||
-wd4457 # Suppress 'declaration of 'var' hides function parameter'
|
||||
-wd4458 # Suppress 'declaration of 'var' hides class member'
|
||||
-wd4459 # Suppress 'declaration of 'var' hides global declaration'
|
||||
-wd4503 # Suppress ''identifier' : decorated name length exceeded, name was truncated'
|
||||
-wd4624 # Suppress ''derived class' : destructor could not be generated because a base class destructor is inaccessible'
|
||||
-wd4722 # Suppress 'function' : destructor never returns, potential memory leak
|
||||
-wd4100 # Suppress 'unreferenced formal parameter'
|
||||
-wd4127 # Suppress 'conditional expression is constant'
|
||||
-wd4512 # Suppress 'assignment operator could not be generated'
|
||||
-wd4505 # Suppress 'unreferenced local function has been removed'
|
||||
-wd4610 # Suppress '<class> can never be instantiated'
|
||||
-wd4510 # Suppress 'default constructor could not be generated'
|
||||
-wd4702 # Suppress 'unreachable code'
|
||||
-wd4245 # Suppress ''conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch'
|
||||
-wd4706 # Suppress 'assignment within conditional expression'
|
||||
-wd4310 # Suppress 'cast truncates constant value'
|
||||
-wd4701 # Suppress 'potentially uninitialized local variable'
|
||||
-wd4703 # Suppress 'potentially uninitialized local pointer variable'
|
||||
-wd4389 # Suppress 'signed/unsigned mismatch'
|
||||
-wd4611 # Suppress 'interaction between '_setjmp' and C++ object destruction is non-portable'
|
||||
-wd4805 # Suppress 'unsafe mix of type <type> and type <type> in operation'
|
||||
-wd4204 # Suppress 'nonstandard extension used : non-constant aggregate initializer'
|
||||
-wd4577 # Suppress 'noexcept used with no exception handling mode specified; termination on exception is not guaranteed'
|
||||
-wd4091 # Suppress 'typedef: ignored on left of '' when no variable is declared'
|
||||
# C4592 is disabled because of false positives in Visual Studio 2015
|
||||
# Update 1. Re-evaluate the usefulness of this diagnostic with Update 2.
|
||||
-wd4592 # Suppress ''var': symbol will be dynamically initialized (implementation limitation)
|
||||
-wd4319 # Suppress ''operator' : zero extending 'type' to 'type' of greater size'
|
||||
# C4709 is disabled because of a bug with Visual Studio 2017 as of
|
||||
# v15.8.8. Re-evaluate the usefulness of this diagnostic when the bug
|
||||
# is fixed.
|
||||
-wd4709 # Suppress comma operator within array index expression
|
||||
|
||||
# Ideally, we'd like this warning to be enabled, but MSVC 2013 doesn't
|
||||
# support the 'aligned' attribute in the way that clang sources requires (for
|
||||
# any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
|
||||
# avoid unwanted alignment warnings.
|
||||
# When we switch to requiring a version of MSVC that supports the 'alignas'
|
||||
# specifier (MSVC 2015?) this warning can be re-enabled.
|
||||
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
|
||||
# We'd like this warning to be enabled, but it triggers from code in
|
||||
# WinBase.h that we don't have control over.
|
||||
-wd5105 # Suppress macro expansion producing 'defined' has undefined behavior
|
||||
|
||||
# Promoted warnings.
|
||||
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
|
||||
# Ideally, we'd like this warning to be enabled, but even MSVC 2019 doesn't
|
||||
# support the 'aligned' attribute in the way that clang sources requires (for
|
||||
# any code that uses the LLVM_ALIGNAS macro), so this is must be disabled to
|
||||
# avoid unwanted alignment warnings.
|
||||
-wd4324 # Suppress 'structure was padded due to __declspec(align())'
|
||||
|
||||
# Promoted warnings to errors.
|
||||
-we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
|
||||
)
|
||||
# Promoted warnings.
|
||||
-w14062 # Promote 'enumerator in switch of enum is not handled' to level 1 warning.
|
||||
|
||||
# Promoted warnings to errors.
|
||||
-we4238 # Promote 'nonstandard extension used : class rvalue used as lvalue' to error.
|
||||
|
||||
-wd4530 # Supress C++ exception handler used, but unwind semantics are not enabled
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
set(msvc_warning_flags "/W4 ${msvc_warning_flags}")
|
||||
string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
#foreach(flag ${msvc_warning_flags})
|
||||
# target_compile_options(LIB_LIEF PRIVATE ${flag})
|
||||
#endforeach(flag)
|
||||
foreach(flag ${msvc_warning_flags})
|
||||
append("${flag}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
||||
endforeach(flag)
|
||||
endif()
|
||||
|
||||
# Speed up MSVC build
|
||||
|
||||
@@ -67,8 +67,8 @@ option(LIEF_OPT_UTFCPP_EXTERNAL OFF)
|
||||
# This option enables to provide an external version of MbedTLS
|
||||
option(LIEF_OPT_MBEDTLS_EXTERNAL OFF)
|
||||
|
||||
# This option enables to provide an external version of pybind11
|
||||
option(LIEF_OPT_PYBIND11_EXTERNAL OFF)
|
||||
# This option enables to provide an external version of nanobind
|
||||
option(LIEF_OPT_NANOBIND_EXTERNAL OFF)
|
||||
|
||||
# This option enables to provide an external
|
||||
# version of https://github.com/tcbrindle/span (e.g. present on the system)
|
||||
@@ -80,6 +80,7 @@ set(_LIEF_USE_FROZEN ON)
|
||||
if(LIEF_DISABLE_FROZEN)
|
||||
set(_LIEF_USE_FROZEN OFF)
|
||||
endif()
|
||||
|
||||
cmake_dependent_option(LIEF_OPT_FROZEN_EXTERNAL "Use an external provided version of Frozen" OFF
|
||||
"_LIEF_USE_FROZEN" OFF)
|
||||
|
||||
@@ -175,8 +176,8 @@ if(LIEF_OPT_EXTERNAL_SPAN)
|
||||
endif()
|
||||
|
||||
if(LIEF_PYTHON_API)
|
||||
if(LIEF_OPT_PYBIND11_EXTERNAL)
|
||||
set(LIEF_EXTERNAL_PYBIND11 1)
|
||||
if(LIEF_OPT_NANOBIND_EXTERNAL)
|
||||
set(LIEF_EXTERNAL_NANOBIND 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
+18
-18
@@ -275,6 +275,24 @@ Signature SpcSpOpusInfo
|
||||
:project: lief
|
||||
|
||||
|
||||
----------
|
||||
|
||||
Signature SpcIndirectData
|
||||
*************************
|
||||
|
||||
.. doxygenclass:: LIEF::PE::SpcIndirectData
|
||||
:project: lief
|
||||
|
||||
|
||||
----------
|
||||
|
||||
Signature GenericContent
|
||||
************************
|
||||
|
||||
.. doxygenclass:: LIEF::PE::GenericContent
|
||||
:project: lief
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
@@ -612,12 +630,6 @@ Utilities
|
||||
Enums
|
||||
*****
|
||||
|
||||
.. doxygenenum:: LIEF::PE::MACHINE_TYPES
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::HEADER_CHARACTERISTICS
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::SYMBOL_STORAGE_CLASS
|
||||
:project: lief
|
||||
|
||||
@@ -639,18 +651,6 @@ Enums
|
||||
.. doxygenenum:: LIEF::PE::RELOCATIONS_ARM
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::DATA_DIRECTORY
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::SUBSYSTEM
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::DLL_CHARACTERISTICS
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::DEBUG_TYPES
|
||||
:project: lief
|
||||
|
||||
.. doxygenenum:: LIEF::PE::RESOURCE_TYPES
|
||||
:project: lief
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ Binary
|
||||
******
|
||||
|
||||
.. autoclass:: lief.Binary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -23,9 +20,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -34,9 +28,6 @@ Section
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.Section
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -44,9 +35,6 @@ Symbol
|
||||
******
|
||||
|
||||
.. autoclass:: lief.Symbol
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -55,9 +43,6 @@ Relocation
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.Relocation
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -66,9 +51,6 @@ Function
|
||||
********
|
||||
|
||||
.. autoclass:: lief.Function
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
@@ -80,9 +62,6 @@ Executable formats
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.EXE_FORMATS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -91,9 +70,6 @@ Object types
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.OBJECT_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -102,9 +78,6 @@ Architectures
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ARCHITECTURES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -112,9 +85,6 @@ Modes
|
||||
~~~~~
|
||||
|
||||
.. autoclass:: lief.MODES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -122,10 +92,3 @@ Endianness
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ENDIANNESS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,9 +25,6 @@ File
|
||||
****
|
||||
|
||||
.. autoclass:: lief.ART.File
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -35,9 +32,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.ART.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ File
|
||||
****
|
||||
|
||||
.. autoclass:: lief.DEX.File
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -33,9 +30,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.DEX.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -44,9 +38,6 @@ Method
|
||||
******
|
||||
|
||||
.. autoclass:: lief.DEX.Method
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -55,9 +46,6 @@ Field
|
||||
*****
|
||||
|
||||
.. autoclass:: lief.DEX.Field
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -67,9 +55,6 @@ Class
|
||||
******
|
||||
|
||||
.. autoclass:: lief.DEX.Class
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -77,9 +62,6 @@ Code Info
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.DEX.CodeInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -88,9 +70,6 @@ Prototype
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.DEX.Prototype
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -99,9 +78,6 @@ Type
|
||||
****
|
||||
|
||||
.. autoclass:: lief.DEX.Type
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -109,9 +85,6 @@ MapList
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.DEX.MapList
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -119,9 +92,6 @@ MapItem
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.DEX.MapItem
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -134,16 +104,3 @@ Access Flags
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.DEX.ACCESS_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,10 +7,6 @@ Parser
|
||||
.. autofunction:: lief.ELF.parse
|
||||
|
||||
.. autoclass:: lief.ELF.ParserConfig
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -18,9 +14,6 @@ Binary
|
||||
******
|
||||
|
||||
.. autoclass:: lief.ELF.Binary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -28,9 +21,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.ELF.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -38,9 +28,6 @@ Section
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.ELF.Section
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -48,9 +35,6 @@ Segment
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.ELF.Segment
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -58,9 +42,6 @@ Dynamic Entry
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -68,9 +49,6 @@ Dynamic Entry Library
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntryLibrary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -78,9 +56,6 @@ Dynamic Shared Object
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicSharedObject
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -88,9 +63,6 @@ Dynamic Entry Run Path
|
||||
**********************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntryRunPath
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -98,9 +70,6 @@ Dynamic Entry RPath
|
||||
*******************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntryRpath
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -108,9 +77,6 @@ Dynamic Entry Array
|
||||
*******************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntryArray
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -118,9 +84,6 @@ Dynamic Entry Flags
|
||||
*******************
|
||||
|
||||
.. autoclass:: lief.ELF.DynamicEntryFlags
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -129,9 +92,6 @@ Relocations
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.ELF.Relocation
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -139,9 +99,6 @@ Symbol
|
||||
******
|
||||
|
||||
.. autoclass:: lief.ELF.Symbol
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -149,9 +106,6 @@ Symbol Version
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.ELF.SymbolVersion
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -159,9 +113,6 @@ Symbol Version Auxiliary
|
||||
************************
|
||||
|
||||
.. autoclass:: lief.ELF.SymbolVersionAux
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -169,9 +120,6 @@ Symbol Version Definition
|
||||
*************************
|
||||
|
||||
.. autoclass:: lief.ELF.SymbolVersionDefinition
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -179,9 +127,6 @@ Symbol Version Requirement
|
||||
**************************
|
||||
|
||||
.. autoclass:: lief.ELF.SymbolVersionRequirement
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -189,42 +134,27 @@ Symbol Version Auxiliary Requirement
|
||||
************************************
|
||||
|
||||
.. autoclass:: lief.ELF.SymbolVersionAuxRequirement
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
GNU Hash table
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.ELF.GnuHash
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
SYSV Hash table
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.ELF.SysvHash
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Note
|
||||
****
|
||||
|
||||
.. autoclass:: lief.ELF.Note
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -232,9 +162,6 @@ Note Details
|
||||
************
|
||||
|
||||
.. autoclass:: lief.ELF.NoteDetails
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -242,9 +169,6 @@ Core PrPsInfo
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.ELF.CorePrPsInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -252,9 +176,6 @@ Core PrStatus
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.ELF.CorePrStatus
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -262,20 +183,13 @@ Core File
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.ELF.CoreFile
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Core File Entry
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.ELF.CoreFileEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -284,20 +198,13 @@ Core Siginfo
|
||||
************
|
||||
|
||||
.. autoclass:: lief.ELF.CoreSigInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Core Auxiliary Vector
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.ELF.CoreAuxv
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -305,9 +212,6 @@ Android Note
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.ELF.AndroidNote
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -315,21 +219,13 @@ Note ABI
|
||||
********
|
||||
|
||||
.. autoclass:: lief.ELF.NoteAbi
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Builder
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.ELF.Builder
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
Enums
|
||||
*****
|
||||
@@ -338,20 +234,13 @@ Identity
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.IDENTITY
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
ELF Class
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.ELF_CLASS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -359,9 +248,6 @@ ELF Data
|
||||
~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.ELF_DATA
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -369,31 +255,20 @@ ELF OS/ABI
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.OS_ABI
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Symbol section index
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SYMBOL_SECTION_INDEX
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Binary types
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.E_TYPE
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -401,9 +276,6 @@ Section types
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SECTION_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -411,9 +283,6 @@ Section flags
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SECTION_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -422,9 +291,6 @@ Segment types
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SEGMENT_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -432,9 +298,6 @@ Segment flags
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SEGMENT_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -443,9 +306,6 @@ Architectures
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.ARCH
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -453,9 +313,6 @@ Version
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.VERSION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -463,9 +320,6 @@ Dynamic tags
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.DYNAMIC_TAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -473,9 +327,6 @@ Dynamic flags
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.DYNAMIC_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -484,9 +335,6 @@ Dynamic flags 1
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.DYNAMIC_FLAGS_1
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -495,9 +343,6 @@ Symbol types
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SYMBOL_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -505,9 +350,6 @@ Symbol bindings
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SYMBOL_BINDINGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -516,9 +358,6 @@ Symbol Visibility
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.SYMBOL_VISIBILITY
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -526,9 +365,6 @@ Relocations x86-64
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_X86_64
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -537,9 +373,6 @@ Relocations x86 (i386)
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_i386
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -547,9 +380,6 @@ Relocations ARM
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_ARM
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -558,9 +388,6 @@ Relocations AARCH64
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_AARCH64
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -568,9 +395,6 @@ Relocations MIPS
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_MIPS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -579,9 +403,6 @@ Relocations PPC
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_PPC
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -590,9 +411,6 @@ Relocations PPC64
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_PPC64
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -601,9 +419,6 @@ Dynamic symbols counting
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.DYNSYM_COUNT_METHODS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -611,31 +426,20 @@ Relocation purpose
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.RELOCATION_PURPOSES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Note types
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.NOTE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Note ABIs
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.NOTE_ABIS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -644,9 +448,6 @@ Note Core types
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.NOTE_TYPES_CORE
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -654,9 +455,6 @@ ARM Processor flags
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.ARM_EFLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -664,9 +462,6 @@ MIPS Processor flags
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.MIPS_EFLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -674,17 +469,11 @@ PPC64 Processor flags
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.PPC64_EFLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Hexagon Processor flags
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.ELF.HEXAGON_EFLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ Logging levels
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.logging.LOGGING_LEVEL
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
.. _python-api-error-handling:
|
||||
|
||||
@@ -55,14 +52,8 @@ Error Handling
|
||||
--------------
|
||||
|
||||
.. autoclass:: lief.lief_errors
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: lief.ok_t
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
See also the section :ref:`err_handling`
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@ Parser
|
||||
.. autofunction:: lief.MachO.parse
|
||||
|
||||
.. autoclass:: lief.MachO.ParserConfig
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -26,9 +23,6 @@ FatBinary
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.MachO.FatBinary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -39,9 +33,6 @@ Binary
|
||||
******
|
||||
|
||||
.. autoclass:: lief.MachO.Binary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -49,9 +40,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.MachO.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -60,9 +48,6 @@ Section
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.MachO.Section
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -71,9 +56,6 @@ SegmentCommand
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.MachO.SegmentCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -82,9 +64,6 @@ LoadCommand
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.MachO.LoadCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -93,9 +72,6 @@ DylibCommand
|
||||
************
|
||||
|
||||
.. autoclass:: lief.MachO.DylibCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -104,9 +80,6 @@ DylinkerCommand
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.DylinkerCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -115,9 +88,6 @@ UUIDCommand
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.MachO.UUIDCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -127,9 +97,6 @@ MainCommand
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.MachO.MainCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -138,9 +105,6 @@ Symbol
|
||||
******
|
||||
|
||||
.. autoclass:: lief.MachO.Symbol
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -149,9 +113,6 @@ Symbol Command
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.MachO.SymbolCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -159,9 +120,6 @@ Dynamic Symbol Command
|
||||
**********************
|
||||
|
||||
.. autoclass:: lief.MachO.DynamicSymbolCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -169,9 +127,6 @@ Dyld Info
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.MachO.DyldInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -179,9 +134,6 @@ Function starts
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.FunctionStarts
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -189,9 +141,6 @@ Source Version
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.MachO.SourceVersion
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -200,9 +149,6 @@ Version Min
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.MachO.VersionMin
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -211,9 +157,6 @@ Relocation
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.MachO.Relocation
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -222,9 +165,6 @@ Relocation Object
|
||||
*****************
|
||||
|
||||
.. autoclass:: lief.MachO.RelocationObject
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -233,9 +173,6 @@ Relocation Dyld
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.RelocationDyld
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -243,9 +180,6 @@ Relocation Fixup
|
||||
****************
|
||||
|
||||
.. autoclass:: lief.MachO.RelocationFixup
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -254,9 +188,6 @@ Binding Info
|
||||
************
|
||||
|
||||
.. autoclass:: lief.MachO.BindingInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -264,9 +195,6 @@ Dyld Binding Info
|
||||
*****************
|
||||
|
||||
.. autoclass:: lief.MachO.DyldBindingInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -275,9 +203,6 @@ Chained Binding Info
|
||||
********************
|
||||
|
||||
.. autoclass:: lief.MachO.ChainedBindingInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -286,9 +211,6 @@ Export Info
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.MachO.ExportInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -297,9 +219,6 @@ Thread Command
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.MachO.ThreadCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -307,9 +226,6 @@ RPath Command
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.MachO.RPathCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -318,9 +234,6 @@ Code Signature
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.MachO.CodeSignature
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -328,9 +241,6 @@ Data In Code
|
||||
************
|
||||
|
||||
.. autoclass:: lief.MachO.DataInCode
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -338,9 +248,6 @@ Data Code Entry
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.DataCodeEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -348,9 +255,6 @@ Segment Split Info
|
||||
******************
|
||||
|
||||
.. autoclass:: lief.MachO.SegmentSplitInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -358,9 +262,6 @@ Sub Framework
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.MachO.SubFramework
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -368,9 +269,6 @@ Dyld Environment
|
||||
****************
|
||||
|
||||
.. autoclass:: lief.MachO.DyldEnvironment
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -378,9 +276,6 @@ Encryption Info
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.EncryptionInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -388,9 +283,6 @@ Build Version
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.MachO.BuildVersion
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -398,9 +290,6 @@ Build Tool Version
|
||||
******************
|
||||
|
||||
.. autoclass:: lief.MachO.BuildToolVersion
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -408,9 +297,6 @@ Fileset Command
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.FilesetCommand
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -418,9 +304,6 @@ DyldChainedFixups Command
|
||||
*************************
|
||||
|
||||
.. autoclass:: lief.MachO.DyldChainedFixups
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -428,9 +311,6 @@ DyldExportsTrie Command
|
||||
***********************
|
||||
|
||||
.. autoclass:: lief.MachO.DyldExportsTrie
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -438,9 +318,6 @@ Code Signature Dir Command
|
||||
**************************
|
||||
|
||||
.. autoclass:: lief.MachO.CodeSignatureDir
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -448,9 +325,6 @@ Two Level Hints
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.MachO.TwoLevelHints
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -458,9 +332,6 @@ Linker Optimization Hint
|
||||
************************
|
||||
|
||||
.. autoclass:: lief.MachO.LinkerOptHint
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -468,9 +339,6 @@ Builder
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.MachO.Builder
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -482,9 +350,6 @@ CPU_TYPES
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.CPU_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -493,9 +358,6 @@ FILE_TYPES
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.FILE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -504,9 +366,6 @@ HEADER_FLAGS
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.HEADER_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -515,9 +374,6 @@ LOAD_COMMAND_TYPES
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.LOAD_COMMAND_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -526,9 +382,6 @@ SECTION_TYPES
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.SECTION_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -537,9 +390,6 @@ MACHO_TYPES
|
||||
~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.MACHO_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -548,9 +398,6 @@ X86_RELOCATION
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.X86_RELOCATION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -559,9 +406,6 @@ X86_64_RELOCATION
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.X86_64_RELOCATION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -570,9 +414,6 @@ PPC_RELOCATION
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.PPC_RELOCATION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -581,9 +422,6 @@ ARM_RELOCATION
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.ARM_RELOCATION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -591,9 +429,6 @@ ARM64_RELOCATION
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.ARM64_RELOCATION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -602,9 +437,6 @@ RELOCATION_ORIGINS
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.RELOCATION_ORIGINS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -613,9 +445,6 @@ REBASE_TYPES
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.REBASE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
@@ -625,9 +454,6 @@ BINDING_CLASS
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.BINDING_CLASS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -636,9 +462,6 @@ REBASE_OPCODES
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.REBASE_OPCODES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -647,9 +470,6 @@ BIND_TYPES
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.BIND_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -658,9 +478,6 @@ BIND_SPECIAL_DYLIB
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.BIND_SPECIAL_DYLIB
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -669,9 +486,6 @@ BIND_OPCODES
|
||||
~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.BIND_OPCODES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -680,9 +494,6 @@ EXPORT_SYMBOL_KINDS
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.EXPORT_SYMBOL_KINDS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -691,9 +502,6 @@ EXPORT_SYMBOL_FLAGS
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.EXPORT_SYMBOL_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -702,9 +510,6 @@ VM_PROTECTIONS
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.VM_PROTECTIONS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -713,9 +518,6 @@ SYMBOL_ORIGINS
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.SYMBOL_ORIGINS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -723,22 +525,14 @@ SECTION_FLAGS
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.SECTION_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
DYLD_CHAINED_FORMAT
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.DYLD_CHAINED_FORMAT
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
DYLD_CHAINED_PTR_FORMAT
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.MachO.DYLD_CHAINED_PTR_FORMAT
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
@@ -24,9 +24,6 @@ Binary
|
||||
******
|
||||
|
||||
.. autoclass:: lief.OAT.Binary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -34,9 +31,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.OAT.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -45,9 +39,6 @@ DexFile
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.OAT.DexFile
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -56,9 +47,6 @@ Class
|
||||
*****
|
||||
|
||||
.. autoclass:: lief.OAT.Class
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -67,9 +55,6 @@ Method
|
||||
******
|
||||
|
||||
.. autoclass:: lief.OAT.Method
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -80,9 +65,6 @@ OAT Class types
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.OAT.OAT_CLASS_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -92,9 +74,6 @@ OAT Class Status
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.OAT.OAT_CLASS_STATUS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -103,9 +82,6 @@ Header Keys
|
||||
~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.OAT.HEADER_KEYS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -114,7 +90,4 @@ Instruction sets
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.OAT.INSTRUCTION_SETS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
+14
-356
@@ -7,18 +7,11 @@ Parser
|
||||
.. autofunction:: lief.PE.parse
|
||||
|
||||
.. autoclass:: lief.PE.ParserConfig
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
Binary
|
||||
******
|
||||
|
||||
.. autoclass:: lief.PE.Binary
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -26,9 +19,6 @@ Dos Header
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.PE.DosHeader
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -36,9 +26,6 @@ Header
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -46,9 +33,6 @@ Optional Header
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.PE.OptionalHeader
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -56,9 +40,6 @@ Data Directory
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.PE.DataDirectory
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -66,9 +47,6 @@ Section
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.Section
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -77,9 +55,6 @@ Import
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.Import
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -88,9 +63,6 @@ Import Entry
|
||||
************
|
||||
|
||||
.. autoclass:: lief.PE.ImportEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -98,20 +70,13 @@ Delay Import
|
||||
************
|
||||
|
||||
.. autoclass:: lief.PE.DelayImport
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Delay Import Entry
|
||||
******************
|
||||
|
||||
.. autoclass:: lief.PE.DelayImportEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -119,9 +84,6 @@ TLS
|
||||
***
|
||||
|
||||
.. autoclass:: lief.PE.TLS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -129,9 +91,6 @@ Symbol
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.Symbol
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -139,9 +98,6 @@ Relocation
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.PE.Relocation
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
@@ -150,10 +106,6 @@ Relocation Entry
|
||||
****************
|
||||
|
||||
.. autoclass:: lief.PE.RelocationEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -161,10 +113,6 @@ Export
|
||||
******
|
||||
|
||||
.. autoclass:: lief.PE.Export
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -172,9 +120,6 @@ Export Entry
|
||||
************
|
||||
|
||||
.. autoclass:: lief.PE.ExportEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -182,9 +127,6 @@ Signature
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.PE.Signature
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -192,20 +134,13 @@ Signature Attribute
|
||||
*******************
|
||||
|
||||
.. autoclass:: lief.PE.Attribute
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Signature ContentType
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.PE.ContentType
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -213,9 +148,6 @@ Signature GenericType
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.PE.GenericType
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -223,9 +155,6 @@ Signature MsSpcNestedSignature
|
||||
******************************
|
||||
|
||||
.. autoclass:: lief.PE.MsSpcNestedSignature
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -233,9 +162,6 @@ Signature MsSpcStatementType
|
||||
****************************
|
||||
|
||||
.. autoclass:: lief.PE.MsSpcStatementType
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -243,9 +169,6 @@ Signature PKCS9AtSequenceNumber
|
||||
*******************************
|
||||
|
||||
.. autoclass:: lief.PE.PKCS9AtSequenceNumber
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -253,9 +176,6 @@ Signature PKCS9CounterSignature
|
||||
*******************************
|
||||
|
||||
.. autoclass:: lief.PE.PKCS9CounterSignature
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -263,9 +183,6 @@ Signature PKCS9MessageDigest
|
||||
****************************
|
||||
|
||||
.. autoclass:: lief.PE.PKCS9MessageDigest
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -273,9 +190,6 @@ Signature PKCS9SigningTime
|
||||
**************************
|
||||
|
||||
.. autoclass:: lief.PE.PKCS9SigningTime
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -283,20 +197,27 @@ Signature SpcSpOpusInfo
|
||||
***********************
|
||||
|
||||
.. autoclass:: lief.PE.SpcSpOpusInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
Signature SpcIndirectData
|
||||
*************************
|
||||
|
||||
.. autoclass:: lief.PE.SpcIndirectData
|
||||
|
||||
----------
|
||||
|
||||
Signature GenericType
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.PE.GenericType
|
||||
|
||||
----------
|
||||
|
||||
RsaInfo
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.RsaInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -304,9 +225,6 @@ x509
|
||||
****
|
||||
|
||||
.. autoclass:: lief.PE.x509
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -314,10 +232,6 @@ ContentInfo
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.PE.ContentInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -326,47 +240,27 @@ SignerInfo
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.PE.SignerInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Builder
|
||||
*******
|
||||
|
||||
.. autoclass:: lief.PE.Builder
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Resource Node
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceNode
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
|
||||
Resource Directory
|
||||
******************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceDirectory
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -375,22 +269,13 @@ Resource Data
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceData
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Resources Manager
|
||||
*****************
|
||||
|
||||
.. autoclass:: lief.PE.ResourcesManager
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -398,22 +283,13 @@ Resource Icon
|
||||
*************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceIcon
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Resource Dialog
|
||||
***************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceDialog
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -421,21 +297,13 @@ Resource Dialog Item
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceDialogItem
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Resource Version
|
||||
****************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceVersion
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -443,9 +311,6 @@ Resource Fixed File Info
|
||||
************************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceFixedFileInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -453,9 +318,6 @@ Resource Var File Info
|
||||
**********************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceVarFileInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -463,9 +325,6 @@ Resource String File Info
|
||||
*************************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceStringFileInfo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -473,9 +332,6 @@ Lang code item
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.PE.LangCodeItem
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -483,9 +339,6 @@ Resource String Table
|
||||
*********************
|
||||
|
||||
.. autoclass:: lief.PE.ResourceStringTable
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -493,9 +346,6 @@ Rich Header
|
||||
***********
|
||||
|
||||
.. autoclass:: lief.PE.RichHeader
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -503,9 +353,6 @@ Rich Entry
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.PE.RichEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -513,9 +360,6 @@ Debug
|
||||
*****
|
||||
|
||||
.. autoclass:: lief.PE.Debug
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -524,20 +368,13 @@ Code View
|
||||
*********
|
||||
|
||||
.. autoclass:: lief.PE.CodeView
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Code View PDB
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.PE.CodeViewPDB
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -545,31 +382,20 @@ Code Integrity
|
||||
**************
|
||||
|
||||
.. autoclass:: lief.PE.CodeIntegrity
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Pogo
|
||||
****
|
||||
|
||||
.. autoclass:: lief.PE.Pogo
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
|
||||
Pogo Entry
|
||||
**********
|
||||
|
||||
.. autoclass:: lief.PE.PogoEntry
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -577,9 +403,6 @@ Repro
|
||||
*****
|
||||
|
||||
.. autoclass:: lief.PE.Repro
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -587,111 +410,83 @@ Load Configuration
|
||||
******************
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfiguration
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
Load Configuration V0
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV0
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V1
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV1
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V2
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV2
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V3
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV3
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V4
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV4
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V5
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV5
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V6
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV6
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V7
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV7
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V8
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV8
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V9
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV9
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V10
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV10
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Load Configuration V11
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.LoadConfigurationV11
|
||||
:members:
|
||||
:show-inheritance:
|
||||
:undoc-members:
|
||||
|
||||
Utilities
|
||||
*********
|
||||
|
||||
|
||||
.. autofunction:: lief.is_pe
|
||||
|
||||
.. autofunction:: lief.PE.get_type
|
||||
@@ -699,9 +494,6 @@ Utilities
|
||||
.. autofunction:: lief.PE.get_imphash
|
||||
|
||||
.. autoclass:: lief.PE.IMPHASH_MODE
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
.. autofunction:: lief.PE.resolve_ordinals
|
||||
|
||||
@@ -714,69 +506,6 @@ PE_TYPE
|
||||
~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.PE_TYPE
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
MACHINE_TYPES
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.MACHINE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
HEADER_CHARACTERISTICS
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.HEADER_CHARACTERISTICS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
SUBSYSTEM
|
||||
~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SUBSYSTEM
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
DATA_DIRECTORY
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.DATA_DIRECTORY
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
DLL_CHARACTERISTICS
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.DLL_CHARACTERISTICS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
SECTION_CHARACTERISTICS
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SECTION_CHARACTERISTICS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -784,9 +513,6 @@ SECTION_TYPES
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SECTION_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -794,9 +520,6 @@ SYMBOL_BASE_TYPES
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SYMBOL_BASE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -804,9 +527,6 @@ SYMBOL_COMPLEX_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SYMBOL_COMPLEX_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -814,9 +534,6 @@ SYMBOL_SECTION_NUMBER
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SYMBOL_SECTION_NUMBER
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -824,9 +541,6 @@ SYMBOL_STORAGE_CLASS
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SYMBOL_STORAGE_CLASS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -834,9 +548,6 @@ RELOCATIONS_BASE_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.RELOCATIONS_BASE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -844,9 +555,6 @@ RESOURCE_TYPES
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.RESOURCE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -854,9 +562,6 @@ RESOURCE_LANGS
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.RESOURCE_LANGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -864,9 +569,6 @@ RESOURCE_SUBLANGS
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.RESOURCE_SUBLANGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -874,9 +576,6 @@ FIXED_VERSION_FILE_SUB_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.CODE_PAGES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -884,10 +583,6 @@ WINDOW_STYLES
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.WINDOW_STYLES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -895,10 +590,6 @@ EXTENDED_WINDOW_STYLES
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.EXTENDED_WINDOW_STYLES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -906,10 +597,6 @@ DIALOG_BOX_STYLES
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.DIALOG_BOX_STYLES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -917,20 +604,13 @@ FIXED_VERSION_OS
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.FIXED_VERSION_OS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
FIXED_VERSION_FILE_FLAGS
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. autoclass:: lief.PE.FIXED_VERSION_FILE_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
.. autoclass:: lief.PE.FIXED_VERSION_FILE_FLAGS
|
||||
|
||||
----------
|
||||
|
||||
@@ -938,10 +618,6 @@ FIXED_VERSION_FILE_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.FIXED_VERSION_FILE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -949,10 +625,6 @@ FIXED_VERSION_FILE_SUB_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.FIXED_VERSION_FILE_SUB_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -960,10 +632,6 @@ WIN_VERSION
|
||||
~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.WIN_VERSION
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -971,10 +639,6 @@ GUARD_CF_FLAGS
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.GUARD_CF_FLAGS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
----------
|
||||
|
||||
@@ -982,15 +646,9 @@ ALGORITHMS
|
||||
~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.ALGORITHMS
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
SIG_ATTRIBUTE_TYPES
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. autoclass:: lief.PE.SIG_ATTRIBUTE_TYPES
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
@@ -24,9 +24,6 @@ File
|
||||
****
|
||||
|
||||
.. autoclass:: lief.VDEX.File
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
----------
|
||||
|
||||
@@ -34,9 +31,6 @@ Header
|
||||
******
|
||||
|
||||
.. autoclass:: lief.VDEX.Header
|
||||
:members:
|
||||
:inherited-members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -31,13 +31,56 @@ Changelog
|
||||
(instead of `lief.MachO.Binary.name`)
|
||||
|
||||
:PE:
|
||||
* ``SECTION_CHARACTERISTICS`` is now scoped within the
|
||||
:class:`~lief.PE.Section` class instead of being globally defined:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Before
|
||||
lief.PE.SECTION_CHARACTERISTICS.CNT_CODE
|
||||
# Now:
|
||||
lief.PE.Section.CHARACTERISTICS.CNT_CODE
|
||||
* ``DATA_DIRECTORY`` is now scoped within the
|
||||
:class:`~lief.PE.DataDirectory` class instead of being globally defined:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Before
|
||||
lief.PE.DATA_DIRECTORY.IAT
|
||||
# Now:
|
||||
lief.PE.DataDirectory.TYPES.IAT
|
||||
|
||||
* ``MACHINE_TYPES`` and ``HEADER_CHARACTERISTICS`` are now scoped within the
|
||||
:class:`~lief.PE.Header` class instead of being globally defined:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Before
|
||||
lief.PE.MACHINE_TYPES.AMD64
|
||||
# Now:
|
||||
lief.PE.Header.MACHINE_TYPES.AMD64
|
||||
|
||||
* :attr:`lief.PE.Header.characteristics` now returns a
|
||||
`list`/`std::vector` instead of a ``set``.
|
||||
* :attr:`lief.PE.OptionalHeader.dll_characteristics_lists` now returns a
|
||||
``list``/``std::vector`` instead of a ``set``.
|
||||
* ``SUBSYSTEM`` and ``DLL_CHARACTERISTICS`` are now scoped within the
|
||||
:class:`~lief.PE.OptionalHeader` class instead of being globally defined:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Before
|
||||
lief.PE.SUBSYSTEM.NATIVE
|
||||
# Now:
|
||||
lief.PE.OptionalHeader.SUBSYSTEM.NATIVE
|
||||
* :attr:`lief.PE.DosHeader.used_bytes_in_the_last_page` has been renamed in
|
||||
:attr:`lief.PE.DosHeader.used_bytes_in_last_page`
|
||||
* Refactoring of the Debug directory processing:
|
||||
- :class:`lief.PE.Debug` is now the root class of:
|
||||
1. :class:`lief.PE.CodeView` / :class:`lief.PE.CodeView`
|
||||
2. :class:`lief.PE.Pogo`
|
||||
3. :class:`lief.PE.Repro`
|
||||
- The parsing logic has been cleaned and the tests updated.
|
||||
:class:`lief.PE.Debug` is now the root class of:
|
||||
:class:`lief.PE.CodeView` / :class:`lief.PE.CodeView`, :class:`lief.PE.Pogo`,
|
||||
:class:`lief.PE.Repro`.
|
||||
|
||||
The parsing logic has been cleaned and the tests updated.
|
||||
* Add a :class:`lief.PE.ParserConfig` interface that can be used to tweak
|
||||
which parts of the PE format should be parsed (:issue:`839`).
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ To build the documentation:
|
||||
|
||||
.. note::
|
||||
|
||||
A compilation from scratch with all the options enabled can take ~30 minutes on a regular laptop.
|
||||
A compilation from scratch with all the options enabled can take ~20 minutes on a regular laptop.
|
||||
|
||||
Libraries only (SDK)
|
||||
--------------------
|
||||
@@ -47,8 +47,6 @@ Libraries only (SDK)
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Debug -DLIEF_USE_CRT_DEBUG=MTd ..
|
||||
$ cmake --build . --target LIB_LIEF --config Debug
|
||||
|
||||
|
||||
|
||||
Python bindings
|
||||
---------------
|
||||
|
||||
@@ -176,7 +174,7 @@ LIEF but it is not required to use LIEF. ``external`` means that it is required
|
||||
+-----------------------------------+--------------+--------------------------------------------+
|
||||
| `json <json_ref>`_ | ``internal`` | Serialize LIEF's object into JSON |
|
||||
+-----------------------------------+--------------+--------------------------------------------+
|
||||
| `pybind11 <pybind11_ref>`_ | ``internal`` | Python bindings |
|
||||
| `nanobind <nanobind_ref>`_ | ``internal`` | Python bindings |
|
||||
+-----------------------------------+--------------+--------------------------------------------+
|
||||
| `Frozen <frozen_ref>`_ | ``internal`` | ``constexpr`` containers |
|
||||
+-----------------------------------+--------------+--------------------------------------------+
|
||||
@@ -191,7 +189,7 @@ LIEF but it is not required to use LIEF. ``external`` means that it is required
|
||||
.. _mbedtls_ref: https://github.com/Mbed-TLS/mbedtls
|
||||
.. _utfcpp_ref: https://github.com/nemtrif/utfcpp
|
||||
.. _json_ref: https://github.com/nlohmann/json
|
||||
.. _pybind11_ref: https://github.com/pybind/pybind11
|
||||
.. _nanobind_ref: https://github.com/wjakob/nanobind
|
||||
.. _frozen_ref: https://github.com/serge-sans-paille/frozen
|
||||
.. _melkor_ref: https://github.com/IOActive/Melkor_ELF_Fuzzer
|
||||
|
||||
@@ -210,7 +208,7 @@ cmake's options:
|
||||
* ``LIEF_OPT_FROZEN_EXTERNAL``
|
||||
* ``LIEF_OPT_EXTERNAL_SPAN/LIEF_EXTERNAL_SPAN_DIR``
|
||||
* ``LIEF_OPT_EXTERNAL_EXPECTED``
|
||||
* ``LIEF_OPT_PYBIND11_EXTERNAL``
|
||||
* ``LIEF_OPT_NANOBIND_EXTERNAL``
|
||||
|
||||
By setting these flags, LIEF resolves the dependencies with CMake ``find_package(...)`` which
|
||||
is aware of ``<DEPS>_DIR`` to find the package.
|
||||
|
||||
+28
-19
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import re
|
||||
import lief
|
||||
import os
|
||||
@@ -9,11 +8,7 @@ from docutils import nodes
|
||||
import inspect
|
||||
from sphinx.util import logging
|
||||
from sphinx.util.inspect import (
|
||||
evaluate_signature,
|
||||
getdoc,
|
||||
object_description,
|
||||
safe_getattr,
|
||||
stringify_signature,
|
||||
signature_from_str
|
||||
)
|
||||
|
||||
@@ -66,6 +61,8 @@ templates_path = ['_templates']
|
||||
source_suffix = '.rst'
|
||||
|
||||
master_doc = 'index'
|
||||
gh_org = "lief-project"
|
||||
gh_repo = "LIEF"
|
||||
|
||||
project = 'LIEF'
|
||||
html_title = "LIEF Documentation"
|
||||
@@ -79,7 +76,11 @@ commit = lief.__commit__
|
||||
language = "en"
|
||||
autoclass_content = 'both'
|
||||
autodoc_default_options = {
|
||||
'exclude-members': '@entries'
|
||||
'exclude-members': '@entries',
|
||||
'undoc-members': True,
|
||||
'inherited-members': True,
|
||||
'undoc-members': True,
|
||||
'members': True,
|
||||
}
|
||||
|
||||
if GENERATE_DOXYGEN:
|
||||
@@ -102,26 +103,29 @@ if GENERATE_DOXYGEN:
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
def commit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
commit_link = nodes.reference(
|
||||
"", text[:7], refuri="https://github.com/lief-project/LIEF/commit/{}".format(text), **options)
|
||||
commit_link = nodes.reference("", text[:7],
|
||||
refuri=f"https://github.com/{gh_org}/{gh_repo}/commit/{text}",
|
||||
**options)
|
||||
|
||||
return [commit_link], []
|
||||
|
||||
def pr_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
pr_link = nodes.reference(
|
||||
"", '#' + text, refuri="https://github.com/lief-project/LIEF/pull/{}".format(text), **options)
|
||||
pr_link = nodes.reference("", '#' + text,
|
||||
refuri=f"https://github.com/{gh_org}/{gh_repo}/pull/{text}",
|
||||
**options)
|
||||
|
||||
return [pr_link], []
|
||||
|
||||
def issue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
issue_link = nodes.reference(
|
||||
"", '#' + text, refuri="https://github.com/lief-project/LIEF/issues/{}".format(text), **options)
|
||||
issue_link = nodes.reference("", '#' + text,
|
||||
refuri=f"https://github.com/{gh_org}/{gh_repo}/issues/{text}",
|
||||
**options)
|
||||
|
||||
return [issue_link], []
|
||||
|
||||
def github_user(name, rawtext, text, lineno, inliner, options={}, content=[]):
|
||||
issue_link = nodes.reference(
|
||||
"", text, refuri="https://github.com/{}".format(text), **options)
|
||||
issue_link = nodes.reference("", text, refuri=f"https://github.com/{text}",
|
||||
**options)
|
||||
|
||||
return [issue_link], []
|
||||
|
||||
@@ -175,7 +179,7 @@ def process_property(name: str, obj, options, signature: str,
|
||||
|
||||
return "()", return_annotation
|
||||
except Exception:
|
||||
logger.warn(f"Error with {name}: {lines[0]}")
|
||||
logger.warning(f"Error with {name}: {lines[0]}")
|
||||
|
||||
return signature, return_annotation
|
||||
|
||||
@@ -286,6 +290,7 @@ if not USE_RTD_THEME:
|
||||
html_theme_options = {
|
||||
"commit": commit,
|
||||
"base_url": f"{base_url}/",
|
||||
"sponsor_link": "https://github.com/sponsors/lief-project/",
|
||||
"repo_url": "https://github.com/lief-project/LIEF/",
|
||||
"repo_name": "LIEF",
|
||||
"html_minify": True,
|
||||
@@ -300,22 +305,26 @@ if not USE_RTD_THEME:
|
||||
{
|
||||
"href": html_base_url,
|
||||
"internal": False,
|
||||
"title": "Home"
|
||||
"title": "Home",
|
||||
"icon": "fa-solid fa-house"
|
||||
},
|
||||
{
|
||||
"href": f"{html_base_url}/blog",
|
||||
"internal": False,
|
||||
"title": "Blog"
|
||||
"title": "Blog",
|
||||
"icon": "fa-solid fa-rss"
|
||||
},
|
||||
{
|
||||
"href": f"{html_base_url}/download",
|
||||
"internal": False,
|
||||
"title": "Download"
|
||||
"title": "Download",
|
||||
"icon": "fa-solid fa-download",
|
||||
},
|
||||
{
|
||||
"href": "index",
|
||||
"internal": True,
|
||||
"title": "Documentation",
|
||||
"icon": "fa-solid fa-book",
|
||||
"subnav": [
|
||||
{
|
||||
"title": "Doxygen",
|
||||
@@ -327,6 +336,7 @@ if not USE_RTD_THEME:
|
||||
"href": f"{html_base_url}/about",
|
||||
"internal": False,
|
||||
"title": "About",
|
||||
"icon": "fa-solid fa-bars-staggered"
|
||||
},
|
||||
],
|
||||
"table_classes": ["plain"],
|
||||
@@ -341,4 +351,3 @@ html_favicon = '_static/favicon.ico'
|
||||
html_static_path = ['_static']
|
||||
|
||||
htmlhelp_basename = 'LIEFdoc'
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ To retrieve the section in which resources are located, one can use the :attr:`~
|
||||
|
||||
binary = lief.parse("C:\\Windows\\explorer.exe")
|
||||
if binary.has_resources:
|
||||
rsrc_directory = binary.data_directory(lief.PE.DATA_DIRECTORY.RESOURCE_TABLE)
|
||||
rsrc_directory = binary.data_directory(lief.PE.DataDirectory.TYPES.RESOURCE_TABLE)
|
||||
if rsrc_directory.has_section:
|
||||
print(rsrc_directory.section)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Introduction
|
||||
~~~~~~~~~~~~
|
||||
|
||||
PE authenticode is the signature scheme used by Windows to sign and verify the integrity of PE executables.
|
||||
The signature is associated with the data directory :attr:`~lief.PE.DATA_DIRECTORY.CERTIFICATE_TABLE`
|
||||
The signature is associated with the data directory :attr:`~lief.PE.DataDirectory.TYPES.CERTIFICATE_TABLE`
|
||||
that is not always tied to a section (it implies that the signature is not necessarily mapped in memory).
|
||||
This signature is wrapped in a PKCS #7 container with custom object types as defined
|
||||
in the official documentation [#]_.
|
||||
|
||||
@@ -27,7 +27,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
fprintf(stdout, "DosHeader\n");
|
||||
fprintf(stdout, "=========\n");
|
||||
fprintf(stdout, "Used bytes in the last page: 0x%x\n", dos_header.used_bytes_in_the_last_page);
|
||||
fprintf(stdout, "Used bytes in the last page: 0x%x\n", dos_header.used_bytes_in_last_page);
|
||||
fprintf(stdout, "File size in pages: 0x%x\n", dos_header.file_size_in_pages);
|
||||
fprintf(stdout, "Number of relocations: 0x%x\n", dos_header.numberof_relocation);
|
||||
fprintf(stdout, "Header size in paragraphs: 0x%x\n", dos_header.header_size_in_paragraphs);
|
||||
@@ -52,7 +52,7 @@ int main(int argc, char **argv) {
|
||||
Pe_Header_t header = pe_binary->header;
|
||||
fprintf(stdout, "Header\n");
|
||||
fprintf(stdout, "======\n");
|
||||
fprintf(stdout, "Machine: %s\n", MACHINE_TYPES_to_string(header.machine));
|
||||
fprintf(stdout, "Machine: %s\n", lief_pe_header_machine_str(header.machine));
|
||||
fprintf(stdout, "Number of sections: %d\n", header.numberof_sections);
|
||||
fprintf(stdout, "Timestamp: 0x%x\n", header.time_date_stamp);
|
||||
fprintf(stdout, "Pointer to symbol table: 0x%x\n", header.pointerto_symbol_table);
|
||||
@@ -86,7 +86,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stdout, "Size of image: 0x%x\n", optional_header.sizeof_image);
|
||||
fprintf(stdout, "Size of headers: 0x%x\n", optional_header.sizeof_headers);
|
||||
fprintf(stdout, "Checksum: 0x%x\n", optional_header.checksum);
|
||||
fprintf(stdout, "subsystem: %s\n", SUBSYSTEM_to_string(optional_header.subsystem));
|
||||
fprintf(stdout, "subsystem: %s\n", lief_pe_subsytem_str(optional_header.subsystem));
|
||||
fprintf(stdout, "DLL characteristics: 0x%x\n", optional_header.dll_characteristics);
|
||||
fprintf(stdout, "Size of stack reserve: 0x%" PRIx64 "\n", optional_header.sizeof_stack_reserve);
|
||||
fprintf(stdout, "Size of stack commit: 0x%" PRIx64 "\n", optional_header.sizeof_stack_commit);
|
||||
|
||||
@@ -78,6 +78,10 @@ class LIEF_API Binary : public Object {
|
||||
|
||||
public:
|
||||
Binary();
|
||||
Binary(EXE_FORMATS fmt) :
|
||||
format_{fmt}
|
||||
{}
|
||||
|
||||
~Binary() override;
|
||||
|
||||
Binary& operator=(const Binary&);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
#ifndef LIEF_ASN1_READER_H
|
||||
#define LIEF_ASN1_READER_H
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "LIEF/errors.hpp"
|
||||
|
||||
struct mbedtls_x509_crt;
|
||||
struct mbedtls_x509_time;
|
||||
|
||||
namespace LIEF {
|
||||
class BinaryStream;
|
||||
|
||||
class ASN1Reader {
|
||||
public:
|
||||
ASN1Reader() = delete;
|
||||
|
||||
ASN1Reader(BinaryStream& stream) :
|
||||
stream_(stream)
|
||||
{}
|
||||
|
||||
ASN1Reader(const ASN1Reader&) = delete;
|
||||
ASN1Reader& operator=(const ASN1Reader&) = delete;
|
||||
|
||||
|
||||
result<bool> is_tag(int tag);
|
||||
|
||||
result<size_t> read_tag(int tag);
|
||||
result<size_t> read_len();
|
||||
result<std::string> read_alg();
|
||||
result<std::string> read_oid();
|
||||
result<bool> read_bool();
|
||||
result<int32_t> read_int();
|
||||
result<int64_t> read_int64();
|
||||
result<std::vector<uint8_t>> read_large_int();
|
||||
|
||||
result<std::vector<uint8_t>> read_bitstring();
|
||||
result<std::vector<uint8_t>> read_octet_string();
|
||||
result<std::string> read_utf8_string();
|
||||
result<std::unique_ptr<mbedtls_x509_crt>> read_cert();
|
||||
result<std::string> x509_read_names();
|
||||
result<std::vector<uint8_t>> x509_read_serial();
|
||||
result<std::unique_ptr<mbedtls_x509_time>> x509_read_time();
|
||||
|
||||
std::string get_str_tag();
|
||||
|
||||
static std::string tag2str(int tag);
|
||||
|
||||
private:
|
||||
BinaryStream& stream_;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -27,15 +27,13 @@
|
||||
#include "LIEF/BinaryStream/Convert.hpp"
|
||||
#include "LIEF/errors.hpp"
|
||||
|
||||
struct mbedtls_x509_crt;
|
||||
struct mbedtls_x509_time;
|
||||
|
||||
namespace LIEF {
|
||||
|
||||
class ASN1Reader;
|
||||
|
||||
//! Class that is used to a read stream of data from different sources
|
||||
class BinaryStream {
|
||||
public:
|
||||
friend class ASN1Reader;
|
||||
enum class STREAM_TYPE {
|
||||
UNKNOWN = 0,
|
||||
VECTOR,
|
||||
@@ -165,20 +163,6 @@ class BinaryStream {
|
||||
|
||||
void set_endian_swap(bool swap);
|
||||
|
||||
/* ASN.1 & X509 parsing functions */
|
||||
virtual result<size_t> asn1_read_tag(int tag);
|
||||
virtual result<size_t> asn1_read_len();
|
||||
virtual result<std::string> asn1_read_alg();
|
||||
virtual result<std::string> asn1_read_oid();
|
||||
virtual result<int32_t> asn1_read_int();
|
||||
virtual result<std::vector<uint8_t>> asn1_read_bitstring();
|
||||
virtual result<std::vector<uint8_t>> asn1_read_octet_string();
|
||||
virtual result<std::unique_ptr<mbedtls_x509_crt>> asn1_read_cert();
|
||||
virtual result<std::string> x509_read_names();
|
||||
virtual result<std::vector<uint8_t>> x509_read_serial();
|
||||
virtual result<std::unique_ptr<mbedtls_x509_time>> x509_read_time();
|
||||
|
||||
|
||||
template<class T>
|
||||
static bool is_all_zero(const T& buffer) {
|
||||
const auto* ptr = reinterpret_cast<const uint8_t *const>(&buffer);
|
||||
@@ -190,6 +174,30 @@ class BinaryStream {
|
||||
return endian_swap_;
|
||||
}
|
||||
|
||||
virtual const uint8_t* p() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual uint8_t* start() {
|
||||
return const_cast<uint8_t*>(static_cast<const BinaryStream*>(this)->start());
|
||||
}
|
||||
|
||||
virtual uint8_t* p() {
|
||||
return const_cast<uint8_t*>(static_cast<const BinaryStream*>(this)->p());
|
||||
}
|
||||
|
||||
virtual uint8_t* end() {
|
||||
return const_cast<uint8_t*>(static_cast<const BinaryStream*>(this)->end());
|
||||
}
|
||||
|
||||
virtual const uint8_t* start() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual const uint8_t* end() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual result<const void*> read_at(uint64_t offset, uint64_t size) const = 0;
|
||||
virtual ok_error_t peek_in(void* dst, uint64_t offset, uint64_t size) const {
|
||||
@@ -242,6 +250,14 @@ class ScopedStream {
|
||||
return &stream_;
|
||||
}
|
||||
|
||||
BinaryStream& operator*() {
|
||||
return stream_;
|
||||
}
|
||||
|
||||
const BinaryStream& operator*() const {
|
||||
return stream_;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t pos_ = 0;
|
||||
BinaryStream& stream_;
|
||||
|
||||
@@ -25,6 +25,10 @@ namespace LIEF {
|
||||
class Binary;
|
||||
class MemoryStream : public BinaryStream {
|
||||
public:
|
||||
using BinaryStream::p;
|
||||
using BinaryStream::end;
|
||||
using BinaryStream::start;
|
||||
|
||||
MemoryStream() = delete;
|
||||
MemoryStream(uintptr_t base_address);
|
||||
MemoryStream(uintptr_t base_address, uint64_t size);
|
||||
@@ -39,8 +43,16 @@ class MemoryStream : public BinaryStream {
|
||||
return this->baseaddr_;
|
||||
}
|
||||
|
||||
uint64_t end() const {
|
||||
return this->baseaddr_ + this->size_;
|
||||
const uint8_t* p() const override {
|
||||
return start() + pos();
|
||||
}
|
||||
|
||||
const uint8_t* start() const override {
|
||||
return reinterpret_cast<const uint8_t*>(baseaddr_);
|
||||
}
|
||||
|
||||
const uint8_t* end() const override {
|
||||
return start() + size_;
|
||||
}
|
||||
|
||||
void binary(Binary& bin) {
|
||||
|
||||
@@ -25,9 +25,20 @@
|
||||
namespace LIEF {
|
||||
class SpanStream : public BinaryStream {
|
||||
public:
|
||||
using BinaryStream::p;
|
||||
using BinaryStream::end;
|
||||
using BinaryStream::start;
|
||||
|
||||
static result<SpanStream> from_vector(const std::vector<uint8_t>& data);
|
||||
SpanStream(span<const uint8_t> data);
|
||||
SpanStream(span<uint8_t> data);
|
||||
|
||||
SpanStream(const uint8_t* p, size_t size) :
|
||||
data_{p, p + size}
|
||||
{
|
||||
stype_ = STREAM_TYPE::SPAN;
|
||||
}
|
||||
|
||||
SpanStream(const std::vector<uint8_t>& data);
|
||||
SpanStream() = delete;
|
||||
|
||||
@@ -41,6 +52,18 @@ class SpanStream : public BinaryStream {
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
const uint8_t* p() const override {
|
||||
return data_.data() + this->pos();
|
||||
}
|
||||
|
||||
const uint8_t* start() const override {
|
||||
return data_.data();
|
||||
}
|
||||
|
||||
const uint8_t* end() const override {
|
||||
return data_.data() + size();
|
||||
}
|
||||
|
||||
std::vector<uint8_t> content() const;
|
||||
|
||||
result<SpanStream> slice(size_t offset, size_t size) const;
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
namespace LIEF {
|
||||
class VectorStream : public BinaryStream {
|
||||
public:
|
||||
using BinaryStream::p;
|
||||
using BinaryStream::end;
|
||||
using BinaryStream::start;
|
||||
|
||||
static result<VectorStream> from_file(const std::string& file);
|
||||
VectorStream(std::vector<uint8_t> data);
|
||||
|
||||
@@ -47,42 +51,18 @@ class VectorStream : public BinaryStream {
|
||||
return std::move(binary_);
|
||||
}
|
||||
|
||||
uint8_t* p() {
|
||||
const uint8_t* p() const override {
|
||||
return this->binary_.data() + this->pos();
|
||||
}
|
||||
|
||||
const uint8_t* p() const {
|
||||
return this->binary_.data() + this->pos();
|
||||
}
|
||||
|
||||
uint8_t* start() {
|
||||
const uint8_t* start() const override {
|
||||
return this->binary_.data();
|
||||
}
|
||||
|
||||
const uint8_t* start() const {
|
||||
return this->binary_.data();
|
||||
}
|
||||
|
||||
uint8_t* end() {
|
||||
const uint8_t* end() const override {
|
||||
return this->binary_.data() + this->binary_.size();
|
||||
}
|
||||
|
||||
const uint8_t* end() const {
|
||||
return this->binary_.data() + this->binary_.size();
|
||||
}
|
||||
|
||||
result<size_t> asn1_read_tag(int tag) override;
|
||||
result<size_t> asn1_read_len() override;
|
||||
result<std::string> asn1_read_alg() override;
|
||||
result<std::string> asn1_read_oid() override;
|
||||
result<int32_t> asn1_read_int() override;
|
||||
result<std::vector<uint8_t>> asn1_read_bitstring() override;
|
||||
result<std::vector<uint8_t>> asn1_read_octet_string() override;
|
||||
result<std::unique_ptr<mbedtls_x509_crt>> asn1_read_cert() override;
|
||||
result<std::string> x509_read_names() override;
|
||||
result<std::vector<uint8_t>> x509_read_serial() override;
|
||||
result<std::unique_ptr<mbedtls_x509_time>> x509_read_time() override;
|
||||
|
||||
static bool classof(const BinaryStream& stream);
|
||||
|
||||
protected:
|
||||
|
||||
+3
-1
@@ -59,12 +59,14 @@
|
||||
#include "LIEF/PE/AuxiliarySymbol.hpp"
|
||||
#include "LIEF/PE/CodeIntegrity.hpp"
|
||||
|
||||
#include "LIEF/PE/signature/attributes.hpp"
|
||||
#include "LIEF/PE/signature/Attribute.hpp"
|
||||
#include "LIEF/PE/signature/ContentInfo.hpp"
|
||||
#include "LIEF/PE/signature/GenericContent.hpp"
|
||||
#include "LIEF/PE/signature/OIDToString.hpp"
|
||||
#include "LIEF/PE/signature/Signature.hpp"
|
||||
#include "LIEF/PE/signature/SignerInfo.hpp"
|
||||
#include "LIEF/PE/signature/SpcIndirectData.hpp"
|
||||
#include "LIEF/PE/signature/attributes.hpp"
|
||||
#include "LIEF/PE/signature/types.hpp"
|
||||
#include "LIEF/PE/signature/x509.hpp"
|
||||
|
||||
|
||||
+139
-49
@@ -24,6 +24,7 @@
|
||||
#include "LIEF/PE/Import.hpp"
|
||||
#include "LIEF/PE/DelayImport.hpp"
|
||||
#include "LIEF/PE/Symbol.hpp"
|
||||
#include "LIEF/PE/DataDirectory.hpp"
|
||||
#include "LIEF/PE/ResourcesManager.hpp"
|
||||
#include "LIEF/PE/signature/Signature.hpp"
|
||||
|
||||
@@ -140,7 +141,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
~Binary() override;
|
||||
|
||||
//! Return `PE32` or `PE32+`
|
||||
PE_TYPE type() const;
|
||||
PE_TYPE type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
//! Convert a Relative Virtual Address into an offset
|
||||
//!
|
||||
@@ -161,7 +164,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
//! Return binary's imagebase. ``0`` if not relevant
|
||||
//!
|
||||
//! The value is the same as those returned by OptionalHeader::imagebase
|
||||
uint64_t imagebase() const override;
|
||||
uint64_t imagebase() const override {
|
||||
return optional_header().imagebase();
|
||||
}
|
||||
|
||||
//! Find the section associated that encompasses the given offset.
|
||||
//!
|
||||
@@ -176,20 +181,40 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
const Section* section_from_rva(uint64_t virtual_address) const;
|
||||
|
||||
//! Return an iterator over the PE's Section
|
||||
it_sections sections();
|
||||
it_const_sections sections() const;
|
||||
it_sections sections() {
|
||||
return sections_;
|
||||
}
|
||||
|
||||
it_const_sections sections() const {
|
||||
return sections_;
|
||||
}
|
||||
|
||||
//! Return a reference to the PE::DosHeader object
|
||||
DosHeader& dos_header();
|
||||
const DosHeader& dos_header() const;
|
||||
DosHeader& dos_header() {
|
||||
return dos_header_;
|
||||
}
|
||||
|
||||
const DosHeader& dos_header() const {
|
||||
return dos_header_;
|
||||
}
|
||||
|
||||
//! Return a reference to the PE::Header object
|
||||
Header& header();
|
||||
const Header& header() const;
|
||||
Header& header() {
|
||||
return header_;
|
||||
}
|
||||
|
||||
const Header& header() const {
|
||||
return header_;
|
||||
}
|
||||
|
||||
//! Return a reference to the OptionalHeader object
|
||||
OptionalHeader& optional_header();
|
||||
const OptionalHeader& optional_header() const;
|
||||
OptionalHeader& optional_header() {
|
||||
return optional_header_;
|
||||
}
|
||||
|
||||
const OptionalHeader& optional_header() const {
|
||||
return optional_header_;
|
||||
}
|
||||
|
||||
//! Compute the binary's virtual size.
|
||||
//! It should match OptionalHeader::sizeof_image
|
||||
@@ -218,20 +243,28 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
//! Check if the current binary contains imports
|
||||
//!
|
||||
//! @see Import
|
||||
bool has_imports() const;
|
||||
bool has_imports() const {
|
||||
return !imports_.empty();
|
||||
}
|
||||
|
||||
//! Check if the current binary contains signatures
|
||||
//!
|
||||
//! @see signatures
|
||||
bool has_signatures() const;
|
||||
bool has_signatures() const {
|
||||
return !signatures_.empty();
|
||||
}
|
||||
|
||||
//! Check if the current binary has exports.
|
||||
//!
|
||||
//! @see Export
|
||||
bool has_exports() const;
|
||||
bool has_exports() const {
|
||||
return export_ != nullptr;
|
||||
}
|
||||
|
||||
//! Check if the current binary has resources
|
||||
bool has_resources() const;
|
||||
bool has_resources() const {
|
||||
return resources_ != nullptr;
|
||||
}
|
||||
|
||||
//! Check if the current binary has exceptions
|
||||
bool has_exceptions() const;
|
||||
@@ -239,7 +272,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
//! Check if the current binary has relocations
|
||||
//!
|
||||
//! @see Relocation
|
||||
bool has_relocations() const;
|
||||
bool has_relocations() const {
|
||||
return relocations_.empty();
|
||||
}
|
||||
|
||||
//! Check if the current binary contains debug information
|
||||
bool has_debug() const {
|
||||
@@ -247,7 +282,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
}
|
||||
|
||||
//! Check if the current binary has a load configuration
|
||||
bool has_configuration() const;
|
||||
bool has_configuration() const {
|
||||
return load_configuration_ != nullptr;
|
||||
}
|
||||
|
||||
//! Check if the current binary is *reproducible build*, replacing timestamps by a compile hash.
|
||||
//!
|
||||
@@ -255,7 +292,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
bool is_reproducible_build() const;
|
||||
|
||||
//! Return an iterator over the Signature object(s) if the binary is signed
|
||||
it_const_signatures signatures() const;
|
||||
it_const_signatures signatures() const {
|
||||
return signatures_;
|
||||
}
|
||||
|
||||
//! Verify the binary against the embedded signature(s) (if any)
|
||||
//! First, it checks that the embedded signatures are correct (c.f. Signature::check)
|
||||
@@ -311,8 +350,13 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
const std::vector<Symbol>& symbols() const;
|
||||
|
||||
//! Return resources as a tree or a nullptr if there is no resources
|
||||
ResourceNode* resources();
|
||||
const ResourceNode* resources() const;
|
||||
ResourceNode* resources() {
|
||||
return resources_.get();
|
||||
}
|
||||
|
||||
const ResourceNode* resources() const {
|
||||
return resources_.get();
|
||||
}
|
||||
|
||||
//! Set a new resource tree
|
||||
void set_resources(const ResourceDirectory& resource);
|
||||
@@ -352,8 +396,13 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
PE_SECTION_TYPES type = PE_SECTION_TYPES::UNKNOWN);
|
||||
|
||||
//! Return an iterator over the PE's Relocation
|
||||
it_relocations relocations();
|
||||
it_const_relocations relocations() const;
|
||||
it_relocations relocations() {
|
||||
return relocations_;
|
||||
}
|
||||
|
||||
it_const_relocations relocations() const {
|
||||
return relocations_;
|
||||
}
|
||||
|
||||
//! Add a PE::Relocation
|
||||
Relocation& add_relocation(const Relocation& relocation);
|
||||
@@ -362,32 +411,64 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
void remove_all_relocations();
|
||||
|
||||
//! Return an iterator over the DataDirectory present in the Binary
|
||||
it_data_directories data_directories();
|
||||
it_const_data_directories data_directories() const;
|
||||
it_data_directories data_directories() {
|
||||
return data_directories_;
|
||||
}
|
||||
|
||||
it_const_data_directories data_directories() const {
|
||||
return data_directories_;
|
||||
}
|
||||
|
||||
//! Return the DataDirectory with the given type (or index)
|
||||
DataDirectory* data_directory(DATA_DIRECTORY index);
|
||||
const DataDirectory* data_directory(DATA_DIRECTORY index) const;
|
||||
DataDirectory* data_directory(DataDirectory::TYPES type);
|
||||
const DataDirectory* data_directory(DataDirectory::TYPES type) const;
|
||||
|
||||
//! Check if the current binary has the given DATA_DIRECTORY
|
||||
bool has(DATA_DIRECTORY index) const;
|
||||
//! Check if the current binary has the given DataDirectory::TYPES
|
||||
bool has(DataDirectory::TYPES type) const {
|
||||
return data_directory(type) != nullptr;
|
||||
}
|
||||
|
||||
//! Return an iterator over the Debug entries
|
||||
it_debug_entries debug();
|
||||
const it_const_debug_entries debug() const;
|
||||
it_debug_entries debug() {
|
||||
return debug_;
|
||||
}
|
||||
|
||||
it_const_debug_entries debug() const {
|
||||
return debug_;
|
||||
}
|
||||
|
||||
//! Retrun the LoadConfiguration object or a nullptr
|
||||
//! if the binary does not use the LoadConfiguration
|
||||
const LoadConfiguration* load_configuration() const;
|
||||
LoadConfiguration* load_configuration();
|
||||
const LoadConfiguration* load_configuration() const {
|
||||
return load_configuration_.get();
|
||||
}
|
||||
|
||||
LoadConfiguration* load_configuration() {
|
||||
return load_configuration_.get();
|
||||
}
|
||||
|
||||
//! Return the overlay content
|
||||
span<const uint8_t> overlay() const;
|
||||
span<uint8_t> overlay();
|
||||
span<const uint8_t> overlay() const {
|
||||
return overlay_;
|
||||
}
|
||||
|
||||
span<uint8_t> overlay() {
|
||||
return overlay_;
|
||||
}
|
||||
|
||||
//! Return the original overlay offset
|
||||
uint64_t overlay_offset() const {
|
||||
return overlay_offset_;
|
||||
}
|
||||
|
||||
//! Return the DOS stub content
|
||||
span<const uint8_t> dos_stub() const;
|
||||
span<uint8_t> dos_stub();
|
||||
span<const uint8_t> dos_stub() const {
|
||||
return dos_stub_;
|
||||
}
|
||||
|
||||
span<uint8_t> dos_stub() {
|
||||
return dos_stub_;
|
||||
}
|
||||
|
||||
//! Update the DOS stub content
|
||||
void dos_stub(const std::vector<uint8_t>& content);
|
||||
@@ -413,8 +494,13 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
}
|
||||
|
||||
//! Return an iterator over the binary imports
|
||||
it_imports imports();
|
||||
it_const_imports imports() const;
|
||||
it_imports imports() {
|
||||
return imports_;
|
||||
}
|
||||
|
||||
it_const_imports imports() const {
|
||||
return imports_;
|
||||
}
|
||||
|
||||
//! Returns the PE::Import from the given name. If it can't be
|
||||
//! found, return a nullptr
|
||||
@@ -426,17 +512,26 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
//! ``True`` if the binary imports the given library name
|
||||
//!
|
||||
//! @param[in] import_name Name of the import
|
||||
bool has_import(const std::string& import_name) const;
|
||||
bool has_import(const std::string& import_name) const {
|
||||
return get_import(import_name) != nullptr;
|
||||
}
|
||||
|
||||
//! Check if the current binary contains delay imports
|
||||
//!
|
||||
//! @see DelayImport
|
||||
//! @see has_import
|
||||
bool has_delay_imports() const;
|
||||
bool has_delay_imports() const {
|
||||
return !delay_imports_.empty();
|
||||
}
|
||||
|
||||
//! Return an iterator over the binary's delay imports
|
||||
it_delay_imports delay_imports();
|
||||
it_const_delay_imports delay_imports() const;
|
||||
it_delay_imports delay_imports() {
|
||||
return delay_imports_;
|
||||
}
|
||||
|
||||
it_const_delay_imports delay_imports() const {
|
||||
return delay_imports_;
|
||||
}
|
||||
|
||||
//! Returns the PE::DelayImport from the given name. If it can't be
|
||||
//! found, return a nullptr
|
||||
@@ -449,7 +544,9 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
//! ``True`` if the binary delay-imports the given library name
|
||||
//!
|
||||
//! @param[in] import_name Name of the delay import
|
||||
bool has_delay_import(const std::string& import_name) const;
|
||||
bool has_delay_import(const std::string& import_name) const {
|
||||
return get_delay_import(import_name) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
//! Add the function @p function of the library @p library.
|
||||
@@ -563,14 +660,7 @@ class LIEF_API Binary : public LIEF::Binary {
|
||||
|
||||
int32_t available_sections_space_ = 0;
|
||||
|
||||
bool has_rich_header_ = false;
|
||||
bool has_tls_ = false;
|
||||
bool has_imports_ = false;
|
||||
bool has_exports_ = false;
|
||||
bool has_resources_ = false;
|
||||
bool has_exceptions_ = false;
|
||||
bool has_relocations_ = false;
|
||||
bool has_configuration_ = false;
|
||||
|
||||
signatures_t signatures_;
|
||||
sections_t sections_;
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
#ifndef LIEF_PE_DATADIRECTORY_H
|
||||
#define LIEF_PE_DATADIRECTORY_H
|
||||
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
|
||||
#include "LIEF/Object.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
#include "LIEF/PE/enums.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
@@ -43,47 +42,94 @@ class LIEF_API DataDirectory : public Object {
|
||||
friend class Binary;
|
||||
|
||||
public:
|
||||
static constexpr size_t DEFAULT_NB = 16;
|
||||
|
||||
enum class TYPES: size_t {
|
||||
EXPORT_TABLE = 0,
|
||||
IMPORT_TABLE,
|
||||
RESOURCE_TABLE,
|
||||
EXCEPTION_TABLE,
|
||||
CERTIFICATE_TABLE,
|
||||
BASE_RELOCATION_TABLE,
|
||||
DEBUG,
|
||||
ARCHITECTURE,
|
||||
GLOBAL_PTR,
|
||||
TLS_TABLE,
|
||||
LOAD_CONFIG_TABLE,
|
||||
BOUND_IMPORT,
|
||||
IAT,
|
||||
DELAY_IMPORT_DESCRIPTOR,
|
||||
CLR_RUNTIME_HEADER,
|
||||
RESERVED,
|
||||
|
||||
UNKNOWN,
|
||||
};
|
||||
DataDirectory();
|
||||
DataDirectory(DATA_DIRECTORY type);
|
||||
DataDirectory(const details::pe_data_directory& header, DATA_DIRECTORY type);
|
||||
DataDirectory(TYPES type) :
|
||||
type_{type}
|
||||
{}
|
||||
|
||||
DataDirectory(const details::pe_data_directory& header, TYPES type);
|
||||
|
||||
DataDirectory(const DataDirectory& other);
|
||||
DataDirectory& operator=(DataDirectory other);
|
||||
void swap(DataDirectory& other);
|
||||
DataDirectory& operator=(const DataDirectory& other);
|
||||
|
||||
DataDirectory(DataDirectory&& other);
|
||||
DataDirectory& operator=(DataDirectory&& other);
|
||||
|
||||
~DataDirectory() override;
|
||||
|
||||
//! The relative virtual address of the content of this data
|
||||
//! directory
|
||||
uint32_t RVA() const;
|
||||
uint32_t RVA() const {
|
||||
return rva_;
|
||||
}
|
||||
|
||||
//! The size of the content
|
||||
uint32_t size() const;
|
||||
uint32_t size() const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
//! Check if the content of this data directory is associated
|
||||
//! with a PE Cection
|
||||
bool has_section() const;
|
||||
bool has_section() const {
|
||||
return section_ != nullptr;
|
||||
}
|
||||
|
||||
//! Section associated with the DataDirectory
|
||||
Section* section();
|
||||
const Section* section() const;
|
||||
Section* section() {
|
||||
return section_;
|
||||
}
|
||||
const Section* section() const {
|
||||
return section_;
|
||||
}
|
||||
|
||||
//! Type of the data directory
|
||||
DATA_DIRECTORY type() const;
|
||||
TYPES type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
void size(uint32_t size);
|
||||
void RVA(uint32_t rva);
|
||||
void size(uint32_t size) {
|
||||
size_ = size;
|
||||
}
|
||||
|
||||
void RVA(uint32_t rva) {
|
||||
rva_ = rva;
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const DataDirectory& entry);
|
||||
|
||||
private:
|
||||
uint32_t rva_ = 0;
|
||||
uint32_t size_ = 0;
|
||||
DATA_DIRECTORY type_ = DATA_DIRECTORY::NUM_DATA_DIRECTORIES;
|
||||
Section* section_ = nullptr;
|
||||
uint32_t rva_ = 0;
|
||||
uint32_t size_ = 0;
|
||||
TYPES type_ = TYPES::UNKNOWN;
|
||||
Section* section_ = nullptr;
|
||||
};
|
||||
|
||||
LIEF_API const char* to_string(DataDirectory::TYPES e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+179
-58
@@ -25,6 +25,8 @@
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
|
||||
enum class PE_TYPE : uint16_t;
|
||||
|
||||
namespace details {
|
||||
struct pe_dos_header;
|
||||
}
|
||||
@@ -38,80 +40,199 @@ class LIEF_API DosHeader : public Object {
|
||||
using reserved_t = std::array<uint16_t, 4>;
|
||||
using reserved2_t = std::array<uint16_t, 10>;
|
||||
|
||||
static constexpr uint16_t MAGIC = 0x5a4d; // MZ
|
||||
|
||||
DosHeader(const details::pe_dos_header& header);
|
||||
DosHeader();
|
||||
DosHeader(const DosHeader&);
|
||||
DosHeader& operator=(const DosHeader&);
|
||||
|
||||
DosHeader(DosHeader&&);
|
||||
DosHeader& operator=(DosHeader&&);
|
||||
|
||||
~DosHeader() override;
|
||||
|
||||
//! Magic bytes identifying a DOS/PE binary
|
||||
uint16_t magic() const;
|
||||
uint16_t used_bytes_in_the_last_page() const;
|
||||
uint16_t file_size_in_pages() const;
|
||||
uint16_t numberof_relocation() const;
|
||||
uint16_t header_size_in_paragraphs() const;
|
||||
uint16_t minimum_extra_paragraphs() const;
|
||||
uint16_t maximum_extra_paragraphs() const;
|
||||
uint16_t initial_relative_ss() const;
|
||||
uint16_t initial_sp() const;
|
||||
uint16_t checksum() const;
|
||||
uint16_t initial_ip() const;
|
||||
uint16_t initial_relative_cs() const;
|
||||
uint16_t addressof_relocation_table() const;
|
||||
uint16_t overlay_number() const;
|
||||
reserved_t reserved() const;
|
||||
uint16_t oem_id() const;
|
||||
uint16_t oem_info() const;
|
||||
reserved2_t reserved2() const;
|
||||
uint16_t magic() const {
|
||||
return magic_;
|
||||
}
|
||||
|
||||
//! It returns the offset to the PE::Header structure.
|
||||
uint32_t addressof_new_exeheader() const;
|
||||
uint16_t used_bytes_in_last_page() const {
|
||||
return used_bytes_in_last_page_;
|
||||
}
|
||||
|
||||
void magic(uint16_t magic);
|
||||
void used_bytes_in_the_last_page(uint16_t usedBytesInTheLastPage);
|
||||
void file_size_in_pages(uint16_t fileSizeInPages);
|
||||
void numberof_relocation(uint16_t numberOfRelocation);
|
||||
void header_size_in_paragraphs(uint16_t headerSizeInParagraphs);
|
||||
void minimum_extra_paragraphs(uint16_t minimumExtraParagraphs);
|
||||
void maximum_extra_paragraphs(uint16_t maximumExtraParagraphs);
|
||||
void initial_relative_ss(uint16_t initialRelativeSS);
|
||||
void initial_sp(uint16_t initialSP);
|
||||
void checksum(uint16_t checksum);
|
||||
void initial_ip(uint16_t initialIP);
|
||||
void initial_relative_cs(uint16_t initialRelativeCS);
|
||||
void addressof_relocation_table(uint16_t addressOfRelocationTable);
|
||||
void overlay_number(uint16_t overlayNumber);
|
||||
void reserved(const reserved_t& reserved);
|
||||
void oem_id(uint16_t oEMid);
|
||||
void oem_info(uint16_t oEMinfo);
|
||||
void reserved2(const reserved2_t& reserved2);
|
||||
void addressof_new_exeheader(uint32_t addressOfNewExeHeader);
|
||||
uint16_t file_size_in_pages() const {
|
||||
return file_sz_in_pages_;
|
||||
}
|
||||
|
||||
uint16_t numberof_relocation() const {
|
||||
return nb_relocations_;
|
||||
}
|
||||
|
||||
uint16_t header_size_in_paragraphs() const {
|
||||
return header_sz_in_paragraphs_;
|
||||
}
|
||||
|
||||
uint16_t minimum_extra_paragraphs() const {
|
||||
return min_extra_paragraphs_;
|
||||
}
|
||||
|
||||
uint16_t maximum_extra_paragraphs() const {
|
||||
return max_extra_paragraphs_;
|
||||
}
|
||||
|
||||
uint16_t initial_relative_ss() const {
|
||||
return init_relative_ss_;
|
||||
}
|
||||
|
||||
uint16_t initial_sp() const {
|
||||
return init_sp_;
|
||||
}
|
||||
|
||||
uint16_t checksum() const {
|
||||
return checksum_;
|
||||
}
|
||||
|
||||
uint16_t initial_ip() const {
|
||||
return init_ip_;
|
||||
}
|
||||
|
||||
uint16_t initial_relative_cs() const {
|
||||
return init_rel_cs_;
|
||||
}
|
||||
|
||||
uint16_t addressof_relocation_table() const {
|
||||
return addr_reloc_table_;
|
||||
}
|
||||
|
||||
uint16_t overlay_number() const {
|
||||
return overlay_number_;
|
||||
}
|
||||
|
||||
const reserved_t& reserved() const {
|
||||
return reserved_;
|
||||
}
|
||||
|
||||
uint16_t oem_id() const {
|
||||
return oem_id_;
|
||||
}
|
||||
|
||||
uint16_t oem_info() const {
|
||||
return oem_info_;
|
||||
}
|
||||
|
||||
const reserved2_t& reserved2() const {
|
||||
return reserved2_;
|
||||
}
|
||||
|
||||
//! Return the offset to the PE::Header structure.
|
||||
uint32_t addressof_new_exeheader() const {
|
||||
return addr_new_exe_header_;
|
||||
}
|
||||
|
||||
void magic(uint16_t magic) {
|
||||
magic_ = magic;
|
||||
}
|
||||
|
||||
void used_bytes_in_last_page(uint16_t value) {
|
||||
used_bytes_in_last_page_ = value;
|
||||
}
|
||||
|
||||
void file_size_in_pages(uint16_t value) {
|
||||
file_sz_in_pages_ = value;
|
||||
}
|
||||
|
||||
void numberof_relocation(uint16_t value) {
|
||||
nb_relocations_ = value;
|
||||
}
|
||||
|
||||
void header_size_in_paragraphs(uint16_t value) {
|
||||
header_sz_in_paragraphs_ = value;
|
||||
}
|
||||
|
||||
void minimum_extra_paragraphs(uint16_t value) {
|
||||
min_extra_paragraphs_ = value;
|
||||
}
|
||||
|
||||
void maximum_extra_paragraphs(uint16_t value) {
|
||||
max_extra_paragraphs_ = value;
|
||||
}
|
||||
|
||||
void initial_relative_ss(uint16_t value) {
|
||||
init_relative_ss_ = value;
|
||||
}
|
||||
|
||||
void initial_sp(uint16_t value) {
|
||||
init_sp_ = value;
|
||||
}
|
||||
|
||||
void checksum(uint16_t value) {
|
||||
checksum_ = value;
|
||||
}
|
||||
|
||||
void initial_ip(uint16_t value) {
|
||||
init_ip_ = value;
|
||||
}
|
||||
|
||||
void initial_relative_cs(uint16_t value) {
|
||||
init_rel_cs_ = value;
|
||||
}
|
||||
|
||||
void addressof_relocation_table(uint16_t value) {
|
||||
addr_reloc_table_ = value;
|
||||
}
|
||||
|
||||
void overlay_number(uint16_t value) {
|
||||
overlay_number_ = value;
|
||||
}
|
||||
|
||||
void reserved(const reserved_t& reserved) {
|
||||
reserved_ = reserved;
|
||||
}
|
||||
|
||||
void oem_id(uint16_t value) {
|
||||
oem_id_ = value;
|
||||
}
|
||||
|
||||
void oem_info(uint16_t value) {
|
||||
oem_info_ = value;
|
||||
}
|
||||
|
||||
void reserved2(const reserved2_t& reserved2) {
|
||||
reserved2_ = reserved2;
|
||||
}
|
||||
|
||||
void addressof_new_exeheader(uint32_t value) {
|
||||
addr_new_exe_header_ = value;
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const DosHeader& entry);
|
||||
|
||||
static DosHeader create(PE_TYPE type);
|
||||
|
||||
private:
|
||||
uint16_t magic_;
|
||||
uint16_t usedBytesInTheLastPage_;
|
||||
uint16_t fileSizeInPages_;
|
||||
uint16_t numberOfRelocation_;
|
||||
uint16_t headerSizeInParagraphs_;
|
||||
uint16_t minimumExtraParagraphs_;
|
||||
uint16_t maximumExtraParagraphs_;
|
||||
uint16_t initialRelativeSS_;
|
||||
uint16_t initialSP_;
|
||||
uint16_t checksum_;
|
||||
uint16_t initialIP_;
|
||||
uint16_t initialRelativeCS_;
|
||||
uint16_t addressOfRelocationTable_;
|
||||
uint16_t overlayNumber_;
|
||||
DosHeader();
|
||||
|
||||
uint16_t magic_ = 0;
|
||||
uint16_t used_bytes_in_last_page_ = 0;
|
||||
uint16_t file_sz_in_pages_ = 0;
|
||||
uint16_t nb_relocations_ = 0;
|
||||
uint16_t header_sz_in_paragraphs_ = 0;
|
||||
uint16_t min_extra_paragraphs_ = 0;
|
||||
uint16_t max_extra_paragraphs_ = 0;
|
||||
uint16_t init_relative_ss_ = 0;
|
||||
uint16_t init_sp_ = 0;
|
||||
uint16_t checksum_ = 0;
|
||||
uint16_t init_ip_ = 0;
|
||||
uint16_t init_rel_cs_ = 0;
|
||||
uint16_t addr_reloc_table_ = 0;
|
||||
uint16_t overlay_number_ = 0;
|
||||
reserved_t reserved_;
|
||||
uint16_t oEMid_;
|
||||
uint16_t oEMinfo_;
|
||||
uint16_t oem_id_ = 0;
|
||||
uint16_t oem_info_ = 0;
|
||||
reserved2_t reserved2_;
|
||||
uint32_t addressOfNewExeHeader_;
|
||||
uint32_t addr_new_exe_header_ = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +30,13 @@ enum class ACCELERATOR_FLAGS : size_t;
|
||||
enum class ACCELERATOR_VK_CODES : size_t;
|
||||
enum class ALGORITHMS : uint32_t;
|
||||
enum class CODE_PAGES : size_t;
|
||||
enum class DATA_DIRECTORY : size_t;
|
||||
enum class DIALOG_BOX_STYLES : size_t;
|
||||
enum class DLL_CHARACTERISTICS : size_t;
|
||||
enum class EXTENDED_WINDOW_STYLES : size_t;
|
||||
enum class FIXED_VERSION_FILE_FLAGS : size_t;
|
||||
enum class FIXED_VERSION_FILE_SUB_TYPES : size_t;
|
||||
enum class FIXED_VERSION_FILE_TYPES : size_t;
|
||||
enum class FIXED_VERSION_OS : size_t;
|
||||
enum class GUARD_CF_FLAGS : size_t;
|
||||
enum class HEADER_CHARACTERISTICS : size_t;
|
||||
enum class MACHINE_TYPES : size_t;
|
||||
enum class PE_SECTION_TYPES : uint8_t;
|
||||
enum class PE_TYPE : uint16_t;
|
||||
enum class RELOCATIONS_AMD64 : size_t;
|
||||
@@ -50,7 +46,6 @@ enum class RELOCATIONS_I386 : size_t;
|
||||
enum class RESOURCE_LANGS : size_t;
|
||||
enum class RESOURCE_SUBLANGS : size_t;
|
||||
enum class RESOURCE_TYPES : size_t;
|
||||
enum class SECTION_CHARACTERISTICS : size_t;
|
||||
enum class SIG_ATTRIBUTE_TYPES : uint32_t;
|
||||
enum class SUBSYSTEM : size_t;
|
||||
enum class SYMBOL_BASE_TYPES : size_t;
|
||||
@@ -59,14 +54,7 @@ enum class WINDOW_STYLES : size_t;
|
||||
enum class WIN_VERSION : size_t;
|
||||
|
||||
LIEF_API const char* to_string(PE_TYPE e);
|
||||
LIEF_API const char* to_string(DATA_DIRECTORY e);
|
||||
|
||||
LIEF_API const char* to_string(MACHINE_TYPES e);
|
||||
LIEF_API const char* to_string(HEADER_CHARACTERISTICS e);
|
||||
LIEF_API const char* to_string(SUBSYSTEM e);
|
||||
LIEF_API const char* to_string(DLL_CHARACTERISTICS e);
|
||||
|
||||
LIEF_API const char* to_string(SECTION_CHARACTERISTICS e);
|
||||
LIEF_API const char* to_string(PE_SECTION_TYPES e);
|
||||
|
||||
LIEF_API const char* to_string(SYMBOL_BASE_TYPES e);
|
||||
|
||||
+133
-35
@@ -16,12 +16,13 @@
|
||||
#ifndef LIEF_PE_HEADER_H
|
||||
#define LIEF_PE_HEADER_H
|
||||
#include <array>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <cstdint>
|
||||
|
||||
#include "LIEF/Object.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
#include "LIEF/enums.hpp"
|
||||
#include "LIEF/PE/enums.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
@@ -35,7 +36,55 @@ struct pe_header;
|
||||
class LIEF_API Header : public Object {
|
||||
public:
|
||||
using signature_t = std::array<uint8_t, /* PE Magic */ 4>;
|
||||
Header();
|
||||
|
||||
enum class MACHINE_TYPES : size_t {
|
||||
UNKNOWN = 0x0,
|
||||
AM33 = 0x1D3, /**< Matsushita AM33 */
|
||||
AMD64 = 0x8664, /**< AMD x64 */
|
||||
ARM = 0x1C0, /**< ARM little endian */
|
||||
ARMNT = 0x1C4, /**< ARMv7 Thumb mode only */
|
||||
ARM64 = 0xAA64, /**< ARMv8 in 64-bits mode */
|
||||
EBC = 0xEBC, /**< EFI byte code */
|
||||
I386 = 0x14C, /**< Intel 386 or later */
|
||||
IA64 = 0x200, /**< Intel Itanium processor family */
|
||||
M32R = 0x9041, /**< Mitsubishi M32R little endian */
|
||||
MIPS16 = 0x266, /**< MIPS16 */
|
||||
MIPSFPU = 0x366, /**< MIPS with FPU */
|
||||
MIPSFPU16 = 0x466, /**< MIPS16 with FPU */
|
||||
POWERPC = 0x1F0, /**< Power PC little endian */
|
||||
POWERPCFP = 0x1F1, /**< Power PC with floating point */
|
||||
R4000 = 0x166, /**< MIPS with little endian */
|
||||
RISCV32 = 0x5032, /**< RISC-V 32-bit address space */
|
||||
RISCV64 = 0x5064, /**< RISC-V 64-bit address space */
|
||||
RISCV128 = 0x5128, /**< RISC-V 128-bit address space */
|
||||
SH3 = 0x1A2, /**< Hitachi SH3 */
|
||||
SH3DSP = 0x1A3, /**< Hitachi SH3 DSP */
|
||||
SH4 = 0x1A6, /**< Hitachi SH4 */
|
||||
SH5 = 0x1A8, /**< Hitachi SH5 */
|
||||
THUMB = 0x1C2, /**< ARM or Thumb */
|
||||
WCEMIPSV2 = 0x169 /**< MIPS little-endian WCE v2 */
|
||||
};
|
||||
|
||||
enum class CHARACTERISTICS : size_t {
|
||||
NONE = 0x0000,
|
||||
RELOCS_STRIPPED = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
|
||||
EXECUTABLE_IMAGE = 0x0002, /**< The file is valid and can be run.*/
|
||||
LINE_NUMS_STRIPPED = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
|
||||
LOCAL_SYMS_STRIPPED = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
|
||||
AGGRESSIVE_WS_TRIM = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
|
||||
LARGE_ADDRESS_AWARE = 0x0020, /**< Image can handle > 2GiB addresses. */
|
||||
BYTES_REVERSED_LO = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
|
||||
NEED_32BIT_MACHINE = 0x0100, /**< Machine is based on a 32bit word architecture. */
|
||||
DEBUG_STRIPPED = 0x0200, /**< Debugging info has been removed. */
|
||||
REMOVABLE_RUN_FROM_SWAP = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
|
||||
NET_RUN_FROM_SWAP = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
|
||||
SYSTEM = 0x1000, /**< The image file is a system file, not a user program.*/
|
||||
DLL = 0x2000, /**< The image file is a DLL. */
|
||||
UP_SYSTEM_ONLY = 0x4000, /**< This file should only be run on a uniprocessor machine. */
|
||||
BYTES_REVERSED_HI = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
|
||||
};
|
||||
static Header create(PE_TYPE type);
|
||||
|
||||
Header(const details::pe_header& header);
|
||||
~Header() override;
|
||||
|
||||
@@ -43,28 +92,40 @@ class LIEF_API Header : public Object {
|
||||
Header(const Header&);
|
||||
|
||||
//! Signature (or magic byte) of the header. It must be: ``PE\0\0``
|
||||
const signature_t& signature() const;
|
||||
const signature_t& signature() const {
|
||||
return signature_;
|
||||
}
|
||||
|
||||
//! The targeted machine architecture like ARM, x86, AMD64, ...
|
||||
MACHINE_TYPES machine() const;
|
||||
MACHINE_TYPES machine() const {
|
||||
return machine_;
|
||||
}
|
||||
|
||||
//! The number of sections in the binary.
|
||||
uint16_t numberof_sections() const;
|
||||
uint16_t numberof_sections() const {
|
||||
return nb_sections_;
|
||||
}
|
||||
|
||||
//! The low 32 bits of the number of seconds since
|
||||
//! January 1, 1970. Basically, it **indicates** when the file was created.
|
||||
uint32_t time_date_stamp() const;
|
||||
uint32_t time_date_stamp() const {
|
||||
return timedatestamp_;
|
||||
}
|
||||
|
||||
//! The offset of the **COFF** symbol table.
|
||||
//!
|
||||
//! This value should be zero for an image because COFF debugging information is deprecated.
|
||||
uint32_t pointerto_symbol_table() const;
|
||||
uint32_t pointerto_symbol_table() const {
|
||||
return pointerto_symtab_;
|
||||
}
|
||||
|
||||
//! The number of entries in the symbol table. This data can be used to locate the string table
|
||||
//! which immediately follows the symbol table.
|
||||
//!
|
||||
//! This value should be zero for an image because COFF debugging information is deprecated.
|
||||
uint32_t numberof_symbols() const;
|
||||
uint32_t numberof_symbols() const {
|
||||
return nb_symbols_;
|
||||
}
|
||||
|
||||
//! Size of the OptionalHeader **AND** the data directories which follows this header.
|
||||
//!
|
||||
@@ -73,46 +134,83 @@ class LIEF_API Header : public Object {
|
||||
//! This size **should** be either:
|
||||
//! * 0xE0 (224) for a PE32 (32 bits)
|
||||
//! * 0xF0 (240) for a PE32+ (64 bits)
|
||||
uint16_t sizeof_optional_header() const;
|
||||
uint16_t sizeof_optional_header() const {
|
||||
return sizeof_opt_header_;
|
||||
}
|
||||
|
||||
//! Characteristics of the binary like whether it is a DLL or an executable
|
||||
HEADER_CHARACTERISTICS characteristics() const;
|
||||
uint32_t characteristics() const {
|
||||
return characteristics_;
|
||||
}
|
||||
|
||||
//! Check if the given HEADER_CHARACTERISTICS is present
|
||||
bool has_characteristic(HEADER_CHARACTERISTICS c) const;
|
||||
//! Check if the given CHARACTERISTICS is present
|
||||
bool has_characteristic(CHARACTERISTICS c) const {
|
||||
return (characteristics() & static_cast<uint32_t>(c)) > 0;
|
||||
}
|
||||
|
||||
//! The list of the HEADER_CHARACTERISTICS as an std::set
|
||||
std::set<HEADER_CHARACTERISTICS> characteristics_list() const;
|
||||
//! The list of the CHARACTERISTICS
|
||||
std::vector<CHARACTERISTICS> characteristics_list() const;
|
||||
|
||||
void machine(MACHINE_TYPES type);
|
||||
void numberof_sections(uint16_t nbOfSections);
|
||||
void time_date_stamp(uint32_t timestamp);
|
||||
void pointerto_symbol_table(uint32_t pointerToSymbol);
|
||||
void numberof_symbols(uint32_t nbOfSymbols);
|
||||
void sizeof_optional_header(uint16_t sizeOfOptionalHdr);
|
||||
void characteristics(HEADER_CHARACTERISTICS characteristics);
|
||||
void signature(const signature_t& sig);
|
||||
void machine(MACHINE_TYPES type) {
|
||||
machine_ = type;
|
||||
}
|
||||
|
||||
void add_characteristic(HEADER_CHARACTERISTICS c);
|
||||
void remove_characteristic(HEADER_CHARACTERISTICS c);
|
||||
void numberof_sections(uint16_t nb) {
|
||||
nb_sections_ = nb;
|
||||
}
|
||||
|
||||
void time_date_stamp(uint32_t timestamp) {
|
||||
timedatestamp_ = timestamp;
|
||||
}
|
||||
|
||||
void pointerto_symbol_table(uint32_t ptr) {
|
||||
pointerto_symtab_ = ptr;
|
||||
}
|
||||
|
||||
void numberof_symbols(uint32_t nb) {
|
||||
nb_symbols_ = nb;
|
||||
}
|
||||
|
||||
void sizeof_optional_header(uint16_t size) {
|
||||
sizeof_opt_header_ = size;
|
||||
}
|
||||
|
||||
void characteristics(uint32_t characteristics) {
|
||||
characteristics_ = characteristics;
|
||||
}
|
||||
|
||||
void signature(const signature_t& sig) {
|
||||
signature_ = sig;
|
||||
}
|
||||
|
||||
void add_characteristic(CHARACTERISTICS c) {
|
||||
characteristics_ |= static_cast<uint32_t>(c);
|
||||
}
|
||||
|
||||
void remove_characteristic(CHARACTERISTICS c) {
|
||||
characteristics_ &= ~static_cast<uint32_t>(c);
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& entry);
|
||||
|
||||
private:
|
||||
signature_t signature_;
|
||||
MACHINE_TYPES machine_;
|
||||
uint16_t numberOfSections_;
|
||||
uint32_t timeDateStamp_;
|
||||
uint32_t pointerToSymbolTable_;
|
||||
uint32_t numberOfSymbols_;
|
||||
uint16_t sizeOfOptionalHeader_;
|
||||
HEADER_CHARACTERISTICS characteristics_;
|
||||
|
||||
Header();
|
||||
signature_t signature_;
|
||||
MACHINE_TYPES machine_ = MACHINE_TYPES::UNKNOWN;
|
||||
uint16_t nb_sections_ = 0;
|
||||
uint32_t timedatestamp_ = 0;
|
||||
uint32_t pointerto_symtab_;
|
||||
uint32_t nb_symbols_ = 0;
|
||||
uint16_t sizeof_opt_header_ = 0;
|
||||
uint32_t characteristics_ = 0;
|
||||
};
|
||||
|
||||
LIEF_API const char* to_string(Header::CHARACTERISTICS c);
|
||||
LIEF_API const char* to_string(Header::MACHINE_TYPES c);
|
||||
}
|
||||
}
|
||||
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::Header::CHARACTERISTICS);
|
||||
#endif
|
||||
|
||||
@@ -53,8 +53,9 @@ class LIEF_API Import : public Object {
|
||||
~Import() override;
|
||||
|
||||
Import(const Import& other);
|
||||
Import& operator=(Import other);
|
||||
void swap(Import& other);
|
||||
Import(Import&& other);
|
||||
Import& operator=(Import&& other);
|
||||
Import& operator=(const Import& other);
|
||||
|
||||
//! The index of the first forwarder reference
|
||||
uint32_t forwarder_chain() const;
|
||||
@@ -97,14 +98,14 @@ class LIEF_API Import : public Object {
|
||||
void name(const std::string& name);
|
||||
|
||||
//! Return the PE::DataDirectory associated with this import.
|
||||
//! It should be the one at index PE::DATA_DIRECTORY::IMPORT_TABLE
|
||||
//! It should be the one at index PE::DataDirectory::TYPES::IMPORT_TABLE
|
||||
//!
|
||||
//! If the data directory can't be found, return a nullptr
|
||||
DataDirectory* directory();
|
||||
const DataDirectory* directory() const;
|
||||
|
||||
//! Return the PE::DataDirectory associated associated with the IAT.
|
||||
//! It should be the one at index PE::DATA_DIRECTORY::IAT
|
||||
//! It should be the one at index PE::DataDirectory::TYPES::IAT
|
||||
//!
|
||||
//! If the data directory can't be found, return a nullptr
|
||||
DataDirectory* iat_directory();
|
||||
|
||||
+293
-100
@@ -13,14 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_PE_OPTIONALHEADER_H
|
||||
#define LIEF_PE_OPTIONALHEADER_H
|
||||
#ifndef LIEF_PE_OPTIONAL_HEADER_H
|
||||
#define LIEF_PE_OPTIONAL_HEADER_H
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "LIEF/Object.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
#include "LIEF/enums.hpp"
|
||||
#include "LIEF/PE/enums.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
@@ -36,103 +38,181 @@ struct pe64_optional_header;
|
||||
class LIEF_API OptionalHeader : public Object {
|
||||
friend class Parser;
|
||||
public:
|
||||
OptionalHeader();
|
||||
|
||||
enum class DLL_CHARACTERISTICS: size_t {
|
||||
HIGH_ENTROPY_VA = 0x0020, ///< ASLR with 64 bit address space.
|
||||
DYNAMIC_BASE = 0x0040, ///< DLL can be relocated at load time.
|
||||
FORCE_INTEGRITY = 0x0080, ///< Code integrity checks are enforced.
|
||||
NX_COMPAT = 0x0100, ///< Image is NX compatible.
|
||||
NO_ISOLATION = 0x0200, ///< Isolation aware, but do not isolate the image.
|
||||
NO_SEH = 0x0400, ///< Does not use structured exception handling (SEH). No SEH handler may be called in this image.
|
||||
NO_BIND = 0x0800, ///< Do not bind the image.
|
||||
APPCONTAINER = 0x1000, ///< Image should execute in an AppContainer.
|
||||
WDM_DRIVER = 0x2000, ///< A WDM driver.
|
||||
GUARD_CF = 0x4000, ///< Image supports Control Flow Guard.
|
||||
TERMINAL_SERVER_AWARE = 0x8000 ///< Terminal Server aware.
|
||||
};
|
||||
|
||||
enum class SUBSYSTEM: size_t {
|
||||
UNKNOWN = 0, ///< An unknown subsystem.
|
||||
NATIVE = 1, ///< Device drivers and native Windows processes
|
||||
WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
|
||||
WINDOWS_CUI = 3, ///< The Windows character subsystem.
|
||||
OS2_CUI = 5, ///< The OS/2 character subsytem.
|
||||
POSIX_CUI = 7, ///< The POSIX character subsystem.
|
||||
NATIVE_WINDOWS = 8, ///< Native Windows 9x driver.
|
||||
WINDOWS_CE_GUI = 9, ///< Windows CE.
|
||||
EFI_APPLICATION = 10, ///< An EFI application.
|
||||
EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot services.
|
||||
EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time services.
|
||||
EFI_ROM = 13, ///< An EFI ROM image.
|
||||
XBOX = 14, ///< XBOX.
|
||||
WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
|
||||
};
|
||||
|
||||
OptionalHeader(const details::pe32_optional_header& header);
|
||||
OptionalHeader(const details::pe64_optional_header& header);
|
||||
~OptionalHeader() override;
|
||||
|
||||
OptionalHeader& operator=(const OptionalHeader&);
|
||||
OptionalHeader(const OptionalHeader&);
|
||||
//! Magic bytes (either ``PE32`` or ``PE32+`` for 64-bits PE files
|
||||
PE_TYPE magic() const;
|
||||
|
||||
static OptionalHeader create(PE_TYPE type);
|
||||
|
||||
//! Magic bytes: either ``PE32`` or ``PE32+`` for 64-bits PE files
|
||||
PE_TYPE magic() const {
|
||||
return magic_;
|
||||
}
|
||||
|
||||
//! The linker major version
|
||||
uint8_t major_linker_version() const;
|
||||
uint8_t major_linker_version() const {
|
||||
return major_linker_version_;
|
||||
}
|
||||
|
||||
//! The linker minor version
|
||||
uint8_t minor_linker_version() const;
|
||||
uint8_t minor_linker_version() const {
|
||||
return minor_linker_version_;
|
||||
}
|
||||
|
||||
//! The size of the code ``.text`` section or the sum of
|
||||
//! all the sections that contain code (ie. PE::Section with the flag SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_CODE)
|
||||
uint32_t sizeof_code() const;
|
||||
//! all the sections that contain code (ie. PE::Section with the flag Section::CHARACTERISTICS::CNT_CODE)
|
||||
uint32_t sizeof_code() const {
|
||||
return sizeof_code_;
|
||||
}
|
||||
|
||||
//! The size of the initialized data which are usually located in the ``.data`` section.
|
||||
//! If the initialized data are split across multiple sections, it is the sum of the sections.
|
||||
//!
|
||||
//! The sections associated with the initialized data are usually identified with the
|
||||
//! flag SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_INITIALIZED_DATA
|
||||
uint32_t sizeof_initialized_data() const;
|
||||
//! flag Section::CHARACTERISTICS::CNT_INITIALIZED_DATA
|
||||
uint32_t sizeof_initialized_data() const {
|
||||
return sizeof_initialized_data_;
|
||||
}
|
||||
|
||||
//! The size of the uninitialized data which are usually located in the ``.bss`` section.
|
||||
//! If the uninitialized data are split across multiple sections, it is the sum of the sections.
|
||||
//!
|
||||
//! The sections associated with the uninitialized data are usually identified with the
|
||||
//! flag SECTION_CHARACTERISTICS::IMAGE_SCN_CNT_UNINITIALIZED_DATA
|
||||
uint32_t sizeof_uninitialized_data() const;
|
||||
//! flag Section::CHARACTERISTICS::CNT_UNINITIALIZED_DATA
|
||||
uint32_t sizeof_uninitialized_data() const {
|
||||
return sizeof_uninitialized_data_;
|
||||
}
|
||||
|
||||
//! The address of the entry point relative to the image base when the executable file is
|
||||
//! loaded into memory. For program images, this is the starting address. For device
|
||||
//! drivers, this is the address of the initialization function.
|
||||
//!
|
||||
//! An entry point is optional for DLLs. When no entry point is present, this field must be zero.
|
||||
uint32_t addressof_entrypoint() const;
|
||||
uint32_t addressof_entrypoint() const {
|
||||
return entrypoint_;
|
||||
}
|
||||
|
||||
//! Address relative to the imagebase where the binary's code starts.
|
||||
uint32_t baseof_code() const;
|
||||
uint32_t baseof_code() const {
|
||||
return baseof_code_;
|
||||
}
|
||||
|
||||
//! Address relative to the imagebase where the binary's data starts.
|
||||
//!
|
||||
//! @warning This value is not present for PE64 files
|
||||
uint32_t baseof_data() const;
|
||||
uint32_t baseof_data() const {
|
||||
return baseof_data_;
|
||||
}
|
||||
|
||||
//! The preferred base address when mapping the binary in memory
|
||||
uint64_t imagebase() const;
|
||||
uint64_t imagebase() const {
|
||||
return imagebase_;
|
||||
}
|
||||
|
||||
//! The alignment (in bytes) of sections when they are loaded into memory.
|
||||
//!
|
||||
//! It must be greater than or equal to file_alignment and
|
||||
//! the default is the page size for the architecture.
|
||||
uint32_t section_alignment() const;
|
||||
uint32_t section_alignment() const {
|
||||
return section_align_;
|
||||
}
|
||||
|
||||
//! The section's file alignment. This value must be a power of 2 between 512 and 64K.
|
||||
//! The default value is usually 512
|
||||
uint32_t file_alignment() const;
|
||||
uint32_t file_alignment() const {
|
||||
return file_align_;
|
||||
}
|
||||
|
||||
//! The **major** version number of the required operating system
|
||||
uint16_t major_operating_system_version() const;
|
||||
uint16_t major_operating_system_version() const {
|
||||
return major_os_version_;
|
||||
}
|
||||
|
||||
//! The **minor** version number of the required operating system
|
||||
uint16_t minor_operating_system_version() const;
|
||||
uint16_t minor_operating_system_version() const {
|
||||
return minor_os_version_;
|
||||
}
|
||||
|
||||
//! The major version number of the image
|
||||
uint16_t major_image_version() const;
|
||||
uint16_t major_image_version() const {
|
||||
return major_image_version_;
|
||||
}
|
||||
|
||||
//! The minor version number of the image
|
||||
uint16_t minor_image_version() const;
|
||||
uint16_t minor_image_version() const {
|
||||
return minor_image_version_;
|
||||
}
|
||||
|
||||
//! The major version number of the subsystem
|
||||
uint16_t major_subsystem_version() const;
|
||||
uint16_t major_subsystem_version() const {
|
||||
return major_subsys_version_;
|
||||
}
|
||||
|
||||
//! The minor version number of the subsystem
|
||||
uint16_t minor_subsystem_version() const;
|
||||
uint16_t minor_subsystem_version() const {
|
||||
return minor_subsys_version_;
|
||||
}
|
||||
|
||||
//! According to the official PE specifications, this value
|
||||
//! is reserved and **should** be 0.
|
||||
uint32_t win32_version_value() const;
|
||||
uint32_t win32_version_value() const {
|
||||
return win32_version_value_;
|
||||
}
|
||||
|
||||
//! The size (in bytes) of the image, including all headers, as the image is loaded in memory.
|
||||
//!
|
||||
//! It must be a multiple of section_alignment and should match Binary::virtual_size
|
||||
uint32_t sizeof_image() const;
|
||||
uint32_t sizeof_image() const {
|
||||
return sizeof_image_;
|
||||
}
|
||||
|
||||
//! Size of the DosHeader + PE Header + Section headers rounded up to a multiple of the file_alignment
|
||||
uint32_t sizeof_headers() const;
|
||||
uint32_t sizeof_headers() const {
|
||||
return sizeof_headers_;
|
||||
}
|
||||
|
||||
//! The image file checksum. The algorithm for computing the checksum is incorporated into ``IMAGHELP.DLL``.
|
||||
//!
|
||||
//! The following are checked for validation at load time all **drivers**, any **DLL loaded at boot**
|
||||
//! time, and any **DLL** that is loaded into a **critical** Windows process.
|
||||
uint32_t checksum() const;
|
||||
uint32_t checksum() const {
|
||||
return checksum_;
|
||||
}
|
||||
|
||||
//! The re-computed value of the OptionalHeader::checksum.
|
||||
//! If both values do not match, it could mean that the binary has been modified
|
||||
@@ -144,39 +224,56 @@ class LIEF_API OptionalHeader : public Object {
|
||||
}
|
||||
|
||||
//! Target subsystem like Driver, XBox, Windows GUI, ...
|
||||
SUBSYSTEM subsystem() const;
|
||||
SUBSYSTEM subsystem() const {
|
||||
return subsystem_;
|
||||
}
|
||||
|
||||
|
||||
//! Some characteristics of the underlying binary like the support of the PIE.
|
||||
//! The prefix ``dll`` comes from the official PE specifications but these characteristics
|
||||
//! are also used for **executables**
|
||||
uint32_t dll_characteristics() const;
|
||||
uint32_t dll_characteristics() const {
|
||||
return dll_characteristics_;
|
||||
}
|
||||
|
||||
//! Size of the stack to reserve when loading the PE binary
|
||||
//!
|
||||
//! Only :attr:`~lief.PE.OptionalHeader.sizeof_stack_commit` is committed, the rest is made
|
||||
//! available one page at a time until the reserve size is reached.
|
||||
uint64_t sizeof_stack_reserve() const;
|
||||
uint64_t sizeof_stack_reserve() const {
|
||||
return sizeof_stack_reserve_;
|
||||
}
|
||||
|
||||
//! Size of the stack to commit
|
||||
uint64_t sizeof_stack_commit() const;
|
||||
uint64_t sizeof_stack_commit() const {
|
||||
return sizeof_stack_commit_;
|
||||
}
|
||||
|
||||
//! Size of the heap to reserve when loading the PE binary
|
||||
uint64_t sizeof_heap_reserve() const;
|
||||
uint64_t sizeof_heap_reserve() const {
|
||||
return sizeof_heap_reserve_;
|
||||
}
|
||||
|
||||
//! Size of the heap to commit
|
||||
uint64_t sizeof_heap_commit() const;
|
||||
uint64_t sizeof_heap_commit() const {
|
||||
return sizeof_heap_commit_;
|
||||
}
|
||||
|
||||
//! According to the PE specifications, this value is *reserved* and **should** be 0.
|
||||
uint32_t loader_flags() const;
|
||||
uint32_t loader_flags() const {
|
||||
return loader_flags_;
|
||||
}
|
||||
|
||||
//! The number of DataDirectory that follow this header.
|
||||
uint32_t numberof_rva_and_size() const;
|
||||
uint32_t numberof_rva_and_size() const {
|
||||
return nb_rva_size_;
|
||||
}
|
||||
|
||||
//! Check if the given DLL_CHARACTERISTICS is included in the dll_characteristics
|
||||
bool has(DLL_CHARACTERISTICS c) const;
|
||||
|
||||
//! Return the list of the dll_characteristics as an std::set of DLL_CHARACTERISTICS
|
||||
std::set<DLL_CHARACTERISTICS> dll_characteristics_list() const;
|
||||
std::vector<DLL_CHARACTERISTICS> dll_characteristics_list() const;
|
||||
|
||||
//! Add a DLL_CHARACTERISTICS to the current characteristics
|
||||
void add(DLL_CHARACTERISTICS c);
|
||||
@@ -184,80 +281,176 @@ class LIEF_API OptionalHeader : public Object {
|
||||
//! Remove a DLL_CHARACTERISTICS from the current characteristics
|
||||
void remove(DLL_CHARACTERISTICS c);
|
||||
|
||||
void magic(PE_TYPE magic);
|
||||
void major_linker_version(uint8_t majorLinkerVersion);
|
||||
void minor_linker_version(uint8_t minorLinkerVersion);
|
||||
void sizeof_code(uint32_t sizeOfCode);
|
||||
void sizeof_initialized_data(uint32_t sizeOfInitializedData);
|
||||
void sizeof_uninitialized_data(uint32_t sizeOfUninitializedData);
|
||||
void addressof_entrypoint(uint32_t addressOfEntryPoint);
|
||||
void baseof_code(uint32_t baseOfCode);
|
||||
void baseof_data(uint32_t baseOfData);
|
||||
void imagebase(uint64_t imageBase);
|
||||
void section_alignment(uint32_t sectionAlignment);
|
||||
void file_alignment(uint32_t fileAlignment);
|
||||
void major_operating_system_version(uint16_t majorOperatingSystemVersion);
|
||||
void minor_operating_system_version(uint16_t minorOperatingSystemVersion);
|
||||
void major_image_version(uint16_t majorImageVersion);
|
||||
void minor_image_version(uint16_t minorImageVersion);
|
||||
void major_subsystem_version(uint16_t majorSubsystemVersion);
|
||||
void minor_subsystem_version(uint16_t minorSubsystemVersion);
|
||||
void win32_version_value(uint32_t win32VersionValue);
|
||||
void sizeof_image(uint32_t sizeOfImage);
|
||||
void sizeof_headers(uint32_t sizeOfHeaders);
|
||||
void checksum(uint32_t checkSum);
|
||||
void subsystem(SUBSYSTEM subsystem);
|
||||
void dll_characteristics(uint32_t DLLCharacteristics);
|
||||
void sizeof_stack_reserve(uint64_t sizeOfStackReserve);
|
||||
void sizeof_stack_commit(uint64_t sizeOfStackCommit);
|
||||
void sizeof_heap_reserve(uint64_t sizeOfHeapReserve);
|
||||
void sizeof_heap_commit(uint64_t sizeOfHeapCommit);
|
||||
void loader_flags(uint32_t loaderFlags);
|
||||
void numberof_rva_and_size(uint32_t numberOfRvaAndSize);
|
||||
void magic(PE_TYPE magic) {
|
||||
magic_ = magic;
|
||||
}
|
||||
|
||||
void major_linker_version(uint8_t value) {
|
||||
major_linker_version_ = value;
|
||||
}
|
||||
|
||||
void minor_linker_version(uint8_t value) {
|
||||
minor_linker_version_ = value;
|
||||
}
|
||||
|
||||
void sizeof_code(uint32_t value) {
|
||||
sizeof_code_ = value;
|
||||
}
|
||||
|
||||
void sizeof_initialized_data(uint32_t value) {
|
||||
sizeof_initialized_data_ = value;
|
||||
}
|
||||
|
||||
void sizeof_uninitialized_data(uint32_t value) {
|
||||
sizeof_uninitialized_data_ = value;
|
||||
}
|
||||
|
||||
void addressof_entrypoint(uint32_t value) {
|
||||
entrypoint_ = value;
|
||||
}
|
||||
|
||||
void baseof_code(uint32_t value) {
|
||||
baseof_code_ = value;
|
||||
}
|
||||
|
||||
void baseof_data(uint32_t value) {
|
||||
baseof_data_ = value;
|
||||
}
|
||||
|
||||
void imagebase(uint64_t value) {
|
||||
imagebase_ = value;
|
||||
}
|
||||
|
||||
void section_alignment(uint32_t value) {
|
||||
section_align_ = value;
|
||||
}
|
||||
|
||||
void file_alignment(uint32_t value) {
|
||||
file_align_ = value;
|
||||
}
|
||||
|
||||
void major_operating_system_version(uint16_t value) {
|
||||
major_os_version_ = value;
|
||||
}
|
||||
|
||||
void minor_operating_system_version(uint16_t value) {
|
||||
minor_os_version_ = value;
|
||||
}
|
||||
|
||||
void major_image_version(uint16_t value) {
|
||||
major_image_version_ = value;
|
||||
}
|
||||
|
||||
void minor_image_version(uint16_t value) {
|
||||
minor_image_version_ = value;
|
||||
}
|
||||
|
||||
void major_subsystem_version(uint16_t value) {
|
||||
major_subsys_version_ = value;
|
||||
}
|
||||
|
||||
void minor_subsystem_version(uint16_t value) {
|
||||
minor_subsys_version_ = value;
|
||||
}
|
||||
|
||||
void win32_version_value(uint32_t value) {
|
||||
win32_version_value_ = value;
|
||||
}
|
||||
|
||||
void sizeof_image(uint32_t value) {
|
||||
sizeof_image_ = value;
|
||||
}
|
||||
|
||||
void sizeof_headers(uint32_t value) {
|
||||
sizeof_headers_ = value;
|
||||
}
|
||||
|
||||
void checksum(uint32_t value) {
|
||||
checksum_ = value;
|
||||
}
|
||||
|
||||
void subsystem(SUBSYSTEM value) {
|
||||
subsystem_ = value;
|
||||
}
|
||||
|
||||
void dll_characteristics(uint32_t value) {
|
||||
dll_characteristics_ = value;
|
||||
}
|
||||
|
||||
void sizeof_stack_reserve(uint64_t value) {
|
||||
sizeof_stack_reserve_ = value;
|
||||
}
|
||||
|
||||
void sizeof_stack_commit(uint64_t value) {
|
||||
sizeof_stack_commit_ = value;
|
||||
}
|
||||
|
||||
void sizeof_heap_reserve(uint64_t value) {
|
||||
sizeof_heap_reserve_ = value;
|
||||
}
|
||||
|
||||
void sizeof_heap_commit(uint64_t value) {
|
||||
sizeof_heap_commit_ = value;
|
||||
}
|
||||
|
||||
void loader_flags(uint32_t value) {
|
||||
loader_flags_ = value;
|
||||
}
|
||||
|
||||
void numberof_rva_and_size(uint32_t value) {
|
||||
nb_rva_size_ = value;
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
OptionalHeader& operator+=(DLL_CHARACTERISTICS c);
|
||||
OptionalHeader& operator-=(DLL_CHARACTERISTICS c);
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const OptionalHeader& entry);
|
||||
|
||||
private:
|
||||
PE_TYPE magic_;
|
||||
uint8_t majorLinkerVersion_;
|
||||
uint8_t minorLinkerVersion_;
|
||||
uint32_t sizeOfCode_;
|
||||
uint32_t sizeOfInitializedData_;
|
||||
uint32_t sizeOfUninitializedData_;
|
||||
uint32_t addressOfEntryPoint_; // RVA
|
||||
uint32_t baseOfCode_; // RVA
|
||||
uint32_t baseOfData_; //Not present in PE32+
|
||||
uint64_t imageBase_;
|
||||
uint32_t sectionAlignment_;
|
||||
uint32_t fileAlignment_;
|
||||
uint16_t majorOperatingSystemVersion_;
|
||||
uint16_t minorOperatingSystemVersion_;
|
||||
uint16_t majorImageVersion_;
|
||||
uint16_t minorImageVersion_;
|
||||
uint16_t majorSubsystemVersion_;
|
||||
uint16_t minorSubsystemVersion_;
|
||||
uint32_t win32VersionValue_;
|
||||
uint32_t sizeOfImage_;
|
||||
uint32_t sizeOfHeaders_;
|
||||
uint32_t checkSum_;
|
||||
SUBSYSTEM subsystem_;
|
||||
uint32_t DLLCharacteristics_;
|
||||
uint64_t sizeOfStackReserve_;
|
||||
uint64_t sizeOfStackCommit_;
|
||||
uint64_t sizeOfHeapReserve_;
|
||||
uint64_t sizeOfHeapCommit_;
|
||||
uint32_t loaderFlags_;
|
||||
uint32_t numberOfRvaAndSize_;
|
||||
OptionalHeader();
|
||||
|
||||
PE_TYPE magic_ = PE_TYPE::PE32;
|
||||
uint8_t major_linker_version_ = 0;
|
||||
uint8_t minor_linker_version_ = 0;
|
||||
uint32_t sizeof_code_ = 0;
|
||||
uint32_t sizeof_initialized_data_ = 0;
|
||||
uint32_t sizeof_uninitialized_data_ = 0;
|
||||
uint32_t entrypoint_ = 0;
|
||||
uint32_t baseof_code_ = 0;
|
||||
uint32_t baseof_data_ = 0;
|
||||
uint64_t imagebase_ = 0;
|
||||
uint32_t section_align_ = 0;
|
||||
uint32_t file_align_ = 0;
|
||||
uint16_t major_os_version_ = 0;
|
||||
uint16_t minor_os_version_ = 0;
|
||||
uint16_t major_image_version_ = 0;
|
||||
uint16_t minor_image_version_ = 0;
|
||||
uint16_t major_subsys_version_ = 0;
|
||||
uint16_t minor_subsys_version_ = 0;
|
||||
uint32_t win32_version_value_ = 0;
|
||||
uint32_t sizeof_image_ = 0;
|
||||
uint32_t sizeof_headers_ = 0;
|
||||
uint32_t checksum_ = 0;
|
||||
SUBSYSTEM subsystem_ = SUBSYSTEM::UNKNOWN;
|
||||
uint32_t dll_characteristics_ = 0;
|
||||
uint64_t sizeof_stack_reserve_ = 0;
|
||||
uint64_t sizeof_stack_commit_ = 0;
|
||||
uint64_t sizeof_heap_reserve_ = 0;
|
||||
uint64_t sizeof_heap_commit_ = 0;
|
||||
uint32_t loader_flags_ = 0;
|
||||
uint32_t nb_rva_size_ = 0;
|
||||
|
||||
uint32_t computed_checksum_ = 0;
|
||||
};
|
||||
|
||||
LIEF_API const char* to_string(OptionalHeader::DLL_CHARACTERISTICS);
|
||||
LIEF_API const char* to_string(OptionalHeader::SUBSYSTEM);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::OptionalHeader::DLL_CHARACTERISTICS);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,10 @@ class LIEF_API ResourceNode : public Object {
|
||||
|
||||
void id(uint32_t id);
|
||||
void name(const std::string& name);
|
||||
void name(const std::u16string& name);
|
||||
|
||||
void name(std::u16string name) {
|
||||
name_ = std::move(name);
|
||||
}
|
||||
|
||||
//! Add a ResourceDirectory to the current node
|
||||
ResourceNode& add_child(const ResourceDirectory& child);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#define LIEF_PE_RICH_ENTRY_H
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
#include <cstdint>
|
||||
|
||||
#include "LIEF/Object.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
+109
-23
@@ -23,6 +23,7 @@
|
||||
#include "LIEF/visibility.h"
|
||||
#include "LIEF/iterators.hpp"
|
||||
#include "LIEF/Abstract/Section.hpp"
|
||||
#include "LIEF/enums.hpp"
|
||||
#include "LIEF/PE/enums.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
@@ -45,6 +46,45 @@ class LIEF_API Section : public LIEF::Section {
|
||||
|
||||
public:
|
||||
using LIEF::Section::name;
|
||||
static constexpr size_t MAX_SECTION_NAME = 8;
|
||||
|
||||
enum class CHARACTERISTICS: size_t {
|
||||
TYPE_NO_PAD = 0x00000008,
|
||||
CNT_CODE = 0x00000020,
|
||||
CNT_INITIALIZED_DATA = 0x00000040,
|
||||
CNT_UNINITIALIZED_DATA = 0x00000080,
|
||||
LNK_OTHER = 0x00000100,
|
||||
LNK_INFO = 0x00000200,
|
||||
LNK_REMOVE = 0x00000800,
|
||||
LNK_COMDAT = 0x00001000,
|
||||
GPREL = 0x00008000,
|
||||
MEM_PURGEABLE = 0x00010000,
|
||||
MEM_16BIT = 0x00020000,
|
||||
MEM_LOCKED = 0x00040000,
|
||||
MEM_PRELOAD = 0x00080000,
|
||||
ALIGN_1BYTES = 0x00100000,
|
||||
ALIGN_2BYTES = 0x00200000,
|
||||
ALIGN_4BYTES = 0x00300000,
|
||||
ALIGN_8BYTES = 0x00400000,
|
||||
ALIGN_16BYTES = 0x00500000,
|
||||
ALIGN_32BYTES = 0x00600000,
|
||||
ALIGN_64BYTES = 0x00700000,
|
||||
ALIGN_128BYTES = 0x00800000,
|
||||
ALIGN_256BYTES = 0x00900000,
|
||||
ALIGN_512BYTES = 0x00A00000,
|
||||
ALIGN_1024BYTES = 0x00B00000,
|
||||
ALIGN_2048BYTES = 0x00C00000,
|
||||
ALIGN_4096BYTES = 0x00D00000,
|
||||
ALIGN_8192BYTES = 0x00E00000,
|
||||
LNK_NRELOC_OVFL = 0x01000000,
|
||||
MEM_DISCARDABLE = 0x02000000,
|
||||
MEM_NOT_CACHED = 0x04000000,
|
||||
MEM_NOT_PAGED = 0x08000000,
|
||||
MEM_SHARED = 0x10000000,
|
||||
MEM_EXECUTE = 0x20000000,
|
||||
MEM_READ = 0x40000000,
|
||||
MEM_WRITE = 0x80000000
|
||||
};
|
||||
|
||||
Section(const details::pe_section& header);
|
||||
Section();
|
||||
@@ -62,10 +102,14 @@ class LIEF_API Section : public LIEF::Section {
|
||||
//! Return the size of the data when mapped in memory
|
||||
//!
|
||||
//! If this value is greater than sizeof_raw_data, the section is zero-padded.
|
||||
uint32_t virtual_size() const;
|
||||
uint32_t virtual_size() const {
|
||||
return virtual_size_;
|
||||
}
|
||||
|
||||
//! The actual content of the section
|
||||
span<const uint8_t> content() const override;
|
||||
span<const uint8_t> content() const override {
|
||||
return content_;
|
||||
}
|
||||
|
||||
//! Content of the section's padding area
|
||||
const std::vector<uint8_t>& padding() const {
|
||||
@@ -80,23 +124,33 @@ class LIEF_API Section : public LIEF::Section {
|
||||
//!
|
||||
//! For modern PE binaries, this value is usually set to 0 as the relocations are managed by
|
||||
//! PE::Relocation.
|
||||
uint32_t pointerto_relocation() const;
|
||||
uint32_t pointerto_relocation() const {
|
||||
return pointer_to_relocations_;
|
||||
}
|
||||
|
||||
//! The file pointer to the beginning of line-number entries for the section.
|
||||
//! This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF
|
||||
//! debugging information is deprecated and modern debug information relies on the PDB files.
|
||||
uint32_t pointerto_line_numbers() const;
|
||||
uint32_t pointerto_line_numbers() const {
|
||||
return pointer_to_linenumbers_;
|
||||
}
|
||||
|
||||
//! No longer used in recent PE binaries produced by Visual Studio
|
||||
uint16_t numberof_relocations() const;
|
||||
uint16_t numberof_relocations() const {
|
||||
return number_of_relocations_;
|
||||
}
|
||||
|
||||
//! No longer used in recent PE binaries produced by Visual Studio
|
||||
uint16_t numberof_line_numbers() const;
|
||||
uint16_t numberof_line_numbers() const {
|
||||
return number_of_linenumbers_;
|
||||
}
|
||||
|
||||
//! Characteristics of the section: it gives information about
|
||||
//! the permissions of the section when mapped. It can also provides
|
||||
//! information about the *purpose* of the section (contain code, BSS-like, ...)
|
||||
uint32_t characteristics() const;
|
||||
uint32_t characteristics() const {
|
||||
return characteristics_;
|
||||
}
|
||||
|
||||
//! Deprecated do not use. It will likely change in a future release of LIEF
|
||||
bool is_type(PE_SECTION_TYPES type) const;
|
||||
@@ -104,35 +158,62 @@ class LIEF_API Section : public LIEF::Section {
|
||||
//! Deprecated do not use. It will likely change in a future release of LIEF
|
||||
const std::set<PE_SECTION_TYPES>& types() const;
|
||||
|
||||
//! Check if the section has the given SECTION_CHARACTERISTICS
|
||||
bool has_characteristic(SECTION_CHARACTERISTICS c) const;
|
||||
//! Check if the section has the given CHARACTERISTICS
|
||||
bool has_characteristic(CHARACTERISTICS c) const {
|
||||
return (characteristics() & static_cast<size_t>(c)) > 0;
|
||||
}
|
||||
|
||||
//! List of the section characteristics as a std::set
|
||||
std::set<SECTION_CHARACTERISTICS> characteristics_list() const;
|
||||
std::vector<CHARACTERISTICS> characteristics_list() const;
|
||||
|
||||
//! Fill the content of the section with the given ``char``
|
||||
void clear(uint8_t c);
|
||||
|
||||
void name(const std::string& name) override;
|
||||
void content(const std::vector<uint8_t>& data) override;
|
||||
|
||||
void virtual_size(uint32_t virtualSize);
|
||||
void pointerto_raw_data(uint32_t pointerToRawData);
|
||||
void pointerto_relocation(uint32_t pointerToRelocation);
|
||||
void pointerto_line_numbers(uint32_t pointerToLineNumbers);
|
||||
void numberof_relocations(uint16_t numberOfRelocations);
|
||||
void numberof_line_numbers(uint16_t numberOfLineNumbers);
|
||||
void name(const std::string& name) override;
|
||||
|
||||
void virtual_size(uint32_t virtual_sz) {
|
||||
virtual_size_ = virtual_sz;
|
||||
}
|
||||
|
||||
void pointerto_raw_data(uint32_t ptr);
|
||||
|
||||
void pointerto_relocation(uint32_t ptr) {
|
||||
pointer_to_relocations_ = ptr;
|
||||
}
|
||||
|
||||
void pointerto_line_numbers(uint32_t ptr) {
|
||||
pointer_to_linenumbers_ = ptr;
|
||||
}
|
||||
|
||||
void numberof_relocations(uint16_t nb) {
|
||||
number_of_relocations_ = nb;
|
||||
}
|
||||
|
||||
void numberof_line_numbers(uint16_t nb) {
|
||||
number_of_linenumbers_ = nb;
|
||||
}
|
||||
|
||||
void sizeof_raw_data(uint32_t sizeOfRawData);
|
||||
void characteristics(uint32_t characteristics);
|
||||
|
||||
void characteristics(uint32_t characteristics) {
|
||||
characteristics_ = characteristics;
|
||||
}
|
||||
|
||||
void type(PE_SECTION_TYPES type);
|
||||
void add_type(PE_SECTION_TYPES type);
|
||||
void remove_type(PE_SECTION_TYPES type);
|
||||
void add_characteristic(SECTION_CHARACTERISTICS characteristic);
|
||||
void remove_characteristic(SECTION_CHARACTERISTICS characteristic);
|
||||
|
||||
void remove_characteristic(Section::CHARACTERISTICS characteristic) {
|
||||
characteristics_ &= ~static_cast<size_t>(characteristic);
|
||||
}
|
||||
|
||||
void add_characteristic(Section::CHARACTERISTICS characteristic) {
|
||||
characteristics_ |= static_cast<size_t>(characteristic);
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const Section& section);
|
||||
|
||||
private:
|
||||
@@ -151,6 +232,11 @@ class LIEF_API Section : public LIEF::Section {
|
||||
std::set<PE_SECTION_TYPES> types_ = {PE_SECTION_TYPES::UNKNOWN};
|
||||
};
|
||||
|
||||
LIEF_API const char* to_string(Section::CHARACTERISTICS e);
|
||||
|
||||
} // namespace PE
|
||||
} // namespace LIEF
|
||||
#endif /* _PE_SECTION_H */
|
||||
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::Section::CHARACTERISTICS)
|
||||
|
||||
#endif
|
||||
|
||||
+83
-36
@@ -53,14 +53,17 @@ class LIEF_API TLS : public Object {
|
||||
~TLS() override;
|
||||
|
||||
TLS(const TLS& copy);
|
||||
TLS& operator=(TLS copy);
|
||||
void swap(TLS& other);
|
||||
TLS& operator=(const TLS& copy);
|
||||
|
||||
TLS(TLS&& other);
|
||||
TLS& operator=(TLS&& other);
|
||||
|
||||
//! List of the callback associated with the current TLS.
|
||||
//!
|
||||
//! These functions are called before any other functions of the PE binary.
|
||||
const std::vector<uint64_t>& callbacks() const;
|
||||
|
||||
const std::vector<uint64_t>& callbacks() const {
|
||||
return callbacks_;
|
||||
}
|
||||
|
||||
//! Pair ``(start address, end address)`` of the TLS template.
|
||||
//! The template is a block of data that is used to initialize TLS data.
|
||||
@@ -68,75 +71,119 @@ class LIEF_API TLS : public Object {
|
||||
//! corrupted.
|
||||
|
||||
//! @note
|
||||
//! These addresses are not RVA. It is addresses for which there should be a base
|
||||
//! These addresses are not RVA. It is addresses for which there should be a rebase
|
||||
//! relocation in the ``.reloc`` section.
|
||||
std::pair<uint64_t, uint64_t> addressof_raw_data() const;
|
||||
const std::pair<uint64_t, uint64_t>& addressof_raw_data() const {
|
||||
return va_rawdata_;
|
||||
}
|
||||
|
||||
//! The location to receive the TLS index, which the loader assigns.
|
||||
//! This location is in an ordinary data section, so it can be given a symbolic name that is accessible
|
||||
//! to the program.
|
||||
uint64_t addressof_index() const;
|
||||
uint64_t addressof_index() const {
|
||||
return addressof_index_;
|
||||
}
|
||||
|
||||
|
||||
//! The pointer to an array of TLS callback functions.
|
||||
//!
|
||||
//! The array is null-terminated, so if no callback function
|
||||
//! is supported, this field points to 4 bytes set to zero.
|
||||
uint64_t addressof_callbacks() const;
|
||||
uint64_t addressof_callbacks() const {
|
||||
return addressof_callbacks_;
|
||||
}
|
||||
|
||||
//! The size in bytes of the template, beyond the initialized data delimited by
|
||||
//! the addressof_raw_data field.
|
||||
//! The total template size should be the same as the total size of TLS data in the image file.
|
||||
//! The zero fill is the amount of data that comes after the initialized nonzero data.
|
||||
uint32_t sizeof_zero_fill() const;
|
||||
uint32_t sizeof_zero_fill() const {
|
||||
return sizeof_zero_fill_;
|
||||
}
|
||||
|
||||
//! The four bits [23:20] describe alignment info.
|
||||
//! Possible values are those defined as IMAGE_SCN_ALIGN_*, which are also used to
|
||||
//! describe alignment of section in object files. The other 28 bits are reserved for future use.
|
||||
uint32_t characteristics() const;
|
||||
uint32_t characteristics() const {
|
||||
return characteristics_;
|
||||
}
|
||||
|
||||
//! The data template content
|
||||
span<const uint8_t> data_template() const;
|
||||
span<const uint8_t> data_template() const {
|
||||
return data_template_;
|
||||
}
|
||||
|
||||
//! True if there is a data directory associated with this entry
|
||||
bool has_data_directory() const;
|
||||
bool has_data_directory() const {
|
||||
return directory_ != nullptr;
|
||||
}
|
||||
|
||||
//! Return the DataDirectory associated with this object or a nullptr
|
||||
//! If it exists, its type should be DATA_DIRECTORY::TLS_TABLE
|
||||
DataDirectory* directory();
|
||||
const DataDirectory* directory() const;
|
||||
//! If it exists, its type should be DataDirectory::TYPES::TLS_TABLE
|
||||
DataDirectory* directory() {
|
||||
return directory_;
|
||||
}
|
||||
|
||||
const DataDirectory* directory() const {
|
||||
return directory_;
|
||||
}
|
||||
|
||||
//! Check if there is a section associated with this entry
|
||||
bool has_section() const;
|
||||
bool has_section() const {
|
||||
return section_ != nullptr;
|
||||
}
|
||||
|
||||
//! The section associated with the entry (or a nullptr)
|
||||
Section* section();
|
||||
const Section* section() const;
|
||||
Section* section() {
|
||||
return section_;
|
||||
}
|
||||
|
||||
void callbacks(const std::vector<uint64_t>& callbacks);
|
||||
void addressof_raw_data(std::pair<uint64_t, uint64_t> VAOfRawData);
|
||||
void addressof_index(uint64_t addressOfIndex);
|
||||
void addressof_callbacks(uint64_t addressOfCallbacks);
|
||||
void sizeof_zero_fill(uint32_t sizeOfZeroFill);
|
||||
void characteristics(uint32_t characteristics);
|
||||
void data_template(const std::vector<uint8_t>& dataTemplate);
|
||||
const Section* section() const {
|
||||
return section_;
|
||||
}
|
||||
|
||||
void callbacks(std::vector<uint64_t> callbacks) {
|
||||
callbacks_ = std::move(callbacks);
|
||||
}
|
||||
|
||||
void addressof_raw_data(std::pair<uint64_t, uint64_t> addresses) {
|
||||
va_rawdata_ = addresses;
|
||||
}
|
||||
|
||||
void addressof_index(uint64_t addr_idx) {
|
||||
addressof_index_ = addr_idx;
|
||||
}
|
||||
|
||||
void addressof_callbacks(uint64_t addr) {
|
||||
addressof_callbacks_ = addr;
|
||||
}
|
||||
|
||||
void sizeof_zero_fill(uint32_t size) {
|
||||
sizeof_zero_fill_ = size;
|
||||
}
|
||||
|
||||
void characteristics(uint32_t characteristics) {
|
||||
characteristics_ = characteristics;
|
||||
}
|
||||
|
||||
void data_template(std::vector<uint8_t> data_template) {
|
||||
data_template_ = std::move(data_template);
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const TLS& entry);
|
||||
|
||||
private:
|
||||
std::vector<uint64_t> callbacks_;
|
||||
std::pair<uint64_t, uint64_t> VAOfRawData_;
|
||||
uint64_t addressof_index_ = 0;
|
||||
uint64_t addressof_callbacks_ = 0;
|
||||
uint32_t sizeof_zero_fill_ = 0;
|
||||
uint32_t characteristics_ = 0;
|
||||
DataDirectory* directory_ = nullptr;
|
||||
Section* section_ = nullptr;
|
||||
std::vector<uint8_t> data_template_;
|
||||
|
||||
std::vector<uint64_t> callbacks_;
|
||||
std::pair<uint64_t, uint64_t> va_rawdata_;
|
||||
uint64_t addressof_index_ = 0;
|
||||
uint64_t addressof_callbacks_ = 0;
|
||||
uint32_t sizeof_zero_fill_ = 0;
|
||||
uint32_t characteristics_ = 0;
|
||||
DataDirectory* directory_ = nullptr;
|
||||
Section* section_ = nullptr;
|
||||
std::vector<uint8_t> data_template_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ class LIEF_API CodeViewPDB : public CodeView {
|
||||
age_ = age;
|
||||
}
|
||||
|
||||
void signature(signature_t sig) {
|
||||
signature_ = std::move(sig);
|
||||
void signature(const signature_t& sig) {
|
||||
signature_ = sig;
|
||||
}
|
||||
|
||||
void filename(const std::string& filename) {
|
||||
void filename(std::string filename) {
|
||||
filename_ = std::move(filename);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class LIEF_API PogoEntry : public Object {
|
||||
|
||||
public:
|
||||
PogoEntry();
|
||||
PogoEntry(PogoEntry&& other);
|
||||
PogoEntry& operator=(PogoEntry&& other);
|
||||
PogoEntry(const PogoEntry&);
|
||||
PogoEntry(uint32_t start_rva, uint32_t size, std::string name) :
|
||||
start_rva_{start_rva},
|
||||
|
||||
@@ -28,34 +28,6 @@ enum class PE_TYPES: size_t {
|
||||
PE32_PLUS = 0x20b /** 64 bits */
|
||||
};
|
||||
|
||||
enum class MACHINE_TYPES: size_t {
|
||||
MT_Invalid = 0xffff,
|
||||
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
|
||||
IMAGE_FILE_MACHINE_AM33 = 0x1D3, /**< Matsushita AM33 */
|
||||
IMAGE_FILE_MACHINE_AMD64 = 0x8664, /**< AMD x64 */
|
||||
IMAGE_FILE_MACHINE_ARM = 0x1C0, /**< ARM little endian */
|
||||
IMAGE_FILE_MACHINE_ARMNT = 0x1C4, /**< ARMv7 Thumb mode only */
|
||||
IMAGE_FILE_MACHINE_ARM64 = 0xAA64, /**< ARMv8 in 64-bits mode */
|
||||
IMAGE_FILE_MACHINE_EBC = 0xEBC, /**< EFI byte code */
|
||||
IMAGE_FILE_MACHINE_I386 = 0x14C, /**< Intel 386 or later */
|
||||
IMAGE_FILE_MACHINE_IA64 = 0x200, /**< Intel Itanium processor family */
|
||||
IMAGE_FILE_MACHINE_M32R = 0x9041, /**< Mitsubishi M32R little endian */
|
||||
IMAGE_FILE_MACHINE_MIPS16 = 0x266, /**< MIPS16 */
|
||||
IMAGE_FILE_MACHINE_MIPSFPU = 0x366, /**< MIPS with FPU */
|
||||
IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466, /**< MIPS16 with FPU */
|
||||
IMAGE_FILE_MACHINE_POWERPC = 0x1F0, /**< Power PC little endian */
|
||||
IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1, /**< Power PC with floating point */
|
||||
IMAGE_FILE_MACHINE_R4000 = 0x166, /**< MIPS with little endian */
|
||||
IMAGE_FILE_MACHINE_RISCV32 = 0x5032, /**< RISC-V 32-bit address space */
|
||||
IMAGE_FILE_MACHINE_RISCV64 = 0x5064, /**< RISC-V 64-bit address space */
|
||||
IMAGE_FILE_MACHINE_RISCV128 = 0x5128, /**< RISC-V 128-bit address space */
|
||||
IMAGE_FILE_MACHINE_SH3 = 0x1A2, /**< Hitachi SH3 */
|
||||
IMAGE_FILE_MACHINE_SH3DSP = 0x1A3, /**< Hitachi SH3 DSP */
|
||||
IMAGE_FILE_MACHINE_SH4 = 0x1A6, /**< Hitachi SH4 */
|
||||
IMAGE_FILE_MACHINE_SH5 = 0x1A8, /**< Hitachi SH5 */
|
||||
IMAGE_FILE_MACHINE_THUMB = 0x1C2, /**< ARM or Thumb */
|
||||
IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169 /**< MIPS little-endian WCE v2 */
|
||||
};
|
||||
|
||||
enum SYMBOL_SECTION_NUMBER: int {
|
||||
IMAGE_SYM_DEBUG = -2,
|
||||
@@ -63,27 +35,6 @@ enum SYMBOL_SECTION_NUMBER: int {
|
||||
IMAGE_SYM_UNDEFINED = 0
|
||||
};
|
||||
|
||||
|
||||
enum class HEADER_CHARACTERISTICS: size_t {
|
||||
IMAGE_FILE_INVALID = 0x0000,
|
||||
IMAGE_FILE_RELOCS_STRIPPED = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
|
||||
IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002, /**< The file is valid and can be run.*/
|
||||
IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
|
||||
IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
|
||||
IMAGE_FILE_AGGRESSIVE_WS_TRIM = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
|
||||
IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020, /**< Image can handle > 2GiB addresses. */
|
||||
IMAGE_FILE_BYTES_REVERSED_LO = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
|
||||
IMAGE_FILE_32BIT_MACHINE = 0x0100, /**< Machine is based on a 32bit word architecture. */
|
||||
IMAGE_FILE_DEBUG_STRIPPED = 0x0200, /**< Debugging info has been removed. */
|
||||
IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
|
||||
IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
|
||||
IMAGE_FILE_SYSTEM = 0x1000, /**< The image file is a system file, not a user program.*/
|
||||
IMAGE_FILE_DLL = 0x2000, /**< The image file is a DLL. */
|
||||
IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000, /**< This file should only be run on a uniprocessor machine. */
|
||||
IMAGE_FILE_BYTES_REVERSED_HI = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
|
||||
};
|
||||
|
||||
|
||||
/// Storage class tells where and what the symbol represents
|
||||
enum SYMBOL_STORAGE_CLASS: int {
|
||||
IMAGE_SYM_CLASS_INVALID = 0xFF,
|
||||
@@ -233,82 +184,6 @@ enum class WeakExternalCharacteristics: size_t {
|
||||
};
|
||||
|
||||
|
||||
enum class DATA_DIRECTORY: size_t {
|
||||
EXPORT_TABLE = 0,
|
||||
IMPORT_TABLE = 1,
|
||||
RESOURCE_TABLE = 2,
|
||||
EXCEPTION_TABLE = 3,
|
||||
CERTIFICATE_TABLE = 4,
|
||||
BASE_RELOCATION_TABLE = 5,
|
||||
DEBUG = 6,
|
||||
ARCHITECTURE = 7,
|
||||
GLOBAL_PTR = 8,
|
||||
TLS_TABLE = 9,
|
||||
LOAD_CONFIG_TABLE = 10,
|
||||
BOUND_IMPORT = 11,
|
||||
IAT = 12,
|
||||
DELAY_IMPORT_DESCRIPTOR = 13,
|
||||
CLR_RUNTIME_HEADER = 14,
|
||||
RESERVED = 15,
|
||||
|
||||
NUM_DATA_DIRECTORIES = 16
|
||||
};
|
||||
|
||||
|
||||
enum class SUBSYSTEM: size_t {
|
||||
IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem.
|
||||
IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes
|
||||
IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem.
|
||||
IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem.
|
||||
IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem.
|
||||
IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE.
|
||||
IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application.
|
||||
IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot services.
|
||||
IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time services.
|
||||
IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image.
|
||||
IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
|
||||
};
|
||||
|
||||
enum class DLL_CHARACTERISTICS: size_t {
|
||||
IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020, ///< ASLR with 64 bit address space.
|
||||
IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040, ///< DLL can be relocated at load time.
|
||||
IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080, ///< Code integrity checks are enforced.
|
||||
IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100, ///< Image is NX compatible.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200, ///< Isolation aware, but do not isolate the image.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_SEH = 0x0400, ///< Does not use structured exception handling (SEH). No SEH handler may be called in this image.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_BIND = 0x0800, ///< Do not bind the image.
|
||||
IMAGE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000, ///< Image should execute in an AppContainer.
|
||||
IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000, ///< A WDM driver.
|
||||
IMAGE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000, ///< Image supports Control Flow Guard.
|
||||
IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000 ///< Terminal Server aware.
|
||||
};
|
||||
|
||||
|
||||
enum class DEBUG_TYPES: size_t {
|
||||
IMAGE_DEBUG_TYPE_UNKNOWN = 0,
|
||||
IMAGE_DEBUG_TYPE_COFF = 1, ///< COFF debug information
|
||||
IMAGE_DEBUG_TYPE_CODEVIEW = 2, ///< CodeView debug information (pdb & cie)
|
||||
IMAGE_DEBUG_TYPE_FPO = 3, ///< Frame pointer omission information
|
||||
IMAGE_DEBUG_TYPE_MISC = 4, ///< CodeView Debug Information
|
||||
IMAGE_DEBUG_TYPE_EXCEPTION = 5, ///< A copy of .pdata section.
|
||||
IMAGE_DEBUG_TYPE_FIXUP = 6, ///< Reserved.
|
||||
IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7, ///< The mapping from an RVA in image to an RVA in source image.
|
||||
IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8, ///< The mapping from an RVA in source image to an RVA in image.
|
||||
IMAGE_DEBUG_TYPE_BORLAND = 9, ///< Reserved for Borland.
|
||||
IMAGE_DEBUG_TYPE_RESERVED10 = 10, ///< Reserved for future use.
|
||||
IMAGE_DEBUG_TYPE_CLSID = 11,
|
||||
IMAGE_DEBUG_TYPE_VC_FEATURE = 12,
|
||||
IMAGE_DEBUG_TYPE_POGO = 13,
|
||||
IMAGE_DEBUG_TYPE_ILTCG = 14,
|
||||
IMAGE_DEBUG_TYPE_MPX = 15,
|
||||
IMAGE_DEBUG_TYPE_REPRO = 16,
|
||||
IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS = 20,
|
||||
};
|
||||
|
||||
|
||||
enum class ImportType: size_t {
|
||||
IMPORT_CODE = 0,
|
||||
IMPORT_DATA = 1,
|
||||
@@ -716,46 +591,6 @@ enum class RESOURCE_SUBLANGS: size_t {
|
||||
};
|
||||
|
||||
|
||||
enum class SECTION_CHARACTERISTICS: size_t {
|
||||
SC_Invalid = 0xffffffff,
|
||||
|
||||
IMAGE_SCN_TYPE_NO_PAD = 0x00000008,
|
||||
IMAGE_SCN_CNT_CODE = 0x00000020,
|
||||
IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,
|
||||
IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
|
||||
IMAGE_SCN_LNK_OTHER = 0x00000100,
|
||||
IMAGE_SCN_LNK_INFO = 0x00000200,
|
||||
IMAGE_SCN_LNK_REMOVE = 0x00000800,
|
||||
IMAGE_SCN_LNK_COMDAT = 0x00001000,
|
||||
IMAGE_SCN_GPREL = 0x00008000,
|
||||
IMAGE_SCN_MEM_PURGEABLE = 0x00010000,
|
||||
IMAGE_SCN_MEM_16BIT = 0x00020000,
|
||||
IMAGE_SCN_MEM_LOCKED = 0x00040000,
|
||||
IMAGE_SCN_MEM_PRELOAD = 0x00080000,
|
||||
IMAGE_SCN_ALIGN_1BYTES = 0x00100000,
|
||||
IMAGE_SCN_ALIGN_2BYTES = 0x00200000,
|
||||
IMAGE_SCN_ALIGN_4BYTES = 0x00300000,
|
||||
IMAGE_SCN_ALIGN_8BYTES = 0x00400000,
|
||||
IMAGE_SCN_ALIGN_16BYTES = 0x00500000,
|
||||
IMAGE_SCN_ALIGN_32BYTES = 0x00600000,
|
||||
IMAGE_SCN_ALIGN_64BYTES = 0x00700000,
|
||||
IMAGE_SCN_ALIGN_128BYTES = 0x00800000,
|
||||
IMAGE_SCN_ALIGN_256BYTES = 0x00900000,
|
||||
IMAGE_SCN_ALIGN_512BYTES = 0x00A00000,
|
||||
IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000,
|
||||
IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000,
|
||||
IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000,
|
||||
IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000,
|
||||
IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,
|
||||
IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,
|
||||
IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,
|
||||
IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,
|
||||
IMAGE_SCN_MEM_SHARED = 0x10000000,
|
||||
IMAGE_SCN_MEM_EXECUTE = 0x20000000,
|
||||
IMAGE_SCN_MEM_READ = 0x40000000,
|
||||
IMAGE_SCN_MEM_WRITE = 0x80000000
|
||||
};
|
||||
|
||||
//! From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
|
||||
enum class EXTENDED_WINDOW_STYLES: size_t {
|
||||
WS_EX_DLGMODALFRAME = 0x00000001L,
|
||||
@@ -1687,9 +1522,6 @@ static const GUARD_CF_FLAGS guard_cf_flags_array[] = {
|
||||
}
|
||||
}
|
||||
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::SECTION_CHARACTERISTICS)
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::DLL_CHARACTERISTICS)
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::HEADER_CHARACTERISTICS)
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::GUARD_CF_FLAGS)
|
||||
ENABLE_BITMASK_OPERATORS(LIEF::PE::ACCELERATOR_FLAGS)
|
||||
#endif
|
||||
|
||||
@@ -4,35 +4,6 @@ enum _LIEF_EN(PE_TYPES) {
|
||||
_LIEF_EI(PE32_PLUS) = 0x20b /** 64 bits */
|
||||
};
|
||||
|
||||
enum _LIEF_EN(MACHINE_TYPES) {
|
||||
_LIEF_EI(MT_Invalid) = 0xffff,
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_UNKNOWN) = 0x0,
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_AM33) = 0x1D3, /**< Matsushita AM33 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_AMD64) = 0x8664, /**< AMD x64 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_ARM) = 0x1C0, /**< ARM little endian */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_ARMNT) = 0x1C4, /**< ARMv7 Thumb mode only */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_ARM64) = 0xAA64, /**< ARMv8 in 64-bits mode */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_EBC) = 0xEBC, /**< EFI byte code */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_I386) = 0x14C, /**< Intel 386 or later */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_IA64) = 0x200, /**< Intel Itanium processor family */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_M32R) = 0x9041, /**< Mitsubishi M32R little endian */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_MIPS16) = 0x266, /**< MIPS16 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_MIPSFPU) = 0x366, /**< MIPS with FPU */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_MIPSFPU16) = 0x466, /**< MIPS16 with FPU */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_POWERPC) = 0x1F0, /**< Power PC little endian */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_POWERPCFP) = 0x1F1, /**< Power PC with floating point */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_R4000) = 0x166, /**< MIPS with little endian */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_RISCV32) = 0x5032, /**< RISC-V 32-bit address space */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_RISCV64) = 0x5064, /**< RISC-V 64-bit address space */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_RISCV128) = 0x5128, /**< RISC-V 128-bit address space */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_SH3) = 0x1A2, /**< Hitachi SH3 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_SH3DSP) = 0x1A3, /**< Hitachi SH3 DSP */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_SH4) = 0x1A6, /**< Hitachi SH4 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_SH5) = 0x1A8, /**< Hitachi SH5 */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_THUMB) = 0x1C2, /**< ARM or Thumb */
|
||||
_LIEF_EI(IMAGE_FILE_MACHINE_WCEMIPSV2) = 0x169 /**< MIPS little-endian WCE v2 */
|
||||
};
|
||||
|
||||
enum _LIEF_EN_2(SYMBOL_SECTION_NUMBER, int) {
|
||||
_LIEF_EI(IMAGE_SYM_DEBUG) = -2,
|
||||
_LIEF_EI(IMAGE_SYM_ABSOLUTE) = -1,
|
||||
@@ -40,26 +11,6 @@ enum _LIEF_EN_2(SYMBOL_SECTION_NUMBER, int) {
|
||||
};
|
||||
|
||||
|
||||
enum _LIEF_EN(HEADER_CHARACTERISTICS) {
|
||||
_LIEF_EI(IMAGE_FILE_INVALID) = 0x0000,
|
||||
_LIEF_EI(IMAGE_FILE_RELOCS_STRIPPED) = 0x0001, /**< The file does not contain base relocations and must be loaded at its preferred base. If this cannot be done, the loader will error.*/
|
||||
_LIEF_EI(IMAGE_FILE_EXECUTABLE_IMAGE) = 0x0002, /**< The file is valid and can be run.*/
|
||||
_LIEF_EI(IMAGE_FILE_LINE_NUMS_STRIPPED) = 0x0004, /**< COFF line numbers have been stripped. This is deprecated and should be 0*/
|
||||
_LIEF_EI(IMAGE_FILE_LOCAL_SYMS_STRIPPED) = 0x0008, /**< COFF symbol table entries for local symbols have been removed. This is deprecated and should be 0.*/
|
||||
_LIEF_EI(IMAGE_FILE_AGGRESSIVE_WS_TRIM) = 0x0010, /**< Aggressively trim working set. This is deprecated and must be 0.*/
|
||||
_LIEF_EI(IMAGE_FILE_LARGE_ADDRESS_AWARE) = 0x0020, /**< Image can handle > 2GiB addresses. */
|
||||
_LIEF_EI(IMAGE_FILE_BYTES_REVERSED_LO) = 0x0080, /**< Little endian: the LSB precedes the MSB in memory. This is deprecated and should be 0.*/
|
||||
_LIEF_EI(IMAGE_FILE_32BIT_MACHINE) = 0x0100, /**< Machine is based on a 32bit word architecture. */
|
||||
_LIEF_EI(IMAGE_FILE_DEBUG_STRIPPED) = 0x0200, /**< Debugging info has been removed. */
|
||||
_LIEF_EI(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP) = 0x0400, /**< If the image is on removable media, fully load it and copy it to swap. */
|
||||
_LIEF_EI(IMAGE_FILE_NET_RUN_FROM_SWAP) = 0x0800, /**< If the image is on network media, fully load it and copy it to swap. */
|
||||
_LIEF_EI(IMAGE_FILE_SYSTEM) = 0x1000, /**< The image file is a system file, not a user program.*/
|
||||
_LIEF_EI(IMAGE_FILE_DLL) = 0x2000, /**< The image file is a DLL. */
|
||||
_LIEF_EI(IMAGE_FILE_UP_SYSTEM_ONLY) = 0x4000, /**< This file should only be run on a uniprocessor machine. */
|
||||
_LIEF_EI(IMAGE_FILE_BYTES_REVERSED_HI) = 0x8000 /**< Big endian: the MSB precedes the LSB in memory. This is deprecated */
|
||||
};
|
||||
|
||||
|
||||
/** Storage class tells where and what the symbol represents */
|
||||
enum _LIEF_EN_2(SYMBOL_STORAGE_CLASS, int) {
|
||||
_LIEF_EI(IMAGE_SYM_CLASS_INVALID) = 0xFF,
|
||||
@@ -209,59 +160,6 @@ enum _LIEF_EN(WeakExternalCharacteristics) {
|
||||
};
|
||||
|
||||
|
||||
enum _LIEF_EN(DATA_DIRECTORY) {
|
||||
_LIEF_EI(EXPORT_TABLE) = 0,
|
||||
_LIEF_EI(IMPORT_TABLE) = 1,
|
||||
_LIEF_EI(RESOURCE_TABLE) = 2,
|
||||
_LIEF_EI(EXCEPTION_TABLE) = 3,
|
||||
_LIEF_EI(CERTIFICATE_TABLE) = 4,
|
||||
_LIEF_EI(BASE_RELOCATION_TABLE) = 5,
|
||||
_LIEF_EI(DEBUG) = 6,
|
||||
_LIEF_EI(ARCHITECTURE) = 7,
|
||||
_LIEF_EI(GLOBAL_PTR) = 8,
|
||||
_LIEF_EI(TLS_TABLE) = 9,
|
||||
_LIEF_EI(LOAD_CONFIG_TABLE) = 10,
|
||||
_LIEF_EI(BOUND_IMPORT) = 11,
|
||||
_LIEF_EI(IAT) = 12,
|
||||
_LIEF_EI(DELAY_IMPORT_DESCRIPTOR) = 13,
|
||||
_LIEF_EI(CLR_RUNTIME_HEADER) = 14,
|
||||
_LIEF_EI(RESERVED) = 15,
|
||||
|
||||
_LIEF_EI(NUM_DATA_DIRECTORIES) = 16
|
||||
};
|
||||
|
||||
|
||||
enum _LIEF_EN(SUBSYSTEM) {
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_UNKNOWN) = 0, /**< An unknown subsystem. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_NATIVE) = 1, /**< Device drivers and native Windows processes */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_WINDOWS_GUI) = 2, /**< The Windows GUI subsystem. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_WINDOWS_CUI) = 3, /**< The Windows character subsystem. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_OS2_CUI) = 5, /**< The OS/2 character subsytem. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_POSIX_CUI) = 7, /**< The POSIX character subsystem. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_NATIVE_WINDOWS) = 8, /**< Native Windows 9x driver. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI) = 9, /**< Windows CE. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_EFI_APPLICATION) = 10, /**< An EFI application. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER) = 11, /**< An EFI driver with boot services. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) = 12, /**< An EFI driver with run-time services. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_EFI_ROM) = 13, /**< An EFI ROM image. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_XBOX) = 14, /**< XBOX. */
|
||||
_LIEF_EI(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION) = 16 /**< A BCD application. */
|
||||
};
|
||||
|
||||
enum _LIEF_EN(DLL_CHARACTERISTICS) {
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA) = 0x0020, /**< ASLR with 64 bit address space. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE) = 0x0040, /**< DLL can be relocated at load time. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY) = 0x0080, /**< Code integrity checks are enforced. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_NX_COMPAT) = 0x0100, /**< Image is NX compatible. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION) = 0x0200, /**< Isolation aware, but do not isolate the image. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_NO_SEH) = 0x0400, /**< Does not use structured exception handling (SEH). No SEH handler may be called in this image. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_NO_BIND) = 0x0800, /**< Do not bind the image. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_APPCONTAINER) = 0x1000, /**< Image should execute in an AppContainer. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER) = 0x2000, /**< A WDM driver. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_GUARD_CF) = 0x4000, /**< Image supports Control Flow Guard. */
|
||||
_LIEF_EI(IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE) = 0x8000 /**< Terminal Server aware. */
|
||||
};
|
||||
|
||||
|
||||
enum _LIEF_EN(DEBUG_TYPES) {
|
||||
_LIEF_EI(IMAGE_DEBUG_TYPE_UNKNOWN) = 0,
|
||||
@@ -713,46 +611,6 @@ enum _LIEF_EN(RESOURCE_SUBLANGS) {
|
||||
};
|
||||
|
||||
|
||||
enum _LIEF_EN(SECTION_CHARACTERISTICS) {
|
||||
_LIEF_EI(SC_Invalid) = 0xffffffff,
|
||||
|
||||
_LIEF_EI(IMAGE_SCN_TYPE_NO_PAD) = 0x00000008,
|
||||
_LIEF_EI(IMAGE_SCN_CNT_CODE) = 0x00000020,
|
||||
_LIEF_EI(IMAGE_SCN_CNT_INITIALIZED_DATA) = 0x00000040,
|
||||
_LIEF_EI(IMAGE_SCN_CNT_UNINITIALIZED_DATA) = 0x00000080,
|
||||
_LIEF_EI(IMAGE_SCN_LNK_OTHER) = 0x00000100,
|
||||
_LIEF_EI(IMAGE_SCN_LNK_INFO) = 0x00000200,
|
||||
_LIEF_EI(IMAGE_SCN_LNK_REMOVE) = 0x00000800,
|
||||
_LIEF_EI(IMAGE_SCN_LNK_COMDAT) = 0x00001000,
|
||||
_LIEF_EI(IMAGE_SCN_GPREL) = 0x00008000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_PURGEABLE) = 0x00010000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_16BIT) = 0x00020000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_LOCKED) = 0x00040000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_PRELOAD) = 0x00080000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_1BYTES) = 0x00100000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_2BYTES) = 0x00200000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_4BYTES) = 0x00300000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_8BYTES) = 0x00400000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_16BYTES) = 0x00500000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_32BYTES) = 0x00600000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_64BYTES) = 0x00700000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_128BYTES) = 0x00800000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_256BYTES) = 0x00900000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_512BYTES) = 0x00A00000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_1024BYTES) = 0x00B00000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_2048BYTES) = 0x00C00000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_4096BYTES) = 0x00D00000,
|
||||
_LIEF_EI(IMAGE_SCN_ALIGN_8192BYTES) = 0x00E00000,
|
||||
_LIEF_EI(IMAGE_SCN_LNK_NRELOC_OVFL) = 0x01000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_DISCARDABLE) = 0x02000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_NOT_CACHED) = 0x04000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_NOT_PAGED) = 0x08000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_SHARED) = 0x10000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_EXECUTE) = 0x20000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_READ) = 0x40000000,
|
||||
_LIEF_EI(IMAGE_SCN_MEM_WRITE) = 0x80000000
|
||||
};
|
||||
|
||||
/** From https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles */
|
||||
enum _LIEF_EN(EXTENDED_WINDOW_STYLES) {
|
||||
_LIEF_EI(WS_EX_DLGMODALFRAME) = 0x00000001L,
|
||||
|
||||
@@ -143,6 +143,8 @@ class LIEF_API Hash : public LIEF::Hash {
|
||||
void visit(const x509& x509) override;
|
||||
void visit(const SignerInfo& signerinfo) override;
|
||||
void visit(const ContentInfo& contentinfo) override;
|
||||
void visit(const GenericContent& content) override;
|
||||
void visit(const SpcIndirectData& content) override;
|
||||
void visit(const Attribute& attr) override;
|
||||
void visit(const ContentType& attr) override;
|
||||
void visit(const GenericType& attr) override;
|
||||
|
||||
@@ -81,7 +81,9 @@ class LIEF_API ResourceVersion : public Object {
|
||||
|
||||
void type(uint16_t type);
|
||||
|
||||
void key(const std::u16string& key);
|
||||
void key(std::u16string key) {
|
||||
key_ = std::move(key);
|
||||
}
|
||||
void key(const std::string& key);
|
||||
|
||||
void fixed_file_info(const ResourceFixedFileInfo& fixed_file_info);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define LIEF_PE_CONTENT_INFO_H
|
||||
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
|
||||
#include "LIEF/Object.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
@@ -30,7 +32,8 @@ namespace PE {
|
||||
class Parser;
|
||||
class SignatureParser;
|
||||
|
||||
/** ContentInfo as described in the RFC2315 (https://tools.ietf.org/html/rfc2315#section-7)
|
||||
/**
|
||||
* ContentInfo as described in the RFC2315 (https://tools.ietf.org/html/rfc2315#section-7)
|
||||
*
|
||||
* ```text
|
||||
* ContentInfo ::= SEQUENCE {
|
||||
@@ -43,6 +46,7 @@ class SignatureParser;
|
||||
*
|
||||
* In the case of PE signature, ContentType **must** be set to SPC_INDIRECT_DATA_OBJID
|
||||
* OID: ``1.3.6.1.4.1.311.2.1.4`` and content is defined by the structure: ``SpcIndirectDataContent``
|
||||
*
|
||||
* ```text
|
||||
* SpcIndirectDataContent ::= SEQUENCE {
|
||||
* data SpcAttributeTypeAndOptionalValue,
|
||||
@@ -77,32 +81,47 @@ class LIEF_API ContentInfo : public Object {
|
||||
friend class SignatureParser;
|
||||
|
||||
public:
|
||||
class Content : public Object {
|
||||
public:
|
||||
Content(oid_t oid) :
|
||||
type_(std::move(oid))
|
||||
{}
|
||||
|
||||
const oid_t& content_type() const {
|
||||
return type_;
|
||||
}
|
||||
|
||||
virtual std::unique_ptr<Content> clone() const = 0;
|
||||
virtual void print(std::ostream& os) const = 0;
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const Content& content) {
|
||||
content.print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
~Content() override;
|
||||
private:
|
||||
oid_t type_;
|
||||
};
|
||||
ContentInfo();
|
||||
ContentInfo(const ContentInfo&);
|
||||
ContentInfo& operator=(const ContentInfo&);
|
||||
ContentInfo(const ContentInfo& other);
|
||||
ContentInfo(ContentInfo&& other);
|
||||
ContentInfo& operator=(ContentInfo other);
|
||||
|
||||
void swap(ContentInfo& other);
|
||||
|
||||
//! Return the OID that describes the content wrapped by this object.
|
||||
//! It should match SPC_INDIRECT_DATA_OBJID (1.3.6.1.4.1.311.2.1.4)
|
||||
oid_t content_type() const {
|
||||
return content_type_;
|
||||
return value_->content_type();
|
||||
}
|
||||
|
||||
//! Digest used to hash the file
|
||||
//!
|
||||
//! It should match LIEF::PE::SignerInfo::digest_algorithm
|
||||
ALGORITHMS digest_algorithm() const {
|
||||
return digest_algorithm_;
|
||||
Content& value() {
|
||||
return *value_;
|
||||
}
|
||||
|
||||
//! PE's authentihash
|
||||
//!
|
||||
//! @see LIEF::PE::Binary::authentihash
|
||||
const std::vector<uint8_t>& digest() const {
|
||||
return digest_;
|
||||
}
|
||||
|
||||
const std::string& file() const {
|
||||
return file_;
|
||||
const Content& value() const {
|
||||
return *value_;
|
||||
}
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
@@ -112,12 +131,7 @@ class LIEF_API ContentInfo : public Object {
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const ContentInfo& content_info);
|
||||
|
||||
private:
|
||||
oid_t content_type_;
|
||||
std::string file_;
|
||||
uint8_t flags_ = 0;
|
||||
ALGORITHMS digest_algorithm_ = ALGORITHMS::UNKNOWN;
|
||||
std::vector<uint8_t> digest_;
|
||||
|
||||
std::unique_ptr<Content> value_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
#ifndef LIEF_PE_GENERIC_CONTENT_H
|
||||
#define LIEF_PE_GENERIC_CONTENT_H
|
||||
#include "LIEF/span.hpp"
|
||||
#include "LIEF/PE/signature/ContentInfo.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
class GenericContent : public ContentInfo::Content {
|
||||
friend class SignatureParser;
|
||||
|
||||
public:
|
||||
GenericContent();
|
||||
GenericContent(oid_t oid);
|
||||
GenericContent(const GenericContent&);
|
||||
GenericContent& operator=(const GenericContent&);
|
||||
|
||||
std::unique_ptr<Content> clone() const override {
|
||||
return std::unique_ptr<Content>(new GenericContent{*this});
|
||||
}
|
||||
|
||||
const oid_t& oid() const {
|
||||
return oid_;
|
||||
}
|
||||
|
||||
span<const uint8_t> raw() const {
|
||||
return raw_;
|
||||
}
|
||||
|
||||
span<uint8_t> raw() {
|
||||
return raw_;
|
||||
}
|
||||
|
||||
~GenericContent() override;
|
||||
|
||||
void print(std::ostream& os) const override;
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const GenericContent& content) {
|
||||
content.print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
static bool classof(const ContentInfo::Content* content);
|
||||
|
||||
private:
|
||||
oid_t oid_;
|
||||
std::vector<uint8_t> raw_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -25,11 +25,14 @@
|
||||
#include "LIEF/PE/signature/OIDToString.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
class BinaryStream;
|
||||
class VectorStream;
|
||||
|
||||
namespace PE {
|
||||
class Parser;
|
||||
class Attribute;
|
||||
class SpcIndirectData;
|
||||
class PKCS9TSTInfo;
|
||||
|
||||
class LIEF_API SignatureParser {
|
||||
friend class Parser;
|
||||
@@ -56,38 +59,42 @@ class LIEF_API SignatureParser {
|
||||
//! Parse a PKCS #7 signature given a raw blob
|
||||
static result<Signature> parse(std::vector<uint8_t> data, bool skip_header = false);
|
||||
|
||||
//! Parse a PKCS #7 signature given a BinaryStream
|
||||
static result<Signature> parse(BinaryStream& stream, bool skip_header = false);
|
||||
|
||||
//! Parse a PKCS #7 signature from a file path
|
||||
static result<Signature> parse(const std::string& path);
|
||||
SignatureParser(const SignatureParser&) = delete;
|
||||
SignatureParser& operator=(const SignatureParser&) = delete;
|
||||
private:
|
||||
SignatureParser(std::vector<uint8_t> data);
|
||||
|
||||
~SignatureParser();
|
||||
SignatureParser();
|
||||
|
||||
result<Signature> parse_signature();
|
||||
static result<Signature> parse_signature(BinaryStream& stream);
|
||||
|
||||
static result<ContentInfo> parse_content_info(VectorStream& stream, range_t& range);
|
||||
static result<x509_certificates_t> parse_certificates(VectorStream& stream);
|
||||
result<signer_infos_t> parse_signer_infos(VectorStream& stream);
|
||||
result<attributes_t> parse_attributes(VectorStream& stream);
|
||||
static result<std::unique_ptr<Attribute>> parse_content_type(VectorStream& stream);
|
||||
static result<ContentInfo> parse_content_info(BinaryStream& stream, range_t& range);
|
||||
static result<x509_certificates_t> parse_certificates(BinaryStream& stream);
|
||||
static result<signer_infos_t> parse_signer_infos(BinaryStream& stream);
|
||||
static result<attributes_t> parse_attributes(BinaryStream& stream);
|
||||
static result<std::unique_ptr<Attribute>> parse_content_type(BinaryStream& stream);
|
||||
|
||||
result<signer_infos_t> parse_pkcs9_counter_sign(VectorStream& stream);
|
||||
static result<std::vector<uint8_t>> parse_pkcs9_message_digest(VectorStream& stream);
|
||||
static result<int32_t> parse_pkcs9_at_sequence_number(VectorStream& stream);
|
||||
static result<time_t> parse_pkcs9_signing_time(VectorStream& stream);
|
||||
static result<signer_infos_t> parse_pkcs9_counter_sign(BinaryStream& stream);
|
||||
static result<std::vector<uint8_t>> parse_pkcs9_message_digest(BinaryStream& stream);
|
||||
static result<int32_t> parse_pkcs9_at_sequence_number(BinaryStream& stream);
|
||||
static result<time_t> parse_pkcs9_signing_time(BinaryStream& stream);
|
||||
static result<std::unique_ptr<PKCS9TSTInfo>> parse_pkcs9_tstinfo(BinaryStream& stream);
|
||||
|
||||
static result<void> parse_ms_counter_sign(VectorStream& stream);
|
||||
static result<Signature> parse_ms_spc_nested_signature(VectorStream& stream);
|
||||
result<oid_t> parse_ms_spc_statement_type(VectorStream& stream);
|
||||
static result<std::unique_ptr<Attribute>> parse_ms_counter_sign(BinaryStream& stream);
|
||||
static result<Signature> parse_ms_spc_nested_signature(BinaryStream& stream);
|
||||
static result<oid_t> parse_ms_spc_statement_type(BinaryStream& stream);
|
||||
|
||||
static result<SpcSpOpusInfo> parse_spc_sp_opus_info(BinaryStream& stream);
|
||||
static result<std::string> parse_spc_string(BinaryStream& stream);
|
||||
static result<std::string> parse_spc_link(BinaryStream& stream);
|
||||
static result<SpcPeImageData> parse_spc_pe_image_data(BinaryStream& stream);
|
||||
static result<std::unique_ptr<SpcIndirectData>> parse_spc_indirect_data(BinaryStream& stream, range_t& range);
|
||||
|
||||
result<SpcSpOpusInfo> parse_spc_sp_opus_info(VectorStream& stream);
|
||||
static result<std::string> parse_spc_string(VectorStream& stream);
|
||||
static result<std::string> parse_spc_link(VectorStream& stream);
|
||||
static result<SpcPeImageData> parse_spc_pe_image_data(VectorStream& stream);
|
||||
size_t current_offset() const;
|
||||
std::unique_ptr<VectorStream> stream_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/* Copyright 2017 - 2023 R. Thomas
|
||||
* Copyright 2017 - 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
#ifndef LIEF_PE_SPC_INDIRECT_DATA_H
|
||||
#define LIEF_PE_SPC_INDIRECT_DATA_H
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "LIEF/span.hpp"
|
||||
#include "LIEF/PE/signature/ContentInfo.hpp"
|
||||
|
||||
namespace LIEF {
|
||||
namespace PE {
|
||||
class SpcIndirectData : public ContentInfo::Content {
|
||||
friend class SignatureParser;
|
||||
|
||||
public:
|
||||
SpcIndirectData();
|
||||
SpcIndirectData(const SpcIndirectData&);
|
||||
SpcIndirectData& operator=(const SpcIndirectData&);
|
||||
|
||||
std::unique_ptr<Content> clone() const override {
|
||||
return std::unique_ptr<Content>(new SpcIndirectData{*this});
|
||||
}
|
||||
|
||||
//! Digest used to hash the file
|
||||
//!
|
||||
//! It should match LIEF::PE::SignerInfo::digest_algorithm
|
||||
ALGORITHMS digest_algorithm() const {
|
||||
return digest_algorithm_;
|
||||
}
|
||||
|
||||
//! PE's authentihash
|
||||
//!
|
||||
//! @see LIEF::PE::Binary::authentihash
|
||||
span<const uint8_t> digest() const {
|
||||
return digest_;
|
||||
}
|
||||
|
||||
const std::string& file() const {
|
||||
return file_;
|
||||
}
|
||||
|
||||
void print(std::ostream& os) const override;
|
||||
|
||||
void accept(Visitor& visitor) const override;
|
||||
|
||||
LIEF_API friend std::ostream& operator<<(std::ostream& os, const SpcIndirectData& content) {
|
||||
content.print(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
~SpcIndirectData() override;
|
||||
|
||||
static bool classof(const ContentInfo::Content* content);
|
||||
|
||||
private:
|
||||
std::string file_;
|
||||
uint8_t flags_ = 0;
|
||||
ALGORITHMS digest_algorithm_ = ALGORITHMS::UNKNOWN;
|
||||
std::vector<uint8_t> digest_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -77,6 +77,8 @@ LIEF_PE_FORWARD(Signature)
|
||||
LIEF_PE_FORWARD(x509)
|
||||
LIEF_PE_FORWARD(SignerInfo)
|
||||
LIEF_PE_FORWARD(ContentInfo)
|
||||
LIEF_PE_FORWARD(GenericContent)
|
||||
LIEF_PE_FORWARD(SpcIndirectData)
|
||||
LIEF_PE_FORWARD(Attribute)
|
||||
LIEF_PE_FORWARD(ContentType)
|
||||
LIEF_PE_FORWARD(GenericType)
|
||||
@@ -402,6 +404,12 @@ class LIEF_API Visitor {
|
||||
//! Method to visit a LIEF::PE::ContentType
|
||||
LIEF_PE_VISITABLE(ContentType)
|
||||
|
||||
//! Method to visit a LIEF::PE::GenericContent
|
||||
LIEF_PE_VISITABLE(GenericContent)
|
||||
|
||||
//! Method to visit a LIEF::PE::SpcIndirectData
|
||||
LIEF_PE_VISITABLE(SpcIndirectData)
|
||||
|
||||
//! Method to visit a LIEF::PE::GenericType
|
||||
LIEF_PE_VISITABLE(GenericType)
|
||||
|
||||
|
||||
@@ -60,8 +60,7 @@ class ref_iterator {
|
||||
using pointer_t = typename ref_iterator::pointer;
|
||||
|
||||
ref_iterator(T container) :
|
||||
container_{std::forward<T>(container)},
|
||||
distance_{0}
|
||||
container_{std::forward<T>(container)}
|
||||
{
|
||||
it_ = std::begin(container_);
|
||||
}
|
||||
@@ -280,10 +279,8 @@ class filter_iterator {
|
||||
using filter_t = std::function<bool (const typename DT::value_type&)>;
|
||||
|
||||
filter_iterator(T container, filter_t filter) :
|
||||
size_c_{0},
|
||||
container_{std::forward<T>(container)},
|
||||
filters_{},
|
||||
distance_{0}
|
||||
filters_{}
|
||||
{
|
||||
|
||||
it_ = std::begin(container_);
|
||||
@@ -299,10 +296,8 @@ class filter_iterator {
|
||||
}
|
||||
|
||||
filter_iterator(T container, const std::vector<filter_t>& filters) :
|
||||
size_c_{0},
|
||||
container_{std::forward<T>(container)},
|
||||
filters_{filters},
|
||||
distance_{0}
|
||||
filters_{filters}
|
||||
{
|
||||
|
||||
it_ = std::begin(container_);
|
||||
@@ -315,16 +310,13 @@ class filter_iterator {
|
||||
}
|
||||
|
||||
filter_iterator(T container) :
|
||||
size_c_{0},
|
||||
container_{std::forward<T>(container)},
|
||||
filters_{},
|
||||
distance_{0}
|
||||
filters_{}
|
||||
{
|
||||
it_ = std::begin(container_);
|
||||
}
|
||||
|
||||
filter_iterator(const filter_iterator& copy) :
|
||||
size_c_{0},
|
||||
container_{copy.container_},
|
||||
it_{std::begin(container_)},
|
||||
filters_{copy.filters_},
|
||||
@@ -429,7 +421,7 @@ class filter_iterator {
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
if (filters_.size() == 0) {
|
||||
if (filters_.empty()) {
|
||||
return container_.size();
|
||||
}
|
||||
|
||||
@@ -476,11 +468,11 @@ class filter_iterator {
|
||||
}
|
||||
|
||||
|
||||
mutable size_t size_c_;
|
||||
mutable size_t size_c_ = 0;
|
||||
T container_;
|
||||
ITERATOR_T it_;
|
||||
std::vector<filter_t> filters_;
|
||||
typename filter_iterator::difference_type distance_;
|
||||
typename filter_iterator::difference_type distance_ = 0;
|
||||
};
|
||||
|
||||
//! Iterator which return a const ref on container's values given predicates
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "LIEF/span.hpp"
|
||||
#include "LIEF/types.hpp"
|
||||
#include "LIEF/visibility.h"
|
||||
|
||||
@@ -82,7 +83,11 @@ LIEF_API result<std::u16string> u8tou16(const std::string& string);
|
||||
|
||||
LIEF_API std::string hex_str(uint8_t c);
|
||||
|
||||
LIEF_API std::string hex_dump(const std::vector<uint8_t>& data, const std::string& sep = ":");
|
||||
LIEF_API std::string hex_dump(const std::vector<uint8_t>& data,
|
||||
const std::string& sep = ":");
|
||||
|
||||
LIEF_API std::string hex_dump(span<const uint8_t> data,
|
||||
const std::string& sep = ":");
|
||||
|
||||
//! Check if the given string in printable
|
||||
LIEF_API bool is_printable(const std::string& str);
|
||||
|
||||
@@ -22,11 +22,11 @@ set_target_properties(macho_profiler
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_executable(pe_profilier pe_profilier.cpp)
|
||||
target_compile_options(pe_profilier PUBLIC ${PROFILING_FLAGS})
|
||||
target_link_libraries(pe_profilier PRIVATE LIB_LIEF)
|
||||
add_executable(pe_profiler pe_profilier.cpp)
|
||||
target_compile_options(pe_profiler PUBLIC ${PROFILING_FLAGS})
|
||||
target_link_libraries(pe_profiler PRIVATE LIB_LIEF)
|
||||
|
||||
set_target_properties(pe_profilier
|
||||
set_target_properties(pe_profiler
|
||||
PROPERTIES POSITION_INDEPENDENT_CODE ON
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
+13
-42
@@ -1,45 +1,16 @@
|
||||
set(LIEF_ART_SRC
|
||||
${CMAKE_CURRENT_LIST_DIR}/Parser.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Parser.tcc
|
||||
${CMAKE_CURRENT_LIST_DIR}/File.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Header.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Header.tcc
|
||||
${CMAKE_CURRENT_LIST_DIR}/utils.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Structures.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/hash.cpp
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Parser.cpp
|
||||
Parser.tcc
|
||||
File.cpp
|
||||
EnumToString.cpp
|
||||
Header.cpp
|
||||
Header.tcc
|
||||
utils.cpp
|
||||
Structures.cpp
|
||||
hash.cpp
|
||||
json_api.cpp
|
||||
)
|
||||
|
||||
set(LIEF_ART_INC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/File.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/Header.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/Parser.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/types.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/EnumToString.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/java_structures.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/hash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/enums.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Structures.hpp"
|
||||
|
||||
)
|
||||
|
||||
# JSON Public API: Always present
|
||||
list(APPEND LIEF_ART_SRC "${CMAKE_CURRENT_LIST_DIR}/json_api.cpp")
|
||||
list(APPEND LIEF_ART_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ART/json.hpp")
|
||||
|
||||
# JSON Impl
|
||||
if (LIEF_ENABLE_JSON)
|
||||
list(APPEND LIEF_ART_SRC "${CMAKE_CURRENT_LIST_DIR}/json.cpp")
|
||||
list(APPEND LIEF_ART_INC_FILES "${CMAKE_CURRENT_LIST_DIR}/json_internal.hpp")
|
||||
endif()
|
||||
|
||||
source_group("Source Files\\ART" FILES ${LIEF_ART_SRC})
|
||||
source_group("Header Files\\ART" FILES ${LIEF_ART_INC_FILES})
|
||||
|
||||
if (LIEF_ART)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_ART_SRC}
|
||||
${LIEF_ART_INC_FILES}
|
||||
)
|
||||
if(LIEF_ENABLE_JSON)
|
||||
target_sources(LIB_LIEF PRIVATE json.cpp)
|
||||
endif()
|
||||
|
||||
+15
-43
@@ -1,44 +1,16 @@
|
||||
set(LIEF_ABSTRACT_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.tcc"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Parser.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Relocation.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Function.cpp"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hash.cpp"
|
||||
)
|
||||
|
||||
set(LIEF_ABSTRACT_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Binary.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Symbol.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/EnumToString.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Header.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Section.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Parser.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/enums.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/hash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Relocation.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/Function.hpp"
|
||||
)
|
||||
|
||||
# JSON Public API: Always present
|
||||
list(APPEND LIEF_ABSTRACT_SRC "${CMAKE_CURRENT_LIST_DIR}/json_api.cpp")
|
||||
list(APPEND LIEF_ABSTRACT_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/Abstract/json.hpp")
|
||||
|
||||
# JSON Impl
|
||||
if (LIEF_ENABLE_JSON)
|
||||
list(APPEND LIEF_ABSTRACT_SRC "${CMAKE_CURRENT_LIST_DIR}/json.cpp")
|
||||
list(APPEND LIEF_ABSTRACT_INC_FILES "${CMAKE_CURRENT_LIST_DIR}/json_internal.hpp")
|
||||
endif()
|
||||
|
||||
|
||||
source_group("Source Files\\Abstract" FILES ${LIEF_ABSTRACT_SRC})
|
||||
source_group("Header Files\\Abstract" FILES ${LIEF_ABSTRACT_INCLUDE_FILES})
|
||||
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_ABSTRACT_SRC}
|
||||
${LIEF_ABSTRACT_INCLUDE_FILES})
|
||||
Binary.cpp
|
||||
Symbol.cpp
|
||||
EnumToString.cpp
|
||||
Header.cpp
|
||||
Section.cpp
|
||||
Section.tcc
|
||||
Parser.cpp
|
||||
Relocation.cpp
|
||||
Function.cpp
|
||||
hash.cpp
|
||||
json_api.cpp)
|
||||
|
||||
if(LIEF_ENABLE_JSON)
|
||||
target_sources(LIB_LIEF PRIVATE json.cpp)
|
||||
endif()
|
||||
|
||||
@@ -129,7 +129,7 @@ size_t Section::search(uint64_t integer, size_t pos, size_t size) const {
|
||||
size_t Section::search(const std::vector<uint8_t>& pattern, size_t pos) const {
|
||||
span<const uint8_t> content = this->content();
|
||||
|
||||
const auto it_found = std::search(
|
||||
const auto* it_found = std::search(
|
||||
std::begin(content) + pos, std::end(content),
|
||||
std::begin(pattern), std::end(pattern));
|
||||
|
||||
@@ -179,7 +179,7 @@ std::vector<size_t> Section::search_all(const std::string& v) const {
|
||||
double Section::entropy() const {
|
||||
std::array<uint64_t, 256> frequencies = { {0} };
|
||||
span<const uint8_t> content = this->content();
|
||||
if (content.size() == 0) {
|
||||
if (content.empty()) {
|
||||
return 0.;
|
||||
}
|
||||
for (uint8_t x : content) {
|
||||
|
||||
@@ -0,0 +1,467 @@
|
||||
#include "LIEF/BinaryStream/ASN1Reader.hpp"
|
||||
#include "LIEF/BinaryStream/BinaryStream.hpp"
|
||||
#include "logging.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <mbedtls/platform.h>
|
||||
#include <mbedtls/asn1.h>
|
||||
#include <mbedtls/error.h>
|
||||
#include <mbedtls/oid.h>
|
||||
#include <mbedtls/x509_crt.h>
|
||||
#include <mbedtls/bignum.h>
|
||||
|
||||
namespace LIEF {
|
||||
|
||||
inline void free_names(mbedtls_x509_name& names) {
|
||||
mbedtls_x509_name *name_cur;
|
||||
name_cur = names.next;
|
||||
while (name_cur != nullptr) {
|
||||
mbedtls_x509_name *name_prv = name_cur;
|
||||
name_cur = name_cur->next;
|
||||
mbedtls_free(name_prv);
|
||||
}
|
||||
}
|
||||
|
||||
result<bool> ASN1Reader::is_tag(int tag) {
|
||||
size_t out = 0;
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_tag(&p, end, &out, tag);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
result<size_t> ASN1Reader::read_tag(int tag) {
|
||||
size_t out = 0;
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_tag(&p, end, &out, tag);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) {
|
||||
return make_error_code(lief_errors::asn1_bad_tag);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_tag: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
result<size_t> ASN1Reader::read_len() {
|
||||
size_t len = 0;
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_len(&p, end, &len);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return len;
|
||||
}
|
||||
|
||||
result<std::string> ASN1Reader::read_alg() {
|
||||
mbedtls_asn1_buf alg_oid;
|
||||
std::array<char, 256> oid_str = {0};
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_alg_null(&p, end, &alg_oid);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
ret = mbedtls_oid_get_numeric_string(oid_str.data(), oid_str.size(), &alg_oid);
|
||||
if (ret <= 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::string(oid_str.data());
|
||||
}
|
||||
|
||||
result<std::string> ASN1Reader::read_oid() {
|
||||
mbedtls_asn1_buf buf;
|
||||
std::array<char, 256> oid_str = {0};
|
||||
|
||||
auto len = read_tag(MBEDTLS_ASN1_OID);
|
||||
if (!len) {
|
||||
return make_error_code(len.error());
|
||||
}
|
||||
|
||||
buf.len = len.value();
|
||||
buf.p = stream_.p();
|
||||
buf.tag = MBEDTLS_ASN1_OID;
|
||||
|
||||
int ret = mbedtls_oid_get_numeric_string(oid_str.data(), oid_str.size(), &buf);
|
||||
if (ret == MBEDTLS_ERR_OID_BUF_TOO_SMALL) {
|
||||
LIEF_DEBUG("asn1_read_oid: mbedtls_oid_get_numeric_string return MBEDTLS_ERR_OID_BUF_TOO_SMALL");
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(buf.len);
|
||||
return std::string(oid_str.data());
|
||||
}
|
||||
|
||||
|
||||
result<bool> ASN1Reader::read_bool() {
|
||||
int value;
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_bool(&p, end, &value);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_bool: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return static_cast<bool>(value);
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> ASN1Reader::read_large_int() {
|
||||
std::vector<uint8_t> value;
|
||||
mbedtls_mpi mpi;
|
||||
|
||||
mbedtls_mpi_init(&mpi);
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_mpi(&p, end, &mpi);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_mpi: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
value.resize(mbedtls_mpi_size(&mpi));
|
||||
|
||||
ret = mbedtls_mpi_write_binary_le(&mpi, value.data(), value.size());
|
||||
|
||||
mbedtls_mpi_free(&mpi);
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_mpi: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
result<int64_t> ASN1Reader::read_int64() {
|
||||
int64_t value = 0;
|
||||
mbedtls_mpi mpi;
|
||||
|
||||
mbedtls_mpi_init(&mpi);
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_mpi(&p, end, &mpi);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_mpi: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
if (mbedtls_mpi_size(&mpi) > sizeof(uint64_t)) {
|
||||
mbedtls_mpi_free(&mpi);
|
||||
LIEF_INFO("MPI value can be stored on a 64-bit integer");
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
ret = mbedtls_mpi_write_binary_le(&mpi, reinterpret_cast<uint8_t*>(&value),
|
||||
sizeof(value));
|
||||
|
||||
mbedtls_mpi_free(&mpi);
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_mpi: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
result<int32_t> ASN1Reader::read_int() {
|
||||
int32_t value = 0;
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_int(&p, end, &value);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("mbedtls_asn1_get_int: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return value;
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> ASN1Reader::read_bitstring() {
|
||||
mbedtls_asn1_bitstring bs = {0, 0, nullptr};
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_asn1_get_bitstring(&p, end, &bs);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) {
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{bs.p, bs.p + bs.len};
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{bs.p, bs.p + bs.len};
|
||||
}
|
||||
|
||||
|
||||
result<std::vector<uint8_t>> ASN1Reader::read_octet_string() {
|
||||
auto tag = read_tag(MBEDTLS_ASN1_OCTET_STRING);
|
||||
if (!tag) {
|
||||
return make_error_code(tag.error());
|
||||
}
|
||||
std::vector<uint8_t> raw = {stream_.p(), stream_.p() + tag.value()};
|
||||
stream_.increment_pos(tag.value());
|
||||
return raw;
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_crt>> ASN1Reader::read_cert() {
|
||||
std::unique_ptr<mbedtls_x509_crt> ca{new mbedtls_x509_crt{}};
|
||||
mbedtls_x509_crt_init(ca.get());
|
||||
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
const uintptr_t buff_len = reinterpret_cast<uintptr_t>(end) - reinterpret_cast<uintptr_t>(p);
|
||||
|
||||
int ret = mbedtls_x509_crt_parse_der(ca.get(), p, /* buff len */ buff_len);
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("asn1_read_cert(): {} (pos={})", strerr.c_str(), stream_.pos());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
if (ca->raw.len <= 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
stream_.increment_pos(ca->raw.len);
|
||||
return ca;
|
||||
}
|
||||
|
||||
result<std::string> ASN1Reader::x509_read_names() {
|
||||
mbedtls_x509_name name;
|
||||
std::memset(&name, 0, sizeof(name));
|
||||
|
||||
auto tag = read_tag(/* Name */
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
|
||||
if (!tag) {
|
||||
LIEF_INFO("Wrong tag: 0x{:x} for x509_read_names (pos: {:d})",
|
||||
*stream_.peek<uint8_t>(), stream_.pos());
|
||||
return make_error_code(tag.error());
|
||||
}
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = p + tag.value();
|
||||
int ret = mbedtls_x509_get_name(&p, end, &name);
|
||||
if (ret != 0) {
|
||||
free_names(name);
|
||||
LIEF_DEBUG("mbedtls_x509_get_name failed with {:d}", ret);
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
std::array<char, 1024> buffer = {0};
|
||||
ret = mbedtls_x509_dn_gets(buffer.data(), buffer.size(), &name);
|
||||
free_names(name);
|
||||
|
||||
if (ret < 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::string(buffer.data());
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> ASN1Reader::x509_read_serial() {
|
||||
mbedtls_x509_buf serial;
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_x509_get_serial(&p, end, &serial);
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{serial.p, serial.p + serial.len};
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_time>> ASN1Reader::x509_read_time() {
|
||||
std::unique_ptr<mbedtls_x509_time> tm{new mbedtls_x509_time{}};
|
||||
|
||||
const uint8_t* cur_p = stream_.p();
|
||||
uint8_t* p = stream_.p();
|
||||
const uint8_t* end = stream_.end();
|
||||
|
||||
int ret = mbedtls_x509_get_time(&p, end, tm.get());
|
||||
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_INFO("mbedtls_x509_get_time: {}", strerr.c_str());
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
stream_.increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return tm;
|
||||
}
|
||||
|
||||
result<std::string> ASN1Reader::read_utf8_string() {
|
||||
auto tag = read_tag(MBEDTLS_ASN1_UTF8_STRING);
|
||||
if (!tag) {
|
||||
return make_error_code(tag.error());
|
||||
}
|
||||
std::string raw = {stream_.p(), stream_.p() + tag.value()};
|
||||
stream_.increment_pos(tag.value());
|
||||
return raw;
|
||||
}
|
||||
|
||||
|
||||
std::string ASN1Reader::get_str_tag() {
|
||||
if (auto tag = stream_.peek<uint8_t>()) {
|
||||
return tag2str(*tag);
|
||||
}
|
||||
return "MBEDTLS_ASN1_UNKNOWN";
|
||||
}
|
||||
|
||||
|
||||
std::string ASN1Reader::tag2str(int tag) {
|
||||
#define HANDLE(X) do { \
|
||||
if (tag & MBEDTLS_##X) { \
|
||||
tag_str += " | " #X; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
std::string tag_str;
|
||||
|
||||
HANDLE(ASN1_BOOLEAN);
|
||||
HANDLE(ASN1_INTEGER);
|
||||
HANDLE(ASN1_BIT_STRING);
|
||||
HANDLE(ASN1_OCTET_STRING);
|
||||
HANDLE(ASN1_NULL);
|
||||
HANDLE(ASN1_OID);
|
||||
HANDLE(ASN1_ENUMERATED);
|
||||
HANDLE(ASN1_UTF8_STRING);
|
||||
HANDLE(ASN1_SEQUENCE);
|
||||
HANDLE(ASN1_SET);
|
||||
HANDLE(ASN1_PRINTABLE_STRING);
|
||||
HANDLE(ASN1_T61_STRING);
|
||||
HANDLE(ASN1_IA5_STRING);
|
||||
HANDLE(ASN1_UTC_TIME);
|
||||
HANDLE(ASN1_GENERALIZED_TIME);
|
||||
HANDLE(ASN1_UNIVERSAL_STRING);
|
||||
HANDLE(ASN1_BMP_STRING);
|
||||
HANDLE(ASN1_PRIMITIVE);
|
||||
HANDLE(ASN1_CONSTRUCTED);
|
||||
HANDLE(ASN1_CONTEXT_SPECIFIC);
|
||||
|
||||
return tag_str.substr(3);
|
||||
#undef HANDLE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -346,51 +346,4 @@ void BinaryStream::set_endian_swap(bool swap) {
|
||||
endian_swap_ = swap;
|
||||
}
|
||||
|
||||
result<size_t> BinaryStream::asn1_read_tag(int) {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<size_t> BinaryStream::asn1_read_len() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::string> BinaryStream::asn1_read_alg() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::string> BinaryStream::asn1_read_oid() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<int32_t> BinaryStream::asn1_read_int() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> BinaryStream::asn1_read_bitstring() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> BinaryStream::asn1_read_octet_string() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_crt>> BinaryStream::asn1_read_cert() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::string> BinaryStream::x509_read_names() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> BinaryStream::x509_read_serial() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_time>> BinaryStream::x509_read_time() {
|
||||
return make_error_code(lief_errors::not_implemented);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
BinaryStream.cpp
|
||||
ASN1Reader.cpp
|
||||
VectorStream.cpp
|
||||
FileStream.cpp
|
||||
MemoryStream.cpp
|
||||
SpanStream.cpp
|
||||
Convert.cpp
|
||||
)
|
||||
@@ -33,16 +33,6 @@ namespace LIEF {
|
||||
VectorStream::VectorStream(VectorStream&& other) = default;
|
||||
VectorStream& VectorStream::operator=(VectorStream&& other) = default;
|
||||
|
||||
inline void free_names(mbedtls_x509_name& names) {
|
||||
mbedtls_x509_name *name_cur;
|
||||
name_cur = names.next;
|
||||
while (name_cur != nullptr) {
|
||||
mbedtls_x509_name *name_prv = name_cur;
|
||||
name_cur = name_cur->next;
|
||||
mbedtls_free(name_prv);
|
||||
}
|
||||
}
|
||||
|
||||
result<VectorStream> VectorStream::from_file(const std::string& file) {
|
||||
std::ifstream ifs(file, std::ios::in | std::ios::binary);
|
||||
if (!ifs) {
|
||||
@@ -78,256 +68,10 @@ result<const void*> VectorStream::read_at(uint64_t offset, uint64_t size) const
|
||||
return binary_.data() + offset;
|
||||
}
|
||||
|
||||
|
||||
result<size_t> VectorStream::asn1_read_tag(int tag) {
|
||||
size_t out = 0;
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_asn1_get_tag(&p, end, &out, tag);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) {
|
||||
return make_error_code(lief_errors::asn1_bad_tag);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
result<size_t> VectorStream::asn1_read_len() {
|
||||
size_t len = 0;
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_asn1_get_len(&p, end, &len);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return len;
|
||||
}
|
||||
|
||||
result<std::string> VectorStream::asn1_read_alg() {
|
||||
mbedtls_asn1_buf alg_oid;
|
||||
std::array<char, 256> oid_str = {0};
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_asn1_get_alg_null(&p, end, &alg_oid);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
ret = mbedtls_oid_get_numeric_string(oid_str.data(), oid_str.size(), &alg_oid);
|
||||
if (ret <= 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::string(oid_str.data());
|
||||
}
|
||||
|
||||
result<std::string> VectorStream::asn1_read_oid() {
|
||||
mbedtls_asn1_buf buf;
|
||||
std::array<char, 256> oid_str = {0};
|
||||
|
||||
auto len = asn1_read_tag(MBEDTLS_ASN1_OID);
|
||||
if (!len) {
|
||||
return make_error_code(len.error());
|
||||
}
|
||||
|
||||
buf.len = len.value();
|
||||
buf.p = p();
|
||||
buf.tag = MBEDTLS_ASN1_OID;
|
||||
|
||||
int ret = mbedtls_oid_get_numeric_string(oid_str.data(), oid_str.size(), &buf);
|
||||
if (ret == MBEDTLS_ERR_OID_BUF_TOO_SMALL) {
|
||||
LIEF_DEBUG("asn1_read_oid: mbedtls_oid_get_numeric_string return MBEDTLS_ERR_OID_BUF_TOO_SMALL");
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(buf.len);
|
||||
return std::string(oid_str.data());
|
||||
}
|
||||
|
||||
|
||||
result<int32_t> VectorStream::asn1_read_int() {
|
||||
int32_t value = 0;
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_asn1_get_int(&p, end, &value);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return value;
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> VectorStream::asn1_read_bitstring() {
|
||||
mbedtls_asn1_bitstring bs = {0, 0, nullptr};
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_asn1_get_bitstring(&p, end, &bs);
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_OUT_OF_DATA) {
|
||||
return make_error_code(lief_errors::read_out_of_bound);
|
||||
}
|
||||
|
||||
if (ret == MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) {
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{bs.p, bs.p + bs.len};
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{bs.p, bs.p + bs.len};
|
||||
}
|
||||
|
||||
|
||||
result<std::vector<uint8_t>> VectorStream::asn1_read_octet_string() {
|
||||
auto tag = asn1_read_tag(MBEDTLS_ASN1_OCTET_STRING);
|
||||
if (!tag) {
|
||||
return make_error_code(tag.error());
|
||||
}
|
||||
std::vector<uint8_t> raw = {p(), p() + tag.value()};
|
||||
increment_pos(tag.value());
|
||||
return raw;
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_crt>> VectorStream::asn1_read_cert() {
|
||||
std::unique_ptr<mbedtls_x509_crt> ca{new mbedtls_x509_crt{}};
|
||||
mbedtls_x509_crt_init(ca.get());
|
||||
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
const uintptr_t buff_len = reinterpret_cast<uintptr_t>(end) - reinterpret_cast<uintptr_t>(p);
|
||||
|
||||
int ret = mbedtls_x509_crt_parse_der(ca.get(), p, /* buff len */ buff_len);
|
||||
if (ret != 0) {
|
||||
std::string strerr(1024, 0);
|
||||
mbedtls_strerror(ret, const_cast<char*>(strerr.data()), strerr.size());
|
||||
LIEF_DEBUG("asn1_read_cert(): {}", strerr);
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
if (ca->raw.len <= 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
increment_pos(ca->raw.len);
|
||||
return ca;
|
||||
}
|
||||
|
||||
result<std::string> VectorStream::x509_read_names() {
|
||||
mbedtls_x509_name name;
|
||||
std::memset(&name, 0, sizeof(name));
|
||||
|
||||
auto tag = asn1_read_tag(/* Name */
|
||||
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
|
||||
if (!tag) {
|
||||
LIEF_INFO("Wrong tag: 0x{:x} for x509_read_names (pos: {:d})", *peek<uint8_t>(), pos());
|
||||
return make_error_code(tag.error());
|
||||
}
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = p + tag.value();
|
||||
int ret = mbedtls_x509_get_name(&p, end, &name);
|
||||
if (ret != 0) {
|
||||
free_names(name);
|
||||
LIEF_DEBUG("mbedtls_x509_get_name failed with {:d}", ret);
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
std::array<char, 1024> buffer = {0};
|
||||
ret = mbedtls_x509_dn_gets(buffer.data(), buffer.size(), &name);
|
||||
free_names(name);
|
||||
|
||||
if (ret < 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::string(buffer.data());
|
||||
}
|
||||
|
||||
result<std::vector<uint8_t>> VectorStream::x509_read_serial() {
|
||||
mbedtls_x509_buf serial;
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_x509_get_serial(&p, end, &serial);
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return std::vector<uint8_t>{serial.p, serial.p + serial.len};
|
||||
}
|
||||
|
||||
result<std::unique_ptr<mbedtls_x509_time>> VectorStream::x509_read_time() {
|
||||
std::unique_ptr<mbedtls_x509_time> tm{new mbedtls_x509_time{}};
|
||||
|
||||
const uint8_t* cur_p = p();
|
||||
uint8_t* p = this->p();
|
||||
const uint8_t* end = this->end();
|
||||
|
||||
int ret = mbedtls_x509_get_time(&p, end, tm.get());
|
||||
|
||||
if (ret != 0) {
|
||||
return make_error_code(lief_errors::read_error);
|
||||
}
|
||||
|
||||
increment_pos(reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(cur_p));
|
||||
return tm;
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& VectorStream::content() const {
|
||||
return binary_;
|
||||
}
|
||||
|
||||
|
||||
bool VectorStream::classof(const BinaryStream& stream) {
|
||||
return stream.type() == STREAM_TYPE::VECTOR;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
errors.cpp
|
||||
hash_stream.cpp
|
||||
logging.cpp
|
||||
iostream.cpp
|
||||
utils.cpp
|
||||
internal_utils.cpp
|
||||
Object.tcc
|
||||
Visitor.cpp
|
||||
json_api.cpp
|
||||
visitors/hash.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(BinaryStream)
|
||||
add_subdirectory(Abstract)
|
||||
add_subdirectory(platforms)
|
||||
|
||||
if(LIEF_ENABLE_JSON)
|
||||
target_sources(LIB_LIEF PRIVATE visitors/json.cpp)
|
||||
endif()
|
||||
|
||||
if(LIEF_ELF)
|
||||
add_subdirectory(ELF)
|
||||
endif()
|
||||
|
||||
if(LIEF_PE)
|
||||
add_subdirectory(PE)
|
||||
endif()
|
||||
|
||||
if(LIEF_MACHO)
|
||||
add_subdirectory(MachO)
|
||||
endif()
|
||||
|
||||
if(LIEF_OAT)
|
||||
add_subdirectory(OAT)
|
||||
endif()
|
||||
|
||||
if(LIEF_DEX)
|
||||
add_subdirectory(DEX)
|
||||
endif()
|
||||
|
||||
if(LIEF_VDEX)
|
||||
add_subdirectory(VDEX)
|
||||
endif()
|
||||
|
||||
if(LIEF_ART)
|
||||
add_subdirectory(ART)
|
||||
endif()
|
||||
|
||||
+21
-58
@@ -1,62 +1,25 @@
|
||||
set(LIEF_DEX_SRC
|
||||
${CMAKE_CURRENT_LIST_DIR}/Parser.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Parser.tcc
|
||||
${CMAKE_CURRENT_LIST_DIR}/File.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Header.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Header.tcc
|
||||
${CMAKE_CURRENT_LIST_DIR}/Class.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Method.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Field.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/instructions.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/CodeInfo.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Type.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/Prototype.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/MapList.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/MapItem.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/utils.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/hash.cpp
|
||||
)
|
||||
|
||||
set(LIEF_DEX_INC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/File.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Header.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Class.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Method.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Field.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/CodeInfo.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Parser.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/types.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Type.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/Prototype.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/MapList.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/MapItem.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/instructions.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/EnumToString.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/hash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/enums.hpp"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Structures.hpp"
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Parser.cpp
|
||||
Parser.tcc
|
||||
File.cpp
|
||||
EnumToString.cpp
|
||||
Header.cpp
|
||||
Header.tcc
|
||||
Class.cpp
|
||||
Method.cpp
|
||||
Field.cpp
|
||||
instructions.cpp
|
||||
CodeInfo.cpp
|
||||
Type.cpp
|
||||
Prototype.cpp
|
||||
MapList.cpp
|
||||
MapItem.cpp
|
||||
utils.cpp
|
||||
hash.cpp
|
||||
json_api.cpp
|
||||
)
|
||||
|
||||
|
||||
# JSON Public API: Always present
|
||||
list(APPEND LIEF_DEX_SRC "${CMAKE_CURRENT_LIST_DIR}/json_api.cpp")
|
||||
list(APPEND LIEF_DEX_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/DEX/json.hpp")
|
||||
|
||||
# JSON Impl
|
||||
if (LIEF_ENABLE_JSON)
|
||||
list(APPEND LIEF_DEX_SRC "${CMAKE_CURRENT_LIST_DIR}/json.cpp")
|
||||
list(APPEND LIEF_DEX_INC_FILES "${CMAKE_CURRENT_LIST_DIR}/json_internal.hpp")
|
||||
endif()
|
||||
|
||||
source_group("Source Files\\DEX" FILES ${LIEF_DEX_SRC})
|
||||
source_group("Header Files\\DEX" FILES ${LIEF_DEX_INC_FILES})
|
||||
|
||||
if (LIEF_DEX)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_DEX_SRC}
|
||||
${LIEF_DEX_INC_FILES}
|
||||
)
|
||||
if(LIEF_ENABLE_JSON)
|
||||
target_sources(LIB_LIEF PRIVATE json.cpp)
|
||||
endif()
|
||||
|
||||
+7
-12
@@ -1144,21 +1144,16 @@ bool Binary::is_pie() const {
|
||||
|
||||
|
||||
bool Binary::has_nx() const {
|
||||
const auto it_stack = std::find_if(std::begin(segments_), std::end(segments_),
|
||||
[] (const std::unique_ptr<Segment>& segment) {
|
||||
return segment->type() == SEGMENT_TYPES::PT_GNU_STACK;
|
||||
});
|
||||
if (it_stack == std::end(segments_)) {
|
||||
if (header().machine_type() == ARCH::EM_PPC64) {
|
||||
// The PPC64 ELF ABI has a non-executable stack by default.
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (const Segment* gnu_stack = get(SEGMENT_TYPES::PT_GNU_STACK)) {
|
||||
return gnu_stack->has(ELF_SEGMENT_FLAGS::PF_X);
|
||||
}
|
||||
|
||||
return !(*it_stack)->has(ELF_SEGMENT_FLAGS::PF_X);
|
||||
if (header().machine_type() == ARCH::EM_PPC64) {
|
||||
// The PPC64 ELF ABI has a non-executable stack by default.
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Segment* Binary::add(const Segment& segment, uint64_t base) {
|
||||
|
||||
+42
-98
@@ -1,101 +1,45 @@
|
||||
set(LIEF_ELF_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Binary.tcc"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Builder.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Builder.tcc"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Convert.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataHandler/Handler.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataHandler/Node.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntry.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntryArray.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntryFlags.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntryLibrary.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntryRpath.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicEntryRunPath.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DynamicSharedObject.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/EnumToString.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/GnuHash.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Layout.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Note.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/NoteDetails.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Parser.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Parser.tcc"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Relocation.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/RelocationSizes.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Section.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Segment.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Symbol.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SymbolVersion.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SymbolVersionAux.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SymbolVersionAuxRequirement.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SymbolVersionDefinition.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SymbolVersionRequirement.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SysvHash.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/hash.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/note_utils.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/utils.cpp"
|
||||
)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Binary.cpp
|
||||
Binary.tcc
|
||||
Builder.cpp
|
||||
Builder.tcc
|
||||
Convert.cpp
|
||||
DataHandler/Handler.cpp
|
||||
DataHandler/Node.cpp
|
||||
DynamicEntry.cpp
|
||||
DynamicEntryArray.cpp
|
||||
DynamicEntryFlags.cpp
|
||||
DynamicEntryLibrary.cpp
|
||||
DynamicEntryRpath.cpp
|
||||
DynamicEntryRunPath.cpp
|
||||
DynamicSharedObject.cpp
|
||||
EnumToString.cpp
|
||||
GnuHash.cpp
|
||||
Header.cpp
|
||||
Layout.cpp
|
||||
Note.cpp
|
||||
NoteDetails.cpp
|
||||
Parser.cpp
|
||||
Parser.tcc
|
||||
Relocation.cpp
|
||||
RelocationSizes.cpp
|
||||
Section.cpp
|
||||
Segment.cpp
|
||||
Symbol.cpp
|
||||
SymbolVersion.cpp
|
||||
SymbolVersionAux.cpp
|
||||
SymbolVersionAuxRequirement.cpp
|
||||
SymbolVersionDefinition.cpp
|
||||
SymbolVersionRequirement.cpp
|
||||
SysvHash.cpp
|
||||
hash.cpp
|
||||
note_utils.cpp
|
||||
utils.cpp
|
||||
json_api.cpp)
|
||||
|
||||
set(LIEF_ELF_INC_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Binary.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Builder.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntry.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntryArray.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntryFlags.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntryLibrary.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntryRpath.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicEntryRunPath.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/DynamicSharedObject.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/EnumToString.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/GnuHash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SysvHash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Header.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Parser.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Relocation.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Section.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Segment.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Symbol.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SymbolVersion.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SymbolVersionAux.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SymbolVersionAuxRequirement.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SymbolVersionDefinition.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/SymbolVersionRequirement.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/utils.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/hash.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/Note.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/enums.hpp"
|
||||
)
|
||||
add_subdirectory(NoteDetails)
|
||||
add_subdirectory(DataHandler)
|
||||
|
||||
set(LIEF_ELF_DATA_HANDLER_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataHandler/Handler.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/DataHandler/Node.hpp")
|
||||
|
||||
# Note Details Part
|
||||
# =================
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/NoteDetails/CMakeLists.txt")
|
||||
|
||||
# JSON Public API: Always present
|
||||
list(APPEND LIEF_ELF_SRC "${CMAKE_CURRENT_LIST_DIR}/json_api.cpp")
|
||||
list(APPEND LIEF_ELF_INC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/json.hpp")
|
||||
|
||||
# JSON Impl
|
||||
if (LIEF_ENABLE_JSON)
|
||||
list(APPEND LIEF_ELF_SRC "${CMAKE_CURRENT_LIST_DIR}/json.cpp")
|
||||
list(APPEND LIEF_ELF_INC_FILES "${CMAKE_CURRENT_LIST_DIR}/json_internal.hpp")
|
||||
endif()
|
||||
|
||||
set(LIEF_ELF_INCLUDE_FILES
|
||||
${LIEF_ELF_INC_FILES}
|
||||
${LIEF_ELF_DATA_HANDLER_INCLUDE_FILES})
|
||||
|
||||
source_group("Source Files\\ELF" FILES ${LIEF_ELF_SRC})
|
||||
source_group("Header Files\\ELF" FILES ${LIEF_ELF_INC_FILES})
|
||||
source_group("Header Files\\ELF\\DataHandler" FILES ${LIEF_ELF_DATA_HANDLER_INCLUDE_FILES})
|
||||
|
||||
if (LIEF_ELF)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_ELF_SRC}
|
||||
${LIEF_ELF_INCLUDE_FILES})
|
||||
if(LIEF_ENABLE_JSON)
|
||||
target_sources(LIB_LIEF PRIVATE json.cpp)
|
||||
endif()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
Handler.cpp
|
||||
Node.cpp)
|
||||
+15
-15
@@ -12,8 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_ELF_EXE_LAYOUT_H_
|
||||
#define LIEF_ELF_EXE_LAYOUT_H_
|
||||
#ifndef LIEF_ELF_EXE_LAYOUT_H
|
||||
#define LIEF_ELF_EXE_LAYOUT_H
|
||||
#include <LIEF/types.hpp>
|
||||
#include <LIEF/visibility.h>
|
||||
#include <LIEF/ELF/Binary.hpp>
|
||||
@@ -194,12 +194,12 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
template<class ELF_T>
|
||||
size_t dynamic_arraysize(DYNAMIC_TAGS tag) {
|
||||
using uint__ = typename ELF_T::uint;
|
||||
using uint = typename ELF_T::uint;
|
||||
DynamicEntry* entry = binary_->get(tag);
|
||||
if (entry == nullptr || !DynamicEntryArray::classof(entry)) {
|
||||
return 0;
|
||||
}
|
||||
return entry->as<const DynamicEntryArray&>()->size() * sizeof(uint__);
|
||||
return entry->as<const DynamicEntryArray&>()->size() * sizeof(uint);
|
||||
}
|
||||
|
||||
template<class ELF_T>
|
||||
@@ -280,7 +280,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
//
|
||||
// See also:
|
||||
// * p.9, https://www.akkadia.org/drepper/dsohowto.pdf
|
||||
using uint__ = typename ELF_T::uint;
|
||||
using uint = typename ELF_T::uint;
|
||||
if (!raw_gnu_hash_.empty()) {
|
||||
return raw_gnu_hash_.size();
|
||||
}
|
||||
@@ -327,7 +327,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
vector_iostream raw_gnuhash;
|
||||
raw_gnuhash.reserve(
|
||||
4 * sizeof(uint32_t) + // header
|
||||
maskwords * sizeof(uint__) + // bloom filters
|
||||
maskwords * sizeof(uint) + // bloom filters
|
||||
nb_buckets * sizeof(uint32_t) + // buckets
|
||||
(dynamic_symbols.size() - symndx) * sizeof(uint32_t)); // hash values
|
||||
|
||||
@@ -341,14 +341,14 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
// Compute Bloom filters
|
||||
// =================================
|
||||
std::vector<uint__> bloom_filters(maskwords, 0);
|
||||
size_t C = sizeof(uint__) * 8; // 32 for ELF, 64 for ELF64
|
||||
std::vector<uint> bloom_filters(maskwords, 0);
|
||||
size_t C = sizeof(uint) * 8; // 32 for ELF, 64 for ELF64
|
||||
|
||||
for (size_t i = symndx; i < dynamic_symbols.size(); ++i) {
|
||||
const uint32_t hash = dl_new_hash(dynamic_symbols[i].name().c_str());
|
||||
const size_t pos = (hash / C) & (gnu_hash->maskwords() - 1);
|
||||
uint__ V = (static_cast<uint__>(1) << (hash % C)) |
|
||||
(static_cast<uint__>(1) << ((hash >> gnu_hash->shift2()) % C));
|
||||
uint V = (static_cast<uint>(1) << (hash % C)) |
|
||||
(static_cast<uint>(1) << ((hash >> gnu_hash->shift2()) % C));
|
||||
bloom_filters[pos] |= V;
|
||||
}
|
||||
for (size_t idx = 0; idx < bloom_filters.size(); ++idx) {
|
||||
@@ -559,7 +559,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
interp_segment.type(SEGMENT_TYPES::PT_INTERP);
|
||||
interp_segment.add(ELF_SEGMENT_FLAGS::PF_R);
|
||||
interp_segment.content(std::vector<uint8_t>(interp_size_));
|
||||
if (auto interp = binary_->add(interp_segment)) {
|
||||
if (Segment* interp = binary_->add(interp_segment)) {
|
||||
LIEF_DEBUG("Interp Segment: 0x{:x}:0x{:x}", interp->virtual_address(), interp->virtual_size());
|
||||
} else {
|
||||
LIEF_ERR("Can't add a new PT_INTERP");
|
||||
@@ -685,7 +685,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
|
||||
Section* section = nullptr;
|
||||
Segment::it_sections sections = pt_interp->sections();
|
||||
if (sections.size() > 0) {
|
||||
if (!sections.empty()) {
|
||||
section = §ions[0];
|
||||
}
|
||||
pt_interp->virtual_address(va_r_base);
|
||||
@@ -1042,7 +1042,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
LIEF_ERR("DT_INIT_ARRAY not found");
|
||||
return make_error_code(lief_errors::file_format_error);
|
||||
}
|
||||
DynamicEntryArray* dt_init_array = raw_dt_init->as<DynamicEntryArray>();
|
||||
auto* dt_init_array = raw_dt_init->as<DynamicEntryArray>();
|
||||
DynamicEntry* dt_init_arraysz = binary_->get(DYNAMIC_TAGS::DT_INIT_ARRAYSZ);
|
||||
|
||||
if (dt_init_arraysz == nullptr) {
|
||||
@@ -1098,7 +1098,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
LIEF_ERR("DT_PREINIT_ARRAY not found");
|
||||
return make_error_code(lief_errors::file_format_error);
|
||||
}
|
||||
DynamicEntryArray* dt_preinit_array = raw_dt_preinit->as<DynamicEntryArray>();
|
||||
auto* dt_preinit_array = raw_dt_preinit->as<DynamicEntryArray>();
|
||||
DynamicEntry* dt_preinit_arraysz = binary_->get(DYNAMIC_TAGS::DT_PREINIT_ARRAYSZ);
|
||||
|
||||
if (dt_preinit_array == nullptr) {
|
||||
@@ -1151,7 +1151,7 @@ class LIEF_LOCAL ExeLayout : public Layout {
|
||||
LIEF_ERR("DT_FINI_ARRAY not found");
|
||||
return make_error_code(lief_errors::file_format_error);
|
||||
}
|
||||
DynamicEntryArray* dt_fini_array = raw_dt_fini->as<DynamicEntryArray>();
|
||||
auto* dt_fini_array = raw_dt_fini->as<DynamicEntryArray>();
|
||||
DynamicEntry* dt_fini_arraysz = binary_->get(DYNAMIC_TAGS::DT_FINI_ARRAYSZ);
|
||||
|
||||
if (dt_fini_arraysz == nullptr) {
|
||||
|
||||
+2
-2
@@ -99,10 +99,10 @@ size_t Layout::section_shstr_size() {
|
||||
|
||||
if (!binary_->static_symbols_.empty()) {
|
||||
if (binary_->get(ELF_SECTION_TYPES::SHT_SYMTAB) == nullptr) {
|
||||
sec_names.push_back(".symtab");
|
||||
sec_names.emplace_back(".symtab");
|
||||
}
|
||||
if (binary_->get(ELF_SECTION_TYPES::SHT_SYMTAB) == nullptr) {
|
||||
sec_names.push_back(".strtab");
|
||||
sec_names.emplace_back(".strtab");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -12,13 +12,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef LIEF_ELF_LAYOUT_H_
|
||||
#define LIEF_ELF_LAYOUT_H_
|
||||
#ifndef LIEF_ELF_LAYOUT_H
|
||||
#define LIEF_ELF_LAYOUT_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace LIEF {
|
||||
namespace ELF {
|
||||
class Section;
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
set(LIEF_ELF_NOTE_DETAILS_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/AndroidNote.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/NoteAbi.cpp"
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
AndroidNote.cpp
|
||||
NoteAbi.cpp
|
||||
)
|
||||
|
||||
set(LIEF_ELF_NOTE_DETAILS_INC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/AndroidNote.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/NoteAbi.hpp"
|
||||
)
|
||||
|
||||
if (LIEF_ELF)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_ELF_NOTE_DETAILS_SRC}
|
||||
${LIEF_ELF_NOTE_DETAILS_INC})
|
||||
endif()
|
||||
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/core/CMakeLists.txt")
|
||||
add_subdirectory(core)
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
set(LIEF_ELF_CORE_NOTES_SRC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CorePrPsInfo.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CorePrPsInfo.tcc"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CoreFile.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CoreFile.tcc"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CorePrStatus.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CorePrStatus.tcc"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CoreAuxv.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CoreAuxv.tcc"
|
||||
|
||||
"${CMAKE_CURRENT_LIST_DIR}/CoreSigInfo.cpp"
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
CorePrPsInfo.cpp
|
||||
CorePrPsInfo.tcc
|
||||
CoreFile.cpp
|
||||
CoreFile.tcc
|
||||
CorePrStatus.cpp
|
||||
CorePrStatus.tcc
|
||||
CoreAuxv.cpp
|
||||
CoreAuxv.tcc
|
||||
CoreSigInfo.cpp
|
||||
)
|
||||
|
||||
set(LIEF_ELF_CORE_NOTES_INC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/core/CorePrPsInfo.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/core/CorePrStatus.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/core/CoreFile.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/core/CoreAuxv.hpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/LIEF/ELF/NoteDetails/core/CoreSigInfo.hpp"
|
||||
)
|
||||
|
||||
if (LIEF_ELF)
|
||||
target_sources(LIB_LIEF PRIVATE
|
||||
${LIEF_ELF_CORE_NOTES_SRC}
|
||||
${LIEF_ELF_CORE_NOTES_INC})
|
||||
endif()
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user