<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Hook läuft im falschen Adressraum]]></title><description><![CDATA[<p>Hallo,<br />
ich wurde heute geschockt, als ich feststellte, dass mein Hook automatisch<br />
beendet wird, sobald ich die Anwending schließe, die den Hook installiert hat.<br />
Da es ein globaler Hook ist, sollte dieser eigentlich weiter laufen...<br />
Nun habe ich gelesen, das es Hooks gibt, die wieder im Kontext des aufrufenden Programms geladen werden...<br />
z.B. erster Absatz hier:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/LowLevelMouseProc.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/LowLevelMouseProc.asp</a><br />
Ich verstehe nicht ganz was da steht, bzw. was das bedeutet?<br />
Kann mir jemand weiterhelfen?</p>
<p>Bisher habe ich meinen Hook auf folgende Weise installiert:<br />
- DLL erzeugen, die eine Funktion &quot;Install&quot; exportiert<br />
- &quot;Install&quot; wird von einer zweiten Funktion aufgerufen<br />
- in &quot;Install&quot; steht der Aufruf &quot;SetWindowsHookEx&quot;</p>
<p>Ich habe nun aus lauter Verzweifelung versucht den Hook auf eine andere Art zu installieren:<br />
- in der ausführbahren Applikation wir mit LoadLibrary und GetProcAdress der Hook direkt installiert.<br />
Das sieht dann so aus:</p>
<pre><code>private: System::Void install_button_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			HOOKPROC hkprcSysMsg; 
			HINSTANCE hinstDLL; 
			HHOOK hhookSysMsg; 

			//hinstDLL = LoadLibrary((LPCTSTR) &quot;C:\Documents and Settings\Michael Worobcuk\My Documents\Visual Studio 2005\Projects\Maus Hook_test\Hook_Form\Hook.dll&quot;);

			if (hinstDLL==0)
			{
				OutputDebugString(&quot;nicht geladen&quot;);
			}
			else
			{
				OutputDebugString(&quot;geladen&quot;);
				hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL,&quot;MouseHookProc&quot;); 

			}
			//hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0); 

		}
</code></pre>
<p>Leider gibt es dann einen Linkler Fehler, den ich nicht verstehe:</p>
<pre><code>Error	3	fatal error LNK1000: Internal error during IMAGE::BuildImage	Hook_Form
</code></pre>
<p>Ich währe über Ratschläge sehr dankbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145194/hook-läuft-im-falschen-adressraum</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 22:21:44 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145194.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Apr 2006 19:55:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Hook läuft im falschen Adressraum on Tue, 25 Apr 2006 19:55:14 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich wurde heute geschockt, als ich feststellte, dass mein Hook automatisch<br />
beendet wird, sobald ich die Anwending schließe, die den Hook installiert hat.<br />
Da es ein globaler Hook ist, sollte dieser eigentlich weiter laufen...<br />
Nun habe ich gelesen, das es Hooks gibt, die wieder im Kontext des aufrufenden Programms geladen werden...<br />
z.B. erster Absatz hier:<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/LowLevelMouseProc.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/LowLevelMouseProc.asp</a><br />
Ich verstehe nicht ganz was da steht, bzw. was das bedeutet?<br />
Kann mir jemand weiterhelfen?</p>
<p>Bisher habe ich meinen Hook auf folgende Weise installiert:<br />
- DLL erzeugen, die eine Funktion &quot;Install&quot; exportiert<br />
- &quot;Install&quot; wird von einer zweiten Funktion aufgerufen<br />
- in &quot;Install&quot; steht der Aufruf &quot;SetWindowsHookEx&quot;</p>
<p>Ich habe nun aus lauter Verzweifelung versucht den Hook auf eine andere Art zu installieren:<br />
- in der ausführbahren Applikation wir mit LoadLibrary und GetProcAdress der Hook direkt installiert.<br />
Das sieht dann so aus:</p>
<pre><code>private: System::Void install_button_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			HOOKPROC hkprcSysMsg; 
			HINSTANCE hinstDLL; 
			HHOOK hhookSysMsg; 

			//hinstDLL = LoadLibrary((LPCTSTR) &quot;C:\Documents and Settings\Michael Worobcuk\My Documents\Visual Studio 2005\Projects\Maus Hook_test\Hook_Form\Hook.dll&quot;);

			if (hinstDLL==0)
			{
				OutputDebugString(&quot;nicht geladen&quot;);
			}
			else
			{
				OutputDebugString(&quot;geladen&quot;);
				hkprcSysMsg = (HOOKPROC)GetProcAddress(hinstDLL,&quot;MouseHookProc&quot;); 

			}
			//hhookSysMsg = SetWindowsHookEx(WH_SYSMSGFILTER,hkprcSysMsg,hinstDLL,0); 

		}
</code></pre>
<p>Leider gibt es dann einen Linkler Fehler, den ich nicht verstehe:</p>
<pre><code>Error	3	fatal error LNK1000: Internal error during IMAGE::BuildImage	Hook_Form
</code></pre>
<p>Ich währe über Ratschläge sehr dankbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1045162</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1045162</guid><dc:creator><![CDATA[Originalhanno]]></dc:creator><pubDate>Tue, 25 Apr 2006 19:55:14 GMT</pubDate></item></channel></rss>