Exemple #1
0
static void setup_o(opcode *o) {
	lowerize(o->m);
	if(ISIMM(o->o1)) o->f |= IMM, o->immsz = GETTYPE(o->o1);
	else if(ISIMM(o->o2)) o->f |= IMM, o->immsz = GETTYPE(o->o2);
	else if(ISIMM(o->o3)) o->f |= IMM, o->immsz = GETTYPE(o->o3);
	if(HASMODRM(o->o1) || HASMODRM(o->o2)) o->f |= MODRM;
}
void CDPClient::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
	static size_t	nSize	= sizeof(DPID);

#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, 0xEEEEEEEE );
#endif	// __CRASH_0404

	LPBYTE lpBuf	= (LPBYTE)lpMsg + nSize;
	ULONG	uBufSize	= dwMsgSize - nSize;
	DPID dpidUser	= *(UNALIGNED LPDPID)lpMsg;

	CAr ar( lpBuf, uBufSize );
	GETTYPE( ar );

	void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );
	
#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, dw );
#endif	// __CRASH_0404

	if( pfn )
		( this->*( pfn ) )( ar, dpidUser, lpMsg, dwMsgSize );
	else
		g_DPCacheSrvr.Send( lpBuf, uBufSize, dpidUser );

#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, 0xFFFFFFFF );
#endif	// __CRASH_0404
}
Exemple #3
0
void CDPLoginClient::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
    CAr ar( (LPBYTE)lpMsg, dwMsgSize );
    GETTYPE( ar );
    void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );

    if( pfn )
        ( this->*( pfn ) )( ar );
}
void QMQTT::ClientPrivate::onNetworkReceived(const QMQTT::Frame& frm)
{
    QMQTT::Frame frame(frm);
    quint8 qos = 0;
    bool retain, dup;
    QString topic;
    quint16 mid = 0;
    quint8 header = frame.header();
    quint8 type = GETTYPE(header);
    Message message;

    switch(type)
    {
    case CONNACK:
        frame.readChar();
        handleConnack(frame.readChar());
        break;
    case PUBLISH:
        qos = GETQOS(header);
        retain = GETRETAIN(header);
        dup = GETDUP(header);
        topic = frame.readString();
        if( qos > QOS0) {
            mid = frame.readInt();
        }
        message.setId(mid);
        message.setTopic(topic);
        message.setPayload(frame.data());
        message.setQos(qos);
        message.setRetain(retain);
        message.setDup(dup);
        handlePublish(message);
        break;
    case PUBACK:
    case PUBREC:
    case PUBREL:
    case PUBCOMP:
        mid = frame.readInt();
        handlePuback(type, mid);
        break;
    case SUBACK:
        mid = frame.readInt();
        qos = frame.readChar();
        // todo: send a subscribed signal (only in certain cases? mid? qos?)
        break;
    case UNSUBACK:
        // todo: send an unsubscribed signal (only certain cases? mid?)
        break;
    case PINGRESP:
        // todo: I know I'm suppose to do something with this. Look at specifications.
        break;
    default:
        break;
    }
}
Exemple #5
0
//---------------------------------------------
//---------------------------------------------
void Client::onReceived(Frame &frame)
{
    quint8 qos = 0;
    bool retain, dup;
    QString topic;
    quint16 mid = 0;
    quint8 header = frame.header();
    quint8 type = GETTYPE(header);
    Message message;
    qCDebug(client, "handleFrame: type=%d", type);

    switch(type) {
    case CONNACK:
        //skip reserved
        frame.readChar();
        handleConnack(frame.readChar());
        break;
    case PUBLISH:
        qos = GETQOS(header);;
        retain = GETRETAIN(header);
        dup = GETDUP(header);
        topic = frame.readString();
        if( qos > MQTT_QOS0) {
            mid = frame.readInt();
        }
        message.setId(mid);
        message.setTopic(topic);
        message.setPayload(frame.data());
        message.setQos(qos);
        message.setRetain(retain);
        message.setDup(dup);
        handlePublish(message);
        break;
    case PUBACK:
    case PUBREC:
    case PUBREL:
    case PUBCOMP:
        mid = frame.readInt();
        handlePuback(type, mid);
        break;
    case SUBACK:
        mid = frame.readInt();
        qos = frame.readChar();
        emit subacked(mid, qos);
        break;
    case UNSUBACK:
        emit unsubacked(mid);
        break;
    case PINGRESP:
        emit pong();
        break;
    default:
        break;
    }
}
Exemple #6
0
void CHost::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID dpid )
{
    CAr ar( (LPBYTE)lpMsg, dwMsgSize );
    GETTYPE( ar );
    void ( theClass::*pfn )( theParameters )
        =	GetHandler( dw );

    if( pfn ) {
        ( this->*( pfn ) )( ar, dpid );
    }
    else {
//		ASSERT( 0 );
    }
}
Exemple #7
0
void CDPLoginSrvr::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
	static size_t	nSize	= sizeof(DPID);
	
	CAr ar( (LPBYTE)lpMsg + nSize, dwMsgSize - nSize );
	GETTYPE( ar );
	void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );
	
	if( pfn ) {
		( this->*( pfn ) )( ar, *(UNALIGNED LPDPID)lpMsg, (LPBYTE)lpMsg + nSize + nSize, dwMsgSize - nSize - nSize );
	}
	else {
		TRACE( "Handler not found(%08x)\n", dw );
	}
}
Exemple #8
0
void CDPAccountClient::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
	static size_t	nSize	= sizeof(DPID);

	LPBYTE lpBuf	= (LPBYTE)lpMsg + nSize;
	ULONG	uBufSize	= dwMsgSize - nSize;
	DPID dpid2	= *(UNALIGNED LPDPID)lpMsg;

	CAr ar( lpBuf, uBufSize );
	GETTYPE( ar );


	void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );
