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

KUnzip's own minizip I/O callback sets. More...

#include "ioapi.h"
Include dependency graph for kunzip_filefunc.h:

Go to the source code of this file.

Functions

voidpf KUnzip_fopen_filehandle_func (voidpf opaque, const char *filename, int mode)
 Opens the file-handle-backed archive for reading.
uLong KUnzip_fread_filehandle_func (voidpf opaque, voidpf stream, void *buf, uLong size)
 Reads size bytes from the file-handle-backed archive into buf.
uLong KUnzip_fwrite_filehandle_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
 Write stub for the file-handle-backed archive; always fails.
long KUnzip_ftell_filehandle_func (voidpf opaque, voidpf stream)
 Reports the file-handle-backed archive's current position.
long KUnzip_fseek_filehandle_func (voidpf opaque, voidpf stream, uLong offset, int origin)
 Seeks the file-handle-backed archive.
int KUnzip_fclose_filehandle_func (voidpf opaque, voidpf stream)
 Closes the file-handle-backed archive.
int KUnzip_ferror_filehandle_func (voidpf opaque, voidpf stream)
 Reports the error state of the file-handle-backed archive.
voidpf KUnzip_fopen_mem_func (voidpf opaque, const char *filename, int mode)
 Opens the memory-backed archive by rewinding the cursor.
uLong KUnzip_fread_mem_func (voidpf opaque, voidpf stream, void *buf, uLong size)
 Reads size bytes from the memory-backed archive into buf.
uLong KUnzip_fwrite_mem_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
 Write stub for the memory-backed archive; always fails.
long KUnzip_ftell_mem_func (voidpf opaque, voidpf stream)
 Reports the memory-backed archive's current position, relative to the range start.
long KUnzip_fseek_mem_func (voidpf opaque, voidpf stream, uLong offset, int origin)
 Seeks the memory-backed archive.
int KUnzip_fclose_mem_func (voidpf opaque, voidpf stream)
 Closes the memory-backed archive.
int KUnzip_ferror_mem_func (voidpf opaque, voidpf stream)
 Reports the error state of the memory-backed archive.

Detailed Description

KUnzip's own minizip I/O callback sets.

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

Ghidra address:
values are offsets relative to that image base.

Two zlib_filefunc_def implementations back KUnzip's archive reading. Both take the KUnzip itself as the opaque cookie and ignore the stream argument: the file-handle set reads through the object's fileHandle (installed by -initWithPath:tail:), and the memory set reads out of its data over dataRange with a dataCurrentPos cursor (installed by -initWithData:range:). They are declared extern "C" so KUnzip can install them into a zlib_filefunc_def table, and implemented in kunzip_filefunc.mm because they message Objective-C objects.

Function Documentation

◆ KUnzip_fclose_filehandle_func()

int KUnzip_fclose_filehandle_func ( voidpf opaque,
voidpf stream )

Closes the file-handle-backed archive.

Parameters
opaqueThe KUnzip that owns the handle.
streamThe minizip stream cookie; ignored.
Returns
Always 0.
Ghidra address:
0x7667c

◆ KUnzip_fclose_mem_func()

int KUnzip_fclose_mem_func ( voidpf opaque,
voidpf stream )

Closes the memory-backed archive.

Parameters
opaqueThe KUnzip; ignored.
streamThe minizip stream cookie; ignored.
Returns
Always 0.
Ghidra address:
0x76b2c

◆ KUnzip_ferror_filehandle_func()

int KUnzip_ferror_filehandle_func ( voidpf opaque,
voidpf stream )

Reports the error state of the file-handle-backed archive.

Parameters
opaqueThe KUnzip; ignored.
streamThe minizip stream cookie; ignored.
Returns
Always 0.
Ghidra address:
0x766c4

◆ KUnzip_ferror_mem_func()

int KUnzip_ferror_mem_func ( voidpf opaque,
voidpf stream )

Reports the error state of the memory-backed archive.

Parameters
opaqueThe KUnzip; ignored.
streamThe minizip stream cookie; ignored.
Returns
Always 0.
Ghidra address:
0x76b34

◆ KUnzip_fopen_filehandle_func()

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

Opens the file-handle-backed archive for reading.

Wraps filename in an NSString, opens it with +[NSFileHandle fileHandleForReadingAtPath:], stores the handle on the KUnzip via -setFileHandle: when non-nil, and returns it. mode is ignored, so this backend can never satisfy a write-mode open.

Parameters
opaqueThe KUnzip that receives the handle.
filenameThe UTF-8 path to open.
modeA ZLIB_FILEFUNC_MODE_* bitmask; ignored.
Returns
The opened NSFileHandle as a voidpf, or nullptr when the file cannot be opened.
Ghidra address:
0x76338

