예제 #1
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _OP_RL(cmem *b,uint32 o,uint8 r,uint32 l){
	OPCODE_6 op;
	op.o1=0x03+o&0xFF;
	op.o2=0x85+8*r;
	op.s=l;
	add_block(b,(uint8*)&op,sizeof(OPCODE_6));
	return 6;
}
예제 #2
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _PUSH_C(cmem *b,uint32 c){
	int i=0;
	if (c>0x7f){
		OPCODE_5 op;
		op.o1=0x68;
		op.s=c;
		add_block(b,(uint8*)&op,sizeof(OPCODE_5));
		i=5;
	}else{
		OPCODE_2 op;
		op.o1=0x6A;
		op.o2=c;
		add_block(b,(uint8*)&op,sizeof(OPCODE_2));
		i=2;
	}
	return i;
}
예제 #3
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _OP_RA(cmem *b,uint32 o,uint8 r,uint32 a){
	OPCODE_6 op;
	op.o1=0x03+o&0xFF;
	op.o2=0x05+r*8;
	op.s=a;
	add_block(b,(uint8*)&op,sizeof(OPCODE_6));
	return 6;
}
예제 #4
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _JAE_C(cmem *b,uint32 a){
	int i;
	if (a>255){
		OPCODE_6 op;
		op.o1=0x0F;
		op.o2=0x83;
		op.s=a;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}else{
		OPCODE_2 op;
		op.o1=0x73;
		op.o2=(uint8)a&0xFF;
		add_block(b,(uint8*)&op,sizeof(OPCODE_2));
		i=2;
	}
	return i;
}
예제 #5
0
파일: par.c 프로젝트: awasiljew/athena-cuda
void par_setd(char *block, char *name, char *fmt, double dval, char *comment)
{
  Block *bp = add_block(block);  /* find or add a block with this name */
  char sval[MAXLEN];

  sprintf(sval,fmt,dval);
  add_par(bp,name,sval,comment); /* Add the name = value pair Parameter */
  return;
}
예제 #6
0
    CFGBlock* start_new_block(VMMethod::Iterator& iter) {
      if(!iter.last_instruction()) {
        CFGBlock* blk = add_block(iter.next_position());
        close_current(iter, blk);
        return blk;
      }

      return 0;
    }
예제 #7
0
/**
 * 非阻塞读取数据
 * return 读取的总数据,错误设置在g_errorno上
 */
ssize_t read_buffer( int fd, buffer_t *pbuf ) {

	assert(fd >= 0);
	assert( pbuf != NULL);

	block_t		*pb = NULL;
	int			n, total, size;

	total = 0;
	g_errno = 1;				//无错误

NONREAD:
	pb = pbuf->tail;
	if ( NULL == pb || BLOCK_FULL(pb) ) {
		if ( add_block( pbuf ) < 0 ) {
			return -1;
		}
		pb = pbuf->tail;
	}
	size = BLOCK_REMAIN(pb);	//空闲位置是 [end, BLOCK_DATA]
	n = read( fd, BLOCK_READADDR(pb), size );
	log_message( LOG_DEBUG, "read %d bytes from fd[%d]", n, fd );

	if ( n > 0 ) {
		g_errno = 1;
		total += n;
		pb->end += n;
		pbuf->size += n;		//待发送数据大小

		if ( n == size ) {
			goto NONREAD;		//epoll的ET mode
		}
	}
	else if ( 0 == n ) {		//已经关闭读
		g_errno = 0;
	}
	else {
		switch (errno) {
#ifdef EWOULDBLOCK
		case EWOULDBLOCK:
#else
#  ifdef EAGAIN
		case EAGAIN:
#  endif
#endif
		case EINTR:
			g_errno = 1;		//不是错误,本次读取结束,等待下次事件
			break;

		default:
			g_errno = -1;
			log_message( LOG_ERROR,	"readbuff: recv() error \"%s\" on file descriptor %d",  strerror(errno), fd);
		}
	}

	return total;
}
예제 #8
0
static void
check_buffer(EFLOWDESC *ex, void *mdl)
{
    /* 
     * lookup for a item in the hash table with sequence number = ex->next_seq.
     * if found, repeat until not found
     */
    block_t * block;
    hash_iter_t iterator;
    
    block = (block_t *)hash_lookup_ulong(ex->htable, ex->next_seq);
    
    while (block != NULL) {
        if (block->seq == ex->next_seq) {   /* must ALWAYS be true :) */
            add_block(ex, block, mdl);
            unbuffer_block(ex, block->seq, block->len);
        }
        block = (block_t *)hash_lookup_ulong(ex->htable, ex->next_seq);
    }
    
    /* 
     * in case there are overlapped packets, iterate on the hash table to look 
     * for sequence numbers < ex->next_seq
     */
    hash_iter_init(ex->htable, &iterator);
    
    while (hash_iter_next (&iterator)) {
        block = (block_t *)hash_iter_get_value(&iterator);
        
        if (block->seq <= ex->next_seq) {
            add_block(ex, block, mdl);
            
            /*
             * remove from hash with current key value, because the sequence 
             * number could have changed (in case of overlap with valid data), 
             * so no longer would coincide with the hash key
             */
            unbuffer_block(ex, hash_iter_get_ulong_key(&iterator), block->len);
            
            /* start again */
            hash_iter_init(ex->htable, &iterator);
        }
    }
}
예제 #9
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _DEC_L(cmem *b,uint32 l){
	int i;
	if (l>0x7F){
		OPCODE_6 op;
		op.o1=0xFF;
		op.o2=0x8D;
		op.s=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}else{
		OPCODE_3 op;
		op.o1=0xFF;
		op.o2=0x4D;
		op.o3=(uint8)l&0xFF;
		add_block(b,(uint8*)&op,sizeof(OPCODE_3));
		i=3;
	}
	return i;
}
예제 #10
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _OP_LR(cmem *b,uint32 o,uint32 l,uint8 r){
	int i;
	if (o==_TEST){
		OPCODE_6 op;
		op.o1=0x85;
		op.o2=0x85+8*r;
		op.s=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}else{
		OPCODE_6 op;
		op.o1=0x01+o&0xFF;
		op.o2=0x85+8*r;
		op.s=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}
	return i;
}
예제 #11
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _POP_L(cmem *b,uint32 l){
	int i;
	if (l>0x7F){
		OPCODE_6 op;
		op.o1=0x8F;
		op.o2=0x85;
		op.s=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}else{
		OPCODE_3 op;
		op.o1=0x8F;
		op.o2=0x45;
		op.o3=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_3));
		i=3;
	}
	return i;
}
예제 #12
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _LEA_RRA(cmem *b,uint8 r1,uint8 r2,uint32 l){
	int i;
	if (r2==_ESP){
		OPCODE_3 op;
		op.o1=0x8D;
		op.o2=0x84+8*r1;
		op.o3=0x24;
		add_block(b,(uint8*)&op,sizeof(OPCODE_3));
		add_block(b,(uint8*)&l,4);
		i=7;
	}else{
		OPCODE_6 op;
		op.o1=0x8D;
		op.o2=0x80+8*r1+r2;
		op.s=l;
		add_block(b,(uint8*)&op,sizeof(OPCODE_6));
		i=6;
	}
	return i;
}
예제 #13
0
t_node *add_trigger(t_context *C,const char *name,void*(* f)(t_brick *brick))
{
	// BLOCK
	t_node *node_block = add_block(C,"trigger");
	t_block *block = ( t_block *) node_block->data;

	// LABEL
	add_brick_trigger(C,block,name,f);

	return node_block;
}
예제 #14
0
파일: is-balloc.c 프로젝트: Meijuh/ltsmin
isb_allocator_t
isba_create(int element_size)
{
    isb_allocator_t res = RTmalloc(sizeof *res);
    res->el_size = element_size;
    res->max_blocks = INIT_MAX_BLOCKS;
    res->blocks = RTmalloc(res->max_blocks*sizeof(int*));
    res->num_block = 0;
    add_block(res);
    return res;
}
예제 #15
0
t_node *add_label(t_context *C,const char *name)
{
	// BLOCK
	t_node *node_block = add_block(C,"label");
	t_block *block = ( t_block *) node_block->data;

	// LABEL
	add_brick_label(C,block,name);

	return node_block;
}
예제 #16
0
t_node *add_switch(t_context *C,const char *name,void *data, void *(* f)( t_brick *brick))
{
	// BLOCK
	t_node *node_block = add_block(C,"switch");
	t_block *block = ( t_block *) node_block->data;

	// BRICK SWICH
	add_brick_switch(C,block,name,data, f);

	return node_block;
}
예제 #17
0
void setup(void) {
   add_area("2.4.5");

   set_short("Room wiht black walls");
   set_long("A room with black walls.  There is a door to the east, " +
      "and a door to the west.");

   /* Need to do door stuff here XXX */
   add_exit("east", DIR + "/rooms/well.c");
   add_exit("west", DIR + "/rooms/sub/after_trap.c");

   add_block("east");
}
예제 #18
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;
}
예제 #19
0
std::shared_ptr<Matrix> ASD<VecType>::compute_1e_prop(std::shared_ptr<const Matrix> hAA, std::shared_ptr<const Matrix> hBB, std::shared_ptr<const Matrix> hAB, const double core) const {

  auto out = std::make_shared<Matrix>(dimerstates_, dimerstates_);

  for (auto iAB = subspaces_.begin(); iAB != subspaces_.end(); ++iAB) {
    const int ioff = iAB->offset();
    for (auto jAB = subspaces_.begin(); jAB != iAB; ++jAB) {
      const int joff = jAB->offset();

// TODO remove this comment once the gammaforst issue has been fixed (bra and ket have been exchanged)
      std::array<MonomerKey,4> keys {{ jAB->template monomerkey<0>(), jAB->template monomerkey<1>(),
                                       iAB->template monomerkey<0>(), iAB->template monomerkey<1>() }};
      std::shared_ptr<Matrix> out_block = compute_offdiagonal_1e<true>(keys, hAB);

      out->add_block(1.0, joff, ioff, out_block->ndim(), out_block->mdim(), out_block);
      out->add_block(1.0, ioff, joff, out_block->mdim(), out_block->ndim(), out_block->transpose());
    }
    std::shared_ptr<const Matrix> tmp = compute_diagonal_1e(*iAB, hAA->data(), hBB->data(), core);
    out->add_block(1.0, ioff, ioff, tmp->ndim(), tmp->mdim(), tmp);
  }

  return out;
}
예제 #20
0
파일: morf.cpp 프로젝트: 0x37N0w4N/malware
int _OP_AR(cmem *b,uint32 o,uint32 a,uint8 r){
	int i;
	switch(o){
		case _TEST:{
			OPCODE_6 op;
			op.o1=0x85;
			op.o2=0x05+r*8;
			op.s=a;
			add_block(b,(uint8*)&op,sizeof(OPCODE_6));
			i=6;
			break;
		}
		default:{
			OPCODE_6 op;
			op.o1=0x01+o&0xFF;
			op.o2=0x05+r*8;
			op.s=a;
			add_block(b,(uint8*)&op,sizeof(OPCODE_6));
			i=6;
		}
	}
	return i;
}
예제 #21
0
/*** Reads the next CHRS chunk from clipboard ***/
BOOL CBReadCHRS( void *jbuf, LINE *st, ULONG pos, LONG *nbl )
{
	struct ContextNode * cn;
	BOOL   ret = FALSE;

	/* If clipboard not already allocated, makes it now */
	if( clip == NULL && !CBOpen(STD_CLIP_UNIT) ) return FALSE;

	if( !OpenIFF(clip, IFFF_READ) )
	{
		if( !StopChunk(clip, ID_FTXT, ID_CHRS) )
		{
			if( !ParseIFF(clip, IFFPARSE_SCAN) )
			{
				cn = CurrentChunk(clip);
				if( cn->cn_Type == ID_FTXT && cn->cn_ID == ID_CHRS && cn->cn_Size > 0 )
				{
					STRPTR buf;
					ULONG  size = cn->cn_Size;

					if( (buf = (STRPTR) AllocVec(size, MEMF_PUBLIC)) )
					{
						UBYTE eol;
						ReadChunkBytes(clip, buf, size);

						/* What's kind of paste method shall we used? */
						{	register STRPTR s; register ULONG n;
							for(s=buf,n=size; --n && *s!='\n' && *s!='\r'; s++);
							eol = *s;
						}
						/* Add string to the buffer */
						reg_group_by(jbuf);
						if(eol == '\n') add_string(jbuf,st,pos,buf,size,nbl) ;
						else            add_block (jbuf,st,pos,buf,size,nbl) ;
						reg_group_by(jbuf);
						FreeVec(buf);
						ret = TRUE;
					}
					else ThrowError(Wnd, ErrMsg(ERR_NOMEM));
				}
				else ThrowError(Wnd, ErrMsg(ERR_NOTXTINCLIP));
			}
			else ThrowError(Wnd, ErrMsg(ERR_NOTXTINCLIP));
		}
		else ThrowError(Wnd, ErrMsg(ERR_NOMEM));
		CloseIFF(clip);
	}
	/* ThrowError(Wnd, ErrMsg(ERR_READCLIP)); */
	return ret;
}
예제 #22
0
/*
 * coalesce - Boundary tag coalescing. Return ptr to coalesced block
 */
static void *coalesce(void *bp) 
{
    void *prev = PREV_BLKP(bp);
    void *next = NEXT_BLKP(bp);

    size_t prev_alloc = GET_ALLOC(HDRP(prev));
    size_t next_alloc = GET_ALLOC(HDRP(next));
    size_t size = GET_SIZE(HDRP(bp));

    if (prev_alloc && next_alloc) {            /* Case 1 */
        add_block(bp);
        return bp;
    }
    else if (prev_alloc && !next_alloc) {      /* Case 2 */
        delete_block(next);
        size += GET_SIZE(HDRP(next));
        set_size(bp, size);
        add_block(bp);
        return bp;
    }
    else if (!prev_alloc && next_alloc) {      /* Case 3 */
        delete_block(prev);
        size += GET_SIZE(HDRP(prev));
        set_size(prev, size);
        add_block(prev);
        return prev;
    }
    else {                                     /* Case 4 */
        delete_block(next);
        delete_block(prev);
        size += GET_SIZE(HDRP(prev)) + 
            GET_SIZE(HDRP(next));
        set_size(prev, size);
        add_block(prev);
        return prev;
    }
}
예제 #23
0
void ChiPlotDataSet::load_data(std::istream &f)
{
    string graph_title = trim_label(read_line(f));
    string x_label = trim_label(read_line(f));
    string y_label = trim_label(read_line(f));
    string line = read_line(f);
    string::size_type pos = line.find(',');
    if (pos != string::npos)
        line[pos] = ' ';
    int n_points, n_ycols;
    int r = sscanf(line.c_str(), "%d %d", &n_points, &n_ycols);
    if (r == 1)
        n_ycols = 1;
    else if (r != 2)
        throw FormatError("expected number(s) in line 4");
    if (n_points <= 0 || n_ycols <= 0)
        throw FormatError("expected positive number(s) in line 4");
    vector<VecColumn*> cols(n_ycols + 1);
    for (size_t i = 0; i != cols.size(); ++i)
        cols[i] = new VecColumn;
    try {
        for (int i = 0; i != n_points; ++i) {
            line = read_line(f);
            const char* p = line.c_str();
            for (int j = 0; j != n_ycols + 1; ++j) {
                char *endptr = NULL;
                while (isspace(*p) || *p == ',')
                    ++p;
                double val = strtod(p, &endptr);
                if (endptr == p)
                    throw FormatError("line " + S(5+i) + ", column " + S(j+1));
                cols[j]->add_val(val);
                p = endptr;
            }
        }
    }
    catch (std::exception&) {
        purge_all_elements(cols);
        throw;
    }

    Block *blk = new Block;
    blk->set_name(graph_title);
    cols[0]->set_name(x_label);
    cols[1]->set_name(y_label);
    for (size_t i = 0; i != cols.size(); ++i)
        blk->add_column(cols[i]);
    add_block(blk);
}
예제 #24
0
void TreeSystem::make_ground(
	float thickness,
	float base_angle,
	float delta_angle,
	const sf::Color& base_color,
	const ColorTransform& deltas)
{
	const float density_factor = 1.5;
	const float block_w = 5;
	const float block_h = 1;
	const float block_area = block_w * block_h;
	const float underground_depth = 5;

	auto phys = physicsDimensions();
	auto phys2 = physicsHalfDimensions();
	const float area = (thickness + underground_depth) * phys.x;
	const unsigned density = (area * density_factor) / block_area;

	blocks.reserve(blocks.size() + density + 1);

	polygonDef def;
	def.bodyDef.active = false;
	def.bodyDef.fixedRotation = true;
	def.bodyDef.type = b2_staticBody;
	def.shape.SetAsBox(phys2.x, thickness/2);
	def.bodyDef.angle = 0;
	def.bodyDef.position.Set(phys2.x, phys.y - (thickness/2));

	blocks.emplace_back(
		make_shape(world(), def),
		base_color);
	
	def.shape.SetAsBox(block_w, block_h);
	addProgress(1);

	const b2Vec2 topLeft(0, phys.y - thickness);
	const b2Vec2 bottomRight(phys.x, phys.y + underground_depth);

	maxProgress(blocks.size() + density + 1);
	setProgress(blocks.size());

	for(int i = 0; i < density; ++i)
	{
		def.bodyDef.position = random_in(topLeft, bottomRight);
		def.bodyDef.angle = to_radians(randcentered(base_angle, delta_angle));
		add_block(def, deltas.apply(base_color));
		addProgress(1);
	}
}
예제 #25
0
uint64_t BlockchainDB::add_block( const block& blk
                                , const size_t& block_size
                                , const difficulty_type& cumulative_difficulty
                                , const uint64_t& coins_generated
                                , const std::vector<transaction>& txs
                                )
{
  // sanity
  if (blk.tx_hashes.size() != txs.size())
    throw std::runtime_error("Inconsistent tx/hashes sizes");

  block_txn_start(false);

  TIME_MEASURE_START(time1);
  crypto::hash blk_hash = get_block_hash(blk);
  TIME_MEASURE_FINISH(time1);
  time_blk_hash += time1;

  uint64_t prev_height = height();

  // call out to add the transactions

  time1 = epee::misc_utils::get_tick_count();
  add_transaction(blk_hash, blk.miner_tx);
  int tx_i = 0;
  crypto::hash tx_hash = crypto::null_hash;
  for (const transaction& tx : txs)
  {
    tx_hash = blk.tx_hashes[tx_i];
    add_transaction(blk_hash, tx, &tx_hash);
    ++tx_i;
  }
  TIME_MEASURE_FINISH(time1);
  time_add_transaction += time1;

  // call out to subclass implementation to add the block & metadata
  time1 = epee::misc_utils::get_tick_count();
  add_block(blk, block_size, cumulative_difficulty, coins_generated, blk_hash);
  TIME_MEASURE_FINISH(time1);
  time_add_block1 += time1;

  m_hardfork->add(blk, prev_height);

  block_txn_stop();

  ++num_calls;

  return prev_height;
}
예제 #26
0
t_node *add_slider_char(t_context *C,const char *name,void *target_data)
{
	// NEW BLOCK
	t_node *node_block = add_block(C,name);
	t_block *block = ( t_block *) node_block->data;

	// NEW BRICK
	t_node *node_brick=add_brick_slider_char(C,block,name,target_data);
	t_brick *brick = ( t_brick *) node_brick->data;

	// SET ACTION
	brick->exe=op_slider;

	return node_block;
}
예제 #27
0
    // Same preconditions as 'segregate'
    // Post: !empty()
    void add_ordered_block(void * const block,
        const size_type nsz, const size_type npartition_sz)
    {
      // This (slower) version of add_block segregates the
      //  block and merges its free list into our free list
      //  in the proper order

      // Find where "block" would go in the free list
      void * const loc = find_prev(block);

      // Place either at beginning or in middle/end
      if (loc == 0)
        add_block(block, nsz, npartition_sz);
      else
        nextof(loc) = segregate(block, nsz, npartition_sz, nextof(loc));
    }
예제 #28
0
void *ws_malloc_i(size_t size, const char *file, int line)
{
    WsMemBlockHdr *b;

    if (alloc_number++ >= num_successful_allocs)
        return NULL;

    b = malloc(SIZE(size));

    if (b == NULL)
        return NULL;

    add_block(b, size, file, line);

    return b + 1;
}
예제 #29
0
t_node *add_slider_float(t_context *C,const char *name,void *target_data)
{
	// NEW BLOCK
	t_node *node_block = add_block(C,name);
	t_block *block = ( t_block *) node_block->data;
	block->block_state.draw_outline = 1;

	// NEW BRICK
	t_node *node_brick=add_part_slider_float(C,block,name,target_data);
	t_brick *brick = ( t_brick *) node_brick->data;

	// SET ACTION
	brick->act=op_slider;

	return node_block;
}
예제 #30
0
t_node *add_brick_geo_edge(t_context *C,const char *name, void *data)
{
	// NEW BLOCK
	t_node *node_block = add_block(C,name);
	t_block *block = ( t_block *) node_block->data;
	block->block_state.draw_outline = 1;

	// GEO POINT
	add_brick_geo_point_bare(C,block,"point",NULL,1);
	add_brick_geo_point_bare(C,block,"point",NULL,2);

	// GEO EDGE
	add_part_geo(C,block,"edge",data,dt_geo_edge);

	return node_block;
}