Page 1 of 1

[Done] Issue with imported functions

Posted: Wed Jul 13, 2011 9:14 am
by gnozal
Code snippet to demonstrate the issue (Tailbite 1.4.7 / PB 4.60 BETA3 / Win XP x86) :

Code: Select all

Import "zlibwapi.lib" ; zlib from http://www.winimage.com/zLibDll/zlib123dll.zip
   fclose_file_func() As "_fclose_file_func"
	ferror_file_func() As "_ferror_file_func"
	fopen_file_func() As "_fopen_file_func"
	fread_file_func() As "_fread_file_func"
	fseek_file_func() As "_fseek_file_func"
	ftell_file_func() As "_ftell_file_func"
	fwrite_file_func() As "_fwrite_file_func"
EndImport
Structure pzlib_filefunc_def
  zopen_file.l
  zread_file.l
  zwrite_file.l
  ztell_file.l
  zseek_file.l
  zclose_file.l
  zerror_file.l
  opaque.l
EndStructure
ProcedureDLL Dummy()
  zFileFunctions.pzlib_filefunc_def
  zFileFunctions\zopen_file = @fopen_file_func()
  zFileFunctions\zread_file = @fread_file_func()
  zFileFunctions\zwrite_file = @fwrite_file_func()
  zFileFunctions\ztell_file = @ftell_file_func()
  zFileFunctions\zseek_file = @fseek_file_func()
  zFileFunctions\zclose_file = @fclose_file_func()
  zFileFunctions\zerror_file = @ferror_file_func()
  zFileFunctions\opaque = #Null
EndProcedure
Tailbite wrote:FAsm: Dummy.asm
Error
Line no: 22
Error code: -122
Error String: UNDEFINED_SYMBOL
Dummy.asm wrote: ...
zFileFunctions\zopen_file = @fopen_file_func()
MOV eax,_fopen_file_func <----------------
...
I think "EXTRN _fopen_file_func" is missing in Dummy.asm

Workaround :

Code: Select all

Import "zlibwapi.lib" ; zlib from http://www.winimage.com/zLibDll/zlib123dll.zip
   fclose_file_func() As "_fclose_file_func"
	ferror_file_func() As "_ferror_file_func"
	fopen_file_func() As "_fopen_file_func"
	fread_file_func() As "_fread_file_func"
	fseek_file_func() As "_fseek_file_func"
	ftell_file_func() As "_ftell_file_func"
	fwrite_file_func() As "_fwrite_file_func"
EndImport
Structure pzlib_filefunc_def
  zopen_file.l
  zread_file.l
  zwrite_file.l
  ztell_file.l
  zseek_file.l
  zclose_file.l
  zerror_file.l
  opaque.l
EndStructure
ProcedureDLL Dummy()
  ;{ Tailbite workaround !
  If 0 = 1
    fopen_file_func()
    fread_file_func()
    fwrite_file_func()
    ftell_file_func()
    fseek_file_func()
    fclose_file_func()
    ferror_file_func()
  EndIf ;}
  zFileFunctions.pzlib_filefunc_def
  zFileFunctions\zopen_file = @fopen_file_func()
  zFileFunctions\zread_file = @fread_file_func()
  zFileFunctions\zwrite_file = @fwrite_file_func()
  zFileFunctions\ztell_file = @ftell_file_func()
  zFileFunctions\zseek_file = @fseek_file_func()
  zFileFunctions\zclose_file = @fclose_file_func()
  zFileFunctions\zerror_file = @ferror_file_func()
  zFileFunctions\opaque = #Null
EndProcedure

Re: Issue with imported functions

Posted: Wed Jul 13, 2011 9:32 pm
by ABBKlaus
Hi Gnozal,

have you tried compiling it with the PB-IDE ?

I get this error message on compiling it :

Image

BR Klaus

Re: Issue with imported functions

Posted: Wed Jul 13, 2011 10:59 pm
by ABBKlaus
the 'MOV EAX,_Imported_Function' is ignored by TailBite, only a MOV or JMP (like in your workaround) is triggering the ExternalProc().

This version should fix it : http://www.tailbite.com/downloads/TailBiteV1.4.8.zip

Please test it and report back here ;-)

BR Klaus

Re: Issue with imported functions

Posted: Thu Jul 14, 2011 7:25 am
by gnozal
Thank you, it works.