// output a displacement static void outdispl(void) { if ( is_displ_indx() ) { out_symbol('('); outaddr(cmd.Op1, false); out_symbol(','); if ( !(ash.uflag & UAS_INDX_NOSPACE)) OutChar(' ' ); outreg(cmd.Op1.reg); out_symbol(')'); return; } if ( is_displ_indy() ) { out_symbol('('); outaddr(cmd.Op1, false); out_symbol(')'); out_symbol(','); OutChar(' '); outreg(cmd.Op1.reg); return; } if ( is_displ_zpx() || is_displ_zpy() || is_displ_absx() || is_displ_absy() ) { outaddr(cmd.Op1, false); out_symbol(','); OutChar(' '); outreg(cmd.Op1.reg); return; } INTERR(10023); }
//---------------------------------------------------------------------- void out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); // setup the output pointer OutMnem(); // output instruction mnemonics out_one_operand(0); // output the first operand //Вывод операнда if(cmd.Op2.type != o_void) { out_symbol(',');//вывод разделителя между операндами //если неуказан флаг UAS_NOSPA ставим пробел if(!(ash.uflag & UAS_NOSPA)) OutChar(' '); out_one_operand(1); } if(cmd.Op3.type != o_void) { out_symbol(','); if(!(ash.uflag & UAS_NOSPA)) OutChar(' '); out_one_operand(2); } if(isVoid(cmd.ea, uFlag, 0)) OutImmChar(cmd.Op1); if(isVoid(cmd.ea, uFlag, 1)) OutImmChar(cmd.Op2); if(isVoid(cmd.ea, uFlag, 2)) OutImmChar(cmd.Op3); term_output_buffer(); gl_comm = 1; MakeLine(buf); }
void out( void ) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); OutMnem(); out_one_operand( 0 ); if( cmd.Op2.type != o_void ) { out_symbol( ',' ); OutChar( ' ' ); out_one_operand( 1 ); } if( cmd.Op3.type != o_void ) { out_symbol( ',' ); OutChar( ' ' ); out_one_operand( 2 ); } if( isVoid( cmd.ea, uFlag, 0 ) ) OutImmChar( cmd.Op1 ); if( isVoid( cmd.ea, uFlag, 1 ) ) OutImmChar( cmd.Op2 ); if( isVoid( cmd.ea, uFlag, 2 ) ) OutImmChar( cmd.Op3 ); term_output_buffer(); gl_comm = 1; MakeLine( buf ); }
// outputs an instruction void idaapi out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); OutMnem(); out_one_operand(0); // output the first operand if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); } if ( cmd.Op3.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(2); } // output a character representation of the immediate values // embedded in the instruction as comments if ( isVoid(cmd.ea,uFlag,0)) OutImmChar(cmd.Op1 ); if ( isVoid(cmd.ea,uFlag,1)) OutImmChar(cmd.Op2 ); if ( isVoid(cmd.ea,uFlag,2)) OutImmChar(cmd.Op3 ); term_output_buffer(); // terminate the output string gl_comm = 1; // ask to attach a possible user- // defined comment to it MakeLine(buf); // pass the generated line to the // kernel }
// Output an instruction void out(void) { // // print insn mnemonic // char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); char postfix[5]; postfix[0] = '\0'; if ( is_jmp_cc(cmd.itype) ) qstrncpy(postfix, ConditionCodes[cmd.auxpref], sizeof(postfix)); OutMnem(8, postfix); // // print insn operands // out_one_operand(0); // output the first operand if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); } if ( cmd.Op3.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(2); } // output a character representation of the immediate values // embedded in the instruction as comments if ( isVoid(cmd.ea,uFlag,0)) OutImmChar(cmd.Op1 ); if ( isVoid(cmd.ea,uFlag,1)) OutImmChar(cmd.Op2 ); if ( isVoid(cmd.ea,uFlag,2)) OutImmChar(cmd.Op3 ); if ( gr_cmt != NULL ) { OutChar(' '); out_line(ash.cmnt, COLOR_AUTOCMT); OutChar(' '); out_line(gr_cmt, COLOR_AUTOCMT); if ( ash.cmnt2 != NULL ) { OutChar(' '); out_line(ash.cmnt2, COLOR_AUTOCMT); } gr_cmt = NULL; } term_output_buffer(); // terminate the output string gl_comm = 1; // ask to attach a possible user- // defined comment to it MakeLine(buf); // pass the generated line to the // kernel }
DECODE_REF copen (PVOID InStream, STREAM_TYPE SType, STREAM_MODE SMode) { MEM_HANDLE h; DWORD StreamLength; _StreamType = SType; _Stream = InStream; if (SMode == STREAM_WRITE) /* writing */ { OutChar (0); /* skip future StreamLength */ OutChar (0); OutChar (0); OutChar (0); StreamLength = 0; } else /* reading */ { BYTE lobyte, hibyte; UWORD loword, hiword; lobyte = (BYTE)InChar (); hibyte = (BYTE)InChar (); loword = MAKE_WORD (lobyte, hibyte); lobyte = (BYTE)InChar (); hibyte = (BYTE)InChar (); hiword = MAKE_WORD (lobyte, hibyte); StreamLength = MAKE_DWORD (loword, hiword); } h = 0; if (StreamLength == 0xFFFFFFFF || (h = AllocCodeDesc ()) == 0 || (_lpCurCodeDesc = LockCodeDesc (h)) == 0) { _lpCurCodeDesc = 0; FreeCodeDesc (h); } else { _lpCurCodeDesc->fh = h; _lpCurCodeDesc->Stream = _Stream; _lpCurCodeDesc->StreamType = _StreamType; _lpCurCodeDesc->StreamMode = SMode; _lpCurCodeDesc->StreamLength = StreamLength; _lpCurCodeDesc->buf_index = N - F; memset ((PBYTE)&_lpCurCodeDesc->text_buf[0], ' ', N - F); StartHuff (); } return ((DECODE_REF)_lpCurCodeDesc); }
//---------------------------------------------------------------------- // generate a text representation of an instruction // the information about the instruction is in the 'cmd' structure void idaapi out(void) { char buf[MAXSTR]; // setup the output pointer init_output_buffer(buf, sizeof(buf)); // output instruction mnemonics OutMnem(); // check for JP/JR instruction with condition code // add the condition on as a pseudo operand if present if ((cmd.itype == SAM8_JR) || ((cmd.itype == SAM8_JP) && (cmd.c_condition != ccNone))) { // sanity check if (cmd.c_condition >= cc_last) { warning("%a (%s): Internal error: bad condition code %i", cmd.ea, cmd.get_canon_mnem(), cmd.c_condition); return; } // output the condition code normally out_keyword(ccNames[cmd.c_condition]); out_symbol(','); OutChar(' '); } // output the first operand if (cmd.Op1.type != o_void) { out_one_operand(0); } // output the second operand if (cmd.Op2.type != o_void) { out_symbol(','); OutChar(' '); out_one_operand(1); } // output the third operand if (cmd.Op3.type != o_void) { out_symbol(','); OutChar(' '); out_one_operand(2); } // terminate the output string term_output_buffer(); // ask to attach a possible user-defined comment to it gl_comm = 1; // pass the generated line to the kernel MakeLine(buf); }
//---------------------------------------------------------------------- size_t debLine(void) { OutChar('"'); out_tagoff(COLOR_STRING); if ( change_line()) return(0 ); return(putDeb(1)); }
// Convert number to string (char array) // Writes to timerOutput char array SINT32 BinToDec( int seconds ){ int md = 0; int ctr = 0; while( seconds ){ // Take new least significant digit md = seconds % 10; // Convert to char and place in array timerOutput[ctr] = md + '0'; // Remove handled digit seconds /= 10; ctr++; } // Last increment of ctr is above last index ctr--; // Output in reverse order while( ctr >= 0 ){ OutChar( timerOutput[ctr] ); ctr--; } OutString( (CHAR*)" seconds passed\n\r" ); return RTX_SUCCESS; }
//---------------------------------------------------------------------- uchar chkOutChar(char c) { if ( !checkLine(1)) return(1 ); ++outcnt; OutChar(c); return(0); }
//---------------------------------------------------------------------- // основная выводилка команд void N78K_out(void) { char buf[MAXSTR]; #if IDP_INTERFACE_VERSION > 37 init_output_buffer(buf, sizeof(buf)); // setup the output pointer #else uFlag = getFlags(cmd.ea); u_line = buf; #endif // выведем мнемонику OutMnem(); // выведем первый операнд if(cmd.Op1.type!=o_void)out_one_operand(0); // выведем второй операнд if(cmd.Op2.type != o_void) { out_symbol(','); OutChar(' '); out_one_operand(1); } // выведем непосредственные данные, если они есть if(isVoid(cmd.ea, uFlag, 0)) OutImmChar(cmd.Op1); if(isVoid(cmd.ea, uFlag, 1)) OutImmChar(cmd.Op2); #if IDP_INTERFACE_VERSION > 37 term_output_buffer(); #else *u_line = '\0'; #endif gl_comm = 1; MakeLine(buf); }
// Write string to SERIAL1 void OutString( CHAR* s ){ int ctr = 0; while( s[ctr] != '\0' ){ OutChar( s[ctr] ); ctr++; } }
//---------------------------------------------------------------------- void out(void) { char buf[MAXSTR]; // output .org for enties without any labels if ( !has_any_name(uFlag) && helper.altval(cmd.ea) ) { btoa(buf, sizeof(buf), cmd.ip); printf_line(inf.indent, COLSTR("%s %s", SCOLOR_ASMDIR), ash.origin, buf); } init_output_buffer(buf, sizeof(buf)); OutMnem(); out_one_operand(0); if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); } if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1); if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2); term_output_buffer(); gl_comm = 1; MakeLine(buf); }
//---------------------------------------------------------------------- void out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); int op; if (!(cmd.SpecialModes & TMS_MODE_USER_PARALLEL)) { if ((cmd.SpecialModes & TMS_MODE_LR) || (cmd.SpecialModes & TMS_MODE_CR)) { out_line(cmd.get_canon_mnem(), COLOR_INSN); out_line((cmd.SpecialModes & TMS_MODE_LR) ? ".lr ":".cr ", COLOR_INSN); } else OutMnem(); } else { // user-defined parallelism out_line("|| ", COLOR_INSN); out_line(cmd.get_canon_mnem(), COLOR_INSN); out_line(" ", COLOR_INSN); } for (op = 0; op < UA_MAXOP; op++) { if (cmd.Operands[op].type == o_void) break; if (op != 0) // not the first operand { if (cmd.Parallel != TMS_PARALLEL_BIT && op == cmd.Parallel) // multi-line instruction { term_output_buffer(); MakeLine(buf); // print the second instruction line init_output_buffer(buf, sizeof(buf)); if (cmd.SpecialModes & TMS_MODE_SIMULATE_USER_PARALLEL) out_line("|| ", COLOR_INSN); else out_line(":: ", COLOR_INSN); const char *insn2 = cmd.get_canon_mnem(); insn2 += strlen(insn2); insn2++; out_line(insn2, COLOR_INSN); } else out_symbol(','); OutChar(' '); } // print the operand out_one_operand(op); } // print immediate values for (op = 0; op < UA_MAXOP; op++) if ( isVoid(cmd.ea, uFlag, op) ) OutImmChar(cmd.Operands[op]); term_output_buffer(); gl_comm = 1; MakeLine(buf); }
//---------------------------------------------------------------------- void out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); const char *postfix = NULL; if ( cmd.auxpref & aux_byte ) postfix = ".b"; else if ( cmd.auxpref & aux_word ) postfix = ".w"; else if ( cmd.auxpref & aux_f ) postfix = "/f"; else if ( cmd.auxpref & aux_ne ) postfix = "/ne"; else if ( cmd.auxpref & aux_eq ) postfix = "/eq"; OutMnem(8, postfix); out_one_operand(0); if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); } if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1); if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2); term_output_buffer(); gl_comm = 1; MakeLine(buf); }
//---------------------------------------------------------------------- uchar chkOutSymSpace(char c) { if ( !checkLine(2)) return(1 ); out_symbol(c); OutChar(' '); outcnt += 2; return(0); }
//---------------------------------------------------------------------- bool chkOutChar(char c) { if ( !checkLine(1) ) return true; ++outcnt; OutChar(c); return false; }
//---------------------------------------------------------------------- bool chkOutSymSpace(char c) { if ( !checkLine(2) ) return true; out_symbol(c); OutChar(' '); outcnt += 2; return false; }
static void out_reg_if_bit(ushort reg, uval_t value, int bit) { if ( (value & bit) == bit ) { if ( print_comma ) { out_symbol(','); OutChar(' '); } out_reg(reg); print_comma = true; } }
//---------------------------------------------------------------------- uchar putShort(ushort value, uchar wsym) { char *p = get_output_ptr(); out_tagon(COLOR_ERROR); if ( wsym ) OutChar(wsym); OutLong(value, #ifdef __debug__ debugmode ? 16 : #endif 10); out_tagoff(COLOR_ERROR); char tmpstr[32]; char *end = set_output_ptr(p); size_t len = end - p; qstrncpy(tmpstr, p, qmin(len+1, sizeof(tmpstr))); return chkOutLine(tmpstr, tag_strlen(tmpstr)); }
//---------------------------------------------------------------------- uchar putShort(ushort value, uchar wsym) { char tmpstr[32]; register char *p = get_output_ptr(); out_tagon(COLOR_ERROR); if ( wsym) OutChar(wsym ); OutLong(value, #ifdef __debug__ debugmode ? 16 : #endif 10); out_tagoff(COLOR_ERROR); register size_t len = get_output_ptr() - p; memcpy(tmpstr, p, len); tmpstr[len] ='\0'; *p = '\0'; set_output_ptr(p); return(chkOutLine(tmpstr, tag_strlen(tmpstr))); }
//---------------------------------------------------------------------- void idaapi out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); OutMnem(); out_one_operand(0); if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); if ( cmd.IsParallel ) { // new line for Parallel instructions term_output_buffer(); MakeLine(buf); init_output_buffer(buf, sizeof(buf)); out_line("|| ", COLOR_INSN); const char *insn2 = NULL; switch ( cmd.itype ) { case TMS320C54_ld_mac: insn2 = "mac "; break; case TMS320C54_ld_macr: insn2 = "macr "; break; case TMS320C54_ld_mas: insn2 = "mas "; break; case TMS320C54_ld_masr: insn2 = "masr "; break; case TMS320C54_st_add: insn2 = "add "; break; case TMS320C54_st_sub: insn2 = "sub "; break; case TMS320C54_st_ld: insn2 = "ld "; break; case TMS320C54_st_mpy: insn2 = "mpy "; break; case TMS320C54_st_mac: insn2 = "mac "; break; case TMS320C54_st_macr: insn2 = "macr "; break; case TMS320C54_st_mas: insn2 = "mas "; break; case TMS320C54_st_masr: insn2 = "masr "; break; default: warning("interr: out parallel instruction"); } out_line(insn2, COLOR_INSN); } if ( cmd.Op3.type != o_void ) { if ( !cmd.IsParallel ) { out_symbol(','); OutChar(' '); } out_one_operand(2); if ( cmd.Op4_type != 0 ) { out_symbol(','); OutChar(' '); switch ( cmd.Op4_type ) { case o_reg: out_register(ph.regNames[cmd.Op4_value]); break; case o_cond8: out_cond8(cmd.Op4_value); break; default: break; } } } } if ( isVoid(cmd.ea, uFlag, 0) ) OutImmChar(cmd.Op1); if ( isVoid(cmd.ea, uFlag, 1) ) OutImmChar(cmd.Op2); if ( isVoid(cmd.ea, uFlag, 2) ) OutImmChar(cmd.Op3); term_output_buffer(); gl_comm = 1; MakeLine(buf); }
/************************************************************************ Function: void AnimateText(BYTE mov) Overview: Routine to move or animate the text. Input: mov - number of pixels the text will be moved Output: none ************************************************************************/ void AnimateText(BYTE mov) { static SHORT xPos = STXXPOS, yPos = STXYPOS; static SHORT x, y; SHORT width; SHORT height; SHORT newX, newY, oldX, oldY; XCHAR NewChar, *pString; // set the clipping region SetClip(CLIP_ENABLE); SetClipRgn(STXXPOS + 2, STXYPOS + 2, STXXPOS + STXWIDTH - 2, STXYPOS + STXHEIGHT - 2); // set the font SetFont(pHWData->pHWFont); // calculate string width & height width = GetTextWidth((XCHAR *)pHWData->pHWStr, pHWData->pHWFont); height = GetTextHeight(pHWData->pHWFont); //----------------------------------------------------------------- // interlace the erasing and printing of characters // check first if we need to move in the positive or negative direction if((xPos + width) >= (STXXPOS + STXWIDTH)) x = -(mov); if(xPos <= (STXXPOS)) x = (mov); if((yPos + height) >= (STXYPOS + STXHEIGHT)) y = -(mov); if(yPos <= (STXYPOS)) y = (mov); pString = pHWData->pHWStr; oldX = xPos; oldY = yPos; newX = xPos + x; newY = yPos + y; while((XCHAR)15 < (XCHAR)(NewChar = *pString++)) { // remove the old position of the character SetColor(FontScheme2->CommonBkColor); MoveTo(oldX, oldY); WAIT_UNTIL_FINISH(OutChar(NewChar)); oldX = GetX(); oldY = GetY(); // display the character in the new position SetColor(BRIGHTBLUE); MoveTo(newX, newY); WAIT_UNTIL_FINISH(OutChar(NewChar)); newX = GetX(); newY = GetY(); } xPos += x; yPos += y; // disable the clipping SetClip(CLIP_DISABLE); }
bool idaapi cr16c_outop(op_t& x) { switch(x.type) { case o_reg: out_register(ph.regNames[x.reg]); break; case o_displ: OutValue(x,OOF_SIGNED|OOFW_32); break; case o_phrase: out_symbol('('); switch(x.specflag1) { default: case PAR_ind_reg: out_register(ph.regNames[x.reg]); break; case PAR_ind_rp: out_register(ph.regNames[x.reg+16]); break; /* case PAR_ind_prp: out_register(ph.regNames[x.reg+16]); break;*/ case PAR_ind_rrp: out_register(ph.regNames[x.reg+32]); break; } out_symbol(')'); break; case o_mem: OutValue(x,OOF_SIGNED|OOFW_32); break; case o_imm: out_symbol('$'); OutValue(x,OOF_SIGNED|OOFW_32); break; case o_idpspec0: out_symbol('['); if(x.specval&0x4) OutChar('d'); if((x.specval&0x4)&&((x.specval&0x2)||(x.specval&0x1))) out_symbol(','); if(x.specval&0x2) OutChar('i'); if((x.specval&0x2)&&(x.specval&0x1)) out_symbol(','); if(x.specval&0x1) OutChar('u'); out_symbol(']'); break; default:; } //out_name_expr(x, x.addr, x.addr); /* if (cmd.itype == COMPARE_OP) { //For comparisons, the argument indicates the type of comparison to be //performed. Print a symbolic representation of the comparison rather //than a number. if (x.value < qnumber(compare_ops)) { OutLine(compare_ops[x.value]); } else { OutLine("BAD OPERAND"); } } else if (cmd.auxpref & HAS_JREL) { //we don't test for x.type == o_near here because we need to distinguish //between relative jumps and absolute jumps. In our case, HAS_JREL //implies o_near out_name_expr(x, x.addr, x.addr); } else { //otherwise just print the operand value OutValue(x); }*/ return true; }
void __stdcall out( void ) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); OutMnem(); if (cmd.Op1.type != o_void) { // output first operand out_one_operand( 0 ); } if( cmd.Op2.type != o_void ) { //pading out_symbol( ',' ); OutChar( ' ' ); // output second operand out_one_operand( 1 ); } if( cmd.Op3.type != o_void ) { //pading out_symbol( ',' ); OutChar( ' ' ); // output third operand out_one_operand( 2 ); } if( cmd.Op4.type != o_void ) { //pading out_symbol( ',' ); OutChar( ' ' ); // output fourth operand out_one_operand( 3 ); } if( cmd.Op5.type != o_void ) { //pading out_symbol( ',' ); OutChar( ' ' ); // output fifth operand out_one_operand( 4 ); } if( cmd.Op6.type != o_void ) { //pading out_symbol( ',' ); OutChar( ' ' ); // output sixth operand out_one_operand( 5 ); } //more processing due to instructions //having more than 6 operands op_t op; op.flags = OF_SHOW; switch(cmd.insnpref) { case SWFACTION_PUSH: { uint16 length = get_word(cmd.ea + 1) + 3; uint16 p = cmd.auxpref; uint8 error = 0; while((length - p) > 0 && error == 0) { switch(get_byte(cmd.ea + p++)) { case 0: //string op.type = o_string; op.dtyp = dt_string; op.addr = cmd.ea + p; //increment the pointer past the string while((length - p) > 0 && get_byte(cmd.ea + p)){ p++; } if ((length - p) > 0) { p++; //adjust for the null caracter } else { error = 1; } break; case 1: //float op.type = o_imm; //op.dtyp = dt_float; op.dtyp = dt_dword; if ((length - p) >= 4) { op.value = get_long(cmd.ea + p); p += 4; } else { error = 1; } break; case 2: //null op.type = o_null; op.dtyp = dt_void; break; case 3: //undefined op.type = o_undefined; op.dtyp = dt_void; break; case 4: //register op.type = o_reg; op.dtyp = dt_byte; if ((length - p) >= 1) { op.reg = get_byte(cmd.ea + p++); } else { error = 1; } break; case 5: //bool op.type = o_bool; op.dtyp = dt_byte; if ((length - p) >= 1) { op.value = get_byte(cmd.ea + p++); } else { error = 1; } break; case 6: //double op.type = o_imm; op.dtyp = dt_double; if ((length - p) >= 8) { double d = (double)(get_qword(cmd.ea + p)); op.value = d; p += 8; } else { error = 1; } break; case 7: //integer op.type = o_imm; op.dtyp = dt_dword; if ((length - p) >= 4) { op.value = get_long(cmd.ea + p); p += 4; } else { error = 1; } break; case 8: //constant 8 op.type = o_const; op.dtyp = dt_byte; if ((length - p) >= 1) { op.value = get_byte(cmd.ea + p++); } else { error = 1; } break; case 9: //constant 16 op.type = o_const; op.dtyp = dt_word; if ((length - p) >= 2) { op.value = get_word(cmd.ea + p); p += 2; } else { error = 1; } default: //unknown type, will not search for more items if this happens error = 1; } //switch if (error == 0) { //pading out_symbol( ',' ); OutChar( ' ' ); // output extra operand outop(op); } } //while } //case break; case SWFACTION_TRY: //ToDo break; case SWFACTION_DEFINEFUNCTION: // Todo: highlight somehow the function body // this must be written some other place because // every time IDA rephreshes the view a duplicate line appears. :( //describe(cmd.ea + cmd.size, true, "%s {", cmd.segpref ? (char*)cmd.Op1.addr : "<anonymous>"); //describe(cmd.ea + cmd.size + get_word(cmd.ea + cmd.size - 2), true, " }"); break; default:; } term_output_buffer(); // attach a possible user-defined comment to this instruction gl_comm = 1; MakeLine( buf ); //multiline instruction printing switch (cmd.insnpref) { case SWFACTION_CONSTANTPOOL: { uint16 length = get_word(cmd.ea + 1); uint8 c = 0, count = 0; if(cmd.Op1.value == 0) break; //limit printed lines to 499 //IDA does not suport more than 500 per item if (cmd.Op1.value > 498) { cmd.Op1.value = 498; msg ("\nWarning: CONSTANTPOOL instruction ar %X has more that 498 declared constants!\n", cmd.ea); } char line[MAXSTR], buf[MAXSTR]; init_output_buffer(line, sizeof(line)); OutChar( ' ' ); out_char('0', COLOR_NUMBER); out_line(": \"",COLOR_SYMBOL); for (uint16 i = 2; i < length; i++) { c = get_byte(cmd.ea + i + 3); if (c == 0) { if (count++ < (cmd.Op1.value - 1)) { out_line("\"", COLOR_SYMBOL); //terminate buffer for current constant //and print it term_output_buffer(); MakeLine(line); //initialize buffer for next constant init_output_buffer(line, sizeof(line)); OutChar( ' ' ); qsnprintf(buf, MAXSTR, "%d", count); out_line(buf, COLOR_NUMBER); out_line(": \"", COLOR_SYMBOL); } else break; } else { if (is_printable(c)) out_char(c, COLOR_CHAR); else { qsnprintf(buf, MAXSTR, "\\x%02X", c); out_line(buf, COLOR_STRING); } }//else }//for out_char('"',COLOR_SYMBOL); //terminate buffer for last constant //and print it term_output_buffer(); MakeLine(line); } break; } }
//---------------------------------------------------------------------- bool outop(op_t &x) { switch(x.type) { case o_void: return 0; case o_reg: if(x.prepost) out_symbol('['); //Вывод регистра по номеру в регистре OutReg(x.reg); if(x.xmode) { out_symbol('+'); OutValue(x, OOF_ADDR | OOF_NUMBER | OOFW_8); } if(x.prepost) out_symbol(']'); break; case o_phrase: OutLine(ph.regNames[x.reg]); break; case o_bit: { switch(x.reg) { case rPSW: { OutLine("PSW."); switch(x.value) { case 0: OutLine("CY");break; case 4: OutLine("AC");break; case 6: OutLine("Z");break; case 7: OutLine("IE");break; default:OutValue(x, OOFW_IMM); } break; } case rA: { OutLine( "A." ); OutChar(char('0'+x.value)); } break; default: { if(!OutVarName(x, 1, 0) ) OutValue(x, OOF_ADDR | OOFW_16); out_symbol('.'); //Ичем название бита по указанному адрессу if(!nec_find_ioport_bit((int)x.addr, (int)x.value)) { //Вывод данных(тип o_imm) OutChar(char('0'+x.value)); } }// switch(x.regmode) } // end switch(x.reg) } break; case o_imm: { if(!x.regmode) { out_symbol('#'); //Вывод данных(тип o_imm) OutValue(x, OOFW_IMM ); } else { out_symbol('1'); } } break; case o_mem: { if(x.addr16) out_symbol('!'); //выводит имя переменной из памяти(например byte_98) //Вывод имени переменной if(!OutVarName(x, 1, 0) ) //Вывод данных OutValue(x, OOF_ADDR | OOFW_16); } break; case o_near: { if(x.addr16) out_symbol('!'); if(x.form) out_symbol('['); //Получить линейный адресс ea_t v = toEA(cmd.cs,x.addr); if(!out_name_expr(x, v, x.addr)) { //Вывести значение OutValue(x, OOF_ADDR | OOF_NUMBER | OOFW_16); QueueMark(Q_noName, cmd.ea); } if(x.form) out_symbol(']'); } break; default: warning("out: %a: bad optype %d", cmd.ip, x.type); break; } return(1); }
// output an instruction and its operands void idaapi out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); // setup the output pointer // if this DSP instruction in executed in parallel with a NOP instruction // (example: nop || machi r1, r2), first print the NOP. if ( cmd.segpref & NEXT_INSN_PARALLEL_DSP ) { out_line("nop", COLOR_INSN); OutChar(' '); out_symbol('|'); out_symbol('|'); OutChar(' '); } char postfix[3]; // postfix to eventually insert after the insn name postfix[0] = '\0'; // postfix is null by default // use synthetic option is selected if ( use_synthetic_insn() ) { if ( cmd.segpref & SYNTHETIC_SHORT ) qstrncpy(postfix, (cmd.itype == m32r_ldi ? "8" : ".s"), sizeof(postfix)); if ( cmd.segpref & SYNTHETIC_LONG ) qstrncpy(postfix, (cmd.itype == m32r_ldi ? "16" : ".l"), sizeof(postfix)); } OutMnem(8, postfix); out_one_operand(0); // output the first operand if ( cmd.Op2.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(1); // output the second operand } if ( cmd.Op3.type != o_void ) { out_symbol(','); OutChar(' '); out_one_operand(2); // output the third operand } // output a character representation of the immediate values // embedded in the instruction as comments if ( isVoid(cmd.ea,uFlag,0) ) OutImmChar(cmd.Op1); if ( isVoid(cmd.ea,uFlag,1) ) OutImmChar(cmd.Op2); if ( isVoid(cmd.ea,uFlag,2) ) OutImmChar(cmd.Op3); // print a parallel NOP instruction unless the current instruction // is either push or pop (in this special case, nop cannot be executed in //) if ( (cmd.itype != m32r_push && cmd.itype != m32r_pop) && cmd.segpref & NEXT_INSN_PARALLEL_NOP ) { // don't print NOP if the instruction was ld/st reg, fp, and has been converted to ld/st reg, @(arg, fp) // (in other words, in the second operand is a stack variable). // because the o_displ form of ld/st insn is 32 bits, and cannot handle a parallel nop. if ( (cmd.itype != m32r_ld && cmd.itype != m32r_st) || !isStkvar1(uFlag) ) { if ( cmd.Op1.type != o_void ) OutChar(' '); out_symbol('|'); out_symbol('|'); OutChar(' '); out_line("nop", COLOR_INSN); } } if ( cmd.segpref & NEXT_INSN_PARALLEL_OTHER ) { if ( cmd.Op1.type != o_void ) OutChar(' '); out_symbol('|'); out_symbol('|'); out_symbol('\\'); } term_output_buffer(); // terminate the output string gl_comm = 1; // ask to attach a possible user- // defined comment to it MakeLine(buf); // pass the generated line to the // kernel }
void OutSpaces(Word Count) { do { OutChar(' '); /* Print a space */ } while (--Count); /* Count down */ }
// output an operand bool idaapi outop(op_t &x) { switch ( x.type ) { // register case o_reg: outreg(x.reg); break; // immediate case o_imm: { const ioport_t *port = find_sym(x.value); // this immediate is represented in the .cfg file if ( port != NULL ) { // output the port name instead of the numeric value out_line(port->name, COLOR_IMPNAME); } // otherwise, simply print the value else { out_symbol('#'); OutValue(x, OOFW_IMM|OOF_SIGNED); } } break; // displ @(imm, reg) case o_displ: out_symbol('@'); out_symbol('('); OutValue(x, OOF_SIGNED | OOF_ADDR | OOFW_32); out_symbol(','); OutChar(' '); outreg(x.reg); out_symbol(')'); break; // address case o_near: if ( !out_name_expr(x, toEA(cmd.cs, x.addr), x.addr) ) OutValue(x, OOF_ADDR | OOF_NUMBER | OOFS_NOSIGN | OOFW_32); break; // phrase case o_phrase: switch ( x.specflag1 ) { // @R case fRI: out_symbol('@'); if ( isDefArg(uFlag, x.n) ) { out_symbol('('); OutValue(x, 0); // will print 0 out_symbol(','); OutChar(' '); outreg(x.reg); out_symbol(')'); } else { outreg(x.reg); } break; // @R+ case fRIBA: out_symbol('@'); outreg(x.reg); out_symbol('+'); break; // @+R case fRIAA: out_symbol('@'); out_symbol('+'); outreg(x.reg); break; // @-R case fRIAS: out_symbol('@'); out_symbol('-'); outreg(x.reg); break; } break; } return 1; }
static inline void OutSpace(void) { ++outcnt; OutChar(' '); }