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
-
confirm.rar47 KB · Views: 16 · VirusTotal