flat assembler
Message board for the users of flat assembler.

Index > Windows > FASM generated DLL in VB

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
anybody have any samples regarding above?
Post 04 Apr 2005, 06:55
View user's profile Send private message Visit poster's website Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Well, I suppose FASM generated .dll is exactly the same as any other .dll (only smaller and faster. Wink )

Regards
Post 04 Apr 2005, 08:50
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
problem to use the FASM generated DLL inside Visual Basic

the VB code inside the VB
Code:
Private Declare Function DllVersion Lib "E:\Ln\ln2.dll" ()

Private Sub Command1_Click()
    Call DllVersion
End Sub
    


the fasm code i use to generate the DLL
Code:
format PE GUI 4.0 DLL

entry DllMain

include "%fasminc%\win32a.inc"

section ".data" data readable writeable
        insH            dd ?            ; handle for instance
        boxMsg          db "Please Try Again.",0
        boxTitle        db "General Protection Fault",0

section ".sdata" readable writeable shareable
        addrMsg         dd boxMsg
        addrTitle       dd boxTitle

section ".code" code readable executable
        proc DllMain, dllH, fdwReason, lpvReserved
                push [dllH]
                pop  [insH]
                mov  eax,TRUE
                return
        endp
        
        proc DllVersion
                invoke  MessageBox,NULL,[addrMsg],[addrTitle]
                return
        endp
        
section ".idata" import data readable
        library user32, "USER32.DLL"
        include "%fasminc%\apia\User32.inc"

section ".edata" export data readable
        export "ln2.dll",\
                DllVersion,     "DllVersion"

section ".reloc" fixups data discardable
    


and i got the error Sad
but if i try the following :
Code:
....
        pop  [insH]
        mov  eax,TRUE
        call DllVersion
        return
....
    

i would be able to see the message box (but still in error also) Sad

thanks in advance for those who willing to share knowledge Smile


sincerely,
sulaiman chang
Post 04 Apr 2005, 12:10
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
i am stupid, just realized where goes wrong after the post Razz
Code:
Private Declare Function DllVersion Lib "E:\Ln\ln2.dll" () As Long

Private Sub Command1_Click()
    Call DllVersion
End Sub
    


Code:
section ".code" code readable executable
        proc DllMain, dllH, fdwReason, lpvReserved
                push [dllH]
                pop  [insH]
                mov  eax,TRUE
                return
        endp
        
        proc DllVersion
                invoke  MessageBox,NULL,[addrMsg],[addrTitle],MB_OK
                return
        endp
    


sincerely,
sulaiman chang
Post 04 Apr 2005, 12:19
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
now, i am thinking to use the VB GUI feature to do the application interface and set those event to call on the DLL which is assembled by FASM Smile wat do ur people think?

i am going to link with the SQLITE3.DLL Razz
Post 04 Apr 2005, 12:20
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
it seems it is pretty easy to link both of them Smile
Code:
        proc SetMessage, addrMsgNew
                push [addrMsgNew]
                pop  [addrMsg]
                return
        endp
    


Code:
Private Declare Function SetMessage Lib "E:\Ln\ln2.dll" (ByVal addrMsgNew As Any) As Long

Private Sub Command2_Click()
    Dim newMessage As String
   
    newMessage = "Please shut down your computer." & vbCrLf & "How about an automatically shutdown?"

    SetMessage (newMessage)
End Sub
    


let see, what we could do next Razz
Post 04 Apr 2005, 12:49
View user's profile Send private message Visit poster's website Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
well, a little bit small app for testing purpose
let see Razz
i could see there is some potential to code like this Smile what do you think?
how about a FASM dll file that ease people to use Windows API Confused
eg. get_windows_minor_version
and they got the minor version Confused

Code:
Private Declare Function DllVersion Lib "E:\Ln\ln2.dll" () As Long
Private Declare Function GetWindowsVersion Lib "E:\Ln\ln2.dll" () As Long
Private Declare Function SetMessage Lib "E:\Ln\ln2.dll" (ByVal addrMsgNew As Any) As Long
Private Declare Function CurrentMessage Lib "E:\Ln\ln2.dll" (ByVal addrMsgNew As Any) As Long
Private Declare Sub SetHandle Lib "E:\Ln\ln2.dll" (ByVal handle As Long)


Private Sub Command1_Click()
    Call DllVersion
End Sub

Private Sub Command2_Click()
    Dim newMessage As String
   
    newMessage = "Set Message." & vbCrLf & "How about an automatically shutdown?"

    SetMessage (newMessage)
End Sub

Private Sub Command3_Click()
    Dim msg As String * 12
    CurrentMessage (msg)
    Text1.Text = msg
End Sub

Private Sub Command4_Click()
    Dim minorVersion As Long
    Dim os As String
    minorVersion = GetWindowsVersion
    
    Select Case minorVersion
        Case 1
            os = "Windows XP"
        Case 2
            os = "Windows Server 2003"
        Case 10
            os = "Windows 98"
        Case 51
            os = "Windows 3.51"
        Case 90
            os = "Windows ME"
        Case Else
            os = "Windows 2000 or Windows NT 4.0 or Windows 95"
    End Select
    Text2.Text = os
End Sub

Private Sub Form_Load()
    SetHandle (Me.hWnd)
End Sub
    



Code:
format PE GUI 4.0 DLL

entry DllMain

include "%fasminc%\win32a.inc"


section ".data" data readable writeable
        insH            dd ?            ; handle for instance
        boxMsg          db "Version = 1.0.",0
        boxTitle        db "My Windows XP",0
        buf                     rb 0xFF
                                db 0
        f1                      db "%s",0
        osVersion       OSVERSIONINFO
        appH            dd ?

section ".sdata" readable writeable shareable
        addrMsg         dd boxMsg
        addrTitle       dd boxTitle

section ".code" code readable executable
        proc DllMain, dllH, fdwReason, lpvReserved
                push [dllH]
                pop  [insH]
                mov  eax,TRUE
                return
        endp
        
        proc SetHandle,handle
                push [handle]
                pop  [appH]
                return
        endp
        
        proc DllVersion
                                push boxMsg
                                pop  [addrMsg]
                invoke  MessageBox,[appH],[addrMsg],[addrTitle],MB_OK
                return
        endp
        
        proc SetMessage, addrMsgNew
                push [addrMsgNew]
                pop  [addrMsg]
                return
        endp
        
        proc CurrentMessage, addrMsgNew
                invoke  lstrlen,[addrMsgNew]
                invoke  wsprintf,[addrMsgNew],f1,[addrMsg]
                return
        endp
        
        proc GetWindowsVersion
                                mov  [osVersion.dwOSVersionInfoSize], sizeof.OSVERSIONINFO
                invoke  GetVersionEx,osVersion
                                mov  eax,[osVersion.dwMinorVersion]
                                return
        endp
        
section ".idata" import data readable
        library \
        kernel32, "KERNEL32.DLL",\
        user32, "USER32.DLL"
        include "%fasminc%\apia\Kernel32.inc"
        include "%fasminc%\apia\User32.inc"

section ".edata" export data readable
        export "LN2.DLL",\
                DllVersion,     "DllVersion",\
                SetMessage, "SetMessage",\
                CurrentMessage, "CurrentMessage",\
                GetWindowsVersion, "GetWindowsVersion",\
                SetHandle, "SetHandle"

section ".reloc" fixups data discardable
    


Image

sincerely,
sulaiman chang
Post 04 Apr 2005, 16:41
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
It's easier for fASM and VB to interact than it is for fASM and C++ that's irony! Very Happy
Post 06 Apr 2005, 00:28
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
does it shows VB is a bit superior than C++ when it comes to "interacting"
Very Happy
Post 06 Apr 2005, 02:14
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.