Ayyıldız2 | 2008 TR Yapısı • 1-99 Orta Emek Destan • Oto Avsız • 10 Temmuz 21:00 HEMEN TIKLA!
I`m trying to hook TPacketGCChat from a Pserver to get the chat string. Why chat string? Because, on the server, I can use the command /find metin. It search for me on whole map for the nearest metin and send the coordinate in the chat. Thats why I want go get the Chat String and after I got the coordinate, I use "SetPixelPosition" to teleport me to the Metin stone. Thats the code I started with help from the Internet. But I dont know when I inject the dll, how I can use the function to get the coordinate.
PS: I have the key to pack&unpack the whole client. So I have access to python part. Maybe there is a better way instead of hooking the function
PS: I have the key to pack&unpack the whole client. So I have access to python part. Maybe there is a better way instead of hooking the function
C++:
#include "pch.h"
#include "header.h"
#include <iostream>
using namespace std;
static BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
struct TPacketHeader {
BYTE type;
WORD size;
};
struct TPacketGCChat
{
BYTE header;
WORD size;
BYTE type;
DWORD dwVID;
BYTE bEmpire;
};
int (*oldRecv)(int size, char* pDestBuf);
static int WINAPI RecvHook(int size, char* pDestBuf)
{
TPacketHeader* header = reinterpret_cast<TPacketHeader*>(pDestBuf);
if (header->size == 4)
{
TPacketGCChat* kChat = reinterpret_cast<TPacketGCChat*>(pDestBuf);
char buf[1024 + 1];
size_t uChatSize = kChat->size - sizeof(*kChat);
buf[uChatSize] = '\0';
strncpy(buf, pDestBuf + sizeof(TPacketGCChat), uChatSize);
cout << buf << endl;
}
return oldRecv(size, pDestBuf);
}