<?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[Verlust von Information beim Cast eines Bytebuffer mit int64]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>bisher war ich noch nie in solchen Entwicklerforen unterwegs weil ich meine Probleme normalerweise selbst lösen konnte. Aktuell schreibe ich ein proof of concept für meine Masterarbeit und mir ist dabei ein mir unerklärliches Phänomen aufgefallen:</p>
<p>Beim casten eines ByteBuffers in eine int64, werden mir die letzten 2 Bytes abgeschnitten? Anbei ein Screenshot vom aktuellen Fehler.</p>
<p>Wer von Euch kennt dieses Phänomen und weiß wie man es umgehen kann?</p>
<pre><code class="language-cpp">unsigned __int64 mftReference;

// input ist buffered Stream des typs wifstream und der input im pwszBuffer stimmt auch
if ( input )
{
	input.read ( pwszBuffer , sizeof(unsigned __int64 ));

        //sollte 0x0001000000000024 sein
	mftReference = *(unsigned __int64 *)pwszBuffer;
}
</code></pre>
<p>Bild:<br />
<a href="http://img829.imageshack.us/img829/7840/errorgn.png" rel="nofollow">http://img829.imageshack.us/img829/7840/errorgn.png</a></p>
<p>pwszBuffer ist ein wchar_t * Buffer der teile einer Windows Systemdatei einliest.<br />
mftReference ist als unsigned __int64 deklariert und sollte eigentlich 00 01 00 00 00 00 00 24 sein, und nicht 00 00 00 00 00 00 00 24</p>
<p>Ich hoffe hier kann mir irgendwer helfen <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>
<p>/edit</p>
<p>Im Moment benutze ich den Workaround dass ich die Bytefolge selbst parse</p>
<pre><code class="language-cpp">unsigned __int64 byteToint64LittleEndian ( wchar_t * pwszBuffer )
{
	unsigned __int64 result = 0;
	unsigned __int64 temp = 0;
	result = pwszBuffer[0];
	temp = pwszBuffer[1];
	result = result | temp&lt;&lt;8;
	temp = pwszBuffer[2];
	result = result | temp &lt;&lt; 16;
	temp = pwszBuffer[3];
	result = result | temp&lt;&lt;24;
	temp = pwszBuffer[4];
	result = result | temp&lt;&lt;32;
	temp = pwszBuffer[5];
	result = result | temp&lt;&lt;40;
	temp = pwszBuffer[6];
	result = result | temp&lt;&lt;48;
	temp = pwszBuffer[7];
	result = result | temp &lt;&lt; 56;

	return result;
}
</code></pre>
<p>Das ist aber nicht die Art wie es eigentlich gehen sollte...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/275077/verlust-von-information-beim-cast-eines-bytebuffer-mit-int64</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 07:55:33 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/275077.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Oct 2010 14:47:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Fri, 08 Oct 2010 15:00:45 GMT]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>bisher war ich noch nie in solchen Entwicklerforen unterwegs weil ich meine Probleme normalerweise selbst lösen konnte. Aktuell schreibe ich ein proof of concept für meine Masterarbeit und mir ist dabei ein mir unerklärliches Phänomen aufgefallen:</p>
<p>Beim casten eines ByteBuffers in eine int64, werden mir die letzten 2 Bytes abgeschnitten? Anbei ein Screenshot vom aktuellen Fehler.</p>
<p>Wer von Euch kennt dieses Phänomen und weiß wie man es umgehen kann?</p>
<pre><code class="language-cpp">unsigned __int64 mftReference;

