<?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[Speicher auslesen eines programmes]]></title><description><![CDATA[<p>Huhu<br />
ich hab mir ein kleines Taschenrechner programm geschrieben und von diesem möchte ich nun versuchen die Werte im arbeitsspeicher auszulesen bzw verändern<br />
ich hab in einem Tutorial das so gesehen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt; 
#include &lt;iostream&gt; 

using namespace std; 

typedef unsigned int uint; 

void GetMemMinMax(void); 
void ScanMem(DWORD start, DWORD end); 

HANDLE hproc; 
DWORD procid; 

int main(void) 
{ 
    HWND hWnd; 

    hWnd = FindWindow(0,&quot;Taschenrechner&quot;); 
    if(!hWnd) 
        return 0; 

    GetWindowThreadProcessId(hWnd, &amp;procid); 
    hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procid); 
    GetMemMinMax(); 
    CloseHandle(hproc);//&lt;-- Wichtig! 
    return 0; 
} 

void GetMemMinMax(void) 
{ 
    MEMORY_BASIC_INFORMATION mbi; 
    unsigned int adress = 0x400000; 
    do 
    { 
        VirtualQueryEx( 
                        hproc, 
                        (void*)adress, 
                        &amp;mbi, 
                        sizeof(MEMORY_BASIC_INFORMATION) 
                    ); 

        if((mbi.State == MEM_COMMIT)&amp;&amp; 
           (mbi.Protect == PAGE_READWRITE)&amp;&amp; 
           (mbi.Type == MEM_PRIVATE)) 
        { 
            uint start = (uint)mbi.BaseAddress; 
            uint end = (uint)mbi.BaseAddress+mbi.RegionSize; 

            cout &lt;&lt; &quot;Bereich: &quot; &lt;&lt; 
                            hex &lt;&lt; start &lt;&lt; &quot; - &quot; &lt;&lt; 
                            hex &lt;&lt; end; 

            ScanMem(start,end); 
        } 

        adress += mbi.RegionSize; 
    } while(adress &lt; 0x80000000); 
} 

void ScanMem(DWORD start, DWORD end) 
{ 
    cout &lt;&lt; &quot; Bereich wird gescannt... 
&quot;; 
    DWORD read = 0; 
    int buffer = 0; 
    for(start;start&lt;end;start++) 
    { 
        ReadProcessMemory( 
                            hproc, 
                            (void*)start, 
                            &amp;buffer, 
                            sizeof(int), 
                            &amp;read 
                        ); 
        if(buffer == 15) 
        { 
            cout &lt;&lt; &quot;Wert an &quot; &lt;&lt; hex &lt;&lt; start &lt;&lt; &quot; gefunden!&quot;; 
            char choice; 
            cout &lt;&lt; &quot;Abbrechen? [j,n]&quot;; 
            cin &gt;&gt; choice; 
            if(choice == 'j') 
                return; 
        } 
    } 
}
</code></pre>
<p>leider öffnet sich das programm nur so 2 sekunden und beendet sich dann von<br />
selber. Um zu testen ob das handle nicht funktioniert habe ich if(!hWnd) eingebaut aber es funktioniert. Hat einer eine Idee warum das nicht klappt?<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196109/speicher-auslesen-eines-programmes</link><generator>RSS for Node</generator><lastBuildDate>Mon, 29 Jun 2026 21:22:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196109.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 Oct 2007 14:21:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Speicher auslesen eines programmes on Thu, 25 Oct 2007 14:21:56 GMT]]></title><description><![CDATA[<p>Huhu<br />
ich hab mir ein kleines Taschenrechner programm geschrieben und von diesem möchte ich nun versuchen die Werte im arbeitsspeicher auszulesen bzw verändern<br />
ich hab in einem Tutorial das so gesehen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt; 
#include &lt;iostream&gt; 

using namespace std; 

typedef unsigned int uint; 

void GetMemMinMax(void); 
void ScanMem(DWORD start, DWORD end); 

HANDLE hproc; 
DWORD procid; 

int main(void) 
{ 
    HWND hWnd; 

    hWnd = FindWindow(0,&quot;Taschenrechner&quot;); 
    if(!hWnd) 
        return 0; 

    GetWindowThreadProcessId(hWnd, &amp;procid); 
    hproc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procid); 
    GetMemMinMax(); 
    CloseHandle(hproc);//&lt;-- Wichtig! 
    return 0; 
} 

void GetMemMinMax(void) 
{ 
    MEMORY_BASIC_INFORMATION mbi; 
    unsigned int adress = 0x400000; 
    do 
    { 
        VirtualQueryEx( 
                        hproc, 
                        (void*)adress, 
                        &amp;mbi, 
                        sizeof(MEMORY_BASIC_INFORMATION) 
                    ); 

        if((mbi.State == MEM_COMMIT)&amp;&amp; 
           (mbi.Protect == PAGE_READWRITE)&amp;&amp; 
           (mbi.Type == MEM_PRIVATE)) 
        { 
            uint start = (uint)mbi.BaseAddress; 
            uint end = (uint)mbi.BaseAddress+mbi.RegionSize; 

            cout &lt;&lt; &quot;Bereich: &quot; &lt;&lt; 
                            hex &lt;&lt; start &lt;&lt; &quot; - &quot; &lt;&lt; 
                            hex &lt;&lt; end; 

            ScanMem(start,end); 
        } 

        adress += mbi.RegionSize; 
    } while(adress &lt; 0x80000000); 
} 

void ScanMem(DWORD start, DWORD end) 
{ 
    cout &lt;&lt; &quot; Bereich wird gescannt... 
&quot;; 
    DWORD read = 0; 
    int buffer = 0; 
    for(start;start&lt;end;start++) 
    { 
        ReadProcessMemory( 
                            hproc, 
                            (void*)start, 
                            &amp;buffer, 
                            sizeof(int), 
                            &amp;read 
                        ); 
        if(buffer == 15) 
        { 
            cout &lt;&lt; &quot;Wert an &quot; &lt;&lt; hex &lt;&lt; start &lt;&lt; &quot; gefunden!&quot;; 
            char choice; 
            cout &lt;&lt; &quot;Abbrechen? [j,n]&quot;; 
            cin &gt;&gt; choice; 
            if(choice == 'j') 
                return; 
        } 
    } 
}
</code></pre>
<p>leider öffnet sich das programm nur so 2 sekunden und beendet sich dann von<br />
selber. Um zu testen ob das handle nicht funktioniert habe ich if(!hWnd) eingebaut aber es funktioniert. Hat einer eine Idee warum das nicht klappt?<br />
danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1391940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1391940</guid><dc:creator><![CDATA[Bibor]]></dc:creator><pubDate>Thu, 25 Oct 2007 14:21:56 GMT</pubDate></item></channel></rss>