Module index

Module ida_diskio

File I/O functions for IDA.
You should not use standard C file I/O functions in modules. Use functions from this header, pro.h and fpro.h instead.
This file also declares a call_system() function.

Global variables

var CFG_SUBDIR
CFG_SUBDIR = 'cfg'
var CSIDL_APPDATA
CSIDL_APPDATA = 26
var CSIDL_LOCAL_APPDATA
CSIDL_LOCAL_APPDATA = 28
var CSIDL_PROGRAM_FILES
CSIDL_PROGRAM_FILES = 38
var CSIDL_PROGRAM_FILESX86
CSIDL_PROGRAM_FILESX86 = 42
var CSIDL_PROGRAM_FILES_COMMON
CSIDL_PROGRAM_FILES_COMMON = 43
var IDA_SUBDIR_IDADIR_FIRST
$IDADIR/subdir will be first, not last
var IDA_SUBDIR_IDP
append the processor name as a subdirectory
var IDA_SUBDIR_ONLY_EXISTING
only existing directories will be present
var IDC_SUBDIR
IDC_SUBDIR = 'idc'
var IDP_SUBDIR
IDP_SUBDIR = 'procs'
var IDS_SUBDIR
IDS_SUBDIR = 'ids'
var LDR_SUBDIR
LDR_SUBDIR = 'loaders'
var LINPUT_GENERIC
generic linput
var LINPUT_LOCAL
local file
var LINPUT_NONE
invalid linput
var LINPUT_PROCMEM
debugged process memory (read_dbg_memory())
var LINPUT_RFILE
remote file ( debugger_t::open_file, debugger_t::read_file)
var PLG_SUBDIR
PLG_SUBDIR = 'plugins'
var SIG_SUBDIR
SIG_SUBDIR = 'sig'
var THM_SUBDIR
THM_SUBDIR = 'themes'
var TIL_SUBDIR
TIL_SUBDIR = 'til'

Functions

def choose_ioport_device2(*args) ‑> bool
choose_ioport_device2(_device, file, parse_params) -> bool
_device: qstring *
file: char const *
parse_params: choose_ioport_parser_t *
def close_linput(*args) ‑> void
close_linput(li)
Close loader input.
li: (C++: linput_t *)
def create_bytearray_linput(*args) ‑> linput_t *
create_bytearray_linput(s) -> linput_t *
Trivial memory linput.
s: qstring const &
def create_generic_linput(*args) ‑> linput_t *
create_generic_linput(gl) -> linput_t *
Create a generic linput
gl: (C++: generic_linput_t *) linput description. this object will be destroyed by close_linput()
using "delete gl;"
def create_memory_linput(*args) ‑> linput_t *
create_memory_linput(start, size) -> linput_t *
Create a linput for process memory. This linput will use read_dbg_memory() to read data.
start: (C++: ea_t) starting address of the input
size: (C++: asize_t) size of the memory area to represent as linput if unknown, may be
passed as 0
def eclose(*args) ‑> void
eclose(fp)
fp: FILE *
def enumerate_files(*args) ‑> PyObject *
enumerate_files(path, fname, callback) -> PyObject *
Enumerate files in the specified directory while the callback returns 0.
path: directory to enumerate files in
fname: mask of file names to enumerate
callback: a callable object that takes the filename as
its first argument and it returns 0 to continue enumeration or non-zero to stop enumeration.
return: None in case of script errors
tuple(code, fname) : If the callback returns non-zero
def enumerate_files2(*args) ‑> int
enumerate_files2(answer, answer_size, path, fname, fv) -> int
answer: char *
answer_size: size_t
path: char const *
fname: char const *
fv: file_enumerator_t &
def fopenA(*args) ‑> FILE *
fopenA(file) -> FILE *
Open a file for append in text mode, deny none.
file: (C++: const char *) char const *
return: nullptr if failure
def fopenM(*args) ‑> FILE *
fopenM(file) -> FILE *
Open a file for read/write in binary mode, deny write.
file: (C++: const char *) char const *
return: nullptr if failure
def fopenRB(*args) ‑> FILE *
fopenRB(file) -> FILE *
Open a file for read in binary mode, deny none.
file: (C++: const char *) char const *
return: nullptr if failure
def fopenRT(*args) ‑> FILE *
fopenRT(file) -> FILE *
Open a file for read in text mode, deny none.
file: (C++: const char *) char const *
return: nullptr if failure
def fopenWB(*args) ‑> FILE *
fopenWB(file) -> FILE *
Open a new file for write in binary mode, deny read/write. If a file exists, it will be removed.
file: (C++: const char *) char const *
return: nullptr if failure
def fopenWT(*args) ‑> FILE *
fopenWT(file) -> FILE *
Open a new file for write in text mode, deny write. If a file exists, it will be removed.
file: (C++: const char *) char const *
return: nullptr if failure
def get_ida_subdirs(*args) ‑> qstrvec_t *
get_ida_subdirs(subdir, flags=0) -> int
Get list of directories in which to find a specific IDA resource (see IDA subdirectories). The order of the resulting list is as follows:
  • [$IDAUSR/subdir (0..N entries)]
  • $IDADIR/subdir
