<?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[API-Aufrufe abfangen]]></title><description><![CDATA[<p>Kann man einen API-Aufruf abfangen, d.h. den Zeiger auf eine Prozedur (beipielsweise OpenFile) auf eine andere legen, um Aufrufe zu prokollieren. Dies wäre sinnvoll, wenn man wissen will, welche Dateien bei einer Installation erstellt werden usw.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/98857/api-aufrufe-abfangen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 18:49:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/98857.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 23 Jan 2005 12:24:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to API-Aufrufe abfangen on Sun, 23 Jan 2005 12:24:23 GMT]]></title><description><![CDATA[<p>Kann man einen API-Aufruf abfangen, d.h. den Zeiger auf eine Prozedur (beipielsweise OpenFile) auf eine andere legen, um Aufrufe zu prokollieren. Dies wäre sinnvoll, wenn man wissen will, welche Dateien bei einer Installation erstellt werden usw.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/703752</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/703752</guid><dc:creator><![CDATA[DjFishbone]]></dc:creator><pubDate>Sun, 23 Jan 2005 12:24:23 GMT</pubDate></item><item><title><![CDATA[Reply to API-Aufrufe abfangen on Sun, 23 Jan 2005 19:41:16 GMT]]></title><description><![CDATA[<p>In &quot;Windows Programmierung für Experten&quot; von Jeffrey Richters wird soetwas ähnliches für den MessageBox-Aufruf gemacht. Dort wird dann auch der betreffende Code für das Hooking in eine Klasse gekapselt - der Code, wenn du alle Fälle deinen Hook zu umgehen auch abfangen möchtest ist aber schon etwas umfangreicher <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/704080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/704080</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Sun, 23 Jan 2005 19:41:16 GMT</pubDate></item><item><title><![CDATA[Reply to API-Aufrufe abfangen on Wed, 02 Feb 2005 21:29:08 GMT]]></title><description><![CDATA[<p>Ich wäre ja auch schon zufrieden, wenn ich die Aufrufe protokollieren kann!</p>
<p>-------------------------------------------------------------------------------<br />
Code zum abfangen:<br />
Direkt einen Jump Befehl zur neuen Funktion einsetzen, gibt aber eine &quot;Access Violation&quot;! Warum <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>
<p>Hier die DLL zum Abfangen:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;winreg.h&gt;

typedef UINT (CALLBACK* REGCREATEKEYTYPE)(HKEY, LPCTSTR, PHKEY);

BOOL InterceptAPI(HMODULE hLocalModule,  const char* c_szDllName, const char* c_szApiName, DWORD dwReplaced);
LONG RegCreateKeyIC(HKEY hKey, LPCTSTR lpSubKey, PHKEY phkResult);
bool WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID reserved);

bool WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID reserved) {
	MessageBox(0, &quot;entried dll&quot;, &quot;InterceptAPI&quot;, 0);
    if (dwReason == DLL_PROCESS_ATTACH) {
		LoadLibrary(&quot;advapi32IC.dll&quot;);
        InterceptAPI(hInst, &quot;advapi32.dll&quot;, &quot;RegCreateKey&quot;, (DWORD) RegCreateKeyIC);
    }
    else if (dwReason == DLL_PROCESS_DETACH) {    
        MessageBox(0, &quot;DLL_PROCESS_DETACH&quot;, &quot;InterceptAPI&quot;, 0);
    }
    return true;
}

BOOL InterceptAPI(HMODULE hLocalModule,  const char* c_szDllName, const char* c_szApiName, DWORD dwReplaced) {
    DWORD dwOldProtect;
    DWORD dwAddressToIntercept = (DWORD)GetProcAddress(
            GetModuleHandle((char*)c_szDllName), (char*)c_szApiName);
    BYTE *pbTargetCode = (BYTE *) dwAddressToIntercept;
    BYTE *pbReplaced = (BYTE *) dwReplaced;

    VirtualProtect((void *) dwAddressToIntercept, 5, PAGE_WRITECOPY, &amp;dwOldProtect);
    *pbTargetCode++ = 0xE9;        // jump rel32
    *((signed int *)(pbTargetCode)) = pbReplaced - (pbTargetCode +4);
    VirtualProtect((void *) dwAddressToIntercept, 5, PAGE_EXECUTE, &amp;dwOldProtect);

    FlushInstructionCache(GetCurrentProcess(), NULL, NULL);
    return true;
}

/* Ersetzende Prozeduren */

LONG RegCreateKeyIC(HKEY hKey, LPCTSTR lpSubKey, PHKEY phkResult) {
	REGCREATEKEYTYPE pFunc = (REGCREATEKEYTYPE) GetProcAddress(GetModuleHandle(&quot;advapi32IC.dll&quot;), &quot;RegCreateKey&quot;);

	MessageBox(0, &quot;Prozedur wurde aufgerufen&quot;, &quot;RegCreateKey&quot;, 0);
	return pFunc(hKey, lpSubKey, phkResult);
}
</code></pre>
<p>Hier das simple Aufrufprogramm:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;winreg.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
	PHKEY phkResult;	
	HINSTANCE hInstLib = LoadLibrary(&quot;C:\\RegIntercept.dll&quot;);
	DWORD dwLastError = GetLastError();
	if(!(GetModuleHandle(&quot;RegIntercept.dll&quot;))) {
		MessageBox(0, &quot;RegIntercept.dll wurde nicht im Speicher gefunden&quot;, &quot;Fehler&quot;, MB_ICONWARNING);
	}
	//RegCreateKey(HKEY_CURRENT_USER, &quot;Uli\\EINS&quot;, phkResult);

	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/713291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/713291</guid><dc:creator><![CDATA[DjFishbone]]></dc:creator><pubDate>Wed, 02 Feb 2005 21:29:08 GMT</pubDate></item><item><title><![CDATA[Reply to API-Aufrufe abfangen on Wed, 02 Feb 2005 21:55:49 GMT]]></title><description><![CDATA[<p>guckt ihr: <a href="http://research.microsoft.com/sn/detours/" rel="nofollow">http://research.microsoft.com/sn/detours/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/713306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/713306</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Wed, 02 Feb 2005 21:55:49 GMT</pubDate></item></channel></rss>