@@ -147,50 +147,27 @@ def get_function_assembly_by_address(self, address: int) -> Dict[str, Any]:
147147    def  _get_function_assembly_by_address_internal (self , address : int ) ->  Dict [str , Any ]:
148148        """Internal implementation for get_function_assembly_by_address without sync wrapper""" 
149149        try :
150-             # Get function from address  
151-             func  =  idaapi .get_func (address )
150+             # Get function object  
151+             func  =  ida_funcs .get_func (address )
152152            if  not  func :
153-                 return  {"error" : f"No function found at address 0x{ address :X}  }
154-             
155-             # Get function name 
156-             func_name  =  idaapi .get_func_name (func .start_ea )
157-             
158-             # Generate assembly 
159-             assembly  =  []
153+                 return  {"error" : f"Invalid function at { hex (address )}  }
160154
161-             # Create instruction iterator 
162-             instruction_iterator  =  idaapi .func_item_iterator_t (func )
155+             # Collect all assembly instructions 
156+             assembly_lines  =  []
157+             for  instr_addr  in  idautils .FuncItems (address ):
158+                 disasm  =  idc .GetDisasm (instr_addr )
159+                 assembly_lines .append (f"{ hex (instr_addr )} { disasm }  )
163160
164-             # Get first instruction 
165-             address  =  instruction_iterator .first ()
166-             
167-             # Iterate through all instructions 
168-             while  address  !=  idaapi .BADADDR :
169-                 # Get disassembly line 
170-                 disasm_line  =  idaapi .generate_disasm_line (address , 0 )
171-                 
172-                 # Get comment, if any 
173-                 comment  =  idaapi .get_cmt (address , 0 )  # 0 for non-repeatable comment 
174-                 if  not  comment :
175-                     comment  =  idaapi .get_cmt (address , 1 )  # 1 for repeatable comment 
176-                 
177-                 # Add line with comment 
178-                 if  comment :
179-                     assembly .append (f"{ disasm_line } { comment }  )
180-                 else :
181-                     assembly .append (disasm_line )
161+             if  not  assembly_lines :
162+                 return  {"error" : "No assembly instructions found" }
182163
183-                 # Move to next instruction 
184-                 address  =  instruction_iterator .next ()
185-             
186-             # Join the disassembly lines 
187-             assembly_str  =  "\n " .join (assembly )
188-             
189-             return  {"assembly" : assembly_str , "function_name" : func_name }
164+             return  {"assembly" : "\n " .join (assembly_lines )}
190165        except  Exception  as  e :
166+             print (f"Error getting function assembly: { str (e )}  )
191167            traceback .print_exc ()
192168            return  {"error" : str (e )}
193169
170+ 
194171    @idaread  
195172    def  get_function_decompiled_by_name (self , function_name : str ) ->  Dict [str , Any ]:
196173        """Get decompiled code for a function by its name""" 
0 commit comments