subdir: (C++: const char *) name of the resource to list
flags: (C++: int) Subdirectory modification flags bits
return: number of directories appended to 'dirs'
def get_linput_type(*args) ‑> linput_type_t
get_linput_type(li) -> linput_type_t
Get linput type.
li: (C++: linput_t *)
def get_special_folder(*args) ‑> size_t
get_special_folder(csidl) -> str
Get a folder location by CSIDL (see Common CSIDLs). Path should be of at least MAX_PATH size
csidl: (C++: int)
def get_user_idadir(*args) ‑> char const *
get_user_idadir() -> char const *
Get user ida related directory.
  • if $IDAUSR is defined:
  • the first element in $IDAUSR
  • else
  • default user directory ($HOME/.idapro or %APPDATA%Hex-Rays/IDA Pro)
def getsysfile(*args) ‑> char const *
getsysfile(filename, subdir) -> str
Search for IDA system file. This function searches for a file in: 1. each directory specified by IDAUSR% 2. ida directory [+ subdir] and returns the first match.
filename: (C++: const char *) name of file to search
subdir: (C++: const char *) if specified, the file is looked for in the specified
subdirectory of the ida directory first (see IDA subdirectories)
return: nullptr if not found, otherwise a pointer to full file name.
def idadir(*args) ‑> char const *
idadir(subdir) -> char const *
Get IDA directory (if subdir==nullptr) or the specified subdirectory (see IDA subdirectories)
subdir: (C++: const char *) char const *
def open_linput(*args) ‑> linput_t *
open_linput(file, remote) -> linput_t *
Open loader input.
file: (C++: const char *) char const *
remote: (C++: bool)
def qlgetz(*args) ‑> size_t
qlgetz(li, fpos) -> str
Read a zero-terminated string from the input. If fpos == -1 then no seek will be performed.
li: (C++: linput_t *)
fpos: (C++: int64)
def read_ioports2(*args) ‑> ssize_t
read_ioports2(ports, device, file, callback=None) -> ssize_t
ports: ioports_t *
device: qstring *
file: char const *
callback: ioports_fallback_t *

Classes

class choose_ioport_parser_t (*args)
Proxy of C++ choose_ioport_parser_t class.
__init__(self) -> choose_ioport_parser_t
self: PyObject *

Methods

def parse(self, *args) ‑> bool
parse(self, param, line) -> bool
retval true: and fill PARAM with a displayed string
retval false: and empty PARAM to skip the current device
retval false: and fill PARAM with an error message
param: (C++: qstring *)
line: (C++: const char *) char const *
class file_enumerator_t (*args)
Proxy of C++ file_enumerator_t class.
__init__(self) -> file_enumerator_t
self: PyObject *

Methods

def visit_file(self, *args) ‑> int
visit_file(self, file) -> int
file: char const *
class generic_linput_t (*args, **kwargs)
Proxy of C++ generic_linput_t class.

Instance variables

var blocksize
preferred block size to work with read/write sizes will be in multiples of this number. for example, 4096 is a nice value blocksize 0 means that the filesize is unknown. the internal cache will be disabled in this case. also, seeks from the file end will fail. blocksize=-1 means error.
var filesize
input file size

Methods

def read(self, *args) ‑> ssize_t
read(self, off, buffer, nbytes) -> ssize_t
off: qoff64_t
buffer: void *
nbytes: size_t
class ioports_fallback_t (*args)
Proxy of C++ ioports_fallback_t class.
__init__(self) -> ioports_fallback_t
self: PyObject *

Methods

def handle(self, *args) ‑> bool
handle(self, ports, line) -> bool
ports: ioports_t const &
line: char const *