[Done] Issue with imported functions

TailBite specific forum

Moderators: gnozal, ABBKlaus, lexvictory

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

[Done] Issue with imported functions

Post 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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Issue with imported functions

Post by ABBKlaus »

Hi Gnozal,

have you tried compiling it with the PB-IDE ?

I get this error message on compiling it :

Image

BR Klaus
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: Issue with imported functions

Post 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
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Issue with imported functions

Post by gnozal »

Thank you, it works.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply