예제 #1
0
파일: lab1.cpp 프로젝트: Shuiliusheng/DJ
void transform_array(int n)//数组转换
{
	char op[expr_size],fuc1[expr_size],type[expr_size],op1[expr_size],expr[expr_size];
	sscanf(inst[n],"%s %s %s",op,expr,type);
	sscanf(inst[n+1],"%s %s %s",op1,fuc1,type);
	
	char name[expr_size];
	if(find_base(fuc1,name))//有数组的标志,带有base
	{
		if(strcmp(type,"GP")==0)
		{
			strcpy(var_name[num_v++],name);
		}

		sprintf(inst[n]," nop ");
		sprintf(inst[n+1]," nop ");

		int reg=0;
		int t=get_op(expr,fuc1,reg);
		
		if(t==1)
			sprintf(inst[n+2]," array %s[%s] %s %s ",name,fuc1,name,type);
		else if(t==3)
		{
			sprintf(inst[n+1]," var %s ",expr);
			sprintf(inst[n+2]," array %s[%s] %s %s ",name,fuc1,name,type);
		}
		else if(t==2)
		{
			sprintf(inst[n+2]," array %s[(%s)] %s %s %s %d",name,expr,name,type,"reg",reg);
		}
	}
}
예제 #2
0
unsigned int	eval_nbr(char *str, char *base)
{
  int		i;
  unsigned int	nbr;
  int		pow;
  int		fix;

  i = 0;
  while (base[i] != '\0')
    i++;
  fix = i;
  i = 0;
  nbr = 0;
  pow = 1;
  while (str[i] != '\0')
    i++;
  i--;
  while (i >= 0)
    {
      nbr = nbr + (find_base(str[i], base)) * pow;
      pow = pow * fix;
      i--;
    }
  return (nbr);
}
예제 #3
0
파일: cpu.c 프로젝트: ezrec/vasm
static char *fill_operand(operand *p,section *sec,taddr pc,char *d,rlist **relocs,int roffset)
{
  taddr val;
  if(!p||p->type==OP_REG)
    return d;
  /* FIXME: Test for valid operand, create reloc */
  if(!eval_expr(p->offset,&val,sec,pc)){
    nreloc *reloc=new_nreloc();
    rlist *rl=mymalloc(sizeof(*rl));
    rl->type=REL_ABS;
    reloc->offset=roffset*8;
    reloc->size=16;
    reloc->sym=find_base(p->offset,sec,pc);
    if(!reloc->sym){
      cpu_error(2);
    }else{
      rl->reloc=reloc;
      rl->next=*relocs;
      *relocs=rl;
    }
  }
  *d++=val>>24;
  *d++=val>>16;
  *d++=val>>8;
  *d++=val;
  return d;
}
예제 #4
0
파일: cpu.c 프로젝트: kusma/vasm
static taddr dooffset(int rel,expr *tree,section *sec,taddr pc,rlist **relocs,int roffset,int size,taddr mask)
{
  taddr val;
  if(!eval_expr(tree,&val,sec,pc)){
    taddr addend=val;
    symbol *base;
    if(find_base(tree,&base,sec,pc)!=BASE_OK){
      general_error(38);
      return val;
    }
    if(rel==REL_PC){
      val-=pc;
      addend+=roffset/8;
    }
    if(rel!=REL_PC||!LOCREF(base)||base->sec!=sec){
      add_nreloc_masked(relocs,base,addend,rel,size,roffset,mask);
      return 0;
    }
  }
#if 0
  if(val<-(1<<(size-1))||val>((1<<(size-1))-1))
    cpu_error(1,size);
#endif
  return val&mask;
}
예제 #5
0
/*
 * Build the full tables
 */
