簡體   English   中英

模擬數據包發送和接收

[英]Simulate packet send and recv

我已經將發送和接收功能掛接到了游戲過程中。 現在,我可以處理發送的內容和接收的內容。

我的職能是:

int __stdcall nSend(SOCKET s, char *buf, int len,int flags)
{
    UnHookFunction("ws2_32.dll", "send", KSendHook);   
    int result = send(s, buf, len, flags); // Send data 
    HookFunction("ws2_32.dll", "send", (LPVOID*) nSend, KSendHook);

    return result; 
}

int __stdcall nRecv(SOCKET s, char *buf, int len, int flags)
{
    UnHookFunction("ws2_32.dll", "recv", KRecvHook); 
    int result = recv(s, buf, len, flags); // Receive data
    HookFunction("ws2_32.dll", "recv", (LPVOID*) nRecv, KRecvHook);

    return result;
}

我的問題是:

我迷上了這個函數,所以我只能解釋和修改發送和接收的內容。 我需要像游戲一樣發送新的數據包結構。 使用相同的插座。

我如何模擬鈎子函數的相同套接字的send和recv?

調用掛鈎的接收函數時,請根據需要調用實際的發送和接收函數。 當您有數據要返回給調用方時,請將其返回給調用方。 調用send時,獲取發送的數據,確定是否要將任何內容發送到服務器,然后根據需要調用send和receive來與服務器對話。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM