Rizin
unix-like reverse engineering framework and cli tools
hashtable.h File Reference

Go to the source code of this file.

Functions

st32 get_hash_code (ut32 ins_pos)
 

Function Documentation

◆ get_hash_code()

st32 get_hash_code ( ut32  ins_pos)

Definition at line 2801 of file hashtable.c.

2801  {
2802  ut32 len, ins_part1;
2803  ut32 opcode, pos;
2804  st32 (*get_hashcode_func)(st32 arg, st32 arg2);
2805  ut32 ins_len;
2806  st32 arg, ins_part2, hash_code;
2807 
2808  ins_part1 = 0;
2809  ins_part2 = 0;
2810 
2811  opcode = get_ins_part(ins_pos, 1);
2812  ins_len = get_ins_len(opcode);
2813 
2814  if (C55PLUS_DEBUG) {
2815  printf("opcode: 0x%x part: %d\n", opcode, ins_pos);
2816  printf("ins_len: 0x%x\n", ins_len);
2817  }
2818 
2819  if (ins_len > 1) {
2820  len = ins_len - 1;
2821  if (len >= 4) {
2822  len = 4;
2823  }
2824 
2825  ins_part1 = get_ins_part(ins_pos + 1, len) << (8 * (4 - len));
2826  ins_part2 = 0;
2827  if (ins_len > 5) {
2828  ins_part2 = get_ins_part(ins_pos + 5, 1);
2829  }
2830  }
2831 
2832  pos = (2 * opcode | (ins_part1 >> 31));
2833  // arg = *(ut32 *)(((ut8 *)ins_hash)+ pos * 8);
2834  arg = ins_hash[pos].code;
2835 
2836  ins_part2 >>= 7;
2837  ins_part2 |= (ins_part1 * 2);
2838 
2839  // get_hashcode_func = *(ut32 *)(((ut8 *)ins_hash + sizeof(ut32)) + pos * 8);
2840  get_hashcode_func = ins_hash[pos].hash_func;
2841 
2842  if (C55PLUS_DEBUG) {
2843  printf("hashfunc => %p 0x%x\n", get_hashcode_func, pos);
2844  printf("hashargs => 0x%x 0x%x 0x%x\n", (ut32)arg, ins_part1, ins_part2);
2845  }
2846 
2847  hash_code = get_hashcode_func(arg, ins_part2);
2848  if (C55PLUS_DEBUG) {
2849  printf("ret hashcode: 0x%x\n", hash_code);
2850  }
2851 
2852  return hash_code;
2853 }
size_t len
Definition: 6502dis.c:15
ut32 get_ins_len(ut8 opcode)
Definition: ins.c:11
static const char * arg(RzAnalysis *a, csh *handle, cs_insn *insn, char *buf, int n)
Definition: arm_esil32.c:136
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
uint32_t ut32
static HASHCODE_ENTRY_T ins_hash[]
Definition: hashtable.c:2285
ut32 get_ins_part(ut32 pos, ut32 len)
Definition: ins.c:51
#define C55PLUS_DEBUG
Definition: utils.h:8
#define st32
Definition: rz_types_base.h:12
st32 code
Definition: hashvector.h:10
st32(* hash_func)(st32 A1, st32 A2)
Definition: hashvector.h:11
int pos
Definition: main.c:11

References arg(), C55PLUS_DEBUG, HASHCODE_ENTRY_T::code, get_ins_len(), get_ins_part(), HASHCODE_ENTRY_T::hash_func, ins_hash, len, pos, printf(), and st32.

Referenced by do_decode().