News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

raiseevent of an object, in vb.net, from asm dll?

Started by Fraile, September 29, 2015, 02:45:56 AM

Previous topic - Next topic

Fraile


hutch--

I know that you can call functions from an external DLL from old VB but I doubt you can do it the other way.

jj2007

Given that "event" is more or less a synonym for "message", maybe sending a message to the VB window could trigger an event. But definitely, we would need to see a more concrete example.

Fraile

example in vb6. I want, one example in vb.net.

vb source code

create a class named class1 with this code
Event m()
Event M2(ByVal j As Long, ByVal r As Long)
Event m3()
Event m4()
Event m5(ByVal j As Long, ByVal k As Long, ByVal l As Long, ByVal m As Long, ByVal n As Long, ByVal o As Long)
Event m6(ByVal j As Long)



create a form with 2 buttons with this code

Private WithEvents miobj As Class1
Private Declare Function SomeFunc Lib "thepath\EventRaiser.dll" (ByRef X As Object) As Long
Private Declare Function SomeOther Lib "thepath\EventRaiser.dll" (ByVal X As Object) As Long

Private Sub cmdCommand1_Click()
    Call SomeFunc(miobj)
End Sub

Private Sub cmdCommand2_Click()
    Call SomeOther(miobj)
End Sub

Private Sub Form_Load()
    Set miobj = New Class1
End Sub

Private Sub miobj_m()
    MsgBox "Event N? 1 Raised"
End Sub

Private Sub miobj_m5(ByVal j As Long, ByVal k As Long, ByVal l As Long, ByVal m As Long, ByVal n As Long, ByVal o As Long)
    MsgBox "Event N? 5 Raised, parameters: " & j & "-" & k & "-" & l & "-" & m & "-" & n & "-" & o & "-"
End Sub

Private Sub miobj_m6(ByVal j As Long)
    MsgBox "Event 6 Raised, parameter:" & j
End Sub


and the asm code of the dll is this:


.data
hInstance dd 0
hDllVbVm dd 0
pRaiseEvent dd 0

.code
DllEntry proc hInst:HINSTANCE, reason:DWORD, reserver1:DWORD
LOCAL hList:DWORD

   .if reason == DLL_PROCESS_ATTACH
   push hInst
   pop hInstance
   invoke LoadLibrary,SADD("msvbvm60")
   mov hDllVbVm,eax
   invoke GetProcAddress,hDllVbVm,SADD("__vbaRaiseEvent")
   mov pRaiseEvent,eax
   .elseif reason == DLL_PROCESS_DETACH
   .endif
   mov eax,TRUE
   ret

DllEntry endp

Zen

VB NET ???
WHY ???
:bgrin:

...MABDELOUHAB had a similar question awhile back,...and, it drove us crazy.
COM Events
It won't do you any good,...but, it does demonstrate how little we know about VB and NET,...

GoneFishing

Quote from: AsmAlmeria12 on September 29, 2015, 03:34:30 AM
example in vb6. I want, one example in vb.net.
...

https://msdn.microsoft.com/en-us/library/ms973905.aspx

Zen

VERTOGRAD,
You're still alive ???  :bgrin:
VERTOGRAD is our NET specialist,...

GoneFishing

Quote from: Zen on September 29, 2015, 06:00:01 AM
VERTOGRAD,
You're still alive ???  :bgrin:
VERTOGRAD is our NET specialist,...
TEMPORArily reincarnated ... (EDITED specially for ZEN)
I'm glad that you're glad to see me here again.
You're too kind as usual . It'll take me a couple of months to write an app like this  :biggrin:

Zen

...Locked in a dark room,...living on Snickers bars and Black Sabbath,...feverishly coding assembly code in your underwear,...
What could be better ???  :bgrin:

GoneFishing

Quote from: Zen on September 29, 2015, 06:08:46 AM
...Locked in a dark room,...living on Snickers bars and Black Sabbath,...feverishly coding assembly code in your underwear,...
What could be better ???  :bgrin:
Sounds good!


mabdelouahab

Do you want to create Class1 by masm then used by Vb.Net or do you want to do the opposite? ...


GoneFishing

 AsmAlmeria12,
Could you tell us which version of CLR ( version of .NET Framework) are you going to use  for this project?
Porting VB code to .NET was rather simple and straightforward . The difficult part is rewriting DLL code .


Fraile

#14
My code, is  the next:

In Vb.Net 2010 Framework 3.5

Public Class Form1

    Private Declare Sub Test Lib "D:\Trabajo\Example.dll" (ByRef SubDelegateo As [Delegate]) ' Is DLL ASM.

Delegate Sub ReceptorMsG(ByVal Param1 Integer, ByVal Param2 As String)



Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click

        Dim RMsG As ReceptorMsG = AddressOf AnswerASM

        Test(RMsG)


End Sub

Private Sub AnswerASM(ByVal Param1 As Integer, ByVal Param2 As String)

' this method,  received's the answer asm


        MsgBox(Param1)
        MsgBox(Param2)




End Sub


End Class


CODE IN ASM (DLL Dynamic):

.Data

MyText  Db 'Hello', 0


.
.
.
.



Test Proc SubDelegate: Ptr


                   Push Esi
                   Push Eax
                   Push Ebx

                   Mov Esi, DWord Ptr SubDelegate
                   Mov Eax,[Esi]


                   Push Offset MyText
                   Push 10

                   Call Eax


                   Pop Ebx
                   Pop Eax
                   Pop Esi

                   Ret


Test endp

.
.
.
.

Sorry my english is very bad. :(