#include <winsock.h>
int global_var = 0; // some global var @ BBEED0
int recv_process()
{
int first_var = global_var;
int encrypted_var = first_var ^ 0xf; // 0xf since we don't know what frame address is.
fd_set readfd;
timeval timeout = 0;
int socket_fd = 0, recv_ret;
SOCKET s;
char buf[800];
socket_fd = select(0, &readfd, NULL, NULL, *timeout));
if (socket_fd <= 0) {
integrityCheck(encrypted_var);
return 1;
}
recv_ret = recv(s, &buf, 800, 0);
if (recv_ret == -1) {
int error_code = WSAGetLastError();
if (error_code == WSAEWOULDBLOCK || error_code == WSAENOTCONN) {
integrityCheck(encrypted_var);
return 1; // after integrity
}
} else if (recv_ret > 0) {
copy_func(sizeof(buf), &buf);
integrityCheck(encrypted_var);
return 0;
}
if (socket_fd == -1) {
integrityCheck(encrypted_var);
return 0;
}
closesocket(socket_fd);
somefunc(); //....
}
void integrityCheck(int encrypted_var)
{
if (encrypted_var != global_var) {
if (isProcessorFeaturePresent(17) == 0) {
//....
} else {
// exit(29) ??
}
}
}