I've got another one for DLL calling/loading.

Check the FPU Exception flags - Delphi 4/5 defaults to $1332.

We found we can very easily crash IIS when loading Delphi COM objects
because, Delphi changes the FPU status flags to have an exception thrown on
a FPU error, where as Microsoft seems to mask all errors, hence this causes
JScript to die and hence MTS and IIS (Don't know if the problem also occurs
with VBScript).

The test to perform in JScript is a "parseint()" with a null parameter.

Most DLL's when loaded change the FPU Status word to be what they expect to
catch as exceptions, and if other DLL's don't have the same settings ... bye
bye your dead.

Also the same problem also occurs the other way round, eg if your Delphi
program calls a MS DLL eg a Access DB via ODBC/BDE etc, it will disable FPU
exceptions, so Delphi will then no longer catch them eg Div by 0 etc.

Myles.



> -----Original Message-----
> From: Tony Goodrich [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, 15 December 1999 11:44
> To:   Multiple recipients of list delphi
> Subject:      RE: [DUG]:  exception after running DLL
> 
> My Two Golden Rules for Interfaceing to DLLs etc
> 
> 1)    Check the parameter passing convention.  You are specifyinying
> cdecl, many people use stdcall
> 
> 2)    Check the packing.  Delphi defaults to 4 byte packing and can be
> set to 1 byte packing and C/C++ (microsoft) defaults to 8 byte packing
> and can be set to1,2,4 or 8 bytes.  Be warned this applies to functions
> that are NOT passing data structures (iei just simple parameters).
> 
> 
> regards Tony Goodrich
> 
> > -----Original Message-----
> > From:       [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> > Sent:       Monday, 13 December 1999 22:01
> > To: Multiple recipients of list delphi
> > Subject:    [DUG]:  exception after running DLL
> > 
> > Hi all
> > 
> > I am callin a DLL(not a delphi one) using the following code
> > 
> > Type
> > TGetData = function(Text:LPSTR):integer; cdecl;
> > var
> > LibHandle :Thandle;
> > GetData : TGetData;
> > Retval :Integer;
> > begin
> > LibHandle := LoadLibrary('QBINT32');
> > try
> >    if LibHandle = 0 then begin
> >       Showmessage('Unable to load Dll');
> >       exit;
> >       end;
> >     @GetData := GetProcAddress(libhandle, 'ExportQbwData');
> > 
> > 
> >     if @GetData <>nil then begin
> >     RetVal:= GetData(pChar('D:\qBnz\qbdata\IanFear.QBW'));
> >         ShowMessage('return  '+ inttostr(retVal));
> >         end else
> >         RaiseLastWin32Error;
> > 
> >     finally
> >     Freelibrary(libHandle);
> >    end;
> >    end; 
> > 
> > It runs perfectly but at the end I get the following error message
> > "Application defined exception (code 0xc0000027) at 0xbff852f
> > 8B 45 08 8D 4D E4 51 89 7D E4 89 45"
> > 
> > and the disassembly pane is displayed.
> > it is runing on a stand alone machine and the thread window shows 
> > only one thread the Dll it calls runs another program and does a 
> > data extraction which works fine.
> > 
> > any help greatly appreciated and thanks for your time in reading 
> > this 
> > 
> > Ian Fear
> > 1427 Te Kopia rd
> > RD 1
> > Rotorua
> > New Zealand
> > Phone 64 7 333 1548
> > Fax 64 7 333 2548
> > mob 025 742 772
> > [EMAIL PROTECTED]
> > GMT +1200
> > http://mysite.xtra.co.nz/~IJFear/
> > ----------------------------------------------------------------------
> > -----
> >     New Zealand Delphi Users group - Delphi List -
> > [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > 
> --------------------------------------------------------------------------
> -
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to