Help me! Pleeeeeease! 
Author Message
 Help me! Pleeeeeease!

ARGH I NEED HELP. I try to write an application who is self attached to the
active window like a parasite (not a virus :-) ).

To do that, my idea was to write a shell hook which reinstall at the top a
CallWnd hook every time a new application is created. The CallWnd check if
a wm_Activate is occured and then it inform me.

To test it, I wrote a little code, but it don't work properly. I tryed to
keep a trace while executing into a file and I notice that it never install
the CallWnd hook (I guess ?!) although my system become a little unstable.
In addition, all the application created after the launch of this code are
halted with an "error in the <unknown> module at blablabla". And that is
not the aim of my program.

Could anyone tell me what's wrong with this code or give me another way to
resolve my problem ???

I don't have an e-mail address for the moment so the answer can be posted
with the 'RE: Active Window' title and I'll find it. GREAT THANKS.
                                                        Edd.

Here is main program who call the DLL:

{------------------------------------------------------------}
program TestHook;

uses Dialogs;

procedure LibMain; external 'A{*filter*}' index 1;
procedure Wep; external 'A{*filter*}' index 4;

begin
   LibMain;
   {This dialog box is only to keep the hook for a while in memory}
   MessageDlg('Wait', mtInformation, [mbOk], 0);
   Wep;
end.
{------------------------------------------------------------}

And here is the DLL:

{------------------------------------------------------------}
library A{*filter*};

uses
  Windows, Messages;

var
  F: Text;
  hShellHook: hHook;
  hWndProcHook: hHook;

function WndProcHook(Code: Integer; wParam: LongInt; lParam: LongInt):
LongInt; stdcall;
begin
   if Code = wm_Activate then
      WriteLn(F, 'A window was activated or desactivated');
   WndProcHook := CallNextHookEx(hWndProcHook, Code, wParam, lParam);
end;

procedure RemoveWndProcHook;
begin
   WriteLn(F, 'Unloading the WndProcHook');
   if hWndProcHook <> 0 then UnhookWindowsHookEx(hWndProcHook);
   hWndProcHook := 0;
end;

procedure InstallWndProcHook;
begin
   WriteLn(F, 'Loading the WndProcHook');
   if hWndProcHook <> 0 then RemoveWndProcHook;
   hWndProcHook := SetWindowsHookEx(WH_CALLWNDPROC, WndProcHook, hInstance,
0);
end;

function ShellHook(Code: Integer; wParam: LongInt; lParam: LongInt):
LongInt; stdcall;
begin
   if Code = HSHELL_WINDOWCREATED then begin
      RemoveWndProcHook;
      InstallWndProcHook;
      WriteLn(F, 'An apps was created');
   end;
   ShellHook := CallNextHookEx(hShellHook, Code, wParam, lParam);
end;

procedure InstallHookDLL;
begin
   Assign(F, 'Journal.txt'); Rewrite(F);
   WriteLn(F, 'Loading the ShellHook');
   hShellHook := SetWindowsHookEx(WH_SHELL, ShellHook, hInstance, 0);
end;

procedure RemoveHookDLL;
begin
   WriteLn(F, 'Unloading the ShellHook');
   if hShellHook <> 0 then UnhookWindowsHookEx(hShellHook);
   RemoveWndProcHook;
   Close(F);
end;

exports
  InstallHookDLL index 1,
  ShellHook index 2,
  WndProcHook index 3,
  RemoveHookDLL index 4;
begin
end.
{------------------------------------------------------------}



Sat, 31 Jul 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Need Help on Stored Procedures Pleeeeeease!

2. HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP............

3. Lousy Palette - help, help, help, help, help...

4. HELP HELP HELP HELP!!!

5. HELP!!HELP!!HELP!!HELP!!

6. MDB without ODBC?? Help Help Help

7. help-help-help: convert paradox database to another

8. HELP HELP HELP!!!

9. help help help me!!!!

10. HELP.. HELP ...HELP

11. Help, Help, Help BCD

12. Help, Help, Help BCD

 

 
Powered by phpBB® Forum Software