Results 1 to 5 of 5

Thread: DLL in assembly language for MS Excel 2000

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    DLL in assembly language for MS Excel 2000

    Hi all!
    I'm writing a dynamic link library in assembly language making floating-point computations for VBA (MS Excel 2000). I'm using MASM32 package under Windows 98 SE. I have written and debugged all necessary functions and almost all of them work correctly, with the exception of the main function (it uses all other functions from the DLL). When I call it from the Visual Basic Editor in Excel, it succeeds several times (once, twice, even eleven times) but finally fails. Excel crashes (Err.Number = -2147417848, Err.Description = "Method 'MyMethod' of object 'MyObject' failed") and Windows reports the error in the vbe6.dll (not in my dll):

    Program EXCEL caused an invalid page fault in module VBE6.DLL at 0167:65009f43.
    Registers:
    EAX=00002584 CS=0167 EIP=65009f43 EFLGS=00010202
    EBX=00000000 SS=016f ESP=0062ed8c EBP=0062efd0
    ECX=65225ba0 DS=016f ESI=00000007 FS=2f1f
    EDX=0000d000 ES=016f EDI=00000000 GS=0000
    Bytes at CS:EIP:
    8b 00 8b 40 04 c2 04 00 33 c0 eb f9 b8 a0 5b 22
    Stack dump:
    65009f64 65225ba0 6500ada0 65225ba0 0041767c 00000000 00000000 00001045 00000001 0062edb4 00000000 00000001 0062efe4 0062edc4 00000000 00000001

    (Corresponding excerpt from the vbe6.dll disassembly

    65009F35 fn_65009F35:
    65009F35 8B442404 mov eax,[esp+4]
    65009F39 8B400C mov eax,[eax+0Ch]
    65009F3C 85C0 test eax,eax
    65009F3E 740B jz loc_65009F4B
    65009F40 8B400C mov eax,[eax+0Ch]
    65009F43 8B00 mov eax,[eax] ; <--
    65009F45 8B4004 mov eax,[eax+4]
    65009F48 loc_65009F48:
    65009F48 C20400 ret 4
    )

    or

    Program EXCEL caused an invalid page fault in module VBE6.DLL at 0167:65012c3f.
    Registers:
    EAX=00000009 CS=0167 EIP=65012c3f EFLGS=00010206
    EBX=0062e884 SS=016f ESP=0062f2e8 EBP=0062f338
    ECX=00000000 DS=016f ESI=0062e884 FS=2cf7
    EDX=016e4718 ES=016f EDI=00417350 GS=0000
    Bytes at CS:EIP:
    8b 08 e8 10 aa 06 00 8b 40 14 c2 04 00 8b 44 24
    Stack dump:
    650112c0 0062e884 650112f4 0062e884 00417350 00402c78 00000000 650a0c7b 00000000 650a0c11 016e4718 016e4718 00417350 00000000 00000000 0166403c

    (Corresponding excerpt from the vbe6.dll disassembly
    65012C38 fn_65012C38:
    65012C38 8B442404 mov eax,[esp+4]
    65012C3C 8B400C mov eax,[eax+0Ch]
    65012C3F 8B08 mov ecx,[eax] ; <--
    65012C41 E810AA0600 call fn_6507D656
    65012C46 8B4014 mov eax,[eax+14h]
    65012C49 C20400 ret 4
    65012C4C 8B442404 mov eax,[esp+4]
    65012C50 8B4C2408 mov ecx,[esp+8]
    65012C54 8B809C000000 mov eax,[eax+9Ch]
    65012C5A C1F81F sar eax,1Fh
    65012C5D 8901 mov [ecx],eax
    65012C5F 33C0 xor eax,eax
    65012C61 C20800 ret 8
    )

    or

    Program EXCEL caused an invalid page fault in module VBE6.DLL at 0167:65009f45.
    Registers:
    EAX=0f10e0c1 CS=0167 EIP=65009f45 EFLGS=00010206
    EBX=0062eb0a SS=016f ESP=0062e9d0 EBP=0062ea20
    ECX=65225ba0 DS=016f ESI=ffff8001 FS=0f2f
    EDX=00010008 ES=016f EDI=00000001 GS=0000
    Bytes at CS:EIP:
    8b 40 04 c2 04 00 33 c0 eb f9 b8 a0 5b 22 65 8b
    Stack dump:
    65009f64 65225ba0 65137006 301b5d78 01140674 00000000 0062ea40 300fdda2 00000003 00000000 0062eb0a 00000000 0b480167 0062ea0c 16bf016f 8a1e1547

    (Corresponding excerpt from the vbe6.dll disassembly
    65009F35 fn_65009F35:
    65009F35 8B442404 mov eax,[esp+4]
    65009F39 8B400C mov eax,[eax+0Ch]
    65009F3C 85C0 test eax,eax
    65009F3E 740B jz loc_65009F4B
    65009F40 8B400C mov eax,[eax+0Ch]
    65009F43 8B00 mov eax,[eax]
    65009F45 8B4004 mov eax,[eax+4] ; <--
    65009F48 loc_65009F48:
    65009F48 C20400 ret 4
    )

    I have tried Visual Basic 6.0 Professional 6.0 to get rid of the error in vbe6.dll (VB6 applications doesn't use it), but the situation remains the same: though there is no vbe6.dll loaded when I'm running Visual Basic exe-file, the similar error happens in kernel32.dll:

    Program VB6 caused an invalid page fault in module KERNEL32.DLL at 0167:bff7a4b2.
    Registers:
    EAX=00000000 CS=0167 EIP=bff7a4b2 EFLGS=00010206
    EBX=00000000 SS=016f ESP=007feab0 EBP=007feac0
    ECX=005d0008 DS=016f ESI=005d0000 FS=3777
    EDX=00000010 ES=016f EDI=005d000c GS=0000
    Bytes at CS:EIP:
    8b 03 25 fc ff ff 0f 3b 45 0c 0f 83 81 00 00 00
    Stack dump:
    00000001 0fc00001 00000000 00000000 007fead4 bff88dc4 005d0000 00000010 00000000 007feb24 7ff214f0 005d0000 00000000 0000000c 0fa916c7 7ffce00c

    (Here is the corresponding excerpt from the kernel32.dll disassembly:
    BFF7A4B2 loc_BFF7A4B2:
    BFF7A4B2 8B03 mov eax,[ebx] ; <--
    BFF7A4B4 25FCFFFF0F and eax,0FFFFFFCh
    BFF7A4B9 3B450C cmp eax,[ebp+0Ch]
    BFF7A4BC 0F8381000000 jnb loc_BFF7A543
    BFF7A4C2 8B5B04 mov ebx,[ebx+4]
    BFF7A4C5 3BFB cmp edi,ebx
    BFF7A4C7 75E9 jnz loc_BFF7A4B2
    )

    Dll function is called from the method in class module (I changed their names to MyMethod and MyObject above), it takes a lot of parameters and works (if succeded) for quite a long time (some seconds).

    I've already tried reinstalling Microsoft Office 2000 and Windows 98 SE.
    Search with Google hasn't been very fruitful yet.

    I'd like to complete this work which has already taken some months and combine the power of floating-point instructions with the comfortable interface of Microsoft Office and abilities of Visual Basic for Applications. So I'm not going to change none of the two programming languages I'm using.

    Can anyone give me some advices or related links?
    Thanks in advance.

  2. #2
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    Re: DLL in assembly language for MS Excel 2000

    AleXnderRT,
    What are you returning to Excel VBA from your function in the dll?
    Anything?
    Its hard to say what the problem is without seeing the masm source.

  3. #3
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    Re: DLL in assembly language for MS Excel 2000

    AleXnderRT,
    Also, ive had a simliar problem when creating a dll in masm with vb. I had to push all registers and pop them before returning to vb. Or else vb would crash after random times of the function being called.

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    Re: DLL in assembly language for MS Excel 2000

    Thanks for the reply
    Quote Originally Posted by packetVB
    AleXnderRT,
    Also, ive had a simliar problem when creating a dll in masm with vb. I had to push all registers and pop them before returning to vb. Or else vb would crash after random times of the function being called.
    What instruction did you use? Did you use pusha and popa or something else? I'm saving registers used by the assembly procedure only.
    AleXnderRT,
    What are you returning to Excel VBA from your function in the dll?
    Anything?
    Its hard to say what the problem is without seeing the masm source.
    My function returns a DWORD parameter in EAX.
    I did some debugging. I'd put calls to MessageBox at the beginning and at the end of the main DLL function and between calls to another DLL procedures. Every message box was displayed but after the last one (i. e., on exit from the DLL function) Excel crashed.
    I've been told the possible reason is that memory freed too soon. Don't you know what does it mean? If do, explain me, please, and I'll do some search.
    As for source, it needs adding some comments and editing. It will be ready in a day or two. Is it OK to send it in a private message?

  5. #5
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271

    Re: DLL in assembly language for MS Excel 2000

    AleXnderRT,
    I believe at the beginning of my asm function i push all registers with pusha. At the end I would popa, Then put my return value in eax and ret.

    Dont really get the memory freed to soon. What memory? Are you allocating memory in your dll?

    Yea private message would be fine. Ill take a look at the source.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width