<?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[Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation]]></title><description><![CDATA[<p>Fehlermeldung:</p>
<blockquote>
<p>First-chance exception at 0x00c72548 in DirectXSurfaces.exe: 0xC0000005: Access violation writing location 0x000000a4.</p>
</blockquote>
<p>Relevanter Code aus der Main.cpp:</p>
<pre><code class="language-cpp">case WM_PAINT:

			D3DCOLOR TextColor = D3DCOLOR_XRGB(0xFF,0,0);

			Direct3D.BeginScene();

			StarField.Draw(Direct3D.GetBackbuffer());

			Direct3D.DrawText(&quot;Test&quot;,100,100,D3DCOLOR_XRGB(0,0,0));

			Direct3D.EndScene();
		break;
</code></pre>
<p>Relevanter Code aus der StarField.cpp:</p>
<pre><code class="language-cpp">void CStarField::Draw(LPDIRECT3DSURFACE9 lpSurface)
{
	D3DLOCKED_RECT LockedRect;

	//lock access to the surface
	lpSurface-&gt;LockRect(&amp;LockedRect,NULL,0);

	int Pitch = LockedRect.Pitch / 4;

	//if the lock was successful, lpSurface is a legit pointer to the surface
	D3DCOLOR* Pixels = (D3DCOLOR*)LockedRect.pBits;

	for(int i=0;i&lt;m_NumberOfStars;i++)
	{
		m_Stars[i].Draw(Pixels,Pitch);
		m_Stars[i].Move();
	}

	//important release surface
	lpSurface-&gt;UnlockRect();
}
</code></pre>
<p>Relevanter Code aus der Star.cpp:</p>
<pre><code class="language-cpp">void CStar::Draw(D3DCOLOR* Pixels, int Pitch)
{
	//calculate star position
	int index = ((int)m_y * Pitch + (int)m_x);

	//starcolors

	//take length into consideration and chose color
	for(int i=0;i&lt;m_length;i++)
	{
		Pixels[index + i * Pitch] = D3DCOLOR_XRGB(112+i*16,112+i*16,112+i*16);
	}
}
</code></pre>
<p>Anmerkungen!!!<br />
Selbst wenn ich m_Stars[i].Draw(Pixels,Pitch); aus der StarField.cpp auskommentiere, bekomme ich keine Fehlermeldungen. Wenn ich dann irgendeine Methode, die versucht, auf einen der Pixel zuzugreifen, hinzufuege, spuckt die Console wieder Fehlermeldungen aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/294926/direkter-zugriff-auf-oberflaeche-access-violation</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 15:48:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/294926.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Nov 2011 19:44:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 19:44:33 GMT]]></title><description><![CDATA[<p>Fehlermeldung:</p>
<blockquote>
<p>First-chance exception at 0x00c72548 in DirectXSurfaces.exe: 0xC0000005: Access violation writing location 0x000000a4.</p>
</blockquote>
<p>Relevanter Code aus der Main.cpp:</p>
<pre><code class="language-cpp">case WM_PAINT:

			D3DCOLOR TextColor = D3DCOLOR_XRGB(0xFF,0,0);

			Direct3D.BeginScene();

			StarField.Draw(Direct3D.GetBackbuffer());

			Direct3D.DrawText(&quot;Test&quot;,100,100,D3DCOLOR_XRGB(0,0,0));

			Direct3D.EndScene();
		break;
</code></pre>
<p>Relevanter Code aus der StarField.cpp:</p>
<pre><code class="language-cpp">void CStarField::Draw(LPDIRECT3DSURFACE9 lpSurface)
{
	D3DLOCKED_RECT LockedRect;

	//lock access to the surface
	lpSurface-&gt;LockRect(&amp;LockedRect,NULL,0);

	int Pitch = LockedRect.Pitch / 4;

	//if the lock was successful, lpSurface is a legit pointer to the surface
	D3DCOLOR* Pixels = (D3DCOLOR*)LockedRect.pBits;

	for(int i=0;i&lt;m_NumberOfStars;i++)
	{
		m_Stars[i].Draw(Pixels,Pitch);
		m_Stars[i].Move();
	}

	//important release surface
	lpSurface-&gt;UnlockRect();
}
</code></pre>
<p>Relevanter Code aus der Star.cpp:</p>
<pre><code class="language-cpp">void CStar::Draw(D3DCOLOR* Pixels, int Pitch)
{
	//calculate star position
	int index = ((int)m_y * Pitch + (int)m_x);

	//starcolors

	//take length into consideration and chose color
	for(int i=0;i&lt;m_length;i++)
	{
		Pixels[index + i * Pitch] = D3DCOLOR_XRGB(112+i*16,112+i*16,112+i*16);
	}
}
</code></pre>
<p>Anmerkungen!!!<br />
Selbst wenn ich m_Stars[i].Draw(Pixels,Pitch); aus der StarField.cpp auskommentiere, bekomme ich keine Fehlermeldungen. Wenn ich dann irgendeine Methode, die versucht, auf einen der Pixel zuzugreifen, hinzufuege, spuckt die Console wieder Fehlermeldungen aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140000</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140000</guid><dc:creator><![CDATA[FightClb]]></dc:creator><pubDate>Thu, 03 Nov 2011 19:44:33 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 19:46:44 GMT]]></title><description><![CDATA[<blockquote>
<p>'DirectXSurfaces.exe': Loaded 'D:\Users\ICH\Documents\Visual Studio 2010\Projects\DirectXSurfaces\Debug\DirectXSurfaces.exe', Symbols loaded.<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\d3d9.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\D3DX9_43.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\aticfx32.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\atiu9pag.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\atiumdag.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\atiumdva.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Unloaded 'C:\Windows\SysWOW64\atiumdva.dll'<br />
'DirectXSurfaces.exe': Unloaded 'C:\Windows\SysWOW64\atiumdag.dll'<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\atiumdag.dll', Cannot find or open the PDB file<br />
'DirectXSurfaces.exe': Loaded 'C:\Windows\SysWOW64\atiumdva.dll', Cannot find or open the PDB file<br />
First-chance exception at 0x00c72548 in DirectXSurfaces.exe: 0xC0000005: Access violation writing location 0x000000a4.<br />
Der Fehler ca. 200 mal <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 />
...<br />
...<br />
...<br />
...<br />
The thread 'Win32 Thread' (0xa1c) has exited with code 0 (0x0).<br />
The thread 'Win32 Thread' (0xb4c) has exited with code 0 (0x0).<br />
The thread 'Win32 Thread' (0xa80) has exited with code 0 (0x0).<br />
The thread 'Win32 Thread' (0x1140) has exited with code 0 (0x0).<br />
The thread 'Win32 Thread' (0x109c) has exited with code 0 (0x0).<br />
The thread 'Win32 Thread' (0x12ec) has exited with code 0 (0x0).<br />
The program '[4484] DirectXSurfaces.exe: Native' has exited with code 0 (0x0).</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2140001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140001</guid><dc:creator><![CDATA[FightClb]]></dc:creator><pubDate>Thu, 03 Nov 2011 19:46:44 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 19:54:53 GMT]]></title><description><![CDATA[<p>ich würde mal sagen, du schreibst da in bereich, der dir nicht gehört.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140005</guid><dc:creator><![CDATA[vario-500]]></dc:creator><pubDate>Thu, 03 Nov 2011 19:54:53 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 19:56:41 GMT]]></title><description><![CDATA[<p>Aber wieso? Ich locke ein Rechteck aus dem Backbuffer und moechte dann den einen oder anderen Pixel aendern und das Rechteck wieder freigeben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140006</guid><dc:creator><![CDATA[FightClb]]></dc:creator><pubDate>Thu, 03 Nov 2011 19:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 20:09:50 GMT]]></title><description><![CDATA[<p>So, habe eben das erste mal den Debugger laufen lassen und dabei kam es yu folgendem Ergebnis:</p>
<p><a href="http://u89.img-up.net/?up=starfield1dw1g.png" rel="nofollow"></a><a href="http://u89t.img-up.net/starfield1dw1g.jpg" rel="nofollow">http://u89t.img-up.net/starfield1dw1g.jpg</a></p>
<p>scheinbar laesst sich der backgroundbuffer nicht richtig oeffnen oder zumindest nicht das rechteck darin...<br />
Ausserdem wundert es mich, dass i einen negativen Wert hat?</p>
<p>Dabei ist das der erste Methoden-Aufruf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140016</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140016</guid><dc:creator><![CDATA[FightClb]]></dc:creator><pubDate>Thu, 03 Nov 2011 20:09:50 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 20:44:05 GMT]]></title><description><![CDATA[<p>Returncodes von Funktionen sind dazu da dass man sie auswertet.<br />
Versuch das mal mit dem Returncode von LockRect().<br />
Returncode ausgeben, googeln, verstehen, Programm entsprechend ändern, funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140029</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 03 Nov 2011 20:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to Direkter Zugriff auf Oberflaeche &#x2F;&#x2F; Access-Violation on Thu, 03 Nov 2011 20:49:20 GMT]]></title><description><![CDATA[<p>Das HRESULT ist -2005530516 ich finde dazu aber nichts... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2140040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2140040</guid><dc:creator><![CDATA[FightClb]]></dc:creator><pubDate>Thu, 03 Nov 2011 20:49:20 GMT</pubDate></item></channel></rss>