TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Alle
from: Hermann Ulrichskoetter
date: 1996-08-30 12:15:00
subject: VP/2 and Hook-DLL

Hello,
I try to program a DLL with VP/1 V1.1. This DLL is a Hook-DLL, which hooks  
into the PM-InputQueue. But unfortunaltely it doesn't work. After  
_WinSetHook_ the PM hangs and the program can only be killed by Watchcat  
(WM_Quit doesn't work).
I tried the same with a DLL I generated with EMX and it worked!!
Any ideas??
Following extracts of the Source:
------------------------------------------------------------
Main Program:
-------------
EC :=DosLoadModule(FailedModule,SizeOf(FailedModule),'Testdll',Module);
If EC  0 then
  Begin
    s:='DosLoadModule failed with error code '+int2Str(EC)+#0;
    Message({at}S[1]);
    Halt(1);
  End;
EC := DosQueryProcAddr(Module, 1, nil, pfnInput);
If EC  0 then
  Begin
    Message('DosQueryProcAddr1 failed with error code ');
    Halt(1);
  End;
WinSetHook(Anchor, NULLHANDLE, HK_INPUT, pfnInput, Module);

VP/2 DLL:
---------
Library HotKyDLL;
Uses OS2Base,OS2Def,OS2PMAPI;
{$Cdecl+,OrgName+}
Function InputHook(AB: HAB; Msg: QMSG; fs: ULong): Boolean;
Begin
  If Msg.Msg = WM_CHAR Then
    DosBeep(100,100);
  InputHook:=False
End
{$Cdecl-}
Initialization
End.

DEF-File:
---------
LIBRARY HOTKYDLL INITGLOBAL TERMGLOBAL
DATA SINGLE
DESCRIPTION "HotKey Hook"
EXPORTS
       InputHook

the same DLL in C:
------------------
#define INCL_WIN
#include 

BOOL EXPENTRY InputHook(HAB hab, PQMSG pQmsg, ULONG fs)
{
  if (pQmsg->msg == WM_CHAR)
    DosBeep(100, 100);
  return 0;
}

DEF-File:
----------
LIBRARY testdll INITGLOBAL TERMGLOBAL
DATA SINGLE
DESCRIPTION "TestDLL"

EXPORTS
       InputHook

Compiled with:
--------------
gcc -Zdll -Zso -Zsys -Zomf -o testdll.dll testdll.c testdll.def
-----------------------------------------------------------
Thanks for all Suggestions!
Gruesse, Hermi

-----------------------------------------------
- eMail: ulrichsk{at}mail.uni-freiburg.de
- Fido : Hermann Ulrichskoetter {at} 2:2476/830.27
-----------------------------------------------

--- CrossPoint v3.11 R
* Origin: Hermi's Point (2:2476/830.27)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1
@PATH: 2476/830 800 2433/1400 1200 225 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.