Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Kyboard-Hook im selben Process aber vom parallelen Thread (https://www.delphipraxis.net/26781-kyboard-hook-im-selben-process-aber-vom-parallelen-thread.html)

Reddog 29. Jul 2004 12:34


Kyboard-Hook im selben Process aber vom parallelen Thread
 
Hallo,

ich habe mal einen neuen Thread aufgemacht. Ich habe es dank der Hilfe mehrerer Poster geschafft eine DLL in einen fremden Process(ein Spiel) "einzuschleusen". Diese wird durch CreateRemoteThread geladen. Allerdings kann ich irgendwie keinen localen Keyboard-Hook installieren. Den brauche ich aber um Aktionen auf Tastendruck auszuführen.
Es klappt auch nicht, wenn ich versuche bei SetWindowsHookEx das Handle des DLL-Moduls zu übergeben und die Thread-ID des Spiel-Threads. Wenn ich die DLL direkt in ein Test-Programm lade, dann klappt alles wunderbar, also muss es wohl daran liegen, dass ein anderer Thread innerhalb desselben Processes die DLL lädt.

Fällt jemandem ein Weg ein, um den Hook doch laden zu können?

Eigentlich ist mir jede Lösung recht. Hauptsache die geladene DLL kann auf Tastenbetätigung reagieren, ob jetzt global oder nur innerhalb des Spiels, ist mir im Grunde egal.

Wunderbar wäre natürlich, wenn jemand einen Weg kennt, um die DLL direkt in den Spiel-Thread zu laden.

Danke,
Reddog.

Blutiger Anfänger 22. Aug 2004 01:03

Re: Kyboard-Hook im selben Process aber vom parallelen Threa
 
Die Grundlagen sind wichtig:

Zitat:

Zitat von PSDK
A global hook monitors messages for all threads in the same desktop as the calling thread. [b]A thread-specific hook monitors messages for only an individual thread.[/a] A global hook procedure can be called in the context of any application in the same desktop as the calling thread, so the procedure must be in a separate dynamic-link library (DLL) module. A thread-specific hook procedure is called only in the context of the associated thread. If an application installs a hook procedure for one of its own threads, the hook procedure can be in either the same module as the rest of the application's code or in a DLL. If the application installs a hook procedure for a thread of a different application, the procedure must be in a DLL. For information, see Dynamic-Link Libraries.



Alle Zeitangaben in WEZ +1. Es ist jetzt 12:28 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz