• Welcome to Valhalla Legends Archive.
 

VB6 - Calling an AddressOf?

Started by Joe[x86], December 03, 2006, 01:38 AM

Previous topic - Next topic

Joe[x86]

For a project I'm making, there's a glue class between some plugin DLL's and the main program itself. The glue class will have an Initialize function where several things, primarily a reference to the socket in use, and the AddressOf to the AddChat procedure, will be passed.

From there, though, I'd like to include an AddChat procedure in that class which will call the AddressOf that was passed to it in Initialize, thus calling the real AddChat.

Does anyone know how to do this?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Hero


warz

Well, in C++ you can just pass the address of the addchat function, and in your class create a function pointer, given the original address. I see youre using Visual Basic. I don't know how functions pointers work, or if theyre even possible in Visual Basic. Just after a quick google search though, the following link looks like it talks about visual basic function pointers. You might wanna check it out, or google on your own for that term.

http://www.15seconds.com/issue/021002.htm

Joe[x86]

Quote from: heRo on December 03, 2006, 02:07 AM
Quote from: topaz on December 03, 2006, 01:58 AM
yes
I love you.

I don't.

Quote from: warz on December 03, 2006, 02:25 AM
Well, in C++ you can just pass the address of the addchat function, and in your class create a function pointer, given the original address. I see youre using Visual Basic. I don't know how functions pointers work, or if theyre even possible in Visual Basic. Just after a quick google search though, the following link looks like it talks about visual basic function pointers. You might wanna check it out, or google on your own for that term.

http://www.15seconds.com/issue/021002.htm

Thanks.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

TheMinistered

The short answer would be to rewrite your classes vtable.  The vtable is like a table that contains pointers to all the functions in your class.  It is used at runtime to lookup a procedures address, move it into a register, then call.  Basically, change the adress of the AddChat procedure in the vtable to the AddChat address.  Doing this cross-application might not work.

At any rate, there is an example of how to do this on the VB6 Extrawork Marshaller I released on this forum.  It uses asm via vtable rewriting... the asm emulates the fastcall.


At any rate, I don't suggest doing things this way if its cross-application (i.e. executable and dlls).  You should think about passing object references and such (ObjPtr fxn).

A2

could you use CallWndProc or vb's CallByName as alternatives?