Amiga-C (70/157)

From:Sensei
Date:15 Sep 2001 at 15:40:11
Subject:[amiga-c] Re: MyLibrary and SetFunction

Czesc Twelvebullets!

Dnia 14-Sep-01, Twelvebullets napisał:

> Using SetFunction, I patch DosOpen to call NewDosOpen from MyLibrary.
> This works fine.
>
> But, I can`t seem to call the original DosOpen..
>
> Please help..
>
> There are probably lots of mistakes in my code, wouldn`t mind some some
> guidance as to whats wrong..

Your close library function should looks like:

BPTR __saveds __asm LibClose( register __a6 struct LibBase *LibBase )
{
LibBase->lb_Library.lib_OpenCnt--;
if( LibBase->lb_Library.lib_OpenCnt == 0 )
if( LibBase->lb_Library.lib_Flags & LIBF_DELEXP )
return( LibExpunge( LibBase ) );
return( NULL );
}

and library expunge:

BPTR __saveds __asm LibExpunge( register __a6 struct LibBase *LibBase )
{
LibBase->lb_Library.lib_Flags |= LIBF_DELEXP;
if( LibBase->lib_Library.lib_OpenCnt == 0 )
// the rest of expunge function here.
return( NULL );
}

The first function of your library should be:

int main( void )
{
return( -1 );
}

It'll make sure that executing your library will not crash the computer.

ALWAYS check if some resource was successfully obtained, I saw that you're not
doing this for OpenLibrary(), AllocMem() etc.

Your new Open() function is wrong... It must wait for message to by replied or
copy file name string to message body/data, because it might disappear before
it's copied by message port scanning routine.

What is good reason of having the same function as patched and normal library
function at the same time? IMHO it's not recommended because library base
will be context depended (one time library base and another one patched
library base).

Regards!



Can your ImageFX paint like bitmap painters?
Download: gfx/ifx/REDFiX.lha, ftp.novadesign.com

Przemyslaw 'SENSEI' Gruchala

code/gfx2d/gfx3d/webmaster

Amiga 1200
Apollo 1240/33 MHz, 18 MB RAM, BTC 33.6 bps
HDD 3.2 GB, HDD 520 MB, CD x12



Czy firma powinna poslugiwac sie darmowym kontem pocztowym?
Oferujemy Konto Biznesowe bez doklejek i przesylek reklamowych
Rejestracja wlasnego adresu internetowego (domeny) i 100 MB pojemnosci
Koszt uslugi to tylko 100 PLN/rok Szczegoly http://www.konto.getin.pl

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Secure your servers with 128-bit SSL encryption! Grab your copy of VeriSign's FREE Guide, "Securing Your Web
site for Business" and learn all about serious security. Get it Now!
http://us.click.yahoo.com/r0k.gC/oT7CAA/yigFAA/dpFolB/TM
---------------------------------------------------------------------~->

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/