Announcement

Collapse
No announcement yet.

DLL error - division by zero??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DLL error - division by zero??

    I am having a problem running the following DLL code. Everything seems to work. The value 123 gets from the .efs program to the DLL and is displayed. The DLL returns the value 100 to the .efs program which uses the debugPrint function to display the value. After this I get the "division by zero" error message shown below. I have reduced the code to the very minimum and have included it below. If anyone can help me any suggestions or locations of more info I would be very grateful.

    Borland Builder DLL code:

    Include File
    ---------------------------------------------------------------------------
    #ifndef eSigDataH
    #define eSigDataH

    extern "C" int __declspec(dllexport) __cdecl OpenVar(int iOpen);
    #endif
    ---------------------------------------------------------------------------

    Source File
    ---------------------------------------------------------------------------
    #pragma hdrstop

    #include "eSigData.h"
    #include "Dialogs.hpp"

    #pragma package(smart_init)

    int OpenVar(int iOpen)
    {
    ShowMessage("This is from within the DLL\n" + String(iOpen));
    return (100);
    }

    ---------------------------------------------------------------------------

    DLLTest.efs File
    ---------------------------------------------------------------------------
    var dllOut = new DLL("D:/Projects/eSigDDE.dll");
    dllOut.addFunction ("OpenData", DLL.INT, DLL.CDECL, "_OpenVar", DLL.INT);

    var test = 123;


    function preMain()
    {
    var v = dllOut.call ("OpenData", test);
    debugPrint("v = " + v + "\n");
    }

    function main()
    {
    }

    function postMain()
    {
    }
    ---------------------------------------------------------------------------

    Error message
    ---------------------------------------------------------------------------
    esigdde:winsig.exe - Application Error

    The exception Floating-point division by zero.
    (0xc000008e) occurred in the application at location 0x00495561

    Click on OK to terminate the program
    Click on CANCEL to debug the program
    ---------------------------------------------------------------------------
    Jim

  • #2
    Updated Information

    I have reduced this to the following code by commenting out the dll.addFunction and the dll.call. It still crashes eSignal.


    var dllOut = new DLL("D:\\Projects\\eSigDDE.dll");
    // dllOut.addFunction ("OpenData", DLL.INT, DLL.STDCALL, "_OpenVar", DLL.INT);

    var test = 0;
    var v = 0;

    function preMain()
    {
    debugPrint("preMain\n");
    }

    function main()
    {
    test = test + 1;
    // v = dllOut.call ("OpenData", test);
    v = test;
    debugPrint("v = " + v + "\n");
    }

    function postMain()
    {
    debugPrint("postMain\n");
    }
    Jim

    Comment


    • #3
      Since the function seems to work, the DLL load is succeeding, and there seems to be nothing wrong with the function. Since the problem also occurs when you don't call any functions, it may be the DLL unload code. You might try a MessageBox in your DllMain routine to see if the failure is occurring as the DLL is being unloaded when your efs is done.

      I have been able to debug DLLs I have written using the debugger in MS VC++, but it should also work with Borland's debugger. Just set breakpoints and tell the debugger to run eSignal. You should be able to find the offending line of code by executing one line at a time from the breakpoint.

      Also remember that a lot happens when a DLL is unloaded, much like a program exit, e.g. global objects are destroyed, I/O is closed, etc.

      Comment


      • #4
        More info

        I have tried everything I can think of to determine where the problem is. The call stack shows the problem to be within the winsig.exe after the DLL is exited. Does anyone have a working sample DLL with source that I might try??? Or additional ideas???

        Thanks
        Jim

        Comment


        • #5
          You might try a few things.

          Try changing DLL.STDCALL to DLL.CDECL.

          When you do this, it might not be able to find the _OpenVar function anymore. So you might try OpenVar.

          And, if that doen't work, try this (with both STDCALL and CDECL).

          double __declspec(dllexport) __cdecl Testing123(int i1) {
          }

          Sometimes I have to do this though (if a CPP file)

          extern "C" {
          double __declspec(dllexport) __cdecl Testing123(int i1) {
          }
          }

          If I could find my sample source to EFS & DLL's Icould give you a more dinitive answer - but I can't - sorry.

          m.
          Matt Gundersen

          Comment

          Working...
          X