static void build_tables() {
  state_t i;

  init_tables();
  for (i=0; i<NSTATES; i++) {
    find_base(i);
  }
}
예제 #6
0
파일: lab1.cpp 프로젝트: Shuiliusheng/DJ
void transform_two_array(int n)
{
	char dst2[expr_size];
	char op[expr_size],dst[expr_size],type[expr_size],op1[expr_size],expr[expr_size],op2[expr_size],expr1[expr_size];
	sscanf(inst[n],"%s %s %s",op,expr,type);
	
	int size=0;
	sscanf(type,"%d",&size);

	sscanf(inst[n+1],"%s %s %s",op1,dst,type);
	sscanf(inst[n+3],"%s %s %s",op2,expr1,dst2);

	char name[expr_size];
	if(find_base(dst,name))//有数组的标志,带有base
	{
		if(strcmp(type,"GP")==0)
		{
			strcpy(var_name[num_v],name);
			asize[num_v++]=size/8;
		}
		sprintf(inst[n],"nop ");
		sprintf(inst[n+1],"nop ");


		int reg=0;
		int t=get_op(expr,dst,reg);
		
		if(t==1)
			sprintf(inst[n+2],"ok %s",dst);
		else if(t==3)
		{
			sprintf(inst[n]," var %s ",expr);
			sprintf(inst[n+2],"ok %s",dst);
		}
		else if(t==2)
		{
			sprintf(inst[n+2],"expr %d",reg);
		}

		t=0,reg=0;
		t=get_op(expr1,dst,reg);
		
		if(t==1)
			sprintf(inst[n+3],"ok %s",dst);
		else if(t==3)
		{
			sprintf(inst[n+1]," var %s ",expr1);
			sprintf(inst[n+3],"ok %s",dst);
		}
		else if(t==2)
		{
			sprintf(inst[n+3],"expr %d",reg);
		}

		sprintf(inst[n+4],"array2 %s %s %d",name,type,size/8);
	}
}
예제 #7
0
void	sastantua(int size)
{
	int base;
	int layer;

	base = find_base(size);
	layer = print_layer(base);
	if (layer == size)
	{

	}
}
예제 #8
0
int find_base_from_list(const char *name[], struct base_addr_t *base_addr)
{
    int ret = 0;
    int i = 0;
    base_addr->addr = NULL;
    base_addr->len = 0;

    if (name == NULL)
        return 0;

    while (name[i] != NULL && !(ret = find_base(name[i], base_addr)))
        i++;

    return ret;
}
예제 #9
0
파일: cpu.c 프로젝트: kusma/vasm
int ext_find_base(symbol **base,expr *p,section *sec,taddr pc)
{
  /* addr/256 equals >addr, addr%256 and addr&255 equal <addr */
  if (p->type==DIV || p->type==MOD) {
    if (p->right->type==NUM && p->right->c.val==256)
      p->type = p->type == DIV ? HIBYTE : LOBYTE;
  }
  else if (p->type==BAND && p->right->type==NUM && p->right->c.val==255)
    p->type = LOBYTE;

  if (p->type==LOBYTE || p->type==HIBYTE) {
    modifier = p->type;
    return find_base(p->left,base,sec,pc);
  }
  return BASE_ILLEGAL;
}
예제 #10
0
파일: lab1.cpp 프로젝트: Shuiliusheng/DJ
void global_struct()//结构体定义
{
	int i=0;
	char op[expr_size],fuc1[expr_size],type[expr_size],fuc2[expr_size],dst[expr_size];

	for(i=1;i<num_inst;i++)//遍历所有指令,找到结构体的结构进行转换 结构体都变为单个变量
	{
		sscanf(inst[i],"%s %s %s",op,fuc1,type);
		if(strcmp(op,"add")==0&&find_base(fuc1,dst))//找到base,结构体的标志1
		{
			sprintf(inst[i]," nop ");
			char temp[200];
			strcpy(temp,dst);
			int now=i;
			for(i=i+1;i<num_inst;i++)//offset代表结构体的进一步访问
			{
				sscanf(inst[i],"%s %s %s",op,fuc1,fuc2);
				int reg=0;
				get_op(fuc2,dst,reg);
				if(strcmp(op,"add")==0&&judge_offset(dst,fuc2))
				{
					sprintf(inst[i]," nop ");
					strcat(temp,"_");
					strcat(temp,fuc2);
				}
				else if(i==now+1)//如果只有base没有offset,说明是全局变量,使用了辅助指令global
				{
					sprintf(inst[i-1],"global %s ",temp);
					strcpy(var_name[num_v++],temp);//将全局变量保存下来
					break;
				}
				else if(i>now+1)//如果有offset,则说明为结构体,使用辅助指令struct,指明是结构体
				{
					sprintf(inst[i-1]," struct %s %s ",temp,type);
					if(strcmp(type,"GP")==0)
						strcpy(struct_name[num_s++],temp);//将全局结构体保存下来
					i--;
					break;
				}
				else
					break;
			}
		}
	}
	def_strcut_global();//定义检测到的全局结构体变量
}
예제 #11
0
int main(int argc, char *argv[])
{
	NPBASE *np_base;
	MAC_KEY mkey;
	CIPHER_KEY ckey;
	FILE *iso_fp, *pbp_fp;
	char *npb_name, *iso_name, *pbp_name;
	int i, ap, do_comp, do_crypt, do_save_base, builtin_base;
	int total_block, block_size;
	int iso_size, iso_offset, iso_block;
	int table_offset, table_size;
	u8 *iso_buf, *lzrc_buf, *table_buf;

	ap = 1;
	npb_name = NULL;
	iso_name = NULL;
	pbp_name = NULL;
	do_comp = 0;
	do_crypt = 1;
	do_save_base = 0;
	builtin_base = 1;
	np_base = NULL;

	// parameter process
	while(ap<argc){
		if(argv[ap][0]=='-'){
			if(argv[ap][1]=='b'){
				if(ap+1==argc)
					goto _help;
				npb_name = argv[ap+1];
				builtin_base = 0;
				ap += 1;
			}else if(argv[ap][1]=='c'){
				do_comp = 1;
			}else if(argv[ap][1]=='w'){
				do_save_base = 1;
			}else if(argv[ap][1]=='e'){
				do_crypt = 1;
			}else{
				printf(" unkonw param: %s\n", argv[ap]);
				goto _help;
			}
		}else{
			if(iso_name==NULL){
				iso_name = argv[ap];
			}else if(pbp_name==NULL){
				pbp_name = argv[ap];
			}
		}

		ap += 1;
	}

	if(iso_name==NULL)
		iso_name = "NP.ISO";
	if(pbp_name==NULL)
		pbp_name = "EBOOT.PBP";

	if(builtin_base==0){
		np_base = load_base(npb_name);
		if(np_base==NULL){
			printf("Load base %s faield!\n", npb_name);
			goto _help;
		}
		show_npinfo(np_base);
		if(do_save_base==1){
			save_base(np_base);
		}
	}

	iso_fp = open_file(iso_name, &iso_size);
	if(iso_fp==NULL){
		printf("Open file %s faield!\n", iso_name);
		goto _help;
	}

	if(builtin_base==1){
		np_base = find_base(iso_size);
		show_npinfo(np_base);
	}

	if(iso_size>np_base->max_size){
		printf("ISO is too big to fake! %d>%d\n", iso_size, np_base->max_size);
		goto _help;
	}

	// ready to fake!

	total_block = np_base->total_block;
	block_size  = np_base->block_size;
	iso_block = (iso_size+block_size-1)/block_size;

	show_isoinfo(iso_name, iso_block, iso_size);


	printf("Output: %s\n", pbp_name);
	
	// create PBP file
	pbp_fp = fopen(pbp_name, "wb");
	if(pbp_fp==NULL){
		printf("Create %s failed!\n", pbp_name);
		exit(-1);
	}


	// write pbp header and icon file
	table_offset = write_pbp_part1(np_base, pbp_fp, iso_name);

	// write empty table first.
	table_size = total_block*0x20;
	table_buf = malloc(table_size);
	memset(table_buf, 0, table_size);
	fwrite(table_buf, table_size, 1, pbp_fp);

	iso_offset = 256+table_size;

	iso_buf = malloc(block_size*2);
	lzrc_buf = malloc(block_size*2);

	printf("  write iso block ...\n");
	// process iso block
	for(i=0; i<iso_block; i++){
		u8 *tb = table_buf+i*0x20;
		u8 *wbuf;
		int wsize, lzrc_size, ratio;

		fread(iso_buf, block_size, 1, iso_fp);

		wbuf = iso_buf;
		wsize = block_size;

		if(do_comp==1){
			lzrc_size = lzrc_compress(lzrc_buf, block_size*2, iso_buf, block_size);
			memset(lzrc_buf+lzrc_size, 0, 16);
			ratio = (lzrc_size*100)/block_size;
			if(ratio<RATIO_LIMIT){
				wbuf = lzrc_buf;
				wsize = (lzrc_size+15)&~15;
			}
		}

		*(u32*)(tb+0x10) = iso_offset;
		*(u32*)(tb+0x14) = wsize;
		*(u32*)(tb+0x18) = 0;   // bit0=1: skip MAC check.
								// bit2=1: skip CIPHER encrypt
		*(u32*)(tb+0x1c) = 0;

		// encrypt block
		if(do_crypt==1){
			sceDrmBBCipherInit(&ckey, 1, 2, np_base->np_header+0xa0, np_base->key, iso_offset>>4);
			sceDrmBBCipherUpdate(&ckey, wbuf, wsize);
			sceDrmBBCipherFinal(&ckey);
		}

		// generic MAC
		sceDrmBBMacInit(&mkey, 3);
		sceDrmBBMacUpdate(&mkey, wbuf, wsize);
		sceDrmBBMacFinal(&mkey, tb, np_base->key);
		bbmac_build_final2(3, tb);

		encrypt_table(tb);

		// write iso data
		wsize = (wsize+15)&~15;
		fwrite(wbuf, wsize, 1, pbp_fp);

		// update offset
		iso_offset += wsize;
		printf("\r    %02d%%    ", i*100/iso_block);
	}
예제 #12
0
int main (int argc, char *argv[])
{
    int i, n, ib, nb, nz, nv, celldim, phydim;
    int nn, type, *elems = 0, idata[5];
    cgsize_t ne;
    char *p, basename[33], title[65];
    float value, *var;
    SOLUTION *sol;
    FILE *fp;

    if (argc < 2)
        print_usage (usgmsg, NULL);

    ib = 0;
    basename[0] = 0;
    while ((n = getargs (argc, argv, options)) > 0) {
        switch (n) {
            case 'a':
                ascii = 1;
                break;
            case 'b':
                ib = atoi (argarg);
                break;
            case 'B':
                strncpy (basename, argarg, 32);
                basename[32] = 0;
                break;
            case 'w':
                weighting = 1;
                break;
            case 'S':
                usesol = atoi (argarg);
                break;
        }
    }

    if (argind > argc - 2)
        print_usage (usgmsg, "CGNSfile and/or Tecplotfile not given");
    if (!file_exists (argv[argind]))
        FATAL (NULL, "CGNSfile does not exist or is not a file");

    /* open CGNS file */

    printf ("reading CGNS file from %s\n", argv[argind]);
    nb = open_cgns (argv[argind], 1);
    if (!nb)
        FATAL (NULL, "no bases found in CGNS file");
    if (*basename && 0 == (ib = find_base (basename)))
        FATAL (NULL, "specified base not found");
    if (ib > nb) FATAL (NULL, "base index out of range");
    cgnsbase = ib ? ib : 1;
    if (cg_base_read (cgnsfn, cgnsbase, basename, &celldim, &phydim))
        FATAL (NULL, NULL);
    if (celldim != 3 || phydim != 3)
        FATAL (NULL, "cell and physical dimension must be 3");
    printf ("  using base %d - %s\n", cgnsbase, basename);

    if (NULL == (p = strrchr (argv[argind], '/')) &&
        NULL == (p = strrchr (argv[argind], '\\')))
        strncpy (title, argv[argind], sizeof(title));
    else
        strncpy (title, ++p, sizeof(title));
    title[sizeof(title)-1] = 0;
    if ((p = strrchr (title, '.')) != NULL)
        *p = 0;

    read_zones ();
    if (!nZones)
        FATAL (NULL, "no zones in the CGNS file");
    
    /* verify dimensions fit in an integer */

    for (nz = 0; nz < nZones; nz++) {
        if (Zones[nz].nverts > CG_MAX_INT32)
	    FATAL(NULL, "zone size too large to write with integers");
	if (Zones[nz].type == CGNS_ENUMV(Unstructured)) {
            count_elements (nz, &ne, &type);
            if (ne > CG_MAX_INT32)
	        FATAL(NULL, "too many elements to write with integers");
        }
     }

    nv = 3 + check_solution ();

    /* open Tecplot file */

    printf ("writing %s Tecplot data to <%s>\n",
        ascii ? "ASCII" : "binary", argv[++argind]);
    if (NULL == (fp = fopen (argv[argind], ascii ? "w+" : "w+b")))
        FATAL (NULL, "couldn't open Tecplot output file");

    /* write file header */

    if (ascii)
        fprintf (fp, "TITLE = \"%s\"\n", title);
    else {
        fwrite ("#!TDV75 ", 1, 8, fp);
        i = 1;
        write_ints (fp, 1, &i);
        write_string (fp, title);
    }

    /* write variables */

    if (ascii) {
        fprintf (fp, "VARIABLES = \"X\", \"Y\", \"Z\"");
        if (usesol) {
            sol = Zones->sols;
            for (n = 0; n < sol->nflds; n++)
                fprintf (fp, ",\n\"%s\"", sol->flds[n].name);
        }
    }
    else {
        write_ints (fp, 1, &nv);
        write_string (fp, "X");
        write_string (fp, "Y");
        write_string (fp, "Z");
        if (usesol) {
            sol = Zones->sols;
            for (n = 0; n < sol->nflds; n++)
                write_string (fp, sol->flds[n].name);
        }
    }

    /* write zones */

    if (!ascii) {
        for (nz = 0; nz < nZones; nz++) {
            if (Zones[nz].type == CGNS_ENUMV(Structured)) {
                idata[0] = 0;          /* BLOCK */
                idata[1] = -1;         /* color not specified */
                idata[2] = (int)Zones[nz].dim[0];
                idata[3] = (int)Zones[nz].dim[1];
                idata[4] = (int)Zones[nz].dim[2];
            }
            else {
                count_elements (nz, &ne, &type);
                idata[0] = 2;          /* FEBLOCK */
                idata[1] = -1;         /* color not specified */
                idata[2] = (int)Zones[nz].dim[0];
                idata[3] = (int)ne;
                idata[4] = type;
            }
            value = 299.0;
            write_floats (fp, 1, &value);
            write_string (fp, Zones[nz].name);
            write_ints (fp, 5, idata);
        }
        value = 357.0;
        write_floats (fp, 1, &value);
    }

    for (nz = 0; nz < nZones; nz++) {
        printf ("  zone %d...", nz+1);
        fflush (stdout);
        read_zone_grid (nz+1);
        ne = 0;
        type = 2;
        nn = (int)Zones[nz].nverts;
        var = (float *) malloc (nn * sizeof(float));
        if (NULL == var)
            FATAL (NULL, "malloc failed for temp float array");
        if (Zones[nz].type == CGNS_ENUMV(Unstructured))
            elems = volume_elements (nz, &ne, &type);

        if (ascii) {
            if (Zones[nz].type == CGNS_ENUMV(Structured))
                fprintf (fp, "\nZONE T=\"%s\", I=%d, J=%d, K=%d, F=BLOCK\n",
                    Zones[nz].name, (int)Zones[nz].dim[0],
                    (int)Zones[nz].dim[1], (int)Zones[nz].dim[2]);
            else
                fprintf (fp, "\nZONE T=\"%s\", N=%d, E=%d, F=FEBLOCK, ET=%s\n",
                    Zones[nz].name, nn, (int)ne, type == 2 ? "TETRAHEDRON" : "BRICK");
        }
        else {
            value = 299.0;
            write_floats (fp, 1, &value);
            i = 0;
            write_ints (fp, 1, &i);
            i = 1;
            for (n = 0; n < nv; n++)
                write_ints (fp, 1, &i);
        }

        for (n = 0; n < nn; n++)
            var[n] = (float)Zones[nz].verts[n].x;
        write_floats (fp, nn, var);
        for (n = 0; n < nn; n++)
            var[n] = (float)Zones[nz].verts[n].y;
        write_floats (fp, nn, var);
        for (n = 0; n < nn; n++)
            var[n] = (float)Zones[nz].verts[n].z;
        write_floats (fp, nn, var);

        if (usesol) {
            read_solution_field (nz+1, usesol, 0);
            sol = &Zones[nz].sols[usesol-1];
            if (sol->location != CGNS_ENUMV(Vertex))
                cell_vertex_solution (nz+1, usesol, weighting);
            for (nv = 0; nv < sol->nflds; nv++) {
                for (n = 0; n < nn; n++)
                    var[n] = (float)sol->flds[nv].data[n];
                write_floats (fp, nn, var);
            }
        }

        free (var);

        if (Zones[nz].type == CGNS_ENUMV(Unstructured)) {
            if (!ascii) {
                i = 0;
                write_ints (fp, 1, &i);
            }
            nn = 1 << type;
            for (i = 0, n = 0; n < ne; n++, i += nn)
                write_ints (fp, nn, &elems[i]);
            free (elems);
        }
        puts ("done");
    }

    fclose (fp);
    cg_close (cgnsfn);
    return 0;
}
예제 #13
0
bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
#ifdef WIN32
	hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE, GetCurrentProcessId());
