@@ -208,8 +208,62 @@ def apply_to_high_level_il_body(
208208 return new_lines
209209
210210 def apply_to_flow_graph (self , graph : 'binaryninja.FlowGraph' ):
211- # Don't modify flow graphs
212- pass
211+ log_info (f"[NewlineSplitRenderLayer] apply_to_flow_graph called with { len (graph .nodes )} nodes" )
212+ for node in graph .nodes :
213+ lines = node .lines
214+ new_lines = []
215+
216+ for line in lines :
217+ # Look for string tokens
218+ has_split = False
219+ split_info = None
220+
221+ for i , token in enumerate (line .tokens ):
222+ if token .type == InstructionTextTokenType .StringToken :
223+ log_info (f"[NewlineSplitRenderLayer] Found StringToken in flow graph node" )
224+ split_tokens = self .split_string_token (token )
225+ if len (split_tokens ) > 1 :
226+ has_split = True
227+ split_info = (i , split_tokens )
228+ log_info (f"[NewlineSplitRenderLayer] Will split this line in flow graph into { len (split_tokens )} parts" )
229+ break
230+
231+ if not has_split :
232+ new_lines .append (line )
233+ continue
234+
235+ # Create multiple lines for the split string
236+ token_idx , split_tokens = split_info
237+
238+ # Find the indentation level by looking at the position of the string token
239+ indent_count = 0
240+ for i in range (token_idx ):
241+ indent_count += len (line .tokens [i ].text )
242+
243+ # Create first line with original tokens up to and including first split token
244+ first_tokens = line .tokens [:token_idx ] + [split_tokens [0 ]]
245+ first_line = DisassemblyTextLine (first_tokens , line .address )
246+ first_line .highlight = line .highlight
247+ first_line .il_instruction = line .il_instruction
248+ new_lines .append (first_line )
249+
250+ # Create continuation lines for remaining split tokens
251+ for j in range (1 , len (split_tokens )):
252+ # Add indentation to align with the start of the string
253+ indent_token = InstructionTextToken (InstructionTextTokenType .TextToken , ' ' * indent_count )
254+ cont_tokens = [indent_token , split_tokens [j ]]
255+
256+ # If this is the last split token, add the rest of the original tokens
257+ if j == len (split_tokens ) - 1 :
258+ cont_tokens .extend (line .tokens [token_idx + 1 :])
259+
260+ cont_line = DisassemblyTextLine (cont_tokens , line .address )
261+ cont_line .highlight = line .highlight
262+ cont_line .il_instruction = line .il_instruction
263+ new_lines .append (cont_line )
264+
265+ # Update the node's lines
266+ node .lines = new_lines
213267
214268
215269NewlineSplitRenderLayer .register ()
0 commit comments