I just registered here to ask/report this. This is my code:
for (DWORD i = 0; i < ptTable->dwNumEntries; i++)
{ MIB_TCPROW row;
row.dwLocalAddr = ptTable->table[i].dwLocalAddr;
row.dwLocalPort = ptTable->table[i].dwLocalPort;
row.dwRemoteAddr = ptTable->table[i].dwRemoteAddr;
row.dwRemotePort = ptTable->table[i].dwRemotePort;
row.dwState = ptTable->table[i].dwState;
if (row.dwRemoteAddr)
{
std::unique_ptr<UCHAR> rod = std::unique_ptr<UCHAR>(new UCHAR[rodSize]());
ret = GetPerTcpConnectionEStats
} ((PMIB_TCPROW)&row, TcpConnectionEstatsData, NULL, 0, 0, 0, 0, 0, (PUCHAR)rod.get(), 0, rodSize);
}
Whenever GetPerTcpConnectionEStats is called, the buffer gets freed (the bytes turn into 0xdd 0xdd...).
Note: The problem does not always occur. Within the same debuging session, it happens about 20 times out 100 "for loop" iterations given that every iteration calls GetPerTcpConnectionEStats twice, and only the first call (the one above) causes it.
Also the return from GetPerTcpConnectionEStats is NO_ERROR in all cases. Is it my code that's causing the problem or GetPerTcpConnectionEStats itself is broken?
Cheers