Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE: preparations for a writer outside of Goblin #389

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Commits on Jan 23, 2024

  1. pe(utils): generic alignment tool

    This is a generic function to perform various alignments, this avoids reinventing
    locally the magic alignment dance and reusable for consumers who may themselves align things.
    RaitoBezarius committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    3d1d725 View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2024

  1. pe(section_table): public constructor for SectionTable

    This is a simple function to assemble a template section table with
    zeros in the unpredictable fields, it's up to the caller to carry on the
    fill procedure, e.g. a writer structure which can do the layout.
    
    It can automatically set the virtual address and size based on another
    binary to append it, only the on-disk offsets are left to the caller.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    a690d07 View commit details
    Browse the repository at this point in the history
  2. pe(data_directories): simplify writing data directories

    Previously, we were handling the offset ourselves, but we can just use `gwrite_with`
    to let the offset be moved.
    
    We don't need to use the "read" offset, this is only a distraction and can get wrong results
    sometimes.
    
    We only need to write in the order and assume linearity.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    1e34fbe View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9372220 View commit details
    Browse the repository at this point in the history
  4. pe(data_directories): add dirs_with_offset and data view

    It is now easy to peek into the data of a data directory and list all
    directories with their originally parsed offsets.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    e6d2fdc View commit details
    Browse the repository at this point in the history
  5. pe(data_directories): add support for the "reserved" "data directory"

    > 216/232  8 Reserved, must be zero
    
    According to the table mentioned in https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#optional-header-data-directories-image-only
    In the past, we returned errors in case they were present.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    677f9ac View commit details
    Browse the repository at this point in the history
  6. pe(utils): expose rva2offset to external consumers

    Relative virtual address to disk offset is a classical operation to
    perform for various things, it is likely this operation won't change and
    if it changes, we can keep it around and deprecate it quite easily in
    the next release.
    
    An example for external consumers: compute debug directory data offsets
    from RVAs to write a debug directory.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    34f7f7f View commit details
    Browse the repository at this point in the history
  7. pe(certificate_table): export WIN_CERTIFICATE header

    - derives additionally `Debug` on it for logging
    - derives additionally `Pwrite`, `SizeWith` for good developer
      experience with scroll on it
    - provides a natural type alias in accordance with `WIN_CERTIFICATE` name
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    335f261 View commit details
    Browse the repository at this point in the history
  8. pe(certificate_table): add EFI certificate types

    We forgot those but they come handy in the UEFI ecosystem when you are
    reading UEFI signature lists.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    7d7d1c8 View commit details
    Browse the repository at this point in the history
  9. pe: expose original bytes field via function

    There's no reason to render it as private, this enable a user to peek inside
    the raw structure and perform more complicated reading without holding
    the original bytes around.
    
    Nonetheless, we expose it via a function to make it easier to deprecate
    it or modify as we need.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    dbdcff1 View commit details
    Browse the repository at this point in the history
  10. pe(write): some debug! traces

    It can be hard to debug why your writer is not working as intended, here
    are some `debug!` traces to help in that endeavor.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    51ba0ed View commit details
    Browse the repository at this point in the history
  11. pe(certificate_table): reinforce checks when writing aligned attribut…

    …e certificates
    
    It's possible that a user may pass an improperly created attribute certificate
    and the write will cause all sorts of failure.
    
    We sprinkle some `debug_assert!` to avoid this.
    RaitoBezarius authored and raito committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    d814cbc View commit details
    Browse the repository at this point in the history