#endif
	PLUGIN_SAVEVARS();

	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);


#if defined METAMOD_PLAPI_VERSION
	if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL)
#endif
	{
		ismm->AddListener(this, this);
		ismm->EnableVSPListener();
	}


#if !defined METAMOD_PLAPI_VERSION
	m_EngineCC = SH_GET_CALLCLASS(engine);
#endif

#if SOURCE_ENGINE >= SE_ORANGEBOX
	g_pCVar = icvar;
	ConVar_Register(0, &s_BaseAccessor);
#else
	ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif

	char* base_addr = NULL;
	size_t base_len = 0;

	find_base(matchmaking_dll, base_addr, base_len);

#ifdef WIN32
	if(base_addr == NULL)
		find_base("matchmaking.dll", base_addr, base_len);
#endif

	if(lobby_match_ptr == NULL){
		lobby_match_ptr = (char*)FindSignature(lobby_match, base_addr, base_len, true);
		get_org_sig(lobby_match, (const char*)lobby_match_new, lobby_match_org);
	}

	find_base(engine_dll, base_addr, base_len);
	if(max_players_friend_lobby == NULL){
		max_players_friend_lobby = (char*)FindSignature(friends_lobby, base_addr, base_len);
		get_org_sig(max_players_friend_lobby, (const char*)friends_lobby_new, friends_lobby_org);
	}
	if(max_players_connect == NULL){
		max_players_connect = (char*)FindSignature(max_players, base_addr, base_len);
		if(max_players_connect != NULL){
			get_org_sig(max_players_connect, (const char*)max_players_new, max_players_org);
		}
	}
	if(lobby_sux_ptr==NULL){

#ifdef WIN32
		lobby_sux_ptr = max_players_connect;
#else
		lobby_sux_ptr = (char*)FindSignature(lobby_sux, base_addr, base_len);
#endif
		if(lobby_sux_ptr!=NULL){
			get_org_sig(lobby_sux_ptr, lobby_sux_new, lobby_sux_org);
		}
	}
#ifdef WIN32
	if(max_players_server_browser == NULL){
		max_players_server_browser = (char*)FindSignature(server_bplayers, base_addr, base_len);
		get_org_sig(max_players_server_browser, (const char*)server_bplayers_new, server_bplayers_org);
	}
#endif
	if(tmp_player == NULL){
		tmp_player = (char*)FindSignature(players, base_addr, base_len);
		if(tmp_player != NULL){
#ifdef WIN32
			tmp_player2 = (char*)FindSignature(players2, base_addr, base_len);
#else
			tmp_player2 = tmp_player;
#endif
			if(tmp_player2 != NULL){
				get_org_sig(tmp_player, players_new, players_org);
				WriteSignature(tmp_player, players_new);
				get_org_sig(tmp_player2, players_new2, players_org2);
				WriteSignature(tmp_player2, players_new2);
				engine->ServerCommand("maxplayers 32\n");
				engine->ServerCommand("L4DToolZ [email protected]\n");
			}
		}
	}
	if(unreserved_ptr==NULL){
		unreserved_ptr = (char*)FindSignature(unreserved, base_addr, base_len);
		get_org_sig(unreserved_ptr, unreserved_new, unreserved_org);
	}

	find_base(server_dll, base_addr, base_len);

	if(chuman_limit == NULL){
		chuman_limit = (char*)FindSignature(human_limit, base_addr, base_len);
		get_org_sig(chuman_limit, human_limit_new, human_limit_org);
	}

