Apply this Render Layer to the lines produced by a LinearViewObject for rendering in Linear View, potentially modifying the lines and their contents. .. note:: If you override this function, you will need to call the ``super()`` \ implementation if you want to use the higher level ``apply_
( self, obj: 'binaryninja.LinearViewObject', prev: Optional['binaryninja.LinearViewObject'], next: Optional['binaryninja.LinearViewObject'], lines: List['binaryninja.LinearDisassemblyLine'] )
| 313 | node.lines = lines |
| 314 | |
| 315 | def apply_to_linear_view_object( |
| 316 | self, |
| 317 | obj: 'binaryninja.LinearViewObject', |
| 318 | prev: Optional['binaryninja.LinearViewObject'], |
| 319 | next: Optional['binaryninja.LinearViewObject'], |
| 320 | lines: List['binaryninja.LinearDisassemblyLine'] |
| 321 | ) -> List['binaryninja.LinearDisassemblyLine']: |
| 322 | """ |
| 323 | Apply this Render Layer to the lines produced by a LinearViewObject for rendering |
| 324 | in Linear View, potentially modifying the lines and their contents. |
| 325 | |
| 326 | .. note:: If you override this function, you will need to call the ``super()`` \ |
| 327 | implementation if you want to use the higher level ``apply_to_X_level_il_block`` \ |
| 328 | functionality. |
| 329 | |
| 330 | :param obj: Linear View Object being rendered |
| 331 | :param prev: Linear View Object located directly above this one |
| 332 | :param next: Linear View Object located directly below this one |
| 333 | :param lines: Original lines rendered by the Linear View Object |
| 334 | :return: Modified list of lines to display in Linear View |
| 335 | """ |
| 336 | # Hack: HLIL bodies don't have basic blocks |
| 337 | if len(lines) > 0 and obj.identifier.name in [ |
| 338 | "HLIL Function Body", |
| 339 | "HLIL SSA Function Body", |
| 340 | "Language Representation Function Body" |
| 341 | ]: |
| 342 | return self.apply_to_high_level_il_body(lines[0].function, lines) |
| 343 | |
| 344 | block_lines = [] |
| 345 | final_lines = [] |
| 346 | last_block = None |
| 347 | |
| 348 | def finish_block(): |
| 349 | nonlocal block_lines |
| 350 | nonlocal final_lines |
| 351 | if len(block_lines) > 0: |
| 352 | if last_block is not None: |
| 353 | # Convert linear lines to disassembly lines for the apply() |
| 354 | # and then convert back for linear view |
| 355 | new_block_lines = [] |
| 356 | disasm_lines = [] |
| 357 | misc_lines = [] |
| 358 | |
| 359 | def process_disasm(): |
| 360 | nonlocal disasm_lines |
| 361 | |
| 362 | if len(disasm_lines) > 0: |
| 363 | disasm_lines = self.apply_to_block(last_block, disasm_lines) |
| 364 | func = block_lines[0].function |
| 365 | block = block_lines[0].block |
| 366 | for block_line in disasm_lines: |
| 367 | new_block_lines.append( |
| 368 | LinearDisassemblyLine( |
| 369 | LinearDisassemblyLineType.CodeDisassemblyLineType, |
| 370 | func, |
| 371 | block, |
| 372 | block_line |
no test coverage detected