flat assembler
Message board for the users of flat assembler.

Index > Windows > DLL

Author
Thread Post new topic Reply to topic
idice



Joined: 27 Jun 2004
Posts: 2
idice
Confused hey can i compile Asm code to DLL??? and if so how???
Post 27 Jun 2004, 21:47
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Of course you can.
Check examples section of FASMW package. There is a good example of DLL.

Regards
Post 27 Jun 2004, 21:50
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Another example: A plug-in template for add an "action" to a running program, creating a menu item.
Code:
; Plug-Ins Template
format PE GUI 4.0 DLL
entry DLLEntryPoint
include '%fasminc%\win32a.inc'

; --- EQUATES ---
FM_PLUG = WM_USER + 10

; For plugins on menu make:
IDM_IMPORT = 1420

FMI_MAKE = 3
FMI_MAKE_RUN = 3
section '.data' data readable writeable

about       db 'Template - Fasmer Plug-Ins',0
temp_msg   db 'This plug-ins actually does nothing.',0
_menu_voice db 'Plugins template',09h,'Ctrl+P',0
;. end section '.data'

section '.code' code readable executable

proc Actions,hwnd,wmsg,wparam,lparam
        .mi MENUITEMINFO
    enter
       mov eax,[wmsg]
      cmp eax,WM_COMMAND
  je .wmcommand
       cmp eax,FM_PLUG
     je .fmplug
.wmcommand:
       mov     eax,[wparam]
        cmp     [lparam],0
  jne     .done
.menu_command:
 and     eax,0FFFFh
  cmp     eax,IDM_IMPORT
      je      .idmimport
  jmp .done
.idmimport:
        invoke MessageBox,[hwnd],temp_msg,about,MB_OK
       jmp .done
.fmplug:
   mov [.mi.cbSize],sizeof.MENUITEMINFO
        mov [.mi.wID],IDM_IMPORT
    mov [.mi.fMask],MIIM_TYPE
   mov [.mi.fType],MFT_STRING
  mov [.mi.dwTypeData],_menu_voice
    invoke GetMenu,[hwnd]
       invoke GetSubMenu,eax,FMI_MAKE
      lea edx,[.mi]
       invoke InsertMenuItem,eax,FMI_MAKE_RUN,TRUE,edx
     jmp .done
.done:
     mov     eax,TRUE
    return
endp

proc DLLEntryPoint, hinstDLL,fdwReason,lpvReserved
    enter
       mov eax,[fdwReason]
 cmp     eax,DLL_PROCESS_DETACH
      je      .detach
     cmp     eax,DLL_PROCESS_ATTACH
      jne     .done
  .attach:
  .detach:
  .done:
   mov     eax,TRUE
    return
  .failed:
    mov     eax,FALSE
   return
endp

;. end section '.code'

section '.edata' export data readable

; Remember: all functions here must be sorted
export 'PLUGINS.DLL',\ 
       Actions,'Actions'

;.

section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',user32,'USER32.DLL'

import kernel32,\
      CloseHandle,'CloseHandle',\
      CreateFile,'CreateFileA',\
       ExitProcess,'ExitProcess',\
      GetCommandLine,'GetCommandLineA',\
       GetFileSize,'GetFileSize',\
      GetProcessHeap,'GetProcessHeap',\
        GetStdHandle,'GetStdHandle',\
    HeapAlloc,'HeapAlloc',\
  HeapFree,'HeapFree',\
    LoadLibraryEx,'LoadLibraryExA',\
 ReadFile,'ReadFile',\
    WriteFile,'WriteFile'

import user32,\
     GetMenu,'GetMenu',\
      GetSubMenu,'GetSubMenu',\
        InsertMenuItem,'InsertMenuItemA',\
       MessageBox,'MessageBoxA'
;. end section '.idata'

section '.reloc' fixups data readable discardable    


[edit]
Fixed custom macros to official macros
[/edit]


Last edited by pelaillo on 28 Jun 2004, 12:40; edited 1 time in total
Post 28 Jun 2004, 04:47
View user's profile Send private message Yahoo Messenger Reply with quote
idice



Joined: 27 Jun 2004
Posts: 2
idice
hey i keep getting errors at the

begin

and the

api
Post 28 Jun 2004, 07:09
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Sorry, I forgot to change it.
Please look at the above post.
Post 28 Jun 2004, 12:32
View user's profile Send private message 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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.