<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11927</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11927&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как передать строку в DllCall по ссылке и получить строку назад».]]></description>
		<lastBuildDate>Sun, 21 Aug 2016 03:38:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106946#p106946</link>
			<description><![CDATA[<p>StrLen тоже только до 0 меряет. Так что всё там есть. А убрав &quot;cp0&quot;, вы поменяли кодировку чтения на Юникод, и этот нулевой байт стал восприниматься как часть кода символа. Т.е. строка у вас в кодировке ANSI, а вы её читаете как юникодную. Короче, петрушка получается. Если из DLL выдаётся не осмысленный текст, а набор байтов, то проще с ним работать в переменной StrOut, нет смысла его читать в другую.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sun, 21 Aug 2016 03:38:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106946#p106946</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106939#p106939</link>
			<description><![CDATA[<p><strong>YMP</strong> ее там нет, длина&nbsp; ХЭШ суммы StrLen(OutText) меньше чем Result.</p><p>Что бы она там появиласть пришлось поменять одну строку присвоения значения, убрала&nbsp; &quot;CP0&quot;:<br /></p><div class="codebox"><pre><code>OutText := StrGet(ptr_StrOut, Result)</code></pre></div><p>Спасибо за помощь <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Sat, 20 Aug 2016 17:06:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106939#p106939</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106937#p106937</link>
			<description><![CDATA[<p>Она там и будет. Но MsgBox не воспроизведёт то, что идёт после 0.</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 20 Aug 2016 16:22:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106937#p106937</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106934#p106934</link>
			<description><![CDATA[<p><strong>YMP</strong> речь об одной строке которую возвращает функция из DLL.<br />Алгоритм следующий есть исходная строка <strong>StrIn</strong> ее и ее длину <strong>StrLen(StrIn</strong>) передаем в функцию из DLL, назад получаем ХЭШ этой строки в переменную <strong>StrOut</strong>, также функция из DLL вернет длину этой ХЭШ строки в переменную <strong>Result</strong>.</p><p>В переменной <strong>StrOut</strong> могут быть произвольные символы в том числе и 00:HEX.</p><p>Я реализую алгоритм подсчета SHA-3 <a href="https://ru.wikipedia.org/wiki/SHA-3">https://ru.wikipedia.org/wiki/SHA-3</a><br />мне внутри переменной <strong>StrOut</strong> нужна ХЭШ сумма.</p><p>Как мне получить полностью эту ХЭШ сумму?</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Sat, 20 Aug 2016 15:50:05 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106934#p106934</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106931#p106931</link>
			<description><![CDATA[<p>Ну, вообще-то 0 — это конец строки. Так что всё законно. Поэтому уточните, речь о строке или о нескольких строках?</p>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 20 Aug 2016 15:06:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106931#p106931</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106929#p106929</link>
			<description><![CDATA[<p><strong>YMP</strong> Есть мини проблема, код работает пока в выходном потоке в переменной <strong>StrOut</strong> нет символа с кодом 00:HEX (это нулевой символ). Вот пример в HEX:<br />33 dc 44 21 00 33 1b 35 - так должно быть<br />33 dc 44 21&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- так получается (обрывается на нулевом символе)</p><p>Менять кодировку с &quot;cp0&quot; на что-то другое результата не дает. <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /><br />Как сделать чтобы все символы записались в <strong>StrOut</strong> и даже нулевой?</p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Sat, 20 Aug 2016 14:36:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106929#p106929</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106920#p106920</link>
			<description><![CDATA[<p><strong>YMP</strong> Спасибо, код заработал. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Sat, 20 Aug 2016 10:25:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106920#p106920</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106917#p106917</link>
			<description><![CDATA[<div class="codebox"><pre><code>
; ---- исходные данные ----
StrIn := &quot;AbCdEfGh&quot;        ; исходная строка которую нужно передать в DLL функцию
ptr_StrIn := &amp;StrIn        ; указатель на строку StrIn
VarSetCapacity(StrOut, 20) ; переменная куда поместим результат после вызова DLL, для нее зарезервировали 20 байт
ptr_StrOut := &amp;StrOut      ; указатель на строку StrOut

Result := DllCall(&quot;test.dll\testfunc&quot;, &quot;astr&quot;, StrIn,  UInt64, StrLen(StrIn),  &quot;ptr&quot;, ptr_StrOut, &quot;CDecl&quot;)

OutText := StrGet(ptr_StrOut, Result, &quot;cp0&quot;)

MsgBox, DLL вернула значение: %Result% , ErrorLevel: %ErrorLevel% , значение StrOut после вызова: %OutText%
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (YMP)]]></author>
			<pubDate>Sat, 20 Aug 2016 06:38:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106917#p106917</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как передать строку в DllCall по ссылке и получить строку назад]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=106913#p106913</link>
			<description><![CDATA[<p>Есть переменная со строкой, ее нужно передать внутрь функции из DLL библиотеки и назад из этой же DLL нужно получить строку. Передачу <strong>желательно</strong> делать по ссылке, но если это сложно то можно просто передать саму строку.</p><p>Исходная строка что передали внутрь DLL приходит какая-то кривая, при вызове <strong>MessageBox </strong>из DLL выводится белеберда.<br />Результат что возвращает DLL значение 8 - это длина строки, она верная, ErrorLevel = 0 - значит все отработало нормально, но вот значение <strong>StrOut </strong>после вызова пустое, там ничего нет. <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /></p><p>Помогите разобрать что нужно поправить чтобы все заработало, чтобы строка принималась и записывалась в <strong>StrOut </strong>. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>код AutoHotkey:<br /></p><div class="codebox"><pre><code>
; ---- исходные данные ----
StrIn := &quot;AbCdEfGh&quot;        ; исходная строка которую нужно передать в DLL функцию
ptr_StrIn := &amp;StrIn        ; указатель на строку StrIn
VarSetCapacity(StrOut, 20) ; переменная куда поместим результат после вызова DLL, для нее зарезервировали 20 байт
ptr_StrOut := &amp;StrOut      ; указатель на строку StrOut

Result := DllCall(&quot;test.dll\testfunc&quot;, StrP, ptr_StrIn,  UInt64, StrLen(StrIn),  StrP, ptr_StrOut, &quot;CDecl&quot;)

MsgBox, DLL вернула значение: %Result% , ErrorLevel: %ErrorLevel% , значение StrOut после вызова: %StrOut%
</code></pre></div><p>код функции в DLL (test.c - исходник на C++):<br /></p><div class="codebox"><pre><code>
#include &lt;Windows.h&gt; // для MessageBox()

long int testfunc(const unsigned char *in, unsigned long long int inLen, unsigned char *out)
{
    char str[20] = &quot;&quot;;
    for(unsigned long long int i = 0; i &lt; inLen; i++)
    {
        out[i] = in[i];
        str[i] = in[i];
    }
    MessageBox(NULL, str, &quot;String In&quot;, MB_OK);
    return inLen;
}
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Elena)]]></author>
			<pubDate>Fri, 19 Aug 2016 20:56:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=106913#p106913</guid>
		</item>
	</channel>
</rss>
