//TODO: this is not a f*****g smart function! this is total crap!!! //TODO: kill locating algo by function, Cause there a lot of places, where IDA f*****g sucks, and dont understand bounds of function!!!! //replace by discovery up by the tree ea_t find_instruction_that_changes_operand_backward_smart(ea_t start, op_t operand) { func_t *f = get_func(start); char buf[MAXSTR]; char instr_clean[MAXSTR]; if(f) { ea_t addr = prev_head(start, f->startEA); while (addr != BADADDR) { flags_t flags = getFlags(addr); if (isHead(flags) && isCode(flags)) { ua_ana0(addr); switch(cmd.itype){ case NN_lea: case NN_pop: case NN_shl: case NN_shr: case NN_sal: case NN_sar: case NN_imul: case NN_mul: case NN_idiv: case NN_div: case NN_xor: case NN_or: case NN_not: case NN_neg: case NN_inc: case NN_dec: case NN_add: case NN_sub: case NN_mov: case NN_movsx: case NN_movzx:{ for(int i = 0; cmd.Operands[i].type != o_void; i++){ if((cmd.Operands[i].type == operand.type) && (cmd.Operands[i].reg == operand.reg)){ return addr; } }break; default:break; } } } addr = prev_head(addr, f->startEA); } } return BADADDR; }
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { // Start typing your C/C++ solution below // DO NOT write int main() function ListNode prev_head(0); ListNode *sorted_list = &prev_head; while (l1 && l2) { if (l1->val < l2->val) { sorted_list->next = l1; l1 = l1->next; sorted_list = sorted_list->next; } else { sorted_list->next = l2; l2 = l2->next; sorted_list = sorted_list->next; } } while (l1) { sorted_list->next = l1; l1 = l1->next; sorted_list = sorted_list->next; } while (l2) { sorted_list->next = l2; l2 = l2->next; sorted_list = sorted_list->next; } return prev_head.next; }
ea_t find_instruction_backward(ea_t start, uint16 itype) { func_t *f = get_func(start); if(f) { ea_t addr = prev_head(start, f->startEA); while (addr != BADADDR) { flags_t flags = getFlags(addr); if (isHead(flags) && isCode(flags)) { ua_ana0(addr); if(cmd.itype == itype)return addr; } addr = prev_head(addr, f->startEA); } } return BADADDR; }