I injected a dll into a game client and hooked send/recv using Easyhook. I can easily monitor the packets that the client send to the server and receive from the server. I want to send my own packets so I made a function like this :
public static void SendPacket()
{
string packet= "dance emotion packet";
byte[] byData = System.Text.Encoding.ASCII.GetBytes(packet);
IntPtr unmanagedPointer = Marshal.AllocHGlobal(byData.Length);
Marshal.Copy(byData, 0, unmanagedPointer, byData.Length);
send(socket, unmanagedPointer, byData.Length, 0);
}
I think the program sends the packet just fine but I don't receive anything from the server. For example if I send a packet to do a dance emotion, the server doesn't respond. The interesting thing is when I do something in the client (for example open a shop or move or anything that sends a packet to the server) the server responds to the dance packet that I sent before using the SendPacket() function in my injected dll.
So the problem is either my dll can't send the packet or the server doesn't respond. Anyone have a solution for this?
Thanks in advance.