flat assembler
Message board for the users of flat assembler.

Index > Windows > dlls with fasm

Author
Thread Post new topic Reply to topic
panos90



Joined: 05 Apr 2012
Posts: 3
Location: Greece
panos90
Hello, i have created a dll that contains one function named "testing", using visual studio 2012.

Function "testing" does only one thing, just returns number 2

I am trying to use this dll with fasm, by doing this

Code:
library DllTest,'D:\ASM\DllTest.dll'
import DllTest,testing,'testing'
    


or even this

Code:
library DllTest,'D:\ASM\DllTest.dll'
import DllTest,testing,1
    


Fasm compiles fine
but every time i use the name "testing" inside my code, i get an error when the program executes, even if i dont call the function. For example, the following codes will produce an error

Code:
.data
msg db 'Number is:%d',10,0

.code
start:
        mov eax,5
        push eax
        push msg
        call [printf]

        call [getch]
        push 0
        call [ExitProcess]
        call [testing]

.end start
    



Code:
.data
msg db 'Number is:%d',10,0

.code
start:

        call [testing]
        push eax
        push msg
        call [printf]

        call [getch]
        push 0
        call [ExitProcess]

.end start
    


Code:
.data
msg db 'Number is:%d',10,0

.code
start:

        mov eax,testing
        push eax
        push msg
        call [printf]

        call [getch]
        push 0
        call [ExitProcess]

.end start
    


The error is "The application was unable to start correctly (0x000007b)"

Can anyone help me ? I just want to call function "testing" from fasm
Post 18 Dec 2012, 16:08
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Try copying the DLL to the same folder your executable is at, modify your fasm source to refer the dll just by its filename rather than the full path. If there are still problems, please upload your DLL (the binary, the source is only optional).
Post 18 Dec 2012, 16:13
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 193
nmake
printf uses c calling convention, you are not correcting the stack. You should use cinvoke for cdecl convention, even though it should still work, it is not good practice Very Happy

You must also verify that the dll uses cdecl or stdcall (or fastcall for that matter)

You can also correct the stack manually, after printf, put add esp,8
Post 18 Dec 2012, 16:23
View user's profile Send private message Reply with quote
panos90



Joined: 05 Apr 2012
Posts: 3
Location: Greece
panos90
Thanks for the fast replies.
@nmake
Oops sorry , i missed that, but it does not fix the problem.

@LocoDelAssembly
I just tried that, still the problem remains

Here is the dll


Description:
Download
Filename: DLLTest.rar
Filesize: 52.07 KB
Downloaded: 118 Time(s)

Post 18 Dec 2012, 16:34
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 193
nmake
Ok
Post 18 Dec 2012, 16:38
View user's profile Send private message Reply with quote
nmake



Joined: 13 Sep 2012
Posts: 193
nmake
Your dll does not export any function.

If you make a .def(inition) file and store this inside of it

Code:
LIBRARY MyLibrary
EXPORTS FunctionName @1 <- Ordinal here
    
Post 18 Dec 2012, 16:41
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
nmake is correct, no function is exported. Have you done this? (Or whatever is necessary, I've never made a DLL in VS actually)
Post 18 Dec 2012, 16:47
View user's profile Send private message Reply with quote
panos90



Joined: 05 Apr 2012
Posts: 3
Location: Greece
panos90
I have followed a tutorial to make my dll.
Just tried what msdn says, and it worked fine. Thank you Smile
Post 18 Dec 2012, 17:09
View user's profile Send private message Reply with quote
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
Never forget the examples section on flatassembler.
There is a working example of creating a DLL.
http://flatassembler.net/examples.php
Post 18 Dec 2012, 20:12
View user's profile Send private message Send e-mail Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
Post 20 Dec 2012, 01:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.