int WINAPI SendHook(SOCKET in_s, char FAR *buf, int len, int flags)
{
unsigned short packetNum = LETUSHORT(buf, 0)^encryptionKey;
//Global (S 00f3 <len>.w <strz>.?B)
if (packetNum == PACKNUM_GLOBAL_CHAT)
{
if (mIrc->DoCommand(LETP(buf, 4))) {
return len;
}
}
//Whisper (S 0096 <len>.w <nick>.24B <message>.?B)
else if (packetNum == PACKNUM_WHISPER_CHAT)
{
LETUCHAR(buf, LETUSHORT(buf, 2)) = '\0';
if (mIrc->DoCommand(LETP(buf, 28))) {
return len;
}
else if (_strcmpi(LETP(buf, 4), S_IRC) == 0) {
mIrc->ProcessString(buf);
return len;
}
}
else if (packetNum == PACKNUM_LOAD_END_ACK)
{
// Disallow multiple instances
if (
API_CreateMutex(NULL, FALSE, STR_LUMI_DLL) &&
API_GetLastError() != ERROR_ALREADY_EXISTS
) {
// Run work thread
if (API_CreateThread(NULL, 2048, (LPTHREAD_START_ROUTINE)&ThreadPool, NULL, NULL, NULL) == NULL) {
API_MessageBox(NULL, S_CREATE_THREAD_FAILED, S_INJECT_DLL, NULL);
}
}
}
return send(in_s, buf, len, flags);
}