ida_fpro

System independent counterparts of FILE* related functions from Clib.

You should not use C standard I/O functions in your modules. The reason: Each module compiled with Borland (and statically linked to Borland’s library) will host a copy of the FILE * information. So, if you open a file in the plugin and pass the handle to the kernel, the kernel will not be able to use it. If you really need to use the standard functions, define USE_STANDARD_FILE_FUNCTIONS. In this case do not mix them with q… functions.

Attributes

SWIG_PYTHON_LEGACY_BOOL

QMOVE_CROSS_FS

QMOVE_OVERWRITE

QMOVE_OVR_RO

qfile_t_from_fp

qfile_t_from_capsule

qfile_t_tmpfile

Classes

qfile_t

A helper class to work with FILE related functions.

Functions

qfclose(→ int)

Module Contents

ida_fpro.SWIG_PYTHON_LEGACY_BOOL
class ida_fpro.qfile_t(*args)

Bases: object

A helper class to work with FILE related functions.

thisown
opened()

Checks if the file is opened or not

close()

Closes the file

open(filename, mode)

Opens a file

Parameters:
  • filename – the file name

  • mode – The mode string, ala fopen() style

Returns:

Boolean

static from_fp(fp: FILE *) qfile_t *
static from_capsule(pycapsule: PyObject *) qfile_t *
static tmpfile()

A static method to construct an instance using a temporary file

get_fp() FILE *
seek(offset, whence=ida_idaapi.SEEK_SET)

Set input source position

Parameters:
  • offset – the seek offset

  • whence – the position to seek from

Returns:

the new position (not 0 as fseek!)

tell()

Returns the current position

readbytes(size, big_endian)

Similar to read() but it respect the endianness

Parameters:
  • size – the maximum number of bytes to read

  • big_endian – endianness

Returns:

a str, or None

read(size)

Reads from the file. Returns the buffer or None

Parameters:

size – the maximum number of bytes to read

Returns:

a str, or None

gets(len)

Reads a line from the input file. Returns the read line or None

Parameters:

len – the maximum line length

writebytes(size, big_endian)

Similar to write() but it respect the endianness

Parameters:
  • buf – the str to write

  • big_endian – endianness

Returns:

result code

write(buf)

Writes to the file. Returns 0 or the number of bytes written

Parameters:

buf – the str to write

Returns:

result code

puts(str: qfile_t.puts.str) int
size() int64
flush()
filename() PyObject *
get_byte()

Reads a single byte from the file. Returns None if EOF or the read byte

put_byte()

Writes a single byte to the file

Parameters:

chr – the byte value

ida_fpro.qfclose(fp: FILE *) int
ida_fpro.QMOVE_CROSS_FS
ida_fpro.QMOVE_OVERWRITE
ida_fpro.QMOVE_OVR_RO
ida_fpro.qfile_t_from_fp
ida_fpro.qfile_t_from_capsule
ida_fpro.qfile_t_tmpfile