本文整理汇总了C++中PYW_GIL_CHECK_LOCKED_SCOPE函数的典型用法代码示例。如果您正苦于以下问题:C++ PYW_GIL_CHECK_LOCKED_SCOPE函数的具体用法?C++ PYW_GIL_CHECK_LOCKED_SCOPE怎么用?C++ PYW_GIL_CHECK_LOCKED_SCOPE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PYW_GIL_CHECK_LOCKED_SCOPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply_type_to_stkarg
/*
header: typeinf.hpp
#<pydoc>
def apply_type_to_stkarg(op, v, type, name):
"""
Apply type information to a stack variable
@param op: reference to instruction operand
@param v: immediate value in the operand (usually op.addr)
@param type: type string. Retrieve from idc.ParseType("type string", flags)[1]
@param name: stack variable name
@return: Boolean
"""
pass
#</pydoc>
*/
bool py_apply_type_to_stkarg(
PyObject *py_op,
PyObject *py_uv,
PyObject *py_type,
const char *name)
{
uint64 v;
PYW_GIL_CHECK_LOCKED_SCOPE();
op_t *op = op_t_get_clink(py_op);
if ( op == NULL || !PyW_GetNumber(py_uv, &v) || !PyString_Check(py_type))
{
return false;
}
else
{
const type_t *t = (type_t *) PyString_AsString(py_type);
tinfo_t tif;
tif.deserialize(idati, &t);
borref_t br(py_op);
bool rc;
Py_BEGIN_ALLOW_THREADS;
rc = apply_tinfo_to_stkarg(*op, uval_t(v), tif, name);
Py_END_ALLOW_THREADS;
return rc;
}
}
示例2: add_stkvar3
/*
header: frame.hpp
#<pydoc>
def add_stkvar3(op, v, flags):
"""
Automatically add stack variable if doesn't exist
Processor modules should use ua_stkvar2()
@param op: reference to instruction operand
@param v: immediate value in the operand (usually op.addr)
@param flags: combination of STKVAR_... constants
@return: Boolean
"""
pass
#</pydoc>
*/
bool py_add_stkvar3(PyObject *py_op, PyObject *py_v, int flags)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
op_t *op = op_t_get_clink(py_op);
uint64 v;
return ( op == NULL || !PyW_GetNumber(py_v, &v) || !add_stkvar3(*op, sval_t(v), flags)) ? false : true;
}
示例3: OutImmChar
/*
#<pydoc>
def OutImmChar(op, outflags = 0):
"""
Output operand value as a commented character constant
@param op: operand (of type op_t)
@return: None
"""
pass
#</pydoc>
*/
static void py_OutImmChar(PyObject *x)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
op_t *op = op_t_get_clink(x);
if ( op != NULL )
OutImmChar(*op);
}
示例4: dbg_read_memory
/*
#<pydoc>
def dbg_read_memory(ea, sz):
"""
Reads from the debugee's memory at the specified ea
@return:
- The read buffer (as a string)
- Or None on failure
"""
pass
#</pydoc>
*/
static PyObject *dbg_read_memory(PyObject *py_ea, PyObject *py_sz)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
uint64 ea, sz;
if ( !dbg_can_query() || !PyW_GetNumber(py_ea, &ea) || !PyW_GetNumber(py_sz, &sz) )
Py_RETURN_NONE;
// Create a Python string
PyObject *ret = PyString_FromStringAndSize(NULL, Py_ssize_t(sz));
if ( ret == NULL )
Py_RETURN_NONE;
// Get the internal buffer
Py_ssize_t len;
char *buf;
PyString_AsStringAndSize(ret, &buf, &len);
if ( (size_t)read_dbg_memory(ea_t(ea), buf, size_t(sz)) != sz )
{
// Release the string on failure
Py_DECREF(ret);
// Return None on failure
Py_RETURN_NONE;
}
return ret;
}
示例5: PYW_GIL_CHECK_LOCKED_SCOPE
static PyObject *py_add_menu_item(
const char *menupath,
const char *name,
const char *hotkey,
int flags,
PyObject *pyfunc,
PyObject *args)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
bool no_args;
// No slash in the menu path?
const char *p = strrchr(menupath, '/');
if ( p == NULL )
Py_RETURN_NONE;
if ( args == Py_None )
{
no_args = true;
args = PyTuple_New(0);
if ( args == NULL )
return NULL;
}
else if ( !PyTuple_Check(args) )
{
PyErr_SetString(PyExc_TypeError, "args must be a tuple or None");
return NULL;
}
else
{
no_args = false;
}
// Form a tuple holding the function to be called and its arguments
PyObject *cb_data = Py_BuildValue("(OO)", pyfunc, args);
// If we created an empty tuple, then we must free it
if ( no_args )
Py_DECREF(args);
// Add the menu item
bool b = add_menu_item(menupath, name, hotkey, flags, py_menu_item_callback, (void *)cb_data);
if ( !b )
{
Py_XDECREF(cb_data);
Py_RETURN_NONE;
}
// Create a context (for the delete_menu_item())
py_add_del_menu_item_ctx *ctx = new py_add_del_menu_item_ctx();
// Form the complete menu path
ctx->menupath.append(menupath, p - menupath + 1);
ctx->menupath.append(name);
// Save callback data
ctx->cb_data = cb_data;
// Return context to user
return PyCObject_FromVoidPtr(ctx, NULL);
}
示例6: py_import_enum_cb
//-------------------------------------------------------------------------
// callback for enumerating imports
// ea: import address
// name: import name (NULL if imported by ordinal)
// ord: import ordinal (0 for imports by name)
// param: user parameter passed to enum_import_names()
// return: 1-ok, 0-stop enumeration
static int idaapi py_import_enum_cb(
ea_t ea,
const char *name,
uval_t ord,
void *param)
{
// If no name, try to get the name associated with the 'ea'. It may be coming from IDS
char name_buf[MAXSTR];
if ( name == NULL )
name = get_true_name(BADADDR, ea, name_buf, sizeof(name_buf));
PYW_GIL_CHECK_LOCKED_SCOPE();
ref_t py_name;
if ( name == NULL )
py_name = borref_t(Py_None);
else
py_name = newref_t(PyString_FromString(name));
newref_t py_ord(Py_BuildValue(PY_FMT64, pyul_t(ord)));
newref_t py_ea(Py_BuildValue(PY_FMT64, pyul_t(ea)));
newref_t py_result(
PyObject_CallFunctionObjArgs(
(PyObject *)param,
py_ea.o,
py_name.o,
py_ord.o,
NULL));
return py_result != NULL && PyObject_IsTrue(py_result.o) ? 1 : 0;
}
示例7: tag_addr
//-------------------------------------------------------------------------
PyObject *py_tag_addr(ea_t ea)
{
char buf[100];
tag_addr(buf, buf + sizeof(buf), ea);
PYW_GIL_CHECK_LOCKED_SCOPE();
return PyString_FromString(buf);
}
示例8: set_user_defined_prefix
/*
#<pydoc>
def set_user_defined_prefix(width, callback):
"""
User-defined line-prefixes are displayed just after the autogenerated
line prefixes. In order to use them, the plugin should call the
following function to specify its width and contents.
@param width: the width of the user-defined prefix
@param callback: a get_user_defined_prefix callback to get the contents of the prefix.
Its arguments:
ea - linear address
lnnum - line number
indent - indent of the line contents (-1 means the default instruction)
indent and is used for instruction itself. see explanations for printf_line()
line - the line to be generated. the line usually contains color tags this argument
can be examined to decide whether to generated the prefix
bufsize- the maximum allowed size of the output buffer
It returns a buffer of size < bufsize
In order to remove the callback before unloading the plugin, specify the width = 0 or the callback = None
"""
pass
#</pydoc>
*/
static PyObject *py_set_user_defined_prefix(size_t width, PyObject *pycb)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
if ( width == 0 || pycb == Py_None )
{
// Release old callback reference
Py_XDECREF(py_get_user_defined_prefix);
// ...and clear it
py_get_user_defined_prefix = NULL;
// Uninstall user defind prefix
set_user_defined_prefix(0, NULL);
}
else if ( PyCallable_Check(pycb) )
{
// Release old callback reference
Py_XDECREF(py_get_user_defined_prefix);
// Copy new callback and hold a reference
py_get_user_defined_prefix = pycb;
Py_INCREF(py_get_user_defined_prefix);
set_user_defined_prefix(width, s_py_get_user_defined_prefix);
}
else
{
Py_RETURN_FALSE;
}
Py_RETURN_TRUE;
}
示例9: tag_addr
//-------------------------------------------------------------------------
PyObject *py_tag_addr(ea_t ea)
{
qstring tag;
tag_addr(&tag, ea);
PYW_GIL_CHECK_LOCKED_SCOPE();
return PyString_FromString(tag.begin());
}
示例10: py_testf_cb
//<code(py_bytes)>
//------------------------------------------------------------------------
static bool idaapi py_testf_cb(flags_t flags, void *ud)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
newref_t py_flags(PyLong_FromUnsignedLong(flags));
newref_t result(PyObject_CallFunctionObjArgs((PyObject *) ud, py_flags.o, NULL));
return result != NULL && PyObject_IsTrue(result.o);
}
示例11: tag_remove
/*
#<pydoc>
def tag_remove(colstr):
"""
Remove color escape sequences from a string
@param colstr: the colored string with embedded tags
@return: a new string w/o the tags
"""
pass
#</pydoc>
*/
PyObject *py_tag_remove(const char *instr)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
qstring qbuf;
tag_remove(&qbuf, instr);
return PyString_FromString(qbuf.c_str());
}
示例12: enum_import_names
/*
#<pydoc>
def enum_import_names(mod_index, callback):
"""
Enumerate imports from a specific module.
Please refer to ex_imports.py example.
@param mod_index: The module index
@param callback: A callable object that will be invoked with an ea, name (could be None) and ordinal.
@return: 1-finished ok, -1 on error, otherwise callback return value (<=0)
"""
pass
#</pydoc>
*/
static int py_enum_import_names(int mod_index, PyObject *py_cb)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
if ( !PyCallable_Check(py_cb) )
return -1;
return enum_import_names(mod_index, py_import_enum_cb, py_cb);
}
示例13: generate_disassembly
/*
#<pydoc>
def generate_disassembly(ea, max_lines, as_stack, notags):
"""
Generate disassembly lines (many lines) and put them into a buffer
@param ea: address to generate disassembly for
@param max_lines: how many lines max to generate
@param as_stack: Display undefined items as 2/4/8 bytes
@return:
- None on failure
- tuple(most_important_line_number, tuple(lines)) : Returns a tuple containing
the most important line number and a tuple of generated lines
"""
pass
#</pydoc>
*/
PyObject *py_generate_disassembly(
ea_t ea,
int max_lines,
bool as_stack,
bool notags)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
if ( max_lines <= 0 )
Py_RETURN_NONE;
qstring qbuf;
char **lines = new char *[max_lines];
int lnnum;
int nlines = generate_disassembly(ea, lines, max_lines, &lnnum, as_stack);
newref_t py_tuple(PyTuple_New(nlines));
for ( int i=0; i<nlines; i++ )
{
const char *s = lines[i];
size_t line_len = strlen(s);
if ( notags )
{
qbuf.resize(line_len+5);
tag_remove(s, &qbuf[0], line_len);
s = (const char *)&qbuf[0];
}
PyTuple_SetItem(py_tuple.o, i, PyString_FromString(s));
qfree(lines[i]);
}
delete [] lines;
return Py_BuildValue("(iO)", lnnum, py_tuple.o);
}
示例14: decode_preceding_insn
/*
#<pydoc>
def decode_preceding_insn(ea):
"""
Decodes the preceding instruction. Please check ua.hpp / decode_preceding_insn()
@param ea: current ea
@return: tuple(preceeding_ea or BADADDR, farref = Boolean)
"""
pass
#</pydoc>
*/
PyObject *py_decode_preceding_insn(ea_t ea)
{
bool farref;
ea_t r = decode_preceding_insn(ea, &farref);
PYW_GIL_CHECK_LOCKED_SCOPE();
return Py_BuildValue("(" PY_FMT64 "i)", pyul_t(r), farref ? 1 : 0);
}
示例15: generate_disassembly
/*
#<pydoc>
def generate_disassembly(ea, max_lines, as_stack, notags):
"""
Generate disassembly lines (many lines) and put them into a buffer
@param ea: address to generate disassembly for
@param max_lines: how many lines max to generate
@param as_stack: Display undefined items as 2/4/8 bytes
@return:
- None on failure
- tuple(most_important_line_number, tuple(lines)) : Returns a tuple containing
the most important line number and a tuple of generated lines
"""
pass
#</pydoc>
*/
PyObject *py_generate_disassembly(
ea_t ea,
int max_lines,
bool as_stack,
bool notags)
{
PYW_GIL_CHECK_LOCKED_SCOPE();
if ( max_lines <= 0 )
Py_RETURN_NONE;
qstring qbuf;
qstrvec_t lines;
int lnnum;
int nlines = generate_disassembly(&lines, &lnnum, ea, max_lines, as_stack);
newref_t py_tuple(PyTuple_New(nlines));
for ( int i=0; i < nlines; i++ )
{
const qstring &l = lines[i];
const char *s = l.c_str();
if ( notags )
{
tag_remove(&qbuf, l);
s = qbuf.c_str();
}
PyTuple_SetItem(py_tuple.o, i, PyString_FromString(s));
}
return Py_BuildValue("(iO)", lnnum, py_tuple.o);
}