//00420ED0 addr da AddMessage na TMSrv 7.56
BOOL CPSock::AddMessage(char* pMsg, int Size)
{
int Keyword = 0; //local 2
if (SendQueue[0] != 0)
{
//00420F03
if (SendCount > 15)
{
//00420F10
if (EncodeKey != 0)
{
//00420F19
int encKey = EncodeKey; //local 3
char key = (char)(encKey); //local 4
//00420F28
if (key == 0)
key = (char)(encKey + 3);
//00420F39
if (key == 0)
key = 13;
//00420F45
Keyword = ((encKey + 2) + (encKey + 3)) - ((encKey + 1) * key);
if (Keyword == 0)
Keyword = (char)(encKey);
//00420F77
Keyword ^= 255;
}
//00420F85
else
{
if ((SendQueue[15] % 2) != 0) //004207F1
Keyword = ((SendQueue[13] + SendQueue[11]) - SendQueue[9]) + 4;
else //00420812
Keyword = (SendQueue[5] + (SendQueue[1] + SendQueue[3])) - 87;
Keyword ^= 255;
}
}
//00420FED
else if (SendQueue[0] != 0)
{
if (SendCount > 15)
{
if ((SendQueue[15] % 2) != 0) //00421005
Keyword = ((SendQueue[13] + SendQueue[11]) - SendQueue[9]) + 4;
else //0042103E
Keyword = (SendQueue[5] + (SendQueue[1] + SendQueue[3])) - 87;
Keyword ^= 255;
}
//0042106A
else
{
Keyword = SendQueue[SendCount];
Keyword ^= 255;
SendCount++;
}
}
}
//00421096
BOOL err = AddMessage(pMsg, Size, Keyword);
return err;
}
//00421140 addr da AddMessage na TMSrv 7.56
BOOL CPSock::AddMessage(char* pMsg, int Size, int sendKeyWord)
{
//0042115D
MSG_STANDARD packet = *(MSG_STANDARD*)(pMsg); //local 2
if (Sock <= EMPTY_SOCKET)
{
ErrCount = 10;
return FALSE;
}
//0042117C
if (nSendPosition + Size >= SEND_BUFFER_SIZE)
{
ErrCount = 1;
return FALSE;
}
//0042119E
unsigned char iKeyWord = sendKeyWord; //local 3
if (sendKeyWord == 0)
iKeyWord = rand() % 256;
//004211C0
unsigned char KeyWord = pKeyWord[iKeyWord][0]; //local 4
unsigned char checkSum = 0; //local 5
packet.Size = Size;
packet.KeyWord = iKeyWord;
packet.CheckSum = checkSum;
packet.ClientTick = CurrentTime;
LastSendTime = CurrentTime;
unsigned char Sum1 = 0; //local 6
unsigned char Sum2 = 0; //local 7
int pos = KeyWord; //local 8
for (int i = 4; i < Size; i++, pos++) //local 9
{
Sum1 = Sum1 + pMsg[i];
int qKeyWord = pos % 256; //local 10
unsigned char Trans = pKeyWord[qKeyWord][1]; //local 11
int mod = i & 3; //local 12
if (mod == 0)
pSendBuffer[i + nSendPosition] = pMsg[i] + (Trans * 2);
else if (mod == 1)
pSendBuffer[i + nSendPosition] = pMsg[i] - (Trans >> 3);
else if (mod == 2)
pSendBuffer[i + nSendPosition] = pMsg[i] + (Trans * 4);
else if (mod == 3)
pSendBuffer[i + nSendPosition] = pMsg[i] - (Trans >> 5);
Sum2 = Sum2 + (pSendBuffer[i + nSendPosition]);
}
//00421350
checkSum = Sum2 - Sum1;
packet.CheckSum = checkSum;
//00421370
memcpy(&pSendBuffer[nSendPosition], pMsg, 4);
nSendPosition = nSendPosition + Size;
return TRUE;
}
Como de costume o ideal é fazer uma revisão