mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-28 02:31:53 +01:00
78c79f85b9
What's new: - Proper multi-threaded support - Better PyObject reference counting with ref_t and newref_t helper classes - Improved the pywraps/deployment script - Added IDAViewWrapper class and example - Added idc.GetDisasmEx() - Added idc.AddSegEx() - Added idc.GetLocalTinfo() - Added idc.ApplyType() - Updated type information implementation - Introduced the idaapi.require() - see http://www.hexblog.com/?p=749 - set REMOVE_CWD_SYS_PATH=1 by default in python.cfg (remove current directory from the import search path). Various bugfixes: - fixed various memory leaks - asklong/askaddr/asksel (and corresponding idc.py functions) were returning results truncated to 32 bits in IDA64 - fix wrong documentation for idc.SizeOf - GetFloat/GetDouble functions did not take into account endianness of the processor - idaapi.NO_PROCESS was not defined, and was causing GetProcessPid() to fail - idc.py: insert escape characters to string parameter when call Eval() - idc.SaveFile/savefile were always overwriting an existing file instead of writing only the new data - PluginForm.Close() wasn't passing its arguments to the delegate function, resulting in an error.
93 lines
2.1 KiB
C++
93 lines
2.1 KiB
C++
#ifndef __PY_LOADER___
|
|
#define __PY_LOADER___
|
|
|
|
//------------------------------------------------------------------------
|
|
//<inline(py_loader)>
|
|
|
|
//------------------------------------------------------------------------
|
|
/*
|
|
#<pydoc>
|
|
def mem2base(mem, ea, fpos):
|
|
"""
|
|
Load database from the memory.
|
|
@param mem: the buffer
|
|
@param ea: start linear addresses
|
|
@param fpos: position in the input file the data is taken from.
|
|
if == -1, then no file position correspond to the data.
|
|
@return:
|
|
- Returns zero if the passed buffer was not a string
|
|
- Otherwise 1 is returned
|
|
"""
|
|
pass
|
|
#</pydoc>
|
|
*/
|
|
static int py_mem2base(PyObject *py_mem, ea_t ea, long fpos = -1)
|
|
{
|
|
Py_ssize_t len;
|
|
char *buf;
|
|
{
|
|
PYW_GIL_CHECK_LOCKED_SCOPE();
|
|
if ( PyString_AsStringAndSize(py_mem, &buf, &len) == -1 )
|
|
return 0;
|
|
}
|
|
|
|
return mem2base((void *)buf, ea, ea+len, fpos);
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
/*
|
|
#<pydoc>
|
|
def load_plugin(name):
|
|
"""
|
|
Loads a plugin
|
|
@return:
|
|
- None if plugin could not be loaded
|
|
- An opaque object representing the loaded plugin
|
|
"""
|
|
pass
|
|
#</pydoc>
|
|
*/
|
|
static PyObject *py_load_plugin(const char *name)
|
|
{
|
|
plugin_t *r = load_plugin(name);
|
|
PYW_GIL_CHECK_LOCKED_SCOPE();
|
|
if ( r == NULL )
|
|
Py_RETURN_NONE;
|
|
else
|
|
return PyCObject_FromVoidPtr(r, NULL);
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
/*
|
|
#<pydoc>
|
|
def run_plugin(plg):
|
|
"""
|
|
Runs a plugin
|
|
@param plg: A plugin object (returned by load_plugin())
|
|
@return: Boolean
|
|
"""
|
|
pass
|
|
#</pydoc>
|
|
*/
|
|
static bool py_run_plugin(PyObject *plg, int arg)
|
|
{
|
|
PYW_GIL_CHECK_LOCKED_SCOPE();
|
|
if ( !PyCObject_Check(plg) )
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
plugin_t *p = (plugin_t *)PyCObject_AsVoidPtr(plg);
|
|
bool rc;
|
|
Py_BEGIN_ALLOW_THREADS;
|
|
rc = run_plugin(p, arg);
|
|
Py_END_ALLOW_THREADS;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
//</inline(py_loader)>
|
|
|
|
#endif
|