在下面的截获函数中,我有buff
一个指向缓冲区的指针,如何在不创建自己的新缓冲区的情况下更改数据?
int WINAPI OwnRecv(SOCKET s, char FAR *buff, int len, int flags)
{
if(s == ServerSocket)
{
int received = pTrampolineRecv(s, buff, len, flags);
if(received <= 0)
{
return received;
}
unsigned char ReceiveBuffer[1024]; // how can i avoid creatin this by changing buff directly?
do_decrypt((const unsigned char *) buff, ReceiveBuffer, received, KeyTest, NULL);
buff = (char *) ReceiveBuffer;
return received;
}
return pTrampolineRecv(s, buff, len, flags);
}
更新
我添加了我的do_decrypt
功能
bool do_decrypt(const unsigned char *in, unsigned char *out, int inlen)
{
int buflen, tmplen;
if(!EVP_DecryptUpdate(&Decrypt_ctx, out, &buflen, in, inlen))
{
return false;
}
if(!EVP_DecryptFinal_ex(&Decrypt_ctx, out + buflen, &tmplen))
{
return false;
}
return true;
}