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 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 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)

## Functions

`def choose_ioport_device2(_device: qstring *, file: char const *, parse_params: choose_ioport_parser_t)`

  choose_ioport_device2(_device, file, parse_params) -> bool

  @param _device: qstring * @param file: char const * @param parse_params: choose_ioport_parser_t *

`def close_linput(li: linput_t *)`

  close_linput(li) Close loader input.

  @param li: (C++: linput_t *)

`def create_bytearray_linput(s: qstring const &)`

  create_bytearray_linput(s) -> linput_t * Trivial memory linput.

  @param s: qstring const &

`def create_generic_linput(gl: generic_linput_t)`

  create_generic_linput(gl) -> linput_t * Create a generic linput

  @param gl: (C++: generic_linput_t *) linput description. this object will be destroyed by close_linput() using "delete gl;"

`def create_memory_linput(start: ea_t, size: asize_t)`

  create_memory_linput(start, size) -> linput_t * Create a linput for process memory. This linput will use read_dbg_memory() to read data.

  @param start: (C++: ea_t) starting address of the input @param size: (C++: asize_t) size of the memory area to represent as linput if unknown, may be passed as 0

`def enumerate_files(path: PyObject *, fname: PyObject *, callback: PyObject *)`

  enumerate_files(path, fname, callback) -> PyObject * Enumerate files in the specified directory while the callback returns 0.

  @param path: directory to enumerate files in @param fname: mask of file names to enumerate @param 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 fopenA(file: char const *)`

  fopenA(file) -> FILE * Open a file for append in text mode, deny none.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def fopenM(file: char const *)`

  fopenM(file) -> FILE * Open a file for read/write in binary mode, deny write.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def fopenRB(file: char const *)`

  fopenRB(file) -> FILE * Open a file for read in binary mode, deny none.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def fopenRT(file: char const *)`

  fopenRT(file) -> FILE * Open a file for read in text mode, deny none.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def fopenWB(file: char const *)`

  fopenWB(file) -> FILE * Open a new file for write in binary mode, deny read/write. If a file exists, it will be removed.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def fopenWT(file: char const *)`

  fopenWT(file) -> FILE * Open a new file for write in text mode, deny write. If a file exists, it will be removed.

  @param file: (C++: const char *) char const * @return: nullptr if failure

`def get_ida_subdirs(subdir: char const *, flags: int = 0)`

  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

  @param subdir: (C++: const char *) name of the resource to list (can be nullptr) @param flags: (C++: int) Subdirectory modification flags bits @return: number of directories appended to 'dirs'

`def get_linput_type(li: linput_t *)`

  get_linput_type(li) -> linput_type_t Get linput type.

  @param li: (C++: linput_t *)

`def get_special_folder(csidl: int)`

  get_special_folder(csidl) -> str Get a folder location by CSIDL (see Common CSIDLs). Path should be of at least MAX_PATH size

  @param csidl: (C++: int)

`def get_user_idadir()`

  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(filename: char const *, subdir: 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.

  @param filename: (C++: const char ) name of file to search @param 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(subdir: char const *)`

  idadir(subdir) -> char const * Get IDA directory (if subdir==nullptr) or the specified subdirectory (see IDA subdirectories)

  @param subdir: (C++: const char *) char const *

`def open_linput(file: char const *, remote: bool)`

  open_linput(file, remote) -> linput_t * Open loader input.

  @param file: (C++: const char *) char const * @param remote: (C++: bool)

`def qlgetz(li: linput_t *, fpos: int64)`

  qlgetz(li, fpos) -> str Read a zero-terminated string from the input. If fpos == -1 then no seek will be performed.

  @param li: (C++: linput_t *) @param fpos: (C++: int64)

`def read_ioports(ports: ioports_t *, device: qstring *, file: char const *, callback: ioports_fallback_t = None)`

  read_ioports(ports, device, file, callback=None) -> ssize_t

  @param ports: ioports_t * @param device: qstring * @param file: char const * @param callback: ioports_fallback_t *

## Classes

`class choose_ioport_parser_t`

  Proxy of C++ choose_ioport_parser_t class.

  init(self) -> choose_ioport_parser_t

  @param self: PyObject *

  ### Instance variables

  `var thisown`

    The membership flag

  ### Methods

  `def parse(self, param: qstring *, line: char const *)`

    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 param: (C++: qstring ) @param line: (C++: const char ) char const *

`class file_enumerator_t`

  Proxy of C++ file_enumerator_t class.

  init(self) -> file_enumerator_t

  @param self: PyObject *

  ### Instance variables

  `var thisown`

    The membership flag

  ### Methods

  `def visit_file(self, file: char const *)`

    visit_file(self, file) -> int

    @param file: char const *

`class generic_linput_t (*args, **kwargs)`

  Proxy of C++ generic_linput_t class.

  ### Instance variables

  `var blocksize : uint32`

    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 : uint64`

    input file size

  `var thisown`

    The membership flag

  ### Methods

  `def read(self, off: qoff64_t, buffer: void *, nbytes: size_t)`

    read(self, off, buffer, nbytes) -> ssize_t

    @param off: qoff64_t @param buffer: void * @param nbytes: size_t

`class ioports_fallback_t`

  Proxy of C++ ioports_fallback_t class.

  init(self) -> ioports_fallback_t

  @param self: PyObject *

  ### Instance variables

  `var thisown`

    The membership flag

  ### Methods

  `def handle(self, ports: ioports_t const &, line: char const *)`

    handle(self, ports, line) -> bool

    @param ports: (C++: const ioports_t &) i/o port definitions @param line: (C++: const char *) input line to parse @return: success or fills ERRBUF with an error message