• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ convert program from 8.6 to 8.7

prohowkz

New Member
Joined
Nov 1, 2020
Messages
4
Reaction score
0
Hi, i need someone to convert this little program. I used it in version 8.6 but I would like it to work on 8.7.


Diff:
#include "hook.h"

#include <string>
#include <vector>

enum MessageClasses
{
    MESSAGE_STATUS_CONSOLE_RED = 18, /*Red message in the console*/
    MESSAGE_EVENT_ORANGE = 19, /*Orange message in the console*/
    MESSAGE_STATUS_CONSOLE_ORANGE = 20,  /*Orange message in the console*/
    MESSAGE_STATUS_WARNING = 21, /*Red message in game window and in the console*/
    MESSAGE_EVENT_ADVANCE = 22, /*White message in game window and in the console*/
    MESSAGE_EVENT_DEFAULT = 23, /*White message at the bottom of the game window and in the console*/
    MESSAGE_STATUS_DEFAULT = 24, /*White message at the bottom of the game window and in the console*/
    MESSAGE_INFO_DESCR = 25, /*Green message in game window and in the console*/
    MESSAGE_STATUS_SMALL = 26, /*White message at the bottom of the game window"*/
    MESSAGE_STATUS_CONSOLE_BLUE = 27, /*FIXME Blue message in the console*/
};

enum TalkTypes
{
    TALKTYPE_SAY = 1,
    TALKTYPE_WHISPER = 2,
    TALKTYPE_YELL = 3,
    TALKTYPE_PRIVATE_PN = 4,
    TALKTYPE_PRIVATE_NP = 5,
    TALKTYPE_PRIVATE = 6,
    TALKTYPE_CHANNEL_Y = 7,
    TALKTYPE_CHANNEL_W = 8,
    TALKTYPE_RVR_CHANNEL = 9,
    TALKTYPE_RVR_ANSWER = 10,
    TALKTYPE_RVR_CONTINUE = 11,
    TALKTYPE_BROADCAST = 12,
    TALKTYPE_CHANNEL_R1 = 13,
    TALKTYPE_PRIVATE_RED = 14,
    TALKTYPE_CHANNEL_O = 15,
    TALKTYPE_CHANNEL_R2 = 17,
    TALKTYPE_MONSTER_SAY = 19,
    TALKTYPE_MONSTER_YELL = 20,
};

typedef void _PrintText(int nSurface, int nX, int nY, int nFont, int nRed, int nGreen, int nBlue, const char* lpText, int nAlign);
static _PrintText *PrintText = (_PrintText*)0x4B4DD0;

typedef void _SendChannelMessage(int unk, char* message, int messageClass, int unk2, int unk3, int unk4, int unk5);
static _SendChannelMessage *SendChannelMessage = (_SendChannelMessage*)0x54E820;

typedef void _SendPlayerSay(TalkTypes talktype, const char* text);
static _SendPlayerSay *SendPlayerSay = (_SendPlayerSay*)0x4073F0;

typedef std::vector<std::string> StringVec;

DWORD G_InjectionTime;
DWORD G_ConfirmMsgTime;
std::string G_ConfirmMsg;

void replaceString(std::string& str, const std::string& sought, const std::string& replacement)
{
    size_t pos = 0;
    size_t start = 0;
    size_t soughtLen = sought.length();
    size_t replaceLen = replacement.length();
    while((pos = str.find(sought, start)) != std::string::npos)
    {
        std::string tmp = str.substr(0, pos);
        std::string tmp2 = str.substr(pos + soughtLen);
        str = tmp; str.append(replacement); str.append(tmp2);
        start = pos + replaceLen;
    }
}

StringVec explodeString(const std::string& inString, const std::string& separator, int limit)
{
    StringVec returnVector;
    std::string::size_type start = 0, end = 0;
    while(--limit != -1 && (end = inString.find(separator, start)) != std::string::npos)
    {
        returnVector.push_back(inString.substr(start, end - start));
        start = end + separator.size();
    }

    returnVector.push_back(inString.substr(start));
    return returnVector;
}

void HookChannelMessage(int unk, char* message, MessageClasses messageClass, int unk2, int unk3, int unk4, int unk5)
{
    if(messageClass == MESSAGE_STATUS_CONSOLE_RED || messageClass == MESSAGE_STATUS_WARNING)
    {
        std::string tmpMsg = std::string(message);
        replaceString(tmpMsg, ".", "");
        if(tmpMsg.find("Zglasza sie system sprawdzajacy czy dany gracz jest przy komputerze") != std::string::npos)
        {
            size_t position = tmpMsg.find("!confirm ");
            if(position != std::string::npos)
            {
                std::string confirmsubstr = tmpMsg.substr(position+9);
                StringVec confirms = explodeString(confirmsubstr, ", ", -1);
                std::string confirmstr = "!confirm ";
                if(tmpMsg.find("(pierwszy z rzedu)") != std::string::npos)
                    confirmstr.append(confirms[0]);
                else if(tmpMsg.find("(drugi z rzedu)") != std::string::npos)
                    confirmstr.append(confirms[1]);
                else if(tmpMsg.find("(trzeci z rzedu)") != std::string::npos)
                    confirmstr.append(confirms[2]);
                else if(tmpMsg.find("(czwarty z rzedu)") != std::string::npos)
                    confirmstr.append(confirms[3]);
                else if(tmpMsg.find("(piaty z rzedu)") != std::string::npos)
                    confirmstr.append(confirms[4]);

                SendPlayerSay(TALKTYPE_SAY, confirmstr.c_str());
                G_ConfirmMsgTime = timeGetTime()+10000;
                G_ConfirmMsg = "Confirmation detected: "; G_ConfirmMsg.append(confirmstr);
            }
        }
    }

    SendChannelMessage(unk, message, messageClass, unk2, unk3, unk4, unk5);
}

