Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
81bcb99
Initial commit for dissect.executable.pe
sud0woodo Mar 9, 2024
d23b36d
Fix tabs to spaces
sud0woodo Mar 9, 2024
c307872
Style refactor
sud0woodo Oct 27, 2024
a58b9be
Fix ruff formatting from main
Miauwkeru Feb 17, 2025
325b8dd
Fix tests for cstruct v4 compatibility
Miauwkeru Feb 17, 2025
88d852f
Small cleanup of imports.py
Miauwkeru Feb 18, 2025
7e29922
Small changes to the ResourceManager class
Miauwkeru Feb 24, 2025
7be6602
Clean up Export and export function
Miauwkeru Feb 24, 2025
21c8fa6
Move entries to use list comprehension
Miauwkeru Feb 24, 2025
72b4a5f
Compile and cache structs
Miauwkeru Feb 25, 2025
e70d006
Move architecture specific code to the managers
Miauwkeru Feb 25, 2025
9a64a0a
Move _valid check to `parse_headers`
Miauwkeru Feb 25, 2025
4ecc96c
Reduce indentation _patch_import_rvas
Miauwkeru Mar 4, 2025
6cb4a74
Use a dataclass instead of a dictionary for raw_resources
Miauwkeru Mar 4, 2025
7affc19
replace struct.pack with create_struct().pack
Miauwkeru Mar 4, 2025
d027d1d
Make a function to search through sections
Miauwkeru Mar 4, 2025
6354825
add some checks during the patching if certain sections do not exist
Miauwkeru Mar 26, 2025
8ed8611
Change build from a property to a function in Patcher
Miauwkeru Mar 13, 2025
6051423
Use specific c_pe types for certain options
Miauwkeru Mar 13, 2025
546476d
Retrieve resources using the resource manager
Miauwkeru Mar 13, 2025
f97ad4a
Read section from pe file
Miauwkeru Mar 26, 2025
d0ef4d9
Grab data from the section, instead of reading it from the PE file
Miauwkeru Mar 26, 2025
8197638
Move relocations to a dataclass
Miauwkeru Mar 26, 2025
3498bde
Improve typing
Miauwkeru Mar 26, 2025
72658ad
Initial PESectionManager
Miauwkeru Apr 1, 2025
d8acc68
Refer to all sections using the section manager
Miauwkeru Apr 3, 2025
6a2677e
Remove references to internal sections inside the PE file
Miauwkeru Apr 3, 2025
36a7054
Rename pe.section_manager to pe.sections
Miauwkeru Apr 3, 2025
719d47c
Use utils.Manager for most base classes
Miauwkeru Apr 7, 2025
9ad4b5d
Create a specific dict manager for the ordered dict datastructure
Miauwkeru Apr 7, 2025
463fd56
Move to use different managers
Miauwkeru Apr 8, 2025
15d8690
Move patch to PESectionManager
Miauwkeru Apr 8, 2025
8572b4d
Move assigning section directories to a specific method
Miauwkeru Apr 8, 2025
5de7a41
Readability changes
Miauwkeru Apr 8, 2025
f8f0362
Reorder operations for building
Miauwkeru Apr 8, 2025
dc91018
make sure virtual_address gets defined
Miauwkeru Apr 8, 2025
ce9f60c
Expose inner import manager variables
Miauwkeru Apr 8, 2025
98098cc
Move updating resource to ResourceManager.patch
Miauwkeru Apr 8, 2025
0c32478
Small cleanup
Miauwkeru Apr 9, 2025
0290ec6
Move helpers/utils.py to dissect/executable/utils.py
Miauwkeru Apr 9, 2025
d617e04
Move builder.py out of helpers
Miauwkeru Apr 9, 2025
c72bbbc
Move patcher.py out of helpers
Miauwkeru Apr 9, 2025
aff11da
Rename helpers to sections
Miauwkeru Apr 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ __pycache__/
tests/docs/api
tests/docs/build
.tox/

*.pyi
2 changes: 2 additions & 0 deletions dissect/executable/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from dissect.executable.elf import ELF
from dissect.executable.pe import PE

__all__ = [
"ELF",
"PE",
]
9 changes: 8 additions & 1 deletion dissect/executable/elf/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,14 @@ def patch(self, new_data: bytes) -> None:


class SegmentTable(Table[Segment]):
def __init__(self, fh: BinaryIO, offset: int, entries: int, size: int, c_elf: cstruct = c_elf_64):
def __init__(
self,
fh: BinaryIO,
offset: int,
entries: int,
size: int,
c_elf: cstruct = c_elf_64,
):
super().__init__(entries)
self.fh = fh
self.offset = offset
Expand Down
25 changes: 25 additions & 0 deletions dissect/executable/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,28 @@ class Error(Exception):

class InvalidSignatureError(Error):
"""Exception that occurs if the magic in the header does not match."""


class InvalidPE(Error):
"""Exception that occurs if the PE signature does not match."""


class InvalidVA(Error):
"""Exception that occurs when a virtual address is not found within the PE sections."""


class InvalidAddress(Error):
"""Exception that occurs when a raw address is not found within the PE file when translating from a virtual
address."""


class InvalidArchitecture(Error):
"""Exception that occurs when an invalid value is encountered for the PE architecture types."""


class BuildSectionException(Error):
"""Exception that occurs when the section to be build contains an error."""


class ResourceException(Error):
"""Exception that occurs when an error is thrown parsing the resources."""
25 changes: 25 additions & 0 deletions dissect/executable/pe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from dissect.executable.pe.builder import Builder
from dissect.executable.pe.patcher import Patcher
from dissect.executable.pe.pe import PE
from dissect.executable.pe.sections.exports import ExportFunction, ExportManager
from dissect.executable.pe.sections.imports import (
ImportFunction,
ImportManager,
ImportModule,
)
from dissect.executable.pe.sections.resources import Resource, ResourceManager
from dissect.executable.pe.sections.sections import PESection

__all__ = [
"PE",
"Builder",
"ExportFunction",
"ExportManager",
"ImportFunction",
"ImportManager",
"ImportModule",
"PESection",
"Patcher",
"Resource",
"ResourceManager",
]
Loading