ioncodes/idacode

Imported module not updated

Xartrick opened this issue · 2 comments

Description

Imported modules do not reload when edited, keeping changes from being applied to main script.

How to reproduce

  1. Create imported_module.py
def call_me():
    return 'Foo'
  1. Create main.py
from imported_module import call_me

print(call_me())
  1. Start IDACode from IDA
[IDACode] Listening on 127.0.0.1:7065
  1. Connect IDACode from VSCode
[IDACode] Client connected
[IDACode] Set workspace folder to c:\ida_code_bug
  1. Save main.py to trigger code execution
[IDACode] Executing c:\ida_code_bug\main.py
Foo
  1. Edit call_me in imported_module.py to return Bar
def call_me():
    return 'Bar'
[IDACode] Executing c:\ida_code_bug\imported_module.py
  1. Save main.py to trigger code execution
[IDACode] Executing c:\ida_code_bug\main.py
Foo

Expected result

call_me function should returns Bar.

Related issues

After more digging, this seems to be a known behavior, see Loading your own modules from your IDAPython scripts with idaapi.require() – Hex Rays.

Solution

from idaapi import require
require('imported_module')

from imported_module import call_me

print(call_me())

This can be closed or kept open for future reference.

Thanks for letting me know! I'll reference this issue in the README!