<?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[Dauerhaftes Abspeichern von Adressen]]></title><description><![CDATA[<p>Aufgrund des etwas nichtssagenden Titels einfach mal nen Code-Beispiel:</p>
<pre><code class="language-cpp">typedef VOID (WINAPI* tExitProcess) (UINT uExitCode);
static  VOID (WINAPI* pExitProcess) (UINT uExitCode);

VOID FillPtr( VOID ) {
	HINSTANCE hK32 = LoadLibraryA( &quot;Kernel32.dll&quot; );

	pExitProcess = (tExitProcess)GetProcAddress( hK32, &quot;ExitProcess&quot; );
}

UINT AnotherOne( VOID ) {
	pExitProcess( 0x00 );	// pExitProcess = 0x00000000
}
</code></pre>
<p>Irgendwie steh ich auf dem Schlauch! Hoffe jemand kann mir helfen <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="😉"
    /><br />
MfG, 0x2A</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/265282/dauerhaftes-abspeichern-von-adressen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 07:46:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/265282.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Apr 2010 16:38:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 16:38:44 GMT]]></title><description><![CDATA[<p>Aufgrund des etwas nichtssagenden Titels einfach mal nen Code-Beispiel:</p>
<pre><code class="language-cpp">typedef VOID (WINAPI* tExitProcess) (UINT uExitCode);
static  VOID (WINAPI* pExitProcess) (UINT uExitCode);

VOID FillPtr( VOID ) {
	HINSTANCE hK32 = LoadLibraryA( &quot;Kernel32.dll&quot; );

	pExitProcess = (tExitProcess)GetProcAddress( hK32, &quot;ExitProcess&quot; );
}

UINT AnotherOne( VOID ) {
	pExitProcess( 0x00 );	// pExitProcess = 0x00000000
}
</code></pre>
<p>Irgendwie steh ich auf dem Schlauch! Hoffe jemand kann mir helfen <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="😉"
    /><br />
MfG, 0x2A</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885845</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Tue, 20 Apr 2010 16:38:44 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 17:02:02 GMT]]></title><description><![CDATA[<p>Nochmal kurz als Ergänzung:<br />
Ich möchte die Variable <strong>pExitProcess</strong> in einer Prozedur einmalig initialisieren und diese soll dann auch für alle weiteren Prozeduren verwendbar sein.</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885857</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Tue, 20 Apr 2010 17:02:02 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 17:21:44 GMT]]></title><description><![CDATA[<p>Machst du doch schon.<br />
Wäre natürlich zweckmäßig, FillPtr bei Programmstart auch einmal aufzurufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885868</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885868</guid><dc:creator><![CDATA[Athar]]></dc:creator><pubDate>Tue, 20 Apr 2010 17:21:44 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 17:26:07 GMT]]></title><description><![CDATA[<p>Ja.<br />
Wo soll das Problem sein?</p>
<p>Bis auf dass <code>pExitProcess static</code> ist, was natürlich zu einem Problem führt, wenn du <code>FillPtr</code> und <code>AnotherOne</code> in unterschiedlichen Übersetzungseinheiten definierst.</p>
<p>Davon abgesehen müsste das funktionieren.</p>
<p>Und davon abgesehen dass du, wenn du <code>LoadLibrary</code> aufrufst, auch <code>FreeLibrary</code> aufrufen solltest. (Was natürlich bei der KERNEL32 eine Fleissaufgabe ist - geht einfach um's Prinzip, bzw. darum dass man sich solche Unarten gleich garnicht angewöhnt.)<br />
Man könnte ja schliesslich bei KERNEL32 auch <code>GetModuleHandle</code> statt <code>LoadLibrary</code> verwenden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885871</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 20 Apr 2010 17:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 17:31:37 GMT]]></title><description><![CDATA[<p>Hihi.<br />
<a href="http://www.google.com/search?hl=en&amp;q=%28answer+to+life%2C+the+universe+and+everything%29+in+hexadecimal&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai=" rel="nofollow">0x2A</a><br />
Auch nicht schlecht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885877</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 20 Apr 2010 17:31:37 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 18:02:14 GMT]]></title><description><![CDATA[<p>(answer to life, the universe and everything) in binary</p>
<p>answer to life, the universe and everything = 0b101010</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885895</guid><dc:creator><![CDATA[gjghj]]></dc:creator><pubDate>Tue, 20 Apr 2010 18:02:14 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 20:15:42 GMT]]></title><description><![CDATA[<p>Hier noch einmal (die etwas komplexere) Sachlage:</p>
<p>Ich verwende in einem Projekt eine von mir geschriebene Library. Die Library setzt sich aus verschiedenen Übersetzungseinheiten und aus einer Header-Datei. In der Header-Datei sind die verschiedenen Funktionen definiert ( <code>pExitProcess</code> usw.). <code>#pragma once</code> ist gesetzt. Eine Übersetzungseinheit dient zum Befüllen der Pointer aus der Header-Datei. Diese Initialisierungs-Funktion wird in der Main-Prozedur als erstes aufgerufen und daraufhin werden die Pointer verwendet. Leider sind diese nicht initialisiert.</p>
<p>Kurze Übersicht:</p>
<p><strong>EinHeader.h</strong></p>
<pre><code class="language-cpp">#pragma once
#include &lt;windows.h&gt;

UINT FillPointer();

. . .

typedef INT			(WINAPI* tCompareStringA)		(LCID Locale, DWORD dwCmpFlags, LPCSTR lpString1, INT cchCount1, LPCSTR lpString2, INT cchCount2);
static  INT			(WINAPI* pCompareStringA)		(LCID Locale, DWORD dwCmpFlags, LPCSTR lpString1, INT cchCount1, LPCSTR lpString2, INT cchCount2);

typedef INT			(WINAPI* tCompareStringW)		(LCID Locale, DWORD dwCmpFlags, LPCWSTR lpString1, INT cchCount1, LPCWSTR lpString2, INT cchCount2);
static  INT			(WINAPI* pCompareStringW)		(LCID Locale, DWORD dwCmpFlags, LPCWSTR lpString1, INT cchCount1, LPCWSTR lpString2, INT cchCount2);

typedef LPSTR		(WINAPI* tlstrcatA)				(LPSTR lpString1, LPCSTR lpString2);
static  LPSTR		(WINAPI* plstrcatA)				(LPSTR lpString1, LPCSTR lpString2);

typedef LPWSTR		(WINAPI* tlstrcatW)				(LPWSTR lpString1, LPCWSTR lpString2);
static  LPWSTR		(WINAPI* plstrcatW)				(LPWSTR lpString1, LPCWSTR lpString2);

. . .
</code></pre>
<p><strong>Initialisierungs-Übersetzungseinheit.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;EinHeader.h&quot;

UINT FillPointer2() {
	HINSTANCE hKernel32 		= (HINSTANCE)					/* . . . */;

	pGetProcAddress 			= (tGetProcAddress) 			/* . . . */;
	pLoadLibraryA   			= (tLoadLibraryA)				/* . . . */;

	. . .

	pGetCommandLineA			= (tGetCommandLineA)			pGetProcAddress( hKernel32, &quot;GetCommandLineA&quot; );

	pExitProcess		= (tExitProcess)pGetProcAddress( hKernel32, &quot;ExitProcess&quot; );

	. . .

	return 0;
}
</code></pre>
<p><strong>Main.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;EinHeader.h&quot;

int WINAPI WinMain( /* . . . */ ) {
	FillPointer();
	pExitProcess( 0 );		/* Unhandled exception at 0x00000000 in ........exe: 0xC0000005: Access violation reading location 0x00000000. */
							/* Beim hovern über den Pointer: 0x00000000 */
	return 0;
}
</code></pre>
<p>Das ist nun natürlich eine stark vereinfachte Darstellung. Sie soll nur als Schema dienen und kann Tipp-Fehler/Code-Fehler enthalten.</p>
<p>Wenn ich für die Pointer in der Header-Datei anstatt &quot; <code>static</code> &quot; &quot; <code>extern</code> &quot; o.ä. verwende kommt es zu einem Linker-Error, da die Pointer mehrfach definiert wurden... ist ja logisch <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>
<p>Ich hoffe, dass ich nichts vergessen habe.<br />
MfG, 0x2A</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885936</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Tue, 20 Apr 2010 20:15:42 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 20:53:13 GMT]]></title><description><![CDATA[<p>Inzwischen bin ich dann auch darauf gekommen, dass es unklug war die Pointer als static zu definieren.</p>
<p>Meine Frage nun: Wie sollte ich sie definieren, damit sie in allen Übersetzungsheiten bekannt sind und nicht zu Linker-Fehlern wegen Mehrfach-Definition führen?</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885944</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Tue, 20 Apr 2010 20:53:13 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 20:59:20 GMT]]></title><description><![CDATA[<p>In Header:<br />
extern int Foo;</p>
<p>In Source:<br />
int Foo;</p>
<p>Ist allerdings sehr schlechter Stil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885947</guid><dc:creator><![CDATA[Janjan]]></dc:creator><pubDate>Tue, 20 Apr 2010 20:59:20 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Tue, 20 Apr 2010 21:08:02 GMT]]></title><description><![CDATA[<p>Gibt einen Linkerfehler bei dem Projekt, welches die Library verwendet:</p>
<p><code>error LNK2001: unresolved external symbol &quot;void (__stdcall* pExitProcess)(unsigned int)&quot; (?pExitProcess@@3P6GXI@ZA)</code></p>
<p>Habe die Methode schon getestet. Müssen noch Änderungen an dem Projekt vorgenommen werden, welches die <code>.lib</code> verwendet?</p>
<p>MfG, 0x2A</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1885953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1885953</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Tue, 20 Apr 2010 21:08:02 GMT</pubDate></item><item><title><![CDATA[Reply to Dauerhaftes Abspeichern von Adressen on Wed, 21 Apr 2010 12:04:07 GMT]]></title><description><![CDATA[<p>Habe es nun lösen können. Mein Fehler lag darin, dass ich in den Header zwar</p>
<p><code>extern int foo;</code></p>
<p>geschrieben hatte doch in der Quelldatei nur</p>
<p>`#include &quot;foo.h&quot;</p>
<p>void bar( void ) {</p>
<pre><code>int foo;

. . .
</code></pre>
<p>}`</p>
<p>anstatt</p>
<p>`#include &quot;foo.h&quot;</p>
<p>int foo;</p>
<p>void bar( void ) {</p>
<pre><code>. . .
</code></pre>
<p>}`</p>
<p>Hoffe jemand kann die Info noch brauchen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1886172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1886172</guid><dc:creator><![CDATA[0x2A_]]></dc:creator><pubDate>Wed, 21 Apr 2010 12:04:07 GMT</pubDate></item></channel></rss>