<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: samp chat hook]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=16711</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=16711&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: samp chat hook».]]></description>
		<lastBuildDate>Sat, 06 Nov 2021 08:29:21 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[AHK: samp chat hook]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=150505#p150505</link>
			<description><![CDATA[<p>Due to the context of the text, Google Translator can&#039;t translate it into Russian properly, so it is inevitably written in eng. please understand.</p><div class="codebox"><pre><code>FUNC_ADDTOCHATWND := 0x67650                                ;0.3.DL
dwSAMP := DllCall(GetModuleHandle, Str, &quot;samp.dll&quot;)
hookAddress := dwSAMP + FUNC_SAMP_SHOWDIALOG

Chat := New MinHook(&quot;&quot;, hookAddress , &quot;Chat_Hook&quot;)
Chat.Enable()
Return

Chat_Hook(pChat, nType, szText, szPrefix, textColor, prefixColor)
{
global Chat
Chat.Disable()
DllCall(Chat.original,&quot;UInt&quot;,pChat, &quot;UInt&quot;,nType,&quot;UInt&quot;,szText,&quot;UInt&quot;, szPrefix, &quot;UInt&quot;, textColor, &quot;UInt&quot;, prefixColor)
Chat.Enable()
Return
}</code></pre></div><p>I want to save all chat output from the server. I checked that the hook are properly installed. However, after installing the hook, the chat is not output at all in the game.<br />After searching I found out that this function is the thiscall or fastcall.<br />I also found some c++ stuff that does what I want. <a href="https://www.blast.hk/threads/91079/">https://www.blast.hk/threads/91079/</a><br />According to the link, c++ does hooks like this:</p><div class="codebox"><pre><code>void HOOK_AddChatMessage(void* pChat, int nType, const char* szText, const char* szPrefix, unsigned long textColor, unsigned long prefixColor) {
    std::cout &lt;&lt; &quot;&lt;&quot; &lt;&lt; std::string_view{ ((szPrefix) ? szPrefix : &quot;&quot;) } &lt;&lt; &quot;&gt;: &quot; &lt;&lt; std::string_view{ szText } &lt;&lt; std::endl;
}

void __declspec(naked) HOOK_Raw_AddChatMessage(void) {
    static void* pChat;
    static int nType;
    static const char* szText;
    static const char* szPrefix;
    static unsigned long textColor, prefixColor;
    __asm {
        // Вытаскиваем все аргументы со стека
        mov eax, [esp + 0x04]
        mov nType, eax
        mov eax, [esp + 0x08]
        mov szText, eax
        mov eax, [esp + 0x0C]
        mov szPrefix, eax
        mov eax, [esp + 0x10]
        mov textColor, eax
        mov eax, [esp + 0x14]
        mov prefixColor, eax
        pushad // Сохраняем все регистры
    }

    HOOK_AddChatMessage(pChat, nType, szText, szPrefix, textColor, prefixColor);

    __asm {
        popad // вытаскиваем сохраненные регистры
        // Прыгаем в трамплин для продолжения исполнения. Если не нужно продолжать исполнение - нужно поставить опкод ret
        jmp pOriginalFunction
    }
}</code></pre></div><p>How do I convert that _asm part to ahk? I hope someone can help me.</p>]]></description>
			<author><![CDATA[null@example.com (nullmdn)]]></author>
			<pubDate>Sat, 06 Nov 2021 08:29:21 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=150505#p150505</guid>
		</item>
	</channel>
</rss>
