Re: System-wide hooking, VB+ASM



On Fri, 3 Jun 2005 09:02:57 -0600, "Jonathan Wood"
<jwood@xxxxxxxxxxxxxxxx> wrote:

>J French,
>
>> Just thinking out loud, the DLL must be capable of initializing the
>> run time itself, as one can use a VB DLL happily from another
>> language, my guess is that is done by the LibMain routine

>It can? According to a link someone posted the other day, the key to calling
>exports from a VB DLL is to perform a couple of tricks when loading the DLL:

>http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=54682&lngWId=1

I find it odd that it should not be able to do so, as I've imported VB
OCXes into Delphi and they work just fine

I'm also pretty sure that I've run VB DLLs from Delphi
Yes - I've just checked

V := CreateOleObject('VBDLL.Class1');

Where V is an OleVariant
Tested on both VB4 and VB5

>I was having a little problem with some test code though. I really would
>like to see a small demo that installs a WH_KEYBOARD hook and crashes when a
>key is hit in another project.

Sure - it is just a lashup job - I'm not proud of it

www.jerryfrench.co.uk/hooktest.zip

>> I can't quite get my head around the initialization sequence, but I am
>> certain that LibMain is called both on normal LoadLibrary and when it
>> is being mapped into another process. I've seen that in Delphi.

>I was wondering about that as well. It's not clear to me if Sub Main in a
>DLL corresponds to a call to LibMain or what exactly.

I don't think it does, as LibMain is expected to return pretty
promptly with a success/failure result

I have just been reading this article :
http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html

He says that:
<quote>
A DLL also includes an optional entry point, which is called when a
process or thread loads or unloads the DLL. Windows calls this entry
point when a process loads and unloads the DLL.
<quote>

He calls it DllMain #0
The key is that it is /optional/ - something I did not realize

However if it really is optional, then it should not be needed for a
system wide hook.
In the Delphi Hook DLL it does use it or something like it, but it
does not need to.

Alhough delving deeper, Delphi has something called _InitLib that does
the same.

I just wonder whether that DllMain that he talks about is a red
herring.

This is getting quite interesting.
.



Relevant Pages

  • Re: Using VB6 dll in Delphi app.
    ... to make a *windows standard* .dll with VB6. ... The trouble occurs when we try to use it in a Delphi app. ...
    (microsoft.public.vb.general.discussion)
  • Re: New Delphi roadmap is coming: NO UNICODE PLEASE!
    ... Avoids DLL hell, because it ... The app is deployed and the user is getting an error. ... instances where upgrading .NET broke things that were working. ... Coming from Delphi, this isn't any big deal of course. ...
    (borland.public.delphi.non-technical)
  • Re: DLL with string params callable via D4 and VB
    ... > I have a DLL written in D6 that uses ShortStrings as parameters. ... I can't get beyond Delphi to ... > Is there any guidance you could give in regards to passing string ... written in order to be used by EXCEL 97 VBA. ...
    (borland.public.delphi.language.objectpascal)
  • Re: Why wont this work ?
    ... Yeap, more of a personal tool than a commercial offering, all of the other ... BHO tools i have found just dont seem to offer very much information, ... more about the dll, and hopefully will try and reveal what functions the ... Delphi IDE or RegSvr32 which brings us back in a full circle .... ...
    (alt.comp.lang.borland-delphi)
  • Re: Use of delegate
    ... Delphi application which I wrote. ... VB.NET relies on that Chainlink DLL, ... > Peter Huang ... > Private Sub Button2_Click(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)

Loading