static int GetTypeOf(ea_t ea) { flags_t flags = getFlags(ea); if (isTail(flags)) { // check if it's a struct ptr ea_t head = get_item_head(ea); if (head == ea) return T_UNK; flags = getFlags(head); if (!isData(flags) || !isStruct(flags)) return T_UNK; return GetTypeOfStructInstance(ea, head, flags); } if (!isData(flags)) return T_UNK; if (isStruct(flags)) return GetTypeOfStructInstance(ea, ea, flags); if (isByte(flags)) { char s; if (has_cmt(flags) && (get_cmt(ea, false, &s, 1) != -1) && s == 'S') return T_I8; return T_U8; } if (isWord(flags)) { char s; if (has_cmt(flags) && (get_cmt(ea, false, &s, 1) != -1) && s == 'S') return T_I16; return T_U16; } if (isDwrd(flags)) return T_I32; return T_UNK; }
static int GetTypeOf(ea_t ea) { flags_t flags = getFlags(ea); if (!isData(flags)) return T_UNK; if (isByte(flags)) return T_8BIT; if (isWord(flags)) return T_16BIT; if (isDwrd(flags)) return T_I32; return T_UNK; }
inline void AbstractAssembler::emit_byte(int x) { assert(isByte(x), "not a byte"); *(unsigned char*)_code_pos = (unsigned char)x; _code_pos += sizeof(unsigned char); sync(); }
bool Line::isValid() const { return isInstruction() || isLabel() || isAlign() || isByte(); }
uint32_t Line::getByte() const { assert(isByte()); return byte; }
void enum_members2(struc_t *st) { char buf[MAXSTR]; type_t type[MAXSTR] = {0}; int gap_cnt = 1; asize_t ofs = 0, gapend = BADADDR, gapstart = BADADDR; for (size_t i=0;i<st->memqty;i++) { member_t &mem = st->members[i]; // unexpected beginning of member? if (mem.soff != ofs) { // msg("gap detected @ %a!\n", ofs); gapstart = ofs; } if (gapstart != BADADDR) { gapend = mem.soff; msg("char pad%d[%d]\n", gap_cnt, gapend - gapstart); //msg("gap size=%a\n", gapend - gapstart); gapend = gapstart = BADADDR; gap_cnt++; } typeinfo_t mem_ti; retrieve_member_info(&mem, &mem_ti); // data type size of member asize_t dt_mem_size = get_data_type_size(mem.flag, &mem_ti); // member size asize_t mem_size = get_member_size(&mem); // get the member's name get_member_name(mem.id, buf, sizeof(buf)); char dtype[MAXSTR]; char arraystr[MAXSTR]; char typemod[10]; arraystr[0] = 0; typemod[0] = 0; if (isWord(mem.flag)) strcpy(dtype, "unsigned short"); else if (isDwrd(mem.flag)) strcpy(dtype, "unsigned long"); else if (isByte(mem.flag)) strcpy(dtype, "char"); else if (isStruct(mem.flag)) { struc_t *nested_st = get_sptr(&mem); get_struc_name(nested_st->id, dtype, MAXSTR); } else strcpy(dtype, "user_type"); if (isOff0(mem.flag)) { strcpy(typemod, "*"); } if (isEnum0(mem.flag)) { get_enum_name(mem_ti.ec.tid, dtype, sizeof(dtype)); } asize_t ar_size = mem_size / dt_mem_size; // an array? if (ar_size > 1) { sprintf(arraystr, "[%d]", ar_size); } char out[100]; sprintf(out, "%s " /* type */ "%s" /* typemodif */ "%s" /* varname */ "%s" /*array*/ ";", dtype, typemod, buf, arraystr); msg("%s\n", out); /* inline bool idaapi isByte (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_BYTE; } inline bool idaapi isWord (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_WORD; } inline bool idaapi isDwrd (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_DWRD; } inline bool idaapi isQwrd (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_QWRD; } inline bool idaapi isOwrd (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_OWRD; } inline bool idaapi isTbyt (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_TBYT; } inline bool idaapi isFloat (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_FLOAT; } inline bool idaapi isDouble(flags_t F) { return isData(F) && (F & DT_TYPE) == FF_DOUBLE; } inline bool idaapi isPackReal(flags_t F) { return isData(F) && (F & DT_TYPE) == FF_PACKREAL; } inline bool idaapi isASCII (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_ASCI; } inline bool idaapi isStruct(flags_t F) { return isData(F) && (F & DT_TYPE) == FF_STRU; } inline bool idaapi is3byte (flags_t F) { return isData(F) && (F & DT_TYPE) == FF_3BYTE; } */ /* msg("member[%d], name=%s; %a-%a ; id=%d; flags=%x type=%s dt_mem_size=%a mem_size=%a\n", i, buf, mem.soff, mem.eoff, mem.id, mem.flag, type, dt_mem_size, mem_size); */ // we expect next member to begin @ end of last member ofs = mem.eoff; } }