Author Topic: raiseevent of an object, in vb.net, from asm dll?  (Read 7808 times)

AsmAlmeria12

  • Member
  • **
  • Posts: 65
raiseevent of an object, in vb.net, from asm dll?
« on: September 29, 2015, 02:45:56 AM »
how call the event in vb.net, from asm, dll.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #1 on: September 29, 2015, 02:57:09 AM »
I know that you can call functions from an external DLL from old VB but I doubt you can do it the other way.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 10113
  • Assembler is fun ;-)
    • MasmBasic
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #2 on: September 29, 2015, 03:13:08 AM »
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.

AsmAlmeria12

  • Member
  • **
  • Posts: 65
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #3 on: September 29, 2015, 03:34:30 AM »
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

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #4 on: September 29, 2015, 05:52:43 AM »
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,...
Zen

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing

Zen

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #6 on: September 29, 2015, 06:00:01 AM »
VERTOGRAD,
You're still alive ???  :bgrin:
VERTOGRAD is our NET specialist,...
Zen

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #7 on: September 29, 2015, 06:06:31 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

  • Member
  • ****
  • Posts: 962
  • slightly red-shifted
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #8 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:
Zen

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #9 on: September 29, 2015, 06:17:23 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

  • Member
  • ***
  • Posts: 441
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #10 on: September 29, 2015, 06:27:52 AM »
Do you want to create Class1 by masm then used by Vb.Net or do you want to do the opposite? ...

mabdelouahab

  • Member
  • ***
  • Posts: 441

GoneFishing

  • Member
  • *****
  • Posts: 1071
  • Gone fishing
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #12 on: September 29, 2015, 07:42:22 PM »
 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 .

AsmAlmeria12

  • Member
  • **
  • Posts: 65
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #13 on: September 30, 2015, 12:43:28 AM »
my framework is 3.5

AsmAlmeria12

  • Member
  • **
  • Posts: 65
Re: raiseevent of an object, in vb.net, from asm dll?
« Reply #14 on: October 01, 2015, 02:28:18 AM »
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. :(


« Last Edit: October 01, 2015, 05:02:51 PM by AsmAlmeria12 »