flat assembler
Message board for the users of flat assembler.

Index > Windows > Simple DLL template?

Author
Thread Post new topic Reply to topic
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 19 Dec 2007, 23:55
I have never needed to make a library before, but could somebody please direct me to some code or tutorial of how to make a simple DLL template? I have seen several before, but I never use proc or struc or any of that. I just need a simple dll which will allow me to call the functions from the main program written in C or asm. There will be over a dozen functions contained in the DLL, quite a bit of data, and I was wondering how you would go about importing/exporting the functions to be called in the main program. Could somebody give me a simple template or explanation please?
Post 19 Dec 2007, 23:55
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 20 Dec 2007, 01:19
Erm, you want a DLL that calls procedures from an EXE?
Post 20 Dec 2007, 01:19
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 20 Dec 2007, 01:22
no, I just want a simple dll - I have a lot of asm code that I do not want in the program, so I want to know how to create a dll in assembly, call that dll from a program in assembly (just how to import it) and that is it. Sry for unclear-ness
Post 20 Dec 2007, 01:22
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 20 Dec 2007, 01:41
Have you checked the examples on the package? (EXAMPLES\DLL)
Post 20 Dec 2007, 01:41
View user's profile Send private message Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 20 Dec 2007, 01:46
Yes, they are for gui things, I'll look over -it- again but I got a little lost when they started calling proc. Do you need to have your dll functions declared as proc for them to be exported? or can you just export a label? All I have is raw assembly, no structures, proc, or anything like that. Just a simple, few-line template of how to make the library and anything special that is needed.

PS: do I need to declare .reloc like the example does? Just wonderin.
Is this it?

Code:
format PE DLL ;Don't know if console or gui
entry MyLabel

include '%fasminc%\win32ax.inc'

section '.code' code readable executable
        MyLabel:
                ;?? why does a dll need an entry??
                ;Couldn't I just place all my functions
                ;In here and declare no entry??
                ;Or is it just for show?
        OneOfMyFunctions:
                ;LALALALA

section '.idata' import data readable writeable

        ;Nothing to import!!! all my code i have
        ;But I think windows always needs an import..

section '.edata' export data readable

        export 'MYLIB.DLL',\
               ;All my labels here that represent functions
               MyFunction,'OneOfMyFunctions'

section '.reloc' fixups data discardable
        ;Do I really need to include this section?   
    
Post 20 Dec 2007, 01:46
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 20 Dec 2007, 05:00
Proc is just a fancy lable and local variable set. You don't have to use proc, but it does make it easier. As for the reloc, i heard you do, but i never tested to find out what happens if you don't have it.
Post 20 Dec 2007, 05:00
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20363
Location: In your JS exploiting you and your system
revolution 20 Dec 2007, 05:13
kohlrak wrote:
As for the reloc, i heard you do, but i never tested to find out what happens if you don't have it.
Relocations are important in DLL's. They are used when there is a clash between two or more DLL's/EXE's that load at the same address.

In many cases the DLL will still load and work without the relocations but it is not possible to guarantee it will work in all cases.
Post 20 Dec 2007, 05:13
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 20 Dec 2007, 22:16
Yes, I have known that the reloc in DLL's are needed, but I didn't think that in Windows a program with one dll would need it. I will include it anyway, justfor good practice

NEW QUESTION: Does the entry point in a DLL get executed whenever a function in the dll is called? How does that work? Would this work?

Code:
format PE GUI 4.0 DLL 
entry Init 

;Later 
Init: 
       push ebp 
       mov ebp,esp 
       pusha 
       ret 

;All my functions already have above code done for them?  
    
[/code]
Post 20 Dec 2007, 22:16
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.