◆ KUnzip_fopen_mem_func()

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

Opens the memory-backed archive by rewinding the cursor.

Sends -setDataCurrentPos: with dataRange.location and returns the KUnzip itself as the stream cookie. filename and mode are ignored.

Parameters
opaqueThe KUnzip that holds the data, range, and cursor.
filenameThe path; ignored.
modeA ZLIB_FILEFUNC_MODE_* bitmask; ignored.
Returns
opaque, or nullptr when opaque is nullptr.
Ghidra address:
0x76828

◆ KUnzip_fread_filehandle_func()

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

Reads size bytes from the file-handle-backed archive into buf.

Reads at the handle's current offsetInFile through -readDataOfLength:, clamped so a read can never cross dataRange.length, which this backend treats as an absolute end offset.

Parameters
opaqueThe KUnzip that owns the handle and the range.
streamThe minizip stream cookie; ignored.
bufThe destination buffer.
sizeThe requested byte count; may be clamped down.
Returns
The number of bytes copied; 0 at or past the end offset, or on a nil read.
Ghidra address:
0x763d8

◆ KUnzip_fread_mem_func()

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

Reads size bytes from the memory-backed archive into buf.

Copies out of data starting at the absolute cursor dataCurrentPos through -getBytes:range:, clamped to dataRange.location + dataRange.length, then advances the cursor.

Parameters
opaqueThe KUnzip that owns the data, cursor, and range.
streamThe minizip stream cookie; ignored.
bufThe destination buffer.
sizeThe requested byte count; may be clamped down.
Returns
The number of bytes copied; 0 at or past the end of the range.
Ghidra address:
0x7688c

◆ KUnzip_fseek_filehandle_func()

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

Seeks the file-handle-backed archive.

The base is 0 for ZLIB_FILEFUNC_SEEK_SET, the handle's offsetInFile for ZLIB_FILEFUNC_SEEK_CUR, and dataRange.length (an absolute end offset) for ZLIB_FILEFUNC_SEEK_END. The target is rejected when it passes dataRange.length.

Parameters
opaqueThe KUnzip that owns the handle and the range.
streamThe minizip stream cookie; ignored.
offsetThe displacement from the origin.
originA ZLIB_FILEFUNC_SEEK_* value.
Returns
0 on success, -1 on a bad origin or an out-of-range target.
Ghidra address:
0x7657c

◆ KUnzip_fseek_mem_func()

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

Seeks the memory-backed archive.

The base is dataRange.location for ZLIB_FILEFUNC_SEEK_SET, dataCurrentPos for ZLIB_FILEFUNC_SEEK_CUR, and dataRange.location + dataRange.length for ZLIB_FILEFUNC_SEEK_END. The target is rejected when it passes the end of the range.

Parameters
opaqueThe KUnzip that owns the cursor and range.
streamThe minizip stream cookie; ignored.
offsetThe displacement from the origin.
originA ZLIB_FILEFUNC_SEEK_* value.
Returns
0 on success, -1 on a bad origin or an out-of-range target.
Ghidra address:
0x76a34

◆ KUnzip_ftell_filehandle_func()

long KUnzip_ftell_filehandle_func ( voidpf opaque,
voidpf stream )

Reports the file-handle-backed archive's current position.

Parameters
opaqueThe KUnzip that owns the handle.
streamThe minizip stream cookie; ignored.
Returns
The handle's offsetInFile.
Ghidra address:
0x76530

◆ KUnzip_ftell_mem_func()

long KUnzip_ftell_mem_func ( voidpf opaque,
voidpf stream )

Reports the memory-backed archive's current position, relative to the range start.

Parameters
opaqueThe KUnzip that owns the cursor and range.
streamThe minizip stream cookie; ignored.
Returns
dataCurrentPos - dataRange.location.
Ghidra address:
0x769d8

◆ KUnzip_fwrite_filehandle_func()

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

Write stub for the file-handle-backed archive; always fails.

Parameters
opaqueThe KUnzip; ignored.
streamThe minizip stream cookie; ignored.
bufThe source buffer; ignored.
sizeThe requested byte count; ignored.
Returns
Always 0.
Ghidra address:
0x76528

◆ KUnzip_fwrite_mem_func()

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

Write stub for the memory-backed archive; always fails.

Parameters
opaqueThe KUnzip; ignored.
streamThe minizip stream cookie; ignored.
bufThe source buffer; ignored.
sizeThe requested byte count; ignored.
Returns
Always 0.
Ghidra address:
0x769d0