#ifndef WIN32
	if(max_players_server_browser == NULL){
		max_players_server_browser = (char*)FindSignature(server_bplayers, base_addr, base_len);
		get_org_sig(max_players_server_browser, (const char*)server_bplayers_new, server_bplayers_org);
	}
#endif

	return true;
}
예제 #14
0
bool l4dtoolz::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{

	PLUGIN_SAVEVARS();

	GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);


#if defined METAMOD_PLAPI_VERSION
	if ((vsp_callbacks = ismm->GetVSPInfo(NULL)) == NULL)
#endif
	{
		ismm->AddListener(this, this);
		ismm->EnableVSPListener();
	}


#if !defined METAMOD_PLAPI_VERSION
	m_EngineCC = SH_GET_CALLCLASS(engine);
#endif

#if SOURCE_ENGINE >= SE_ORANGEBOX
	g_pCVar = icvar;
	ConVar_Register(0, &s_BaseAccessor);
#else
	ConCommandBaseMgr::OneTimeInit(&s_BaseAccessor);
#endif

	struct base_addr_t base_addr;
	base_addr.addr = NULL;
	base_addr.len = 0;

	find_base(matchmaking_dll, &base_addr);

	if(base_addr.addr == NULL)
		find_base(matchmaking_dll_alt, &base_addr);

	if(!lobby_match_ptr) {
		lobby_match_ptr = find_signature(lobby_match, &base_addr, 1);
		get_original_signature(lobby_match_ptr, lobby_match_new, lobby_match_org);
	}

	find_base(engine_dll, &base_addr);
	if(!max_players_friend_lobby) {
		max_players_friend_lobby = find_signature(friends_lobby, &base_addr, 0);
		get_original_signature(max_players_friend_lobby, friends_lobby_new, friends_lobby_org);
	}
	if(!max_players_connect) {
		max_players_connect = find_signature(max_players, &base_addr, 0);
		get_original_signature(max_players_connect, max_players_new, max_players_org);
	}
	if(!lobby_sux_ptr) {

#ifdef WIN32
		lobby_sux_ptr = max_players_connect;
#else
		lobby_sux_ptr = find_signature(lobby_sux, &base_addr, 0);
#endif
		get_original_signature(lobby_sux_ptr, lobby_sux_new, lobby_sux_org);
	}
