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

Method _get_lines_for_data

python/datarender.py:133–179  ·  view source on GitHub ↗
(self, ctxt, view, addr, type, prefix, prefixCount, width, count, typeCtx, ctxCount, language)

Source from the content-addressed store, hash-verified

131 return False
132
133 def _get_lines_for_data(self, ctxt, view, addr, type, prefix, prefixCount, width, count, typeCtx, ctxCount, language):
134 try:
135 file_metadata = filemetadata.FileMetadata(handle=core.BNGetFileForView(view))
136 view = binaryview.BinaryView(file_metadata=file_metadata, handle=core.BNNewViewReference(view))
137 type = types.Type.create(handle=core.BNNewTypeReference(type))
138
139 prefixTokens = function.InstructionTextToken._from_core_struct(prefix, prefixCount)
140 pycontext = []
141 for i in range(ctxCount):
142 pycontext.append(
143 TypeContext(types.Type.create(core.BNNewTypeReference(typeCtx[i].type)), typeCtx[i].offset)
144 )
145
146 result = self.perform_get_lines_for_data_with_language(
147 ctxt, view, addr, type, prefixTokens, width, pycontext, language
148 )
149
150 count[0] = len(result)
151 self.line_buf = (core.BNDisassemblyTextLine * len(result))()
152 for i in range(len(result)):
153 line = result[i]
154 color = line.highlight
155 if not isinstance(color,
156 enums.HighlightStandardColor) and not isinstance(color, highlight.HighlightColor):
157 raise ValueError("Specified color is not one of HighlightStandardColor, highlight.HighlightColor")
158 if isinstance(color, enums.HighlightStandardColor):
159 color = highlight.HighlightColor(color)
160 self.line_buf[i].highlight = color._to_core_struct()
161 if line.address is None:
162 if len(line.tokens) > 0:
163 self.line_buf[i].addr = line.tokens[0].address
164 else:
165 self.line_buf[i].addr = 0
166 else:
167 self.line_buf[i].addr = line.address
168 if line.il_instruction is not None:
169 self.line_buf[i].instrIndex = line.il_instruction.instr_index
170 else:
171 self.line_buf[i].instrIndex = 0xffffffffffffffff
172
173 self.line_buf[i].count = len(line.tokens)
174 self.line_buf[i].tokens = function.InstructionTextToken._get_core_struct(line.tokens)
175
176 return ctypes.cast(self.line_buf, ctypes.c_void_p).value
177 except:
178 log_error(traceback.format_exc())
179 return None
180
181 def _free_lines(self, ctxt, lines, count):
182 self.line_buf = None

Callers

nothing calls this directly

Calls 10

_to_core_structMethod · 0.95
TypeContextClass · 0.85
log_errorFunction · 0.85
FileMetadataMethod · 0.80
BinaryViewMethod · 0.80
_get_core_structMethod · 0.80
createMethod · 0.45
_from_core_structMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected