JubeatPlus 3.9.11
Loading...
Searching...
No Matches
ioapi.h File Reference

The stdio I/O callbacks the game hands to minizip's unzip API. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  zlib_filefunc_def_s
 The table of I/O callbacks minizip drives an archive through. More...

Macros

#define ZLIB_FILEFUNC_MODE_READ   1
 Open for reading.
#define ZLIB_FILEFUNC_MODE_WRITE   2
 Open for writing.
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER   3
 The mask used to isolate the read/write mode bits.
#define ZLIB_FILEFUNC_MODE_EXISTING   4
 Open an existing file for update.
#define ZLIB_FILEFUNC_MODE_CREATE   8
 Create (truncate) the file.
#define ZLIB_FILEFUNC_SEEK_SET   0
 Seek relative to the start of the stream.
#define ZLIB_FILEFUNC_SEEK_CUR   1
 Seek relative to the current position.
#define ZLIB_FILEFUNC_SEEK_END   2
 Seek relative to the end of the stream.

Typedefs

typedef void * voidpf
 minizip's opaque pointer type.
typedef unsigned long uLong
 minizip's wide unsigned integer type (zlib's uLong).
typedef voidpf(* open_file_func) (voidpf opaque, const char *filename, int mode)
 Callback that opens a file and returns its stream.
typedef uLong(* read_file_func) (voidpf opaque, voidpf stream, void *buf, uLong size)
 Callback that reads bytes from a stream.
typedef uLong(* write_file_func) (voidpf opaque, voidpf stream, const void *buf, uLong size)
 Callback that writes bytes to a stream.
typedef long(* tell_file_func) (voidpf opaque, voidpf stream)
 Callback that reports the current position of a stream.
typedef long(* seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin)
 Callback that seeks a stream.
typedef int(* close_file_func) (voidpf opaque, voidpf stream)
 Callback that closes a stream.
typedef int(* testerror_file_func) (voidpf opaque, voidpf stream)
 Callback that reports the error state of a stream.
typedef struct zlib_filefunc_def_s zlib_filefunc_def
 The table of I/O callbacks minizip drives an archive through.

Functions

voidpf fopen_file_func (voidpf opaque, const char *filename, int mode)
 Maps a ZLIB_FILEFUNC_MODE_* bitmask to an fopen mode string and opens the file.
uLong fread_file_func (voidpf opaque, voidpf stream, void *buf, uLong size)
 Reads size bytes from stream into buf.
uLong fwrite_file_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
 Writes size bytes from buf to stream.
long ftell_file_func (voidpf opaque, voidpf stream)
 Reports the current position of stream.
long fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
 Seeks stream, translating success to 0 and failure to -1.
int fclose_file_func (voidpf opaque, voidpf stream)
 Closes stream.
int ferror_file_func (voidpf opaque, voidpf stream)
 Reports the error state of stream.
void fill_fopen_filefunc (zlib_filefunc_def *pzlib_filefunc_def)
 Fills pzlib_filefunc_def with the stdio implementations and a nullptr opaque cookie.

Detailed Description

The stdio I/O callbacks the game hands to minizip's unzip API.

Reconstructed from Ghidra program Jubeat (image base 0x100000000). All

Ghidra address:
values are offsets relative to that image base. This is the stock zlib contrib/minizip/ioapi.c file function set: a zlib_filefunc_def table whose seven members forward to the C stdio routines, filled by fill_fopen_filefunc.

Typedef Documentation

◆ zlib_filefunc_def

The table of I/O callbacks minizip drives an archive through.

The layout matches the stores in fill_fopen_filefunc: eight pointer-sized fields, the seven callbacks followed by the opaque cookie, totalling 0x40 bytes.

Function Documentation

◆ fclose_file_func()

int fclose_file_func ( voidpf opaque,
voidpf stream )

Closes stream.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to close.
Returns
The result of fclose.
Ghidra address:
0x72b30

◆ ferror_file_func()

int ferror_file_func ( voidpf opaque,
voidpf stream )

Reports the error state of stream.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to query.
Returns
The result of ferror.
Ghidra address:
0x72b38

◆ fill_fopen_filefunc()

void fill_fopen_filefunc ( zlib_filefunc_def * pzlib_filefunc_def)

Fills pzlib_filefunc_def with the stdio implementations and a nullptr opaque cookie.

Parameters
pzlib_filefunc_defThe table to populate; written unconditionally with no nullptr check.
Ghidra address:
0x72b40

◆ fopen_file_func()

voidpf fopen_file_func ( voidpf opaque,
const char * filename,
int mode )

Maps a ZLIB_FILEFUNC_MODE_* bitmask to an fopen mode string and opens the file.

The mode is selected by priority: read (mode & 3 == 1) becomes "rb", otherwise an existing file (mode & 4) becomes "r+b", otherwise create (mode & 8) becomes "wb"; any other bitmask selects no string. opaque is unused.

Parameters
opaqueThe zlib_filefunc_def opaque cookie; unused.
filenameThe path to open.
modeA ZLIB_FILEFUNC_MODE_* bitmask.
Returns
The opened FILE * as a voidpf, or nullptr when filename is nullptr or the bits select no mode string.
Ghidra address:
0x72a64

◆ fread_file_func()

uLong fread_file_func ( voidpf opaque,
voidpf stream,
void * buf,
uLong size )

Reads size bytes from stream into buf.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to read from.
bufThe destination buffer.
sizeThe number of bytes to read.
Returns
The number of bytes actually read.
Ghidra address:
0x72ac0

◆ fseek_file_func()

long fseek_file_func ( voidpf opaque,
voidpf stream,
uLong offset,
int origin )

Seeks stream, translating success to 0 and failure to -1.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to seek.
offsetThe byte offset.
originA ZLIB_FILEFUNC_SEEK_* value.
Returns
0 on success, -1 on failure or an out-of-range origin.
Ghidra address:
0x72af8

◆ ftell_file_func()

long ftell_file_func ( voidpf opaque,
voidpf stream )

Reports the current position of stream.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to query.
Returns
The current byte offset within the stream.
Ghidra address:
0x72af0

◆ fwrite_file_func()

uLong fwrite_file_func ( voidpf opaque,
voidpf stream,
const void * buf,
uLong size )

Writes size bytes from buf to stream.

Parameters
opaqueThe opaque cookie; unused.
streamThe FILE * to write to.
bufThe source buffer.
sizeThe number of bytes to write.
Returns
The number of bytes actually written.
Ghidra address:
0x72ad8