Re: System-wide hooking, VB+ASM

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Tue, 7 Jun 2005 11:54:52 -0700, "Sam Hobbs"
<samuel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

<snip>
>Note that a VB exe file has a dependency on MSVBVM60.DLL, which is the
>run-time DLL. Look at "Compiling Your Project to Native Code" for a little
>bit about that. Since VB is not designed to create DLLs that are not used
>for ActiveX/COM, it is likely that when a function in a VB-generated DLL is
>called directly that the run-time services in MSVBVM60.DLL have not had the
>opportunity to initialize the VB run-time for processes that have not yet
>used VB.

>If a VB program calls a function in a DLL generated by VB to set a hook, the
>VB program does have the opportunity to initialize the VB run-time for the
>process . I don't know what happens, but my guess is that when a function in
>a VB-generated DLL is called directly by a VB program, that the run-time
>services in MSVBVM60.DLL do not need to be initialized for the DLL function
>since the run-time would have already been initialized for the process.
>However for system-wide hooks, the hook function in a DLL can be called
>without any other VB code being called for the process.

As it happens I know for a fact that DllMain is invoked when a Delphi
DLL is instantiated for a system wide hook.

I do not agree that DLLs are just 'plain code', there is a fairly
complex mechanism for initializing them (LoadLibrary springs to mind)
also being 'under the hood' EXEs they need 'fixing up' - internally
their addresses are relative
- the system performs a little dance down the EXE turning relative
addresses into absolute addresses.

The RTL is (almost certainly) required for calls out of VB, as it has
to perform its rather perverse type conversions.

Interestingly, I've found that calls /into/ VB are pretty bland.

.



Relevant Pages

  • Re: MAPIInitialize(NULL) used to fail after 10-15 successfully attempts!!!
    ... Application is a java code which loads this DLL from ... (initialize and uninitialize each time) ... What was the error when you left MAPI initialized? ... Why not call MAPIInitialize once when your app starts and leave MAPI ...
    (microsoft.public.win32.programmer.messaging)
  • Re: MAPIInitialize(NULL) used to fail after 10-15 successfully attempts!!!
    ... I dont know how to degug a dll using VC++. ... and MAPI Developer Tool ... (initialize and uninitialize each time) ... Why not call MAPIInitialize once when your app starts and leave MAPI ...
    (microsoft.public.win32.programmer.messaging)
  • Re: System-wide hooking, VB+ASM
    ... >>> hook using just VB? ... >My hunch is, in fact I'm well-near certain, that you'd need to initialize the runtime ... the DLL must be capable of initializing the ... LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD ...
    (microsoft.public.vb.winapi)
  • TerminateExtenstion called twice in failed Initialization of ISAPI
    ... Initialization of the DLL fails in GetExtensionVersion. ... The chain of events that leads to the issue is when the call to initialize ... TerminateExtension is called within that failure case and the return value is ...
    (microsoft.public.vc.atl)
  • Re: Using COM in a non-ATL project.
    ... one exception though - if your DLL creates threads, ... can initialize COM on these threads (and only on the DLLs ... minimum specifying Win NT4 as the minimum platform). ... Microsoft MVP, MCSD ...
    (microsoft.public.vc.atl)