//	ASSERT( pfn );
	if( pfn )
		( this->*( pfn ) )( ar, dpid2 );
}
void CDPCoreClient::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
	static size_t	nSize	= sizeof(DPID);

#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, 0xEEEEEEEE );
#endif	// __CRASH_0404

	LPBYTE lpBuf	= (LPBYTE)lpMsg + nSize;
	ULONG	uBufSize	= dwMsgSize - nSize;
	DPID dpidUser	= *(UNALIGNED LPDPID)lpMsg;

	CAr ar( lpBuf, uBufSize );
	GETTYPE( ar );

#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, dw );
#endif	// __CRASH_0404

	void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );
	
	if( pfn )
		( this->*( pfn ) )( ar, dpidUser );
	else
	{
		switch( dw )
		{
			case PACKETTYPE_SUMMONPLAYER:
			case PACKETTYPE_TELEPORTPLAYER:
			case PACKETTYPE_MODIFYMODE:
			case PACKETTYPE_BUYING_INFO:
				{
					CMclAutoLock	Lock( CPlayerMng::Instance()->m_AddRemoveLock );
					g_DPClientArray.SendToServer( dpidUser, lpMsg, dwMsgSize );
					break;
				}
			default:
				g_DPCacheSrvr.Send( lpBuf, uBufSize, dpidUser );
				break;
		}
	}
#ifdef __CRASH_0404
	CCrashStatus::GetInstance()->SetLastPacket( this, 0xFFFFFFFF );
#endif	// __CRASH_0404
}
void CDPCertified::UserMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID dpId )
{
	CAr ar( (LPBYTE)lpMsg, dwMsgSize );

	GETTYPE( ar );
	
	void ( theClass::*pfn )( theParameters )	=	GetHandler( dw );

	if( pfn ) {
		( this->*( pfn ) )( ar, dpId );
	}
	else {
		/*
		switch( dw ) {
			default:
				TRACE( "Handler not found(%08x)\n", dw );
				break;
		}
		*/
	}
}
Exemple #11
0
void print_bb(struct ext2_inode *ip, int node_num){
char t= GETTYPE(ip);
 printf("[%d] type: %c size: %d links: %d blocks: %d\n[%d] Blocks: %d\n",
  node_num, t, ip->i_size,ip->i_links_count, ip->i_blocks, node_num, ip->i_block[0]);
}
Exemple #12
0
// decodes operand
static void decopr(x86_opr *out, decstruct *d, u4 o) {
	u4 t = OPRTOK(o);

	if(ISREG(t)) {
isreg:
		if(t < ES) { // gpr
			int s = GETTYPE(o);
			if(!d->opr32 || s == WORD) t += AX-eAX; // 16-bit register
			else if(s == BYTE) t += AL-eAX; // 8-bit register
		}
		out->tok = X86_OREG;
		out->reg = t;
	} else if(ISMODRM(t)) {
		if(ISMODRM_REG(t) || R == t || (M != t && MOD(d->modrm) == 3)) {
			o = ISMODRM_REG(t) ? REG(d->modrm) : RM(d->modrm);
			if(S == t) o += ES; // segment register
			else if(T == t) o += TR0;	// test register
			else if(D == t) o += DR0;	// debug register
			else o += eAX;
			t = o;
			goto isreg;
		}
		// else it is a memory reference
		memcpy(&out->mem, &d->mem, sizeof(d->mem));
		out->tok = X86_OMEM;
		out->mem.size = GETTYPE(o);
	} else switch(t) {
		case I:
			out->tok = X86_OVAL;
			memcpy(&out->val, &d->imm, sizeof(d->imm));
			break;
		case J:
			out->tok = X86_OVAL;
			memcpy(&out->val, &d->imm, sizeof(d->imm));
			out->val.sign = 1;
			break;
		case O: case A: // direct address or ds:offset
			out->tok = X86_OMEM;
			if(t == A) out->mem.disp.val = LSB16(d->q)*16;
			else out->mem.seg = DS; // offset in ds
			d->q += 2;
			if(d->adr32) {
				out->mem.disp.val += LSB32(d->q);
				d->q += 4;
			} else {
				out->mem.disp.val += LSB16(d->q);
				d->q += 2;
			}
			if(!(out->mem.size = GETTYPE(o)))
				out->mem.size = d->opr32 ? DWORD : WORD;
			break;
		case X: case Y: // string instruction
			break;
		default:
			if(t >= CONST_0 && t <= CONST_LAST) {
				out->tok = X86_OVAL;
				out->val.val = t-CONST_0;
				out->val.sign = 0;
				out->val.size = GETTYPE(o);
			} else out->tok = X86_ONON;
			break;
	}
	return;
}