System independent counterparts of FILE* related functions from Clib. More...
Macros | |
#define | stdin dont_use_stdin |
use gets() | |
#define | stdout dont_use_stdout |
use qprintf() | |
#define | stderr dont_use_stderr |
use qeprintf() | |
#define | fopen dont_use_fopen |
use qfopen() | |
#define | fread dont_use_fread |
use qfread() | |
#define | fwrite dont_use_fwrite |
use qfwrite() | |
#define | ftell dont_use_ftell |
use qftell() | |
#define | fseek dont_use_fseek |
use qfseek() | |
#define | fclose dont_use_fclose |
use qfclose() | |
#define | fflush dont_use_fflush |
use qflush() | |
#define | fputc dont_use_fputc |
use qfputc() | |
#define | fgetc dont_use_fgetc |
use qfgetc() | |
#define | fgets dont_use_fgets |
use qfgets() | |
#define | fputs dont_use_fputs |
use qfputs() | |
#define | vfprintf dont_use_vfprintf |
use qvfprintf() | |
#define | vfscanf dont_use_vfscanf |
use qvfscanf() | |
#define | fprintf dont_use_fprintf |
use qfprintf() | |
#define | fscanf dont_use_fscanf |
use qfscanf() | |
readbytes/writebytes | |||||||||||
Add-ins for 2..32 byte read/writes.
| |||||||||||
#define | DEF_FREADBYTES(read, write, type, size) | ||||||||||
idaman THREAD_SAFE int ida_export | freadbytes (FILE *fp, void *res, int size, int mostfirst) | ||||||||||
idaman THREAD_SAFE int ida_export | fwritebytes (FILE *fp, const void *l, int size, int mostfirst) | ||||||||||
int | fread2bytes (FILE *fp, int16 *res, bool mostfirst) | ||||||||||
int | fwrite2bytes (FILE *fp, const int16 *res, bool mostfirst) | ||||||||||
int | fread2bytes (FILE *fp, uint16 *res, bool mostfirst) | ||||||||||
int | fwrite2bytes (FILE *fp, const uint16 *res, bool mostfirst) | ||||||||||
int | fread4bytes (FILE *fp, int32 *res, bool mostfirst) | ||||||||||
int | fwrite4bytes (FILE *fp, const int32 *res, bool mostfirst) | ||||||||||
int | fread4bytes (FILE *fp, uint32 *res, bool mostfirst) | ||||||||||
int | fwrite4bytes (FILE *fp, const uint32 *res, bool mostfirst) | ||||||||||
int | fread8bytes (FILE *fp, int64 *res, bool mostfirst) | ||||||||||
int | fwrite8bytes (FILE *fp, const int64 *res, bool mostfirst) | ||||||||||
int | fread8bytes (FILE *fp, uint64 *res, bool mostfirst) | ||||||||||
int | fwrite8bytes (FILE *fp, const uint64 *res, bool mostfirst) | ||||||||||
File I/O | |
The following functions work just like their counterparts from Clib, only they are safer, system independent, and they set qerrno (see get_qerrno()). | |
enum | { QMOVE_CROSS_FS = 0x01 , QMOVE_OVERWRITE = 0x02 , QMOVE_OVR_RO = 0x04 } |
typedef janitor_t< FILE * > | file_janitor_t |
File janitor: will close a file at destruction-time. | |
idaman THREAD_SAFE FILE *ida_export | qfopen (const char *file, const char *mode) |
idaman THREAD_SAFE ssize_t ida_export | qfread (FILE *fp, void *buf, size_t n) |
idaman THREAD_SAFE ssize_t ida_export | qfwrite (FILE *fp, const void *buf, size_t n) |
idaman THREAD_SAFE qoff64_t ida_export | qftell (FILE *fp) |
idaman THREAD_SAFE int ida_export | qfseek (FILE *fp, qoff64_t offset, int whence) |
idaman THREAD_SAFE int ida_export | qfclose (FILE *fp) |
idaman THREAD_SAFE int ida_export | qflush (FILE *fp) |
idaman THREAD_SAFE int ida_export | qfputc (int chr, FILE *fp) |
idaman THREAD_SAFE int ida_export | qfgetc (FILE *fp) |
idaman THREAD_SAFE char *ida_export | qfgets (char *s, size_t len, FILE *fp) |
idaman THREAD_SAFE int ida_export | qfputs (const char *s, FILE *fp) |
idaman FILE *ida_export | qtmpfile (void) |
idaman THREAD_SAFE int ida_export | qunlink (const char *fname) |
idaman THREAD_SAFE int ida_export | qaccess (const char *fname, int mode) |
idaman THREAD_SAFE char *ida_export | qgets (char *line, size_t linesize) |
idaman THREAD_SAFE uint64 ida_export | qfsize (FILE *fp) |
idaman THREAD_SAFE int ida_export | qvfprintf (FILE *fp, const char *format, va_list va) |
idaman THREAD_SAFE int ida_export | qvprintf (const char *format, va_list va) |
idaman THREAD_SAFE int ida_export | qveprintf (const char *format, va_list va) |
idaman THREAD_SAFE int ida_export | qvfscanf (FILE *fp, const char *format, va_list va) |
THREAD_SAFE int | qfprintf (FILE *fp, const char *format,...) |
THREAD_SAFE int | qprintf (const char *format,...) |
THREAD_SAFE int | qeprintf (const char *format,...) |
THREAD_SAFE int | qfscanf (FILE *fp, const char *format,...) |
idaman THREAD_SAFE ssize_t ida_export | qgetline (qstring *buf, FILE *fp) |
Read line from file (the newline is removed from the output buffer) More... | |
idaman THREAD_SAFE int ida_export | qrename (const char *oldfname, const char *newfname) |
Rename a file: 'newname' may exist, and will be deleted. | |
idaman THREAD_SAFE int ida_export | qmove (const char *oldfname, const char *newfname, uint32 flags) |
Move a file - more powerful version of qrename. More... | |
idaman THREAD_SAFE int ida_export | qcopyfile (const char *from, const char *to, bool overwrite=true, bool(idaapi *cb)(uint64 pos, uint64 total, void *ud)=nullptr, void *ud=nullptr, int flags=0) |
Copy a file. More... | |
idaman char *ida_export | qtmpdir (char *buf, size_t bufsize) |
Get temporary directory name Returns absolute path. | |
idaman char *ida_export | qtmpnam (char *buf, size_t bufsize) |
Get temporary file name. More... | |
Detailed Description
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.
Macro Definition Documentation
◆ DEF_FREADBYTES
#define DEF_FREADBYTES | ( | read, | |
write, | |||
type, | |||
size | |||
) |
Function Documentation
◆ qgetline()
idaman THREAD_SAFE ssize_t ida_export qgetline | ( | qstring * | buf, |
FILE * | fp | ||
) |
Read line from file (the newline is removed from the output buffer)
- Parameters
-
buf output buffer fp pointer to file
- Returns
- -1 or length of line
◆ qmove()
idaman THREAD_SAFE int ida_export qmove | ( | const char * | oldfname, |
const char * | newfname, | ||
uint32 | flags | ||
) |
Move a file - more powerful version of qrename.
- Return values
-
0 success -1 system error else a combination of flags to be given for successful move
◆ qcopyfile()
idaman THREAD_SAFE int ida_export qcopyfile | ( | const char * | from, |
const char * | to, | ||
bool | overwrite = true , |
||
bool(idaapi *)(uint64 pos, uint64 total, void *ud) | cb = nullptr , |
||
void * | ud = nullptr , |
||
int | flags = 0 |
||
) |
Copy a file.
- Parameters
-
from source file name to destination file name overwrite overwrite output if it exists? cb user callback. return false to abort the copy loop ud user data passed back to cb flags reserved (should be zero)
- Return values
-
-1 input file not found -2 output file not writable -3 output file already exists while overwrite is false -4 write failure -5 interrupted from the callback
◆ qtmpnam()
idaman char *ida_export qtmpnam | ( | char * | buf, |
size_t | bufsize | ||
) |
Get temporary file name.
Returns absolute path (includes directory)
Generated by