在下面截取的函數中,我有buff
作爲指向緩衝區的指針,如何在不創建新的自己的緩衝區的情況下更改數據?從指針C++中更改數據
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);
}
UPD
我說我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;
}
你的意思是說你想改變'buff'中的數據嗎? –
你想在這裏解決什麼問題?也就是說,爲什麼要試圖避免在堆棧上創建緩衝區? – Greg
您正在將單位化的「int bufflen」傳遞給「EVP_DecryptUpdate」,這可能需要輸出緩衝區長度。 Roman,你需要學習基本的C++課程,而不是在SO上提問。 –