News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

zlib

Started by jj2007, July 09, 2012, 03:53:51 AM

Previous topic - Next topic

dedndave

i would remove these lines from ZlibTest.inc

include windows.inc
include user32.inc
include kernel32.inc
include shell32.inc
include comctl32.inc

includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib

include msvcrt.inc      ; required for zlibstat _malloc & _free
includelib msvcrt.lib  ; required for zlibstat _malloc & _free


part of the reason.....

in the ASM file
.686
.MMX
.XMM
.model flat,stdcall
option casemap:none
include \masm32\macros\macros.asm

include ZlibTest.inc

include zlibstat.inc
includelib zlibstat128.lib


windows.inc should be first in the list
and, most of us use hard-coded paths because that's how the masm32 package is designed to be used

dedndave

i removed all that stuff from the INC file

and modified the ASM file to start like this

include \masm32\include\masm32rt.inc
.686
include ZlibTest.inc
include zlibstat.inc
includelib zlibstat128.lib

.code


notice that, by using masm32rt.inc, i only have to set 1 path   :biggrin:

the program seems to assemble and run ok

fearless

Cheers Dave :D

Hopefully someone will find it useful and can test out a few of the other functions in zlib



dedndave

maybe i am doing something wrong - lol

these do not appear to be exported by the LIB
fclose_file_func        PROTO :DWORD,:DWORD
ferror_file_func        PROTO :DWORD,:DWORD
fopen_file_func         PROTO :DWORD,:DWORD,:DWORD
fread_file_func         PROTO :DWORD,:DWORD,:DWORD,:DWORD
fseek_file_func         PROTO :DWORD,:DWORD,:DWORD,:DWORD
ftell_file_func         PROTO :DWORD,:DWORD
fwrite_file_func        PROTO :DWORD,:DWORD,:DWORD,:DWORD


i used Vortex's Lib2Def program - it shows....

"fill_fopen64_filefunc"
"fill_fopen_filefunc"
"fill_zlib_filefunc64_32_def_from_filefunc32"


those are probably data symbols, as they do not have @(n) at the end (or maybe macros ?)

maybe the original header file aliases those names to some API or CRT functions

fearless

Searching the entire set of files downloaded from the zlib128.zip from the zlib website, the only reference to those functions are in contrib\minizip\ioapi.c

In the main zlibstat.lib there are references to gzopen, unzOpen, call_zopen64 instead of fopen_file_func. In the zlibextract.lib i created, i used the unz functions: unzGoToFirstFile, unzGetCurrentFileInfo, unzOpenCurrentFile, unzReadCurrentFile, unzCloseCurrentFile & unzGoToNextFile to read a file (unzips it) into a buffer (GlobalAlloc) and write it out using WriteFile.

Not sure how the fopen_file_func and the others are used - possibly they are a wrapper for some of the main zlib functions?

dedndave

ok - found them
they are CALLBACK function prototypes   :biggrin:

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

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

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

long ZCALLBACK ftell_file_func (
   voidpf opaque,
   voidpf stream);

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

int ZCALLBACK fclose_file_func (
   voidpf opaque,
   voidpf stream);

int ZCALLBACK ferror_file_func (
   voidpf opaque,
   voidpf stream);

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