// input ist buffered Stream des typs wifstream und der input im pwszBuffer stimmt auch
if ( input )
{
	input.read ( pwszBuffer , sizeof(unsigned __int64 ));

        //sollte 0x0001000000000024 sein
	mftReference = *(unsigned __int64 *)pwszBuffer;
}
</code></pre>
<p>Bild:<br />
<a href="http://img829.imageshack.us/img829/7840/errorgn.png" rel="nofollow">http://img829.imageshack.us/img829/7840/errorgn.png</a></p>
<p>pwszBuffer ist ein wchar_t * Buffer der teile einer Windows Systemdatei einliest.<br />
mftReference ist als unsigned __int64 deklariert und sollte eigentlich 00 01 00 00 00 00 00 24 sein, und nicht 00 00 00 00 00 00 00 24</p>
<p>Ich hoffe hier kann mir irgendwer helfen <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>
<p>/edit</p>
<p>Im Moment benutze ich den Workaround dass ich die Bytefolge selbst parse</p>
<pre><code class="language-cpp">unsigned __int64 byteToint64LittleEndian ( wchar_t * pwszBuffer )
{
	unsigned __int64 result = 0;
	unsigned __int64 temp = 0;
	result = pwszBuffer[0];
	temp = pwszBuffer[1];
	result = result | temp&lt;&lt;8;
	temp = pwszBuffer[2];
	result = result | temp &lt;&lt; 16;
	temp = pwszBuffer[3];
	result = result | temp&lt;&lt;24;
	temp = pwszBuffer[4];
	result = result | temp&lt;&lt;32;
	temp = pwszBuffer[5];
	result = result | temp&lt;&lt;40;
	temp = pwszBuffer[6];
	result = result | temp&lt;&lt;48;
	temp = pwszBuffer[7];
	result = result | temp &lt;&lt; 56;

	return result;
}
</code></pre>
<p>Das ist aber nicht die Art wie es eigentlich gehen sollte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1962961</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1962961</guid><dc:creator><![CDATA[markus.schmidt84]]></dc:creator><pubDate>Fri, 08 Oct 2010 15:00:45 GMT</pubDate></item><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Fri, 08 Oct 2010 15:54:59 GMT]]></title><description><![CDATA[<p>Ich sehe nicht, wieso die 01 da reinkomen sollte. Bedenke, dass jedes Element von pwszBuffer 2 Bytes groß ist, sodass nur pwszBuffer[0] bis einschließlich pwszBuffer[3] eingelesen werden.</p>
<p>Edit: Dein Workaround ist übrigens fehleranfällig. Wenn du im High Byte mal was stehen hast, kommt nicht mehr das raus, was du willst. Sollte pwszBuffer nicht besser ein char[] statt ein wchar_t[] sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1962984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1962984</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Fri, 08 Oct 2010 15:54:59 GMT</pubDate></item><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Sat, 09 Oct 2010 00:10:38 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>vielen Dank schonmal für die Antwort. Werde es morgen noch ausprobieren... vielleicht hatte ich die ganze Zeit einen Denkfehler drin weil ich halt eben auch nen Unicode String aus der Datei auspacken soll.</p>
<p>Den Bug im Workaround hab ich schon gefunden, wird aber niemals auftreten in meiner Anwendung... habe ihn aber trotzdem beseitigt indem ich das zuvor ge-or'te Feld immer zwangsläufig nulle.</p>
<p>Heute keinen Nerv mehr um weiter zu proggen.. werde es Euch morgen wissen lassen was der Fehler hier war.</p>
<p>Vielen herzlichen Dank für die Hilfe schonmal! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963175</guid><dc:creator><![CDATA[markus.schmidt84]]></dc:creator><pubDate>Sat, 09 Oct 2010 00:10:38 GMT</pubDate></item><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Sat, 09 Oct 2010 00:20:54 GMT]]></title><description><![CDATA[<p>Was Michael meint, ist Folgendes:</p>
<p>Du liest acht wchar_ts in einen Buffer. Diese sind jeweils 2 Byte breit, macht zusammen 16 Byte. Dann interpretierst du das Ganze als 8-Byte-Integer.</p>
<p>Dass nicht der gesamte Inhalt des Buffers im Integer auftaucht, ist wenig verwunderlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963177</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963177</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Sat, 09 Oct 2010 00:20:54 GMT</pubDate></item><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Sat, 09 Oct 2010 10:51:21 GMT]]></title><description><![CDATA[<p>Guten Tag <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>
<p>Das hab ich schon verstanden - kam nur heute noch nicht zum programmieren. Werde gleich mein Problem fixen. Vielen Dank für die Hilfe Jungs &amp; Mädels, manchmal sieht man vor lauter Bäumen den Wald nicht mehr</p>
<p><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/1963255</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963255</guid><dc:creator><![CDATA[markus.schmidt84]]></dc:creator><pubDate>Sat, 09 Oct 2010 10:51:21 GMT</pubDate></item><item><title><![CDATA[Reply to Verlust von Information beim Cast eines Bytebuffer mit int64 on Sun, 10 Oct 2010 18:51:56 GMT]]></title><description><![CDATA[<p>Hallo Zusammen,</p>
<p>wollte es Euch nur nochmal wissen lassen. Der Tipp war goldrichtig und ich hab nebenher noch ein paar andere fixes innerhalb meines Programms eingebaut.</p>
<p>Vielen Dank für alles Leute!</p>
<p>Beste Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963626</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963626</guid><dc:creator><![CDATA[markus.schmidt84]]></dc:creator><pubDate>Sun, 10 Oct 2010 18:51:56 GMT</pubDate></item></channel></rss>