#ifdef WIN32
	if(!max_players_server_browser) {
		max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
		get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
	}
#endif
	if(!tmp_player) {
		tmp_player = find_signature(players, &base_addr, 0);
		if(tmp_player) {
#ifdef WIN32
			tmp_player2 = find_signature(players2, &base_addr, 0);
#else
			tmp_player2 = tmp_player;
#endif
			if(tmp_player2) {
				get_original_signature(tmp_player, players_new, players_org);
				write_signature(tmp_player, players_new);
				get_original_signature(tmp_player2, players_new2, players_org2);
				write_signature(tmp_player2, players_new2);
				engine->ServerCommand("maxplayers 32\n");
				engine->ServerCommand("L4DToolZ [email protected]\n");
			}
		}
	}
	if(!unreserved_ptr) {
		unreserved_ptr = find_signature(unreserved, &base_addr, 0);
		get_original_signature(unreserved_ptr, unreserved_new, unreserved_org);
	}

	find_base(server_dll, &base_addr);

	if(!chuman_limit) {
		chuman_limit = find_signature(human_limit, &base_addr, 0);
		get_original_signature(chuman_limit, human_limit_new, human_limit_org);
	}

#ifndef WIN32
	if(!max_players_server_browser) {
		max_players_server_browser = find_signature(server_bplayers, &base_addr, 0);
		get_original_signature(max_players_server_browser, server_bplayers_new, server_bplayers_org);
	}
