📄 evaimreceive.cpp
字号:
char* fa; fa=(char*)_alloca(len-pos);#else char fa[len-pos];#endif memcpy(fa, buf+pos, len-pos); fontSize = fa[0] & 0x1F; bold = ((fa[0] & 0x20) != 0); italic = ((fa[0] & 0x40) != 0); underline = ((fa[0] & 0x80) != 0); red = fa[1] & 0xFF; green = fa[2] & 0xFF; blue = fa[3] & 0xFF; encoding = ntohs(*(short*)(fa+5) );#ifdef WIN32 char* fn; fn=(char*)_alloca(len-pos-7);#else char fn[len-pos-7];#endif memcpy(fn, fa+7, len-pos-7-1); fn[len-pos-7-1]=0x00; fontName.assign(fn); } }/* =========================================================== */ReceivedQunIMJoinRequest::ReceivedQunIMJoinRequest() : externalID(0), sender(0), type(0), message(""), commander(0), m_Code(0), m_CodeLen(0), m_Token(0), m_TokenLen(0){}// many thanks to starkwong. He found the change of this bit in QQ2006ReceivedQunIMJoinRequest::ReceivedQunIMJoinRequest(const unsigned short imType, const unsigned char * buf, const int len) : externalID(0), sender(0), type(0), message(""), commander(0), m_Code(0), m_CodeLen(0), m_Token(0), m_TokenLen(0){ printf("ReceivedQunIMJoinRequest\n"); for(int i=0; i<len; i++){ if(!(i%8)) printf("\n%d: ", i); printf("%2x ", (uint8_t)buf[i]); } printf("\n\n"); int pos=0; externalID = ntohl(*(unsigned int*)buf); pos+=4; type = buf[pos++]; switch(imType){ case QQ_RECV_IM_ADDED_TO_QUN: sender = READ32(buf+pos); pos+=4; pos++; commander = READ32(buf+pos); pos+=4; break; case QQ_RECV_IM_DELETED_FROM_QUN: sender = READ32(buf+pos); pos+=4; pos++; break; case QQ_RECV_IM_REQUEST_JOIN_QUN: sender = READ32(buf+pos); pos+=4; break; case QQ_RECV_IM_APPROVE_JOIN_QUN: case QQ_RECV_IM_REJECT_JOIN_QUN: commander = READ32(buf+pos); pos+=4; break; case QQ_RECV_IM_SET_QUN_ADMIN: commander = buf[pos++]; // just use the commander variable to save the action. 0:unset, 1:set sender = READ32(buf + pos); // sender is the persion which the action performed on pos += 4; pos++;// unknonw, probably the admin value of the above member break; case QQ_RECV_IM_CREATE_QUN: default: sender = READ32(buf+pos); pos+=4; break; } if(imType != QQ_RECV_IM_DELETED_FROM_QUN){ if(len == pos) { message = ""; return; } unsigned length = (unsigned int)buf[pos++]; char *msg = (char *)malloc((length+1) * sizeof(char)); memcpy(msg, buf + pos, length); msg[length] = 0x00; message.assign(msg); free(msg); pos += length; } m_CodeLen = READ16(buf + pos); pos +=2; setCode(buf+pos, m_CodeLen); pos += m_CodeLen; if(imType == QQ_RECV_IM_REQUEST_JOIN_QUN){ m_TokenLen = READ16(buf + pos); pos +=2; setToken(buf+pos, m_TokenLen); pos += m_TokenLen; }}ReceivedQunIMJoinRequest::ReceivedQunIMJoinRequest( const ReceivedQunIMJoinRequest & rhs ){ *this = rhs;}ReceivedQunIMJoinRequest::~ReceivedQunIMJoinRequest(){ if(m_Code) delete []m_Code; if(m_Token) delete []m_Token;}ReceivedQunIMJoinRequest & ReceivedQunIMJoinRequest::operator =( const ReceivedQunIMJoinRequest & rhs ){ externalID = rhs.getExtID(); sender = rhs.getSender(); type = rhs.getType(); message = rhs.getMessage(); commander = rhs.getCommander(); setCode(rhs.getCode(), rhs.getCodeLength()); setToken(rhs.getToken(), rhs.getTokenLength()); return *this;}void ReceivedQunIMJoinRequest::setCode(const unsigned char *code, const unsigned short len){ if(code && len){ if(m_Code) delete []m_Code; m_CodeLen = len; m_Code = new unsigned char [m_CodeLen]; memcpy(m_Code, code, m_CodeLen); }}void ReceivedQunIMJoinRequest::setToken(const unsigned char *token, const unsigned short len){ if(token && len){ if(m_Token) delete []m_Token; m_TokenLen = len; m_Token = new unsigned char [m_TokenLen]; memcpy(m_Token, token, m_TokenLen); }}/* =========================================================== */SignatureChangedPacket::SignatureChangedPacket( const unsigned char * buf, const int len ){ parseData(buf, len);}SignatureChangedPacket::SignatureChangedPacket( const SignatureChangedPacket & rhs ){ *this = rhs;}SignatureChangedPacket & SignatureChangedPacket::operator =( const SignatureChangedPacket & rhs ){ qq = rhs.getQQ(); time = rhs.getTime(); signature = rhs.getSignature(); return *this;}void SignatureChangedPacket::parseData( const unsigned char * buf, const int /*len*/ ){ int pos=0; qq = READ32(buf); pos+=4; // your buddy qq number time = READ32(buf+pos); pos+=4; // the time he/she changed his/her signature unsigned char tmp = buf[pos++]; // the length of signature char *str = new char[tmp+1]; memcpy(str, buf+pos, tmp); // we get the new signature str[tmp] = 0x00; signature.assign(str); delete []str;}/* =========================================================== */ReceivedFileIM::ReceivedFileIM( const unsigned char * buf, const int len ) : NormalIMBase(buf, len) , m_FileName("") , m_FileSize(0){}ReceivedFileIM::ReceivedFileIM( const ReceivedFileIM & rhs ) : NormalIMBase(rhs){ *this = rhs;}ReceivedFileIM & ReceivedFileIM::operator =( const ReceivedFileIM & rhs ){ *((NormalIMBase *)this) = (NormalIMBase)rhs; m_TransferType = rhs.getTransferType(); m_ConnectMode = rhs.getConnectMode(); m_SessionId = getSessionId(); m_WanIp = rhs.getWanIp(); m_WanPort = rhs.getWanPort(); //m_MajorPort = rhs.getMajorPort(); //m_LanIp = rhs.getLanIp(); //m_LanPort = rhs.getLanPort(); memcpy(m_AgentServerKey, rhs.getAgentServerKey(), 16); m_FileName = rhs.getFileName(); m_FileSize = rhs.getFileSize(); return *this;}void ReceivedFileIM::parseContents( const unsigned char * buf, const int len ){ int pos = 27; // ignore 27 bytes m_TransferType = buf[pos++]; if(m_TransferType != QQ_TRANSFER_FILE && m_TransferType != QQ_TRANSFER_IMAGE) return; if(getNormalIMType() == QQ_IM_REQUEST_CANCELED) return; m_ConnectMode = buf[pos++]; if(getNormalIMType() != QQ_IM_TCP_REQUEST){ // this part actually is for UDP only(maybe Request cancellation as well) pos++; // unknown bytes, 0x66 or 0x67 if(getNormalIMType() != QQ_IM_EX_REQUEST_CANCELLED) pos+=2; // unknown 2 bytes, 0x0000 pos+=4; // unknown 4 bytes, 0x00000001, or all 0x0s// pos+=2; // unknown 2 bytes, 0x0000// m_SessionId = EvaUtil::read16(buf+pos); pos+=2; m_SessionId = EvaUtil::read32(buf+pos); pos+=4; if(getNormalIMType() == QQ_IM_NOTIFY_FILE_AGENT_INFO) pos++; // 0x00, and all above after m_ConnectionMode are 0x00s } m_WanIp = EvaUtil::read32(buf+pos); pos+=4; // if is cancellation, 0x00000001 m_WanPort = EvaUtil::read16(buf+pos); pos+=2; // if is UDP_EX request, 0x00000000 if(getNormalIMType() == QQ_IM_NOTIFY_FILE_AGENT_INFO){ m_SessionId = EvaUtil::read32(buf+pos); pos+=4; memcpy(m_AgentServerKey, buf+pos, 16); pos++; // last byte always be 0x01 return; } pos+=2; // request cancellation finished, actually, there are still 2 bytes(0x0000) afterwards // we just ignore them :) if(getNormalIMType() == QQ_IM_EX_REQUEST_CANCELLED) return; // request acceptation finished, actually, there are still 16 bytes afterwards // they are all unknown, we just ignore them :) if(getNormalIMType() == QQ_IM_EX_REQUEST_ACCEPTED) return; if(getNormalIMType() != QQ_IM_TCP_REQUEST){ pos+=4; // unknown, 0x00000000 pos++; // unknown, 0x02 or 0x04 } pos+=2; // if UDP request: 0x0000, if TCP request: 0x0102 if(getNormalIMType() != QQ_IM_TCP_REQUEST) pos+=4; // unknown, 0x00000000 or 0x00000001 pos+=2; // unknown 2 bytes, 0x0000 if(getNormalIMType() != QQ_IM_TCP_REQUEST){ pos+=2; //FIXME the length of the following part, we should check this pos++; // unknown, 0x01 pos+=2; //FIXME the length of the following part, we should check this, again! } if(getNormalIMType() == QQ_IM_ACCEPT_UDP_REQUEST || getNormalIMType() == QQ_IM_NOTIFY_IP) return; // now type should be QQ_IM_UDP_REQUEST or QQ_IM_TCP_REQUEST pos+=2; //FIXME we should check if they space and 0x1F, they should be 0x201f int strLen = 0; while(buf[pos+strLen]!=0x1f) strLen++;#ifdef WIN32 char* strFile; strFile=(char*)_alloca(strLen + 1);#else char strFile[strLen + 1];#endif memcpy(strFile, buf+pos, strLen); strFile[strLen] = 0x00; m_FileName.assign(strFile); pos+=strLen; pos++; // the 0x1f strLen = len - pos - 5; // ignore last 5 bytes " zijie" in Chinese#ifdef WIN32 char* strSize; strSize=(char*)_alloca(strLen + 1);#else char strSize[strLen + 1];#endif memcpy(strSize, buf+pos, strLen); strSize[strLen] = 0x00; m_FileSize = atoi(strSize);}/** =========================================================== **/ReceivedFileExIpIM::ReceivedFileExIpIM( const unsigned char * buf, const int len ) : NormalIMBase(buf, len), m_WanIp1(0), m_WanPort1(0), m_WanIp2(0), m_WanPort2(0), m_WanIp3(0), m_WanPort3(0), m_LanIp1(0), m_LanPort1(0), m_LanIp2(0), m_LanPort2(0), m_LanIp3(0), m_LanPort3(0), m_SyncIp(0), m_SyncPort(0), m_SyncSession(0){}ReceivedFileExIpIM::ReceivedFileExIpIM( const ReceivedFileExIpIM & rhs ) : NormalIMBase(rhs){ *this = rhs;}ReceivedFileExIpIM & ReceivedFileExIpIM::operator =( const ReceivedFileExIpIM & rhs ){ *((NormalIMBase *)this) = (NormalIMBase)rhs; m_TransferType = rhs.getTransferType(); m_ConnectMode = rhs.getConnectMode(); m_SessionId = getSessionId(); m_WanIp1 = rhs.getWanIp1(); m_WanPort1 = rhs.getWanPort1(); m_WanIp2 = rhs.getWanIp2(); m_WanPort2 = rhs.getWanPort2(); m_WanIp3 = rhs.getWanIp3(); m_WanPort3 = rhs.getWanPort3(); m_LanIp1 = rhs.getLanIp1(); m_LanPort1 = rhs.getLanPort1(); m_LanIp2 = rhs.getLanIp2(); m_LanPort2 = rhs.getLanPort2(); m_LanIp3 = rhs.getLanIp3(); m_LanPort3 = rhs.getLanPort3(); return *this;}void ReceivedFileExIpIM::parseContents( const unsigned char * buf, const int len ){ int pos = 27; // ignore 19 + 8 bytes m_TransferType = buf[pos++]; m_ConnectMode = buf[pos++]; // this part actually is for UDP only(maybe Request cancellation as well) pos++; // unknown bytes, 0x66 or 0x67 pos+=4; // unknown 4 bytes, 0x00000001 m_SessionId = EvaUtil::read32(buf+pos); pos+=4; if(EvaUtil::read16(buf+pos) == 0x0001) m_IsSender = true; else m_IsSender = false; pos+=2; int l = EvaUtil::read16(buf+pos); pos+=2; // following length if(l!= (len - pos)) return; // all ip is in little endian format, whereas port is in big endian memcpy(&m_WanIp1, buf+pos, 4); pos+=4; m_WanPort1 = EvaUtil::read16(buf+pos); pos+=2; memcpy(&m_WanIp2, buf+pos, 4); pos+=4; m_WanPort2 = EvaUtil::read16(buf+pos); pos+=2; memcpy(&m_LanIp1, buf+pos, 4); pos+=4; m_LanPort1 = EvaUtil::read16(buf+pos); pos+=2; memcpy(&m_LanIp2, buf+pos, 4); pos+=4; // always 0? m_LanPort2 = EvaUtil::read16(buf+pos); pos+=2; // always 0? memcpy(&m_LanIp3, buf+pos, 4); pos+=4; m_LanPort3 = EvaUtil::read16(buf+pos); pos+=2; if(m_IsSender){ memcpy(&m_SyncIp, buf+pos, 4); pos+=4; m_SyncPort = EvaUtil::read16(buf+pos); pos+=2; m_SyncSession = EvaUtil::read32(buf+pos); pos+=4; } memcpy(&m_WanIp3, buf+pos, 4); pos+=4; m_WanPort3 = EvaUtil::read16(buf+pos); pos+=2; // following are unknown 12 bytes, starting with 0x00 00 14 00 .... pos+=12;}/** =========================================================== **/ReceivedQQNews::ReceivedQQNews( const unsigned char * buf, const int len ) : m_Title(""), m_Brief(""), m_URL(""){ parseData(buf, len);}ReceivedQQNews::ReceivedQQNews( const ReceivedQQNews & rhs ) : m_Title(""), m_Brief(""), m_URL(""){ *this = rhs;}ReceivedQQNews & ReceivedQQNews::operator =( const ReceivedQQNews & rhs ){ m_Title = rhs.getTitle(); m_Brief = rhs.getBrief(); m_URL = rhs.getURL(); return *this;}void ReceivedQQNews::parseData( const unsigned char * buf, const int /*len*/ ){ int pos = 4; // ignore unknown 4 bytes unsigned char slen = buf[pos++]; char *str = new char[slen+1]; memcpy(str, buf+pos, slen); str[slen] = 0x00; m_Title = str; delete []str; pos += slen; slen = buf[pos++]; str = new char[slen+1]; memcpy(str, buf+pos, slen); str[slen] = 0x00; m_Brief = str; delete []str; pos += slen; slen = buf[pos++]; str = new char[slen+1]; memcpy(str, buf+pos, slen); str[slen] = 0x00; m_URL = str; delete []str; pos += slen; // still 5 unknown 0x00s}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -