flat assembler
Message board for the users of flat assembler.

Index > Windows > Problem with DLLs

Author
Thread Post new topic Reply to topic
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 01 Jun 2005, 06:59
Hi!
I`ve got a problem. I wrote a little DLL, and if I want to import it to program, it causes error.
Code:
format PE GUI 4.0 DLL
entry DllEntryPoint

include 'C:\Program Files\Flat Asembler\INCLUDE\win32a.inc'

section '.code' code readable executable

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

proc CWindow, hInst, hIco, hCur, wProc, bGrnd, Class, wTit, Style, wX, wY, wWidth, wHeight

 Msg  MSG
 Wind WNDCLASS
 Buffer dd ?

         cmp [hIco], NULL
         je  lCur
         mov EAX, [hIco]
         mov [Wind.hIcon], EAX
 lCur:
         cmp [hCur], NULL
         je  lReq
         mov EAX, [hCur]
         mov [Wind.hCursor], EAX
 lReq:
         mov [Wind.style], 0
         mov EAX, [wProc]
         mov [Wind.lpfnWndProc], EAX
         mov [Wind.cbClsExtra], 0
         mov [Wind.cbWndExtra], 0
         mov EAX, [hInst]
         mov [Wind.hInstance], EAX

         mov    EAX, [bGrnd]
         invoke CreateSolidBrush, EAX
         mov    [Wind.hbrBackground], EAX

         mov [Wind.lpszMenuName], 0
         mov EAX, [Class]
         mov [Wind.lpszClassName], EAX

         invoke RegisterClass, [Wind]

         pushd 0
         pushd [hInst]
         pushd 0
         pushd 0
         pushd [wHeight]
         pushd [wWidth]
         pushd [wY]
         pushd [wX]

         mov EAX, WS_VISIBLE

         mov EBX, [Style]
         and EBX, 1b         ;bit 0 - Title bar
         cmp EBX, 1b
         jne lMAX
         mov [Buffer], EAX
         mov EAX, [Buffer + WS_CAPTION]
 lMAX:
         mov EBX, [Style]
         and EBX, 10b        ;bit 1 - Maximize
         cmp EBX, 10b
         jne lTit
         mov [Buffer], EAX
         mov EAX, [Buffer + WS_MAXIMIZE]
 lTit:
         pushd EAX
         pushd [wTit]
         pushd [Class]

         xor EAX, EAX
         mov EBX, [Style]
         and EAX, 100b       ;bit 2 - Tool Window
         cmp EBX, 100b
         jne lSOT
         mov [Buffer], EAX
         mov EAX, [Buffer + WS_EX_TOOLWINDOW]
 lSOT:
         mov EBX, [Style]
         and EBX, 1000b      ;bit 3 - Stay On Top
         cmp EBX, 1000b
         jne lcFin
         mov [Buffer], EAX
         mov EAX, [Buffer + WS_EX_TOPMOST]
 lcFin:
         pushd EAX
         call CreateWindowEx
 mLoop:
         invoke  GetMessage, Msg, NULL, 0, 0
         or      EAX, EAX
         jz      mLoopE
         invoke  TranslateMessage, Msg
         invoke  DispatchMessage,  Msg
         jmp     mLoop
 mLoopE:
         invoke  ExitProcess,[Msg.wParam]

endp

section '.idata' import data readable writeable

  library Kernel, 'KERNEL32.DLL',\
          User32, 'USER32.DLL',\
          GDI, 'GDI32.DLL'

  import GDI,\
         CreateSolidBrush, 'CreateSolidBrush'

  import Kernel,\
         ExitProcess, 'ExitProcess'

  import User32,\
         RegisterClass, 'RegisterClassA',\
         CreateWindowEx, 'CreateWindowExA',\
         GetMessage, 'GetMessageA',\
         TranslateMessage, 'TranslateMessage',\
         DispatchMessage, 'DispatchMessageA'

section '.edata' export data readable

  export 'BPDL.DLL',\
         CWindow, 'CWindow'

section '.reloc' fixups data discardable
    

What`s wrong with it?
Post 01 Jun 2005, 06:59
View user's profile Send private message Reply with quote
Torrey



Joined: 12 Oct 2003
Posts: 78
Torrey 01 Jun 2005, 07:09
Can you zip together all files of this? It'll make for easier debugging to narrow down the problems.
Post 01 Jun 2005, 07:09
View user's profile Send private message Visit poster's website Reply with quote
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 01 Jun 2005, 07:28
ok... here you have a full source of DLL and program, which uses it.


Description:
Download
Filename: BPDL.zip
Filesize: 1.73 KB
Downloaded: 259 Time(s)

Post 01 Jun 2005, 07:28
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 01 Jun 2005, 08:56
looking at the code right off hand, you need an enter after your data statements, and a return just before the 'endp'

Code:
 proc CWindow, hInst, hIco, hCur, wProc, bGrnd, Class, wTit, Style, wX, wY, wWidth, wHeight 
     Msg  MSG 
     Wind WNDCLASS 
     Buffer dd ?
     enter

     .....Your Code

     return
endp    
Post 01 Jun 2005, 08:56
View user's profile Send private message Reply with quote
Barf



Joined: 17 Sep 2004
Posts: 34
Location: Poland
Barf 01 Jun 2005, 13:55
that`s still not enough
Post 01 Jun 2005, 13:55
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.