Skip to content

Commit

Permalink
Merge pull request volatilityfoundation#1440 from dgmcdona/dgmcdona/n…
Browse files Browse the repository at this point in the history
…etwork_extensions_attributeerrors

Windows Extensions: Fix potential AttributeErrors
  • Loading branch information
ikelos authored Dec 20, 2024
2 parents 1b28b13 + 7464a3b commit 435d68b
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions volatility3/framework/symbols/windows/extensions/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging
import socket
from typing import Dict, Tuple, List, Union
from typing import Dict, Tuple, List, Union, Optional

from volatility3.framework import exceptions
from volatility3.framework import objects, interfaces
Expand Down Expand Up @@ -86,19 +86,29 @@ def get_owner(self):
except exceptions.InvalidAddressException:
return None

def get_owner_pid(self):
if self.get_owner().is_valid():
if self.get_owner().has_valid_member("UniqueProcessId"):
return self.get_owner().UniqueProcessId
def get_owner_pid(self) -> Optional[int]:
owner = self.get_owner()

if owner is None:
return None

if owner.is_valid():
if owner.has_valid_member("UniqueProcessId"):
return owner.UniqueProcessId

return None

def get_owner_procname(self):
if self.get_owner().is_valid():
if self.get_owner().has_valid_member("ImageFileName"):
return self.get_owner().ImageFileName.cast(
def get_owner_procname(self) -> Optional[str]:
owner = self.get_owner()

if owner is None:
return None

if owner.is_valid():
if owner.has_valid_member("ImageFileName"):
return owner.ImageFileName.cast(
"string",
max_length=self.get_owner().ImageFileName.vol.count,
max_length=owner.ImageFileName.vol.count,
errors="replace",
)

Expand Down

0 comments on commit 435d68b

Please sign in to comment.