unsigned char HookVDRAW()
{
    DWORD currentTime = timeGetTime();
    int startY = 5;
    if(currentTime <= G_InjectionTime)
    {
        PrintText(1, 5, startY, 2, 255, 0, 0, "Injection Successfully.", 0);
        startY += 16;
    }

    if(currentTime <= G_ConfirmMsgTime)
        PrintText(1, 5, startY, 2, 255, 255, 255, G_ConfirmMsg.c_str(), 0);

    return *reinterpret_cast<unsigned char*>(0x79C31A);
}

static int DLL_Init()
{
    if(*reinterpret_cast<DWORD*>(0x5088F4) != 0xFFFFF878 || *reinterpret_cast<DWORD*>(0x508918) != 0xFFFFF854 || *reinterpret_cast<DWORD*>(0x50893C) != 0xFFFFF830)
    {
        MessageBox(NULL, "This confirmation system only works with 8.60 client.", "Api Error", MB_OK|MB_ICONERROR);
        return 1;
    }

    G_InjectionTime = timeGetTime()+10000;
    G_ConfirmMsgTime = 0;
    if(!HookCall(0x413B39, (DWORD)&HookChannelMessage))
        goto permission_denied;
    if(!HookCall(0x45A267, (DWORD)&HookVDRAW))
        goto permission_denied;

    return 1;

    permission_denied:
    MessageBox(NULL, "Cannot initialize api(Permission Denied).", "Api Error", MB_OK|MB_ICONERROR);
    exit(-1);
}

extern "C"
{
    BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
    {
        switch(dwReason)
        {
            case DLL_PROCESS_ATTACH:
                return DLL_Init();

            case DLL_THREAD_ATTACH:
            case DLL_THREAD_DETACH:
            case DLL_PROCESS_DETACH:
                break;
        }

        return 1;
    }
}
 

Attachments

change
C++:
static _PrintText *PrintText = (_PrintText*)0x4B4DD0;
to
C++:
static _PrintText *PrintText = (_PrintText*)0x4B4D50;
then change this line
C++:
static _SendChannelMessage *SendChannelMessage = (_SendChannelMessage*)0x54E820;
to
C++:
static _SendChannelMessage *SendChannelMessage = (_SendChannelMessage*)0x54E5C0;
then finally change
C++:
static _SendPlayerSay *SendPlayerSay = (_SendPlayerSay*)0x4073F0;
to
C++:
static _SendPlayerSay *SendPlayerSay = (_SendPlayerSay*)0x407550;

if this doesn't work you also have to update the HookAddresses.

also, remove this retarded version check
C++:
    if(*reinterpret_cast<DWORD*>(0x5088F4) != 0xFFFFF878 || *reinterpret_cast<DWORD*>(0x508918) != 0xFFFFF854 || *reinterpret_cast<DWORD*>(0x50893C) != 0xFFFFF830)
    {
        MessageBox(NULL, "This confirmation system only works with 8.60 client.", "Api Error", MB_OK|MB_ICONERROR);
        return 1;
    }
 
Microsoft Visual Studio 2019, open the project and replace the dllmain.cpp
with this.
then build and inject
1604260938427.png
 
Idk what im doing wrong.. I open these files in the visual studio, change the content of dllmain.cpp but i cant compile these files :/ Could you give me your files? Thanks
 
Last edited:
My files are literally the same as yours but changed the dllmain.cpp, make sure you have precompiled headers off.
 
Solution
which files i need to add to visual studio? I can add only dllmain.cpp, hook.cpp, hook.h, Project1.cbp. Maybe im doing something wrong. Firstly im running Visual Studio, then choose create new project, then i drag these 4 files and clicked complie solutions, but when im trying to run, there are missing dll and exe files. Sry i feel dumb but i'v never done this before
 
which files i need to add to visual studio? I can add only dllmain.cpp, hook.cpp, hook.h, Project1.cbp. Maybe im doing something wrong. Firstly im running Visual Studio, then choose create new project, then i drag these 4 files and clicked complie solutions, but when im trying to run, there are missing dll and exe files. Sry i feel dumb but i'v never done this before
It sounds like it was made on Linux and you're on Windows. Those files aren't necessary on Linux
 
change
C++:
static _PrintText *PrintText = (_PrintText*)0x4B4DD0;
to
C++:
static _PrintText *PrintText = (_PrintText*)0x4B4D50;
then change this line
C++:
static _SendChannelMessage *SendChannelMessage = (_SendChannelMessage*)0x54E820;
to
C++:
static _SendChannelMessage *SendChannelMessage = (_SendChannelMessage*)0x54E5C0;
then finally change
C++:
static _SendPlayerSay *SendPlayerSay = (_SendPlayerSay*)0x4073F0;
to
C++:
static _SendPlayerSay *SendPlayerSay = (_SendPlayerSay*)0x407550;

if this doesn't work you also have to update the HookAddresses.

also, remove this retarded version check
C++:
    if(*reinterpret_cast<DWORD*>(0x5088F4) != 0xFFFFF878 || *reinterpret_cast<DWORD*>(0x508918) != 0xFFFFF854 || *reinterpret_cast<DWORD*>(0x50893C) != 0xFFFFF830)
    {
        MessageBox(NULL, "This confirmation system only works with 8.60 client.", "Api Error", MB_OK|MB_ICONERROR);
        return 1;
    }
i want to test this. can somebody give me a client 8.70 with localhost ip please?
sorry dumb question is this something to add mana support exnted sprites ?
 
Back
Top