繁体   English   中英

是否有可能在传递给函数的输入缓冲区中写入超出预期的值? (没有堆栈溢出)

[英]Is it possible to write in input buffer passed into function more than was expected? (no stack overflow)

我正在做一些数据包翻译补丁。 我的dll注入中文游戏,钩住recv,侦听数据包并转换以中文接收的字符串。 我一直在编码,编码和编码……直到我发现我应该如何用buf来写超过数据包长度的东西?

int __stdcall Hooked_recv(SOCKET s, char *buf, int len, int flags)
{
    h_recv.PreHook();

    int ret_val = recv(s, buf, len, flags);
//ret_val is the number of bytes received. Ok, I can increase it, but...
//what to do with buf? Sure I can write there as much as no access violation appears.
//but I need a safe way.
//I guess if I do buf = new char[NEW_SIZE] then caller will fail to read buf because of pointer changed?
//what could I do to make received packet longer?
//I no want to reverse exe and increase buffer in hex editor. at least for now.

    h_recv.PostHook();

    return ret_val;
}

尽可能多地填充缓冲区。 如果有剩余,请将其保存以供下一次对挂钩的接收函数的调用(首先输入,如果已满,则重复保存新的剩余)。 您将需要使用缓冲区,这是不可避免的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM