Skip to content

Commit

Permalink
Add PeIdent to uniquely identify PE files
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Vejnár committed Sep 15, 2021
1 parent 174b848 commit 5286179
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pe_tools/pe_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ class _IMAGE_DEBUG_CODEVIEW(Struct3):
age: u32

@dataclass
class PeIdent:
image_name: str
timestamp: int
size_of_image: int

@classmethod
def from_pelink(cls, pelink: str):
fname, tssize = pelink.split('/')
ts = int(tssize[:8], 16)
size = int(tssize[8:], 16)
return cls(image_name=fname, timestamp=ts, size_of_image=size)

@property
def pelink(self):
return f'{self.image_name}/{self.timestamp:08x}{self.size_of_image:x}'

def __str__(self):
return self.pelink
@dataclass
class CodeviewLink:
guid: uuid.UUID
age: int
Expand Down

0 comments on commit 5286179

Please sign in to comment.