Hello. I am using Nektra's Deviare to hook winsock's send method calls. My ideia is to learn to also send messages through the same socket than the original application. So what I'm doing is when i detect the first call to send message, I save the socket id(the first argument of the send function), so I can use it later.
So here is my code:
uint socket = 0;
[DllImport("Ws2_32.dll")]
private static extern int send(uint socket, string buf, int len, int flags);
void _proxy_OnFunctionCalled(DeviareTools.IProcess proc, DeviareParams.ICallInfo callInfo, Deviare.IRemoteCall rCall)
{
socket = (uint)callInfo.Params.get_Item(0).Value;
}
and later
int ret = send(socket, "ABC", 3, 0);
MessageBox.Show(ret.ToString());
This last messagebox is poping up always -1. Why should be it?
Thanks
edit: calling WSAGetLastError() returns 2. Which I do not know what it means, as it doesn't seem to appear on msdn.