#endif

	return true;
}
예제 #15
0
파일: cpu.c 프로젝트: kusma/vasm
static int translate(instruction *p,section *sec,taddr pc)
{
  int c=p->code,e=mnemonics[c].ext.encoding;
  taddr val;

  if(p->qualifiers[0]){
    /* extend to larger variants if ccs are required */
    if(e==EN_MEMDISP16)
      c=replace(c,EN_MEMDISP32);
    if(e==EN_ARITHR16)
      c=replace(c,EN_ARITHR32);
    if(e==EN_ARITHI16)
      c=replace(c,EN_ARITHI32);
  }
  if(e==EN_ARITHI32){
    if(p->op[2]){
      if(!chkval(p->op[2]->offset,sec,pc,6,1)&&(!strcmp("add",mnemonics[c].name)||!strcmp("sub",mnemonics[c].name)))
	c=replace(c,EN_ADD48);
    }else{
      if((c<32)&&(!chkval(p->op[1]->offset,sec,pc,6,1)))
	c=replace(c,EN_ARITHI48);
    }
  }
  if(e==EN_ARITHI16){
    if(!chkval(p->op[1]->offset,sec,pc,5,0))
      c=replace(c,EN_ARITHI48);
  }
  if(e==EN_RBRANCH16){
    symbol *base;
    if(find_base(p->op[0]->offset,&base,sec,pc)!=BASE_OK||!LOCREF(base)||base->sec!=sec)
      c=replace(c,EN_RBRANCH32);
    else{
      int i;
      i=eval_expr(p->op[0]->offset,&val,sec,pc);
      val-=pc;
      if(val>126||val<-128)
	c=replace(c,EN_RBRANCH32);
    }
  }
  if(e==EN_ADDCMPB32){
    int i;
    i=eval_expr(p->op[3]->offset,&val,sec,pc);
    val-=pc;
    if(val>1022||val<-1024)
      c+=4;
    else if(p->op[2]->type!=OP_REG&&(val>254||val<-256))
      c+=4;
  }
  if((e==EN_MEMDISP16||e==EN_MEMDISP32||e==EN_MEM12DISP32||e==EN_MEM16DISP32)){
    if(!eval_expr(p->op[1]->offset,&val,sec,pc)){
      c=replace(c,EN_MEM48);
    }else{
      if(e==EN_MEMDISP16&&(val<0||val>54||(val&3))){
	if(val<=4095&&val>=-4096)
	  c=replace(c,EN_MEM12DISP32);
	else
	  c=replace(c,EN_MEM48);
      }
    }
  }
  /* todo */
  return c;
}
예제 #16
0
int main (int argc, char *argv[])
{
    int n, ib, nb, is, nz, celldim, phydim;
    cgsize_t imax;
    char basename[33];

    if (argc < 2)
        print_usage (usgmsg, NULL);

    ib = 0;
    basename[0] = 0;
    while ((n = getargs (argc, argv, options)) > 0) {
        switch (n) {
            case 's':
                mblock = 0;
                break;
            case 'p':
                whole = 0;
                break;
            case 'n':
                use_iblank = 0;
                break;
            case 'f':
            case 'u':
                format = n;
                break;
            case 'd':
                use_double = 1;
                break;
            case 'b':
                ib = atoi (argarg);
                break;
            case 'B':
                strncpy (basename, argarg, 32);
                basename[32] = 0;
                break;
            case 'g':
                gamma = atof (argarg);
                if (gamma <= 1.0)
                    FATAL (NULL, "invalid value for gamma");
                break;
            case 'w':
                weighting = 1;
                break;
            case 'S':
                usesol = atoi (argarg);
                break;
        }
    }

    if (argind > argc - 2)
        print_usage (usgmsg, "CGNSfile and/or XYZfile not given");
    if (!file_exists (argv[argind]))
        FATAL (NULL, "CGNSfile does not exist or is not a file");

    /* open CGNS file */

    printf ("reading CGNS file from %s\n", argv[argind]);
    nb = open_cgns (argv[argind], 1);
    if (!nb)
        FATAL (NULL, "no bases found in CGNS file");
    if (*basename && 0 == (ib = find_base (basename)))
        FATAL (NULL, "specified base not found");
    if (ib > nb) FATAL (NULL, "base index out of range");
    cgnsbase = ib ? ib : 1;
    if (cg_base_read (cgnsfn, cgnsbase, basename, &celldim, &phydim))
        FATAL (NULL, NULL);
    if (celldim != 3 || phydim != 3)
        FATAL (NULL, "cell and/or physical dimension must be 3");
    printf ("  using base %d - %s\n", cgnsbase, basename);

    read_zones ();
    for (nz = 0; nz < nZones; nz++) {
	if (Zones[nz].type == CGNS_ENUMV(Structured)) {
	    /* verify we can write out using ints */
	    for (n = 0; n < 3; n++) {
		if (Zones[nz].dim[n] > CG_MAX_INT32)
		    FATAL(NULL, "zone dimensions too large for integer");
	    }
	    if (whole) {
		if (Zones[nz].nverts > CG_MAX_INT32)
		    FATAL(NULL, "zone too large to write as whole using an integer");
	    }
	    else {
	        if (Zones[nz].dim[0]*Zones[nz].dim[1] > CG_MAX_INT32)
		    FATAL(NULL, "zone too large to write using an integer");
	    }
	    nblocks++;
	}
    }
    if (!nblocks) FATAL (NULL, "no structured zones found");

    /* read the nodes */

    printf ("reading %d zones\n", nblocks);
    ib = is = 0;
    imax = 0;
    for (nz = 0; nz < nZones; nz++) {
        if (Zones[nz].type == CGNS_ENUMV(Structured)) {
            printf ("  zone %d - %s ... ", nz+1, Zones[nz].name);
            fflush (stdout);
            read_zone_grid (nz+1);
            ib += read_zone_interface (nz+1);
            is += check_solution (nz);
            if (imax < Zones[nz].nverts) imax = Zones[nz].nverts;
            puts ("done");
        }
    }

    if (!ib) use_iblank = 0;
    if (use_iblank) {
        iblank = (int *) malloc ((size_t)imax * sizeof(int));
        if (NULL == iblank)
            FATAL (NULL, "malloc failed for iblank array");
    }

    /* write Plot3d XYZ file */

    if (format == 'f')
        write_xyz_formatted (argv[++argind]);
    else if (format == 'u')
        write_xyz_unformatted (argv[++argind]);
    else
        write_xyz_binary (argv[++argind]);

    if (use_iblank) free (iblank);

    /* write solution file */

    if (++argind < argc) {
        if (is != nblocks) {
            fprintf (stderr, "solution file is not being written since not\n");
            fprintf (stderr, "all the blocks contain a complete solution\n");
            cg_close (cgnsfn);
            exit (1);
        }
        for (n = 0; n < 5; n++) {
            q[n] = (double *) malloc ((size_t)imax * sizeof(double));
            if (NULL == q[n])
                FATAL (NULL, "malloc failed for solution working array");
        }
        get_reference ();
        if (format == 'f')
            write_q_formatted (argv[argind]);
        else if (format == 'u')
            write_q_unformatted (argv[argind]);
        else
            write_q_binary (argv[argind]);
    }

    cg_close (cgnsfn);
    return 0;
}
예제 #17
0
파일: lab1.cpp 프로젝트: Shuiliusheng/DJ
void global_struct_array()//结构体定义
{
	int i=0;
	char op[expr_size],fuc1[expr_size],type[expr_size],fuc2[expr_size],dst[expr_size];

	for(i=2;i<num_inst-1;i++)//遍历所有指令,找到结构体的结构进行转换 结构体都变为单个变量
	{
		sscanf(inst[i-1],"%s %s %s",fuc2,op,op);
		sscanf(inst[i+1],"%s %s %s",dst,op,op);
		sscanf(inst[i],"%s %s %s",op,fuc1,type);
		if(strcmp(fuc2,"mul")==0&&strcmp(dst,"add")==0&&strcmp(op,"add")==0&&find_base(fuc1,dst))//找到base,结构体的标志1
		{
			char temp[200];
			strcpy(temp,dst);
			int now=i;
			for(i=i+2;i<num_inst;i++)//offset代表结构体的进一步访问
			{
				sscanf(inst[i],"%s %s %s",op,fuc1,fuc2);
				int reg=0;
				get_op(fuc2,dst,reg);
				if(strcmp(op,"add")==0&&judge_offset(dst,fuc2))
				{
					strcat(temp,"_");
					strcat(temp,fuc2);
				}
				else if(i>now+2)//如果有offset,则说明为结构体,使用辅助指令struct,指明是结构体
				{
					if(strcmp(type,"GP")==0)
						strcpy(var_name[num_v++],temp);//将全局结构体保存下来

					sscanf(inst[now-1],"%s %s %s",op,fuc1,fuc2);

					int reg=0;
					int t=get_op(fuc1,dst,reg);
		
					if(t==1)
						sprintf(inst[i-1]," array %s[%s] %s %s ",temp,dst,temp,type);
					else if(t==3)
					{
						sprintf(inst[now-1]," var %s ",fuc1);
						sprintf(inst[i-1]," array %s[%s] %s %s ",temp,dst,temp,type);
					}
					else if(t==2)
					{
						sprintf(inst[i-1]," array %s[(%s)] %s %s %s %d",temp,fuc1,temp,type,"reg",reg);
					}
					i--;
					for(now;now<i;now++)
						sprintf(inst[now],"nop ");
					break;
				}
				else
					break;
			}
		}
		
	}
	int list[1000],num=0;
	define_var(var_name,num_v,list,num);//局部变量定义
	for(i=0;i<num;i++)
	{
		add_tab();
		fprintf(fw,"long %s[%d]; \n",var_name[list[i]],array_size);
	}
}