1 (изменено: nullmdn, 2021-11-06 12:31:30)

Тема: AHK: samp chat hook

Due to the context of the text, Google Translator can't translate it into Russian properly, so it is inevitably written in eng. please understand.

FUNC_ADDTOCHATWND := 0x67650                                ;0.3.DL
dwSAMP := DllCall(GetModuleHandle, Str, "samp.dll")

Chat := New MinHook("", hookAddress , "Chat_Hook")

Chat_Hook(pChat, nType, szText, szPrefix, textColor, prefixColor)
global Chat
DllCall(Chat.original,"UInt",pChat, "UInt",nType,"UInt",szText,"UInt", szPrefix, "UInt", textColor, "UInt", prefixColor)

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.
After searching I found out that this function is the thiscall or fastcall.
I also found some c++ stuff that does what I want. https://www.blast.hk/threads/91079/
According to the link, c++ does hooks like this:

void HOOK_AddChatMessage(void* pChat, int nType, const char* szText, const char* szPrefix, unsigned long textColor, unsigned long prefixColor) {
    std::cout << "<" << std::string_view{ ((szPrefix) ? szPrefix : "") } << ">: " << std::string_view{ szText } << 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

How do I convert that _asm part to ahk? I hope someone can help me.