flat assembler
Message board for the users of flat assembler.

Index > Windows > dll questions..

Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Im pretty new to assembly and I have a couple of dll questions. I wanna make dlls for a program called Gamemaker but gamemaker only reads doubles. EX dev-c++ code:
Code:
#define export extern "C" __declspec( dllexport )
export double add(double n1, double n2)
{
return n1+n2;
}
    

can you export doubles in FASM?
O, and one more question.
when i do invoke something like getsyscolor
how do I put that in a var?

btw: My first post here!

_________________
----> * <---- My star, won HERE
Post 30 Jun 2004, 23:19
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Welcome windwakr,

"double" in this case is an integer type with 32 bit size. What does it mean is that you get two 32bit values and return one.
In assembly the type of the values is given by the size. A 32 bit value is called a DoubleWord or dword.
One of the characteristics of win32 in 32 bit processors is that you wrtie faster and simpler programs if the values passed to functions and returned from them are dword values.

The procedure in Fasm will look like:
Code:
proc add,n1,n2
    enter
    mov eax,[n1]
    add eax,[n2]
    return
endp    


For the rest of the code for the dll, give a look at
http://board.flatassembler.net/topic.php?t=1760
Post 30 Jun 2004, 23:38
View user's profile Send private message Yahoo Messenger Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Quote:
when i do invoke something like getsyscolor
how do I put that in a var?


The returned value is in eax, so here is an example using a local variable (local variables exists only within procedures, because they are located on stack)
Code:
proc WinProc,hwnd,wmsg,wparam,lparam
  .background_brush dd ?
        enter
       push    ebx esi edi
 mov     eax,[wmsg]
  cmp     eax,WM_CREATE
       je      .wm_create
  .defwndproc:
    invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     .finish
  .wm_create:
        invoke GetSysColor,COLOR_WINDOW
     mov     [.background_brush],eax
  .finish:
   pop     edi esi ebx
 return
endp
    
Post 30 Jun 2004, 23:58
View user's profile Send private message Yahoo Messenger Reply with quote
VitalOne



Joined: 29 Jul 2003
Posts: 54
Location: USA
VitalOne
Hi, I use to use Game Maker (as VitalDragon, made the download DLL) and made other DLLs using FASM for Game Maker. You have to use FPU Instructions for GM (for some reason...) which are documented in the FASM PDF.

Code:
format PE GUI 4.0 DLL
entry DllEntryPoint

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
ans dq 0

section '.code' code readable executable

proc DllEntryPoint, hinstDLL,fdwReason,lpvReserved
        mov     eax,TRUE
        return
endp

proc add_asm,arg1,arg1a,arg2,arg2a
     fld [ans]
     fld qword [arg1]
     fadd qword [arg2]
     return
endp

section '.idata' import data readable writeable

  library kernel,"KERNEL32.DLL"

  import kernel,\
         GetProcAddress,"GetProcAddress"

section '.edata' export data readable

  export 'add.dll',\
         add_asm,"add_asm"

section '.reloc' fixups data discardable
    


That's a simple example that adds two numbers. Since doubles are 64-bit, one double argument is two 32-bit arguments, (hence arg1,arg1a).

Also if the DLL is less than 3.5KB Game Maker displays an error (?)...
Post 01 Jul 2004, 02:40
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
ok thanks for all the information!

btw:You were vitaldragon?
Post 01 Jul 2004, 14:59
View user's profile Send private message Reply with quote
VitalOne



Joined: 29 Jul 2003
Posts: 54
Location: USA
VitalOne
windwakr wrote:
ok thanks for all the information!

btw:You were vitaldragon?

Yeah...I don't use that program much anymore though
Post 02 Jul 2004, 02:52
View user's profile Send private message AIM Address Yahoo Messenger 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.

Powered by rwasa.