void wxExHexMode::AppendText(const std::string& buffer) { if (!m_Active) return; m_Buffer += buffer; m_BufferOriginal = m_Buffer; std::string text; text.reserve( // offset: (1 + 1) * buffer.size() / m_BytesPerLine + // hex field: m_EachHexField * buffer.size() + // ascii field: buffer.size()); for (wxFileOffset offset = 0; offset < buffer.size(); offset += m_BytesPerLine) { text += MakeLine(m_STC, buffer, offset, m_BytesPerLine, m_EachHexField); } m_STC->AppendTextRaw(text.data(), text.size()); }
void SimpleOSMToWSMObject::BuildMesh(TimeValue t) { float l, w, h; ivalid = FOREVER; pblock->GetValue(PB_OSMTOWSM_LENGTH,t,l,ivalid); pblock->GetValue(PB_OSMTOWSM_WIDTH,t,w,ivalid); pblock->GetValue(PB_OSMTOWSM_HEIGHT,t,h,ivalid); w = w/2.0f; l = l/2.0f; float zmin, zmax; int axis; BOOL limit = mod->GetModLimits(t,zmin,zmax,axis); if (limit) { mesh.setNumVerts(20*(MESH_SEGMENTS+1)+1); mesh.setNumFaces(20*MESH_SEGMENTS); } else { mesh.setNumVerts(12*(MESH_SEGMENTS+1)+1); mesh.setNumFaces(12*MESH_SEGMENTS); } int vi=0, fi=0; mesh.setVert(vi++, Point3(0.0f,0.0f,h/2.0f)); Point3 data1[] = { Point3(-w, -l, 0.0f), Point3( w, -l, 0.0f), Point3( w, l, 0.0f), Point3(-w, l, 0.0f), Point3(-w, -l, h), Point3( w, -l, h), Point3( w, l, h), Point3(-w, l, h)}; for (int j=0; j<4; j++) { for (int i=0; i<=MESH_SEGMENTS; i++) { float u = float(i)/float(MESH_SEGMENTS); mesh.setVert(vi++, (1.0f-u)*data1[j] + u*data1[j+4]); if (i) MakeLine(&mesh.faces[fi++], vi-2, vi-1); } } Point3 data2[] = { Point3(-w, -l, 0.0f), Point3(-w, l, 0.0f), Point3(-w, l, h), Point3(-w, -l, h), Point3( w, -l, 0.0f), Point3( w, l, 0.0f), Point3( w, l, h), Point3( w, -l, h)}; for (j=0; j<4; j++) { for (int i=0; i<=MESH_SEGMENTS; i++) { float u = float(i)/float(MESH_SEGMENTS); mesh.setVert(vi++, (1.0f-u)*data2[j] + u*data2[j+4]); if (i) MakeLine(&mesh.faces[fi++], vi-2, vi-1); } } Point3 data3[] = { Point3(-w, -l, 0.0f), Point3( w, -l, 0.0f), Point3( w, -l, h), Point3(-w, -l, h), Point3(-w, l, 0.0f), Point3( w, l, 0.0f), Point3( w, l, h), Point3(-w, l, h)}; for (j=0; j<4; j++) { for (int i=0; i<=MESH_SEGMENTS; i++) { float u = float(i)/float(MESH_SEGMENTS); mesh.setVert(vi++, (1.0f-u)*data3[j] + u*data3[j+4]); if (i) MakeLine(&mesh.faces[fi++], vi-2, vi-1); } } if (limit) { Point3 data3[] = { Point3(-w, -l, 0.0f), Point3( w, -l, 0.0f), Point3( w, l, 0.0f), Point3(-w, l, 0.0f)}; Point3 data1[] = { Point3(-l, 0.0f, 0.0f), Point3( l, 0.0f, 0.0f), Point3( l, h, 0.0f), Point3(-l, h, 0.0f)}; Point3 data2[] = { Point3(0.0f ,-w, 0.0f), Point3(0.0f, w, 0.0f), Point3( h, w, 0.0f), Point3( h, -w, 0.0f)}; Point3 *data[] = {data1,data2,data3}; // Min limit for (j=0; j<4; j++) { for (int i=0; i<=MESH_SEGMENTS; i++) { float u = float(i)/float(MESH_SEGMENTS); Point3 p1, p2; p1[(axis+1)%3] = data[axis][j].x; p1[(axis+2)%3] = data[axis][j].y; p1[axis] = zmin; p2[(axis+1)%3] = data[axis][(j+1)%4].x; p2[(axis+2)%3] = data[axis][(j+1)%4].y; p2[axis] = zmin; mesh.setVert(vi++, (1.0f-u)*p1 + u*p2); if (i) MakeLine(&mesh.faces[fi++], vi-2, vi-1); } } // Max limit for (j=0; j<4; j++) { for (int i=0; i<=MESH_SEGMENTS; i++) { float u = float(i)/float(MESH_SEGMENTS); Point3 p1, p2; p1[(axis+1)%3] = data[axis][j].x; p1[(axis+2)%3] = data[axis][j].y; p1[axis] = zmax; p2[(axis+1)%3] = data[axis][(j+1)%4].x; p2[(axis+2)%3] = data[axis][(j+1)%4].y; p2[axis] = zmax; mesh.setVert(vi++, (1.0f-u)*p1 + u*p2); if (i) MakeLine(&mesh.faces[fi++], vi-2, vi-1); } } } Matrix3 tm(1); ModContext mc; mc.tm = NULL; mc.box = new Box3; mc.box->pmin = Point3(-w,-l,0.0f); mc.box->pmax = Point3( w, l,h); Deformer &def = GetDecayDeformer(t,mod->GetDeformer(t,mc,tm,tm),Point3(0,0,0),ivalid); for (int i=0; i<mesh.getNumVerts(); i++) { mesh.verts[i] = def.Map(i, mesh.verts[i]); } ivalid &= mod->GetValidity(t); mesh.InvalidateGeomCache(); }
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; } }
//---------------------------------------------------------------------- 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); }
//---------------------------------------------------------------------- bool block_end(uint32 off) { return(MakeLine(COLSTR("}", SCOLOR_SYMBOL), off)); }
//---------------------------------------------------------------------- bool close_comment(void) { return(MakeLine(COLSTR("*/", SCOLOR_AUTOCMT), 0)); }
//---------------------------------------------------------------------- bool block_begin(uchar off) { return MakeLine(COLSTR("{", SCOLOR_SYMBOL), off); }
//---------------------------------------------------------------------- void idaapi cr16c_out(void) { char str[MAXSTR]; //MAXSTR is an IDA define from pro.h init_output_buffer(str, sizeof(str)); OutMnem(12); //first we output the mnemonic switch(cmd.auxpref) { case ooType0: //no operands break; case ooType1: //4,0x444(r0) ->1,20 out_one_operand(1); out_symbol(','); out_one_operand(2); out_one_operand(0); break; case ooType2: //4 ->0 out_one_operand(0); break; case ooType3: //6(r5), r1 ->20,1 out_one_operand(2); out_one_operand(0); out_symbol(','); out_one_operand(1); break; case ooType4: //$4,0x444 ->1,0 out_one_operand(1); out_symbol(','); out_one_operand(0); break; case ooType5: //0x66666, r5 ->0,1 out_one_operand(0); out_symbol(','); out_one_operand(1); break; case ooType6: //$7, [r12]0x26666 ->1,[2]0 out_one_operand(1); out_symbol(','); out_symbol('['); out_one_operand(2); out_symbol(']'); out_one_operand(0); break; case ooType7: //$7, [r12]0x26666(r3,r2) out_one_operand(1); out_symbol(','); out_symbol('['); out_one_operand(3); out_symbol(']'); out_one_operand(2); out_one_operand(0); break; case ooType8: //[r12]0x26666(r3,r2), r0 out_symbol('['); out_one_operand(3); out_symbol(']'); out_one_operand(2); out_one_operand(0); out_symbol(','); out_one_operand(1); break; case ooType9: //[r12]0x26666,R3 ->[2]0,1 out_symbol('['); out_one_operand(2); out_symbol(']'); out_one_operand(0); out_symbol(','); out_one_operand(1); break; case ooType10: //x,y,z ->0,1,2 out_one_operand(0); out_symbol(','); out_one_operand(1); out_symbol(','); out_one_operand(2); break; case ooType11: //4 ->2 out_one_operand(2); break; case ooType12: //y,x{,z} ->1,0{,2} out_one_operand(1); out_symbol(','); out_one_operand(0); if(cmd.Op3.type != o_void) { out_symbol(','); out_one_operand(2); } break; default: if(cmd.Op1.type != o_void) { out_one_operand(0); } out_snprintf(" , "); if(cmd.Op2.type != o_void) { //then there is an argument to print out_one_operand(1); } out_snprintf(" , "); if(cmd.Op3.type != o_void) { //then there is an argument to print out_one_operand(2); } } term_output_buffer(); gl_comm = 1; //we want comments! MakeLine(str); //output the line with default indentation }
// 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 out(void) { char buf[MAXSTR]; init_output_buffer(buf, sizeof(buf)); // output instruction mnemonics char postfix[10]; postfix[0] = '\0'; OutMnem(8); bool comma = out_one_operand(0); if ( cmd.Op2.type != o_void ) { if ( comma ) out_symbol(','); out_one_operand(1); } if ( cmd.Op3.type != o_void ) { out_symbol(','); 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, 3) ) OutImmChar(cmd.Op3); switch ( cmd.itype ) { case OAK_Dsp_callr: case OAK_Dsp_ret: case OAK_Dsp_br: case OAK_Dsp_call: case OAK_Dsp_reti: case OAK_Dsp_brr: case OAK_Dsp_shfc: case OAK_Dsp_shr: case OAK_Dsp_shr4: case OAK_Dsp_shl: case OAK_Dsp_shl4: case OAK_Dsp_ror: case OAK_Dsp_rol: case OAK_Dsp_clr: case OAK_Dsp_not: case OAK_Dsp_neg: case OAK_Dsp_rnd: case OAK_Dsp_pacr: case OAK_Dsp_clrr: case OAK_Dsp_inc: case OAK_Dsp_dec: case OAK_Dsp_copy: case OAK_Dsp_maxd: case OAK_Dsp_max: case OAK_Dsp_min: qsnprintf(postfix, sizeof(postfix), "%s%s%s", ( (cmd.auxpref & aux_comma_cc) ? ", ": ""), \ cc_text[cmd.auxpref & aux_cc], \ ( (cmd.auxpref & aux_iret_context) ? ", context": "") ); out_line(postfix, COLOR_REG); break; } term_output_buffer(); gl_comm = 1; MakeLine(buf); }
//-------------------------------------------------------------------------- void segstart(ea_t ea) { char buf[MAXSTR]; char *const end = buf + sizeof(buf); segment_t *Sarea = getseg(ea); if ( is_spec_segm(Sarea->type) ) return; const char *align; switch ( Sarea->align ) { case saAbs: align = "at: "; break; case saRelByte: align = "byte"; break; case saRelWord: align = "word"; break; case saRelPara: align = "para"; break; case saRelPage: align = "page"; break; case saRel4K: align = "4k"; break; case saRel64Bytes: align = "64"; break; default: align = NULL; break; } if ( align == NULL ) { gen_cmt_line("Segment alignment '%s' can not be represented in assembly", get_segment_alignment(Sarea->align)); align = ""; } char sname[MAXNAMELEN]; char sclas[MAXNAMELEN]; get_true_segm_name(Sarea, sname, sizeof(sname)); get_segm_class(Sarea, sclas, sizeof(sclas)); char *ptr = buf + qsnprintf(buf, sizeof(buf), SCOLOR_ON SCOLOR_ASMDIR "%-*s segment %s ", inf.indent-1, sname, align); if ( Sarea->align == saAbs ) { ea_t absbase = get_segm_base(Sarea); ptr += btoa(ptr, end-ptr, absbase); APPCHAR(ptr, end, ' '); } const char *comb; switch ( Sarea->comb ) { case scPub: case scPub2: case scPub3: comb = ""; break; case scCommon: comb = "common"; break; default: comb = NULL; break; } if ( comb == NULL ) { gen_cmt_line("Segment combination '%s' can not be represented in assembly", get_segment_combination(Sarea->comb)); comb = ""; } ptr += qsnprintf(ptr, end-ptr, "%s '%s'", comb, sclas); tag_off(ptr, end, COLOR_ASMDIR); MakeLine(buf, 0); }