MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / FileMetadata

Class FileMetadata

python/filemetadata.py:120–647  ·  view source on GitHub ↗

``class FileMetadata`` represents the file being analyzed by Binary Ninja. It is responsible for opening, closing, creating the database (.bndb) files, and is used to keep track of undoable actions. :param str filename: The string path to the file to be opened. Defaults to None. :param handle:

Source from the content-addressed store, hash-verified

118
119
120class FileMetadata:
121 """
122 ``class FileMetadata`` represents the file being analyzed by Binary Ninja. It is responsible for opening,
123 closing, creating the database (.bndb) files, and is used to keep track of undoable actions.
124
125 :param str filename: The string path to the file to be opened. Defaults to None.
126 :param handle: A handle to the underlying C FileMetadata object. Defaults to None. (Internal use only.)
127 """
128
129 _associated_data = {}
130
131 def __init__(self, filename: Optional[str] = None, handle: Optional[core.BNFileMetadataHandle] = None):
132 if handle is not None:
133 _type = core.BNFileMetadataHandle
134 _handle = ctypes.cast(handle, _type)
135 else:
136 binaryninja._init_plugins()
137 _handle = core.BNCreateFileMetadata()
138 if filename is not None:
139 core.BNSetFilename(_handle, str(filename))
140 self._nav: Optional[NavigationHandler] = None
141 assert _handle is not None
142 self.handle = _handle
143
144 def __repr__(self):
145 return f"<FileMetadata: {self.filename}>"
146
147 def __del__(self):
148 if core is not None:
149 if self.navigation is not None:
150 core.BNSetFileMetadataNavigationHandler(self.handle, None)
151 core.BNFreeFileMetadata(self.handle)
152
153 def __eq__(self, other):
154 if not isinstance(other, self.__class__):
155 return NotImplemented
156 return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents)
157
158 def __ne__(self, other):
159 if not isinstance(other, self.__class__):
160 return NotImplemented
161 return not (self == other)
162
163 def __hash__(self):
164 return hash(ctypes.addressof(self.handle.contents))
165
166 @property
167 def nav(self) -> Optional[NavigationHandler]:
168 """Navigation handler for this FileMetadata (read/write)"""
169 return self._nav
170
171 @nav.setter
172 def nav(self, value: NavigationHandler) -> None:
173 self._nav = value
174
175 @property
176 def session_id(self) -> int:
177 return core.BNFileMetadataGetSessionId(self.handle)

Callers 4

base_fileMethod · 0.50
first_fileMethod · 0.50
second_fileMethod · 0.50
download_fileFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected