MCPcopy Create free account
hub / github.com/ELMERIKH/PyinMemoryPE / KernelObject

Class KernelObject

windows/winobject/object_manager.py:34–197  ·  view source on GitHub ↗

Represent an object in the Object Manager namespace

Source from the content-addressed store, hash-verified

32
33
34class KernelObject(object):
35 """Represent an object in the Object Manager namespace"""
36 def __init__(self, path, name, type=None):
37 self.path = path
38 self.name = name
39 if path and not path.endswith("\\"):
40 path += "\\"
41 self.fullname = path + name
42 self.type = type
43
44 @property
45 def target(self):
46 """Resolve the target of a symbolic link object.
47
48 :rtype: :class:`str` or None if object is not a link
49 """
50 try:
51 return query_link(self.fullname)
52 except windows.generated_def.ntstatus.NtStatusException as e:
53 if e.code != gdef.STATUS_OBJECT_TYPE_MISMATCH:
54 raise
55 return None
56
57 def items(self):
58 """Return the list of tuple (object's name, object) in the current directory object.
59
60 :rtype: [(:class:`str`, :class:`KernelObject`)] -- A list of tuple
61
62 .. note::
63
64 the :class:`KernelObject` must be of type ``Directory`` or
65 it will raise :class:`~windows.generated_def.ntstatus.NtStatusException` with
66 code :data:`~windows.generated_def.STATUS_OBJECT_TYPE_MISMATCH`
67 """
68 path = self.fullname
69 return [(name, KernelObject(path, name, typename)) for name, typename in self._directory_query_generator()]
70
71 def keys(self):
72 """Return the list of objects' name in the current directory object.
73
74 :rtype: [:class:`str`] -- A list of name
75
76 .. note::
77
78 the :class:`KernelObject` must be of type ``Directory`` or
79 it will raise :class:`~windows.generated_def.ntstatus.NtStatusException` with
80 code :data:`~windows.generated_def.STATUS_OBJECT_TYPE_MISMATCH`
81 """
82 return list(self)
83
84 def values(self):
85 """Return the list of objects in the current directory object.
86
87 :rtype: [:class:`KernelObject`] -- A list of object
88
89 .. note::
90
91 the :class:`KernelObject` must be of type ``Directory`` or

Callers 4

itemsMethod · 0.85
valuesMethod · 0.85
getMethod · 0.85
rootMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected