mirror of
https://github.com/cemu-project/idapython.git
synced 2026-01-31 01:15:17 +01:00
Migrating wiki contents from Google Code
This commit is contained in:
29
Using_RunPythonStatement.md
Normal file
29
Using_RunPythonStatement.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Introduction #
|
||||
|
||||
This is a small example on how to run Python statement from IDC and catch the errors
|
||||
|
||||
|
||||
# Code #
|
||||
|
||||
```
|
||||
def function():
|
||||
print "Hello...."
|
||||
print z # !!! Cause runtime errors.... !!!
|
||||
|
||||
err = idaapi.CompileLine(r"""
|
||||
static key_ALTN()
|
||||
{
|
||||
auto s = RunPythonStatement("function()");
|
||||
if (IsString(s))
|
||||
{
|
||||
Message("Error in the python statement: %s\n", s);
|
||||
return;
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
if err:
|
||||
print "Error compiling IDC code: %s" % err
|
||||
else:
|
||||
AddHotkey("ALT-N", 'key_ALTN')
|
||||
```
|
||||
Reference in New Issue
Block a user