static int out_equ(ea_t ea) { char buf[MAXSTR]; char *const end = buf + sizeof(buf); segment_t *s = getseg(ea); if ( s != NULL && s->type == SEG_IMEM && ash.a_equ != NULL) { char nbuf[MAXSTR]; char *name = get_name(BADADDR, ea, nbuf, sizeof(nbuf)); if ( name != NULL && ((ash.uflag & UAS_PBYTNODEF) == 0 || !IsPredefined(name)) ) { get_colored_name(BADADDR, ea, buf, sizeof(buf)); uchar off = uchar(ea - get_segm_base(s)); do_out_equ(buf, ash.a_equ, off); if ( (ash.uflag & UAS_AUBIT) == 0 && (off & 0xF8) == off ) { char *ptr = tag_on(tail(buf), end, COLOR_SYMBOL); APPCHAR(ptr, end, ash.uflag & UAS_NOBIT ? '_' : '.'); APPCHAR(ptr, end, '0'); tag_off(ptr, end, COLOR_SYMBOL); for ( int i=0; i < 8; i++ ) { const ioport_bit_t *b = find_bit(off, i); char *p2 = ptr; if ( b == NULL || b->name == NULL ) ptr[-1] = '0' + i; else p2 = tag_addstr(ptr-1, end, COLOR_HIDNAME, b->name); tag_off(p2, end, COLOR_SYMBOL); do_out_equ(buf, ash.a_equ, off+i); } MakeNull(); } } else { gl_name = 0; MakeLine(""); } return 1; } if ( ash.uflag & UAS_NODS ) { if ( !isLoaded(ea) && s->type == SEG_CODE ) { adiff_t org = ea - get_segm_base(s) + get_item_size(ea); btoa(buf, sizeof(buf), org); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); return 1; } } return 0; }
int sig_add_address(psig_t * sig, short opcodes[256], ea_t ea, bool b, bool line, char options) { unsigned char byte; unsigned char buf[200]; uint32 s, i; bool call; bool cj; ea_t tea; flags_t f; if (line) dline_add(&sig->dl, ea, options); if (is_jump(sig, ea, &call, &cj)) return -1; byte = get_byte_with_optimization(ea); if (remove_instr(byte, ea)) return -1; sig->lines++; opcodes[byte]++; if (!b && !call) { if (cj) { buf[0] = byte; s = 1; } else { s = (uint32)get_item_size(ea); if (s > sizeof(buf)) s = sizeof(buf); get_many_bytes(ea, buf, s); } for (i=0; i<s; i++) { sig->crc_hash += buf[i]; sig->crc_hash += ( sig->crc_hash << 10 ); sig->crc_hash ^= ( sig->crc_hash >> 6 ); } } else if (b)
static void get_user_defined_prefix(ea_t ea, int lnnum, int indent, const char *line, char *buf, size_t bufsize) { buf[0] = '\0'; // empty prefix by default // We want to display the prefix only the lines which // contain the instruction itself if ( indent != -1 ) return; // a directive if ( line[0] == '\0' ) return; // empty line if ( *line == COLOR_ON ) line += 2; if ( *line == ash.cmnt[0] ) return; // comment line... // We don't want the prefix to be printed again for other lines of the // same instruction/data. For that we remember the line number // and compare it before generating the prefix static ea_t old_ea = BADADDR; static int old_lnnum; if ( old_ea == ea && old_lnnum == lnnum ) return; // Let's display the size of the current item as the user-defined prefix ulong our_size = get_item_size(ea); // seems to be an instruction line. we don't bother about the width // because it will be padded with spaces by the kernel qsnprintf(buf, bufsize, " %d", our_size); // Remember the address and line number we produced the line prefix for: old_ea = ea; old_lnnum = lnnum; }
/* * * reads a variable out the configfile * fp = stream * var_name = variable name * section_name = section name * if NULL sections are ignored * mode = 0 -> normal mode * 1 -> get only global variables * return = value * = NULL bij een fout * */ char * real_get_config(FILE *fp,char *section_name,char *var_name,int mode) { int l; int sect=0,global=1; char *r=NULL,*c=NULL,*ss=NULL,s[BUFFER_LEN],*start_section=NULL; char *end_section=NULL,*current_section=NULL; if(var_name==NULL) return(NULL); if(fp==NULL) return NULL; fseek(fp,0,SEEK_SET); if (s==NULL) return(NULL); if (section_name!=NULL) { start_section=(char *)xmalloc(strlen(section_name)+1+strlen("<")+strlen(">")); end_section=(char *)xmalloc(strlen(section_name)+1+strlen("</")+strlen(">")); strcpy(start_section,"<"); strcat(start_section,section_name); strcat(start_section,">"); strcpy(end_section,"</"); strcat(end_section,section_name); strcat(end_section,">"); } else sect=1; while (fgets(s,BUFFER_LEN,fp)) { if(!(strrchr(s,'\n'))) {errno=E2BIG;return(NULL);} /* line too long */ s[strlen(s)-1]='\0'; cut_rem(s); if(mode==1) { ss=only_global(s,¤t_section,&global); } else ss=s; if(ss==NULL) return (NULL); if (section_name!=NULL) { if (!sect) { if((c=istrstr(ss,start_section))!=NULL) { ss=c;sect=1; } } if (sect) { if ((c=istrstr(ss,end_section))!=NULL) { ss=c;sect=0; } } } if ((sect)&&(ss!=NULL)) { c=mv_2_next(ss); l=strlen(var_name); if (get_item_size(c)==l) { if (!strncasecmp(c,var_name,l)) { c+=l; c=mv_2_next(c); if (r==NULL) r=(char *)xmalloc(strlen(c)+1); else r=(char *) xrealloc(r,strlen(c)+1); if(r==NULL) break; strcpy(r,c); } } } } if((mode==1)&&(ss!=NULL)) xfree(ss); if(start_section!=NULL) xfree(start_section); if(end_section!=NULL) xfree(end_section); if(current_section!=NULL) xfree(current_section); return(r); }