📄 8db.c
字号:
[0x77] Jbs,0, "JHI %p",[0x78] Jbs,0, "JMI %p",[0x79] Jbs,0, "JPL %p",[0x7a] Jbs,0, "JPS %p",[0x7b] Jbs,0, "JPC %p",[0x7c] Jbs,0, "JLT %p",[0x7d] Jbs,0, "JGE %p",[0x7e] Jbs,0, "JLE %p",[0x7f] Jbs,0, "JGT %p",[0x80] RMOPB,0, optab80,[0x81] RMOP,0, optab81,[0x83] RMOP,0, optab83,[0x84] RMB,0, "TESTB %r,%e",[0x85] RM,0, "TEST%S %r,%e",[0x86] RMB,0, "XCHGB %r,%e",[0x87] RM,0, "XCHG%S %r,%e",[0x88] RMB,0, "MOVB %r,%e",[0x89] RM,0, "MOV%S %r,%e",[0x8a] RMB,0, "MOVB %e,%r",[0x8b] RM,0, "MOV%S %e,%r",[0x8c] RM,0, "MOVW %g,%e",[0x8d] RM,0, "LEA%S %e,%r",[0x8e] RM,0, "MOVW %e,%g",[0x8f] RM,0, "POP%S %e",[0x90] 0,0, "NOP",[0x91] 0,0, "XCHG %OCX,%OAX",[0x92] 0,0, "XCHG %ODX,%OAX",[0x93] 0,0, "XCHG %OBX,%OAX",[0x94] 0,0, "XCHG %OSP,%OAX",[0x95] 0,0, "XCHG %OBP,%OAX",[0x96] 0,0, "XCHG %OSI,%OAX",[0x97] 0,0, "XCHG %ODI,%OAX",[0x98] 0,0, "%W", /* miserable CBW or CWDE */[0x99] 0,0, "%w", /* idiotic CWD or CDQ */[0x9a] PTR,0, "CALL%S %d",[0x9b] 0,0, "WAIT",[0x9c] 0,0, "PUSHF",[0x9d] 0,0, "POPF",[0x9e] 0,0, "SAHF",[0x9f] 0,0, "LAHF",[0xa0] Awd,0, "MOVB %i,AL",[0xa1] Awd,0, "MOV%S %i,%OAX",[0xa2] Awd,0, "MOVB AL,%i",[0xa3] Awd,0, "MOV%S %OAX,%i",[0xa4] 0,0, "MOVSB (%ASI),(%ADI)",[0xa5] 0,0, "MOVS%S (%ASI),(%ADI)",[0xa6] 0,0, "CMPSB (%ASI),(%ADI)",[0xa7] 0,0, "CMPS%S (%ASI),(%ADI)",[0xa8] Ib,0, "TESTB %i,AL",[0xa9] Iwd,0, "TEST%S %i,%OAX",[0xaa] 0,0, "STOSB AL,(%ADI)",[0xab] 0,0, "STOS%S %OAX,(%ADI)",[0xac] 0,0, "LODSB (%ASI),AL",[0xad] 0,0, "LODS%S (%ASI),%OAX",[0xae] 0,0, "SCASB (%ADI),AL",[0xaf] 0,0, "SCAS%S (%ADI),%OAX",[0xb0] Ib,0, "MOVB %i,AL",[0xb1] Ib,0, "MOVB %i,CL",[0xb2] Ib,0, "MOVB %i,DL",[0xb3] Ib,0, "MOVB %i,BL",[0xb4] Ib,0, "MOVB %i,AH",[0xb5] Ib,0, "MOVB %i,CH",[0xb6] Ib,0, "MOVB %i,DH",[0xb7] Ib,0, "MOVB %i,BH",[0xb8] Iwdq,0, "MOV%S %i,%OAX",[0xb9] Iwdq,0, "MOV%S %i,%OCX",[0xba] Iwdq,0, "MOV%S %i,%ODX",[0xbb] Iwdq,0, "MOV%S %i,%OBX",[0xbc] Iwdq,0, "MOV%S %i,%OSP",[0xbd] Iwdq,0, "MOV%S %i,%OBP",[0xbe] Iwdq,0, "MOV%S %i,%OSI",[0xbf] Iwdq,0, "MOV%S %i,%ODI",[0xc0] RMOPB,0, optabC0,[0xc1] RMOP,0, optabC1,[0xc2] Iw,0, "RET %i",[0xc3] RET,0, "RET",[0xc4] RM,0, "LES %e,%r",[0xc5] RM,0, "LDS %e,%r",[0xc6] RMB,Ib, "MOVB %i,%e",[0xc7] RM,Iwd, "MOV%S %i,%e",[0xc8] Iw2,Ib, "ENTER %i,%I", /* loony ENTER */[0xc9] RET,0, "LEAVE", /* bizarre LEAVE */[0xca] Iw,0, "RETF %i",[0xcb] RET,0, "RETF",[0xcc] 0,0, "INT 3",[0xcd] Ib,0, "INTB %i",[0xce] 0,0, "INTO",[0xcf] 0,0, "IRET",[0xd0] RMOPB,0, optabD0,[0xd1] RMOP,0, optabD1,[0xd2] RMOPB,0, optabD2,[0xd3] RMOP,0, optabD3,[0xd4] OA,0, "AAM",[0xd5] OA,0, "AAD",[0xd7] 0,0, "XLAT",[0xd8] FRMOP,0, optabD8,[0xd9] FRMEX,0, optabD9,[0xda] FRMOP,0, optabDA,[0xdb] FRMEX,0, optabDB,[0xdc] FRMOP,0, optabDC,[0xdd] FRMOP,0, optabDD,[0xde] FRMOP,0, optabDE,[0xdf] FRMOP,0, optabDF,[0xe0] Jbs,0, "LOOPNE %p",[0xe1] Jbs,0, "LOOPE %p",[0xe2] Jbs,0, "LOOP %p",[0xe3] Jbs,0, "JCXZ %p",[0xe4] Ib,0, "INB %i,AL",[0xe5] Ib,0, "IN%S %i,%OAX",[0xe6] Ib,0, "OUTB AL,%i",[0xe7] Ib,0, "OUT%S %OAX,%i",[0xe8] Iwds,0, "CALL %p",[0xe9] Iwds,0, "JMP %p",[0xea] PTR,0, "JMP %d",[0xeb] Jbs,0, "JMP %p",[0xec] 0,0, "INB DX,AL",[0xed] 0,0, "IN%S DX,%OAX",[0xee] 0,0, "OUTB AL,DX",[0xef] 0,0, "OUT%S %OAX,DX",[0xf0] PRE,0, "LOCK",[0xf2] OPRE,0, "REPNE",[0xf3] OPRE,0, "REP",[0xf4] 0,0, "HALT",[0xf5] 0,0, "CMC",[0xf6] RMOPB,0, optabF6,[0xf7] RMOP,0, optabF7,[0xf8] 0,0, "CLC",[0xf9] 0,0, "STC",[0xfa] 0,0, "CLI",[0xfb] 0,0, "STI",[0xfc] 0,0, "CLD",[0xfd] 0,0, "STD",[0xfe] RMOPB,0, optabFE,[0xff] RMOP,0, optabFF,[0x100] RM,0, "MOVLQSX %r,%e",};/* * get a byte of the instruction */static intigetc(Map *map, Instr *ip, uchar *c){ if(ip->n+1 > sizeof(ip->mem)){ werrstr("instruction too long"); return -1; } if (get1(map, ip->addr+ip->n, c, 1) < 0) { werrstr("can't read instruction: %r"); return -1; } ip->mem[ip->n++] = *c; return 1;}/* * get two bytes of the instruction */static intigets(Map *map, Instr *ip, ushort *sp){ uchar c; ushort s; if (igetc(map, ip, &c) < 0) return -1; s = c; if (igetc(map, ip, &c) < 0) return -1; s |= (c<<8); *sp = s; return 1;}/* * get 4 bytes of the instruction */static intigetl(Map *map, Instr *ip, ulong *lp){ ushort s; long l; if (igets(map, ip, &s) < 0) return -1; l = s; if (igets(map, ip, &s) < 0) return -1; l |= (s<<16); *lp = l; return 1;}/* * get 8 bytes of the instruction */static intigetq(Map *map, Instr *ip, vlong *qp){ ulong l; uvlong q; if (igetl(map, ip, &l) < 0) return -1; q = l; if (igetl(map, ip, &l) < 0) return -1; q |= ((uvlong)l<<32); *qp = q; return 1;}static intgetdisp(Map *map, Instr *ip, int mod, int rm, int code, int pcrel){ uchar c; ushort s; if (mod > 2) return 1; if (mod == 1) { if (igetc(map, ip, &c) < 0) return -1; if (c&0x80) ip->disp = c|0xffffff00; else ip->disp = c&0xff; } else if (mod == 2 || rm == code) { if (ip->asize == 'E') { if (igetl(map, ip, &ip->disp) < 0) return -1; if (mod == 0) ip->rip = pcrel; } else { if (igets(map, ip, &s) < 0) return -1; if (s&0x8000) ip->disp = s|0xffff0000; else ip->disp = s; } if (mod == 0) ip->base = -1; } return 1;}static intmodrm(Map *map, Instr *ip, uchar c){ uchar rm, mod; mod = (c>>6)&3; rm = c&7; ip->mod = mod; ip->base = rm; ip->reg = (c>>3)&7; ip->rip = 0; if (mod == 3) /* register */ return 1; if (ip->asize == 0) { /* 16-bit mode */ switch(rm) { case 0: ip->base = BX; ip->index = SI; break; case 1: ip->base = BX; ip->index = DI; break; case 2: ip->base = BP; ip->index = SI; break; case 3: ip->base = BP; ip->index = DI; break; case 4: ip->base = SI; break; case 5: ip->base = DI; break; case 6: ip->base = BP; break; case 7: ip->base = BX; break; default: break; } return getdisp(map, ip, mod, rm, 6, 0); } if (rm == 4) { /* scummy sib byte */ if (igetc(map, ip, &c) < 0) return -1; ip->ss = (c>>6)&0x03; ip->index = (c>>3)&0x07; if (ip->index == 4) ip->index = -1; ip->base = c&0x07; return getdisp(map, ip, mod, ip->base, 5, 0); } return getdisp(map, ip, mod, rm, 5, ip->amd64);}static Optable *mkinstr(Map *map, Instr *ip, uvlong pc){ int i, n, norex; uchar c; ushort s; Optable *op, *obase; char buf[128]; memset(ip, 0, sizeof(*ip)); norex = 1; ip->base = -1; ip->index = -1; if(asstype == AI8086) ip->osize = 'W'; else { ip->osize = 'L'; ip->asize = 'E'; ip->amd64 = asstype != AI386; norex = 0; } ip->addr = pc; if (igetc(map, ip, &c) < 0) return 0; obase = optable;newop: if(ip->amd64 && !norex){ if(c >= 0x40 && c <= 0x4f) { ip->rex = c; if(igetc(map, ip, &c) < 0) return 0; } if(c == 0x63){ op = &obase[0x100]; /* MOVLQSX */ goto hack; } } op = &obase[c];hack: if (op->proto == 0) {badop: n = snprint(buf, sizeof(buf), "opcode: ??"); for (i = 0; i < ip->n && n < sizeof(buf)-3; i++, n+=2) _hexify(buf+n, ip->mem[i], 1); strcpy(buf+n, "??"); werrstr(buf); return 0; } for(i = 0; i < 2 && op->operand[i]; i++) { switch(op->operand[i]) { case Ib: /* 8-bit immediate - (no sign extension)*/ if (igetc(map, ip, &c) < 0) return 0; ip->imm = c&0xff; ip->imm64 = ip->imm; break; case Jbs: /* 8-bit jump immediate (sign extended) */ if (igetc(map, ip, &c) < 0) return 0; if (c&0x80) ip->imm = c|0xffffff00; else ip->imm = c&0xff; ip->imm64 = (long)ip->imm; ip->jumptype = Jbs; break; case Ibs: /* 8-bit immediate (sign extended) */ if (igetc(map, ip, &c) < 0) return 0; if (c&0x80) if (ip->osize == 'L') ip->imm = c|0xffffff00; else ip->imm = c|0xff00; else ip->imm = c&0xff; ip->imm64 = (long)ip->imm; break; case Iw: /* 16-bit immediate -> imm */ if (igets(map, ip, &s) < 0) return 0; ip->imm = s&0xffff; ip->imm64 = ip->imm; ip->jumptype = Iw; break; case Iw2: /* 16-bit immediate -> in imm2*/ if (igets(map, ip, &s) < 0) return 0; ip->imm2 = s&0xffff; break; case Iwd: /* Operand-sized immediate (no sign extension unless 64 bits)*/ if (ip->osize == 'L') { if (igetl(map, ip, &ip->imm) < 0) return 0; ip->imm64 = ip->imm; if(ip->rex&REXW && (ip->imm & (1<<31)) != 0) ip->imm64 |= (vlong)~0 << 32; } else { if (igets(map, ip, &s)< 0) return 0; ip->imm = s&0xffff; ip->imm64 = ip->imm; } break; case Iwdq: /* Operand-sized immediate, possibly big */ if (ip->osize == 'L') { if (igetl(map, ip, &ip->imm) < 0) return 0; ip->imm64 = ip->imm; if (ip->rex & REXW) { ulong l; if (igetl(map, ip, &l) < 0) return 0; ip->imm64 |= (uvlong)l << 32; } } else { if (igets(map, ip, &s)< 0) return 0; ip->imm = s&0xffff; } break; case Awd: /* Address-sized immediate (no sign extension)*/ if (ip->asize == 'E') { if (igetl(map, ip, &ip->imm) < 0) return 0; /* TO DO: REX */ } else { if (igets(map, ip, &s)< 0) return 0; ip->imm = s&0xffff; } break; case Iwds: /* Operand-sized immediate (sign extended) */ if (ip->osize == 'L') { if (igetl(map, ip, &ip->imm) < 0) return 0; } else { if (igets(map, ip, &s)< 0) return 0; if (s&0x8000) ip->imm = s|0xffff0000; else ip->imm = s&0xffff; } ip->jumptype = Iwds; break; case OA: /* literal 0x0a byte */ if (igetc(map, ip, &c) < 0) return 0; if (c != 0x0a) goto badop; break; case R0: /* base register must be R0 */ if (ip->base != 0) goto badop; break; case R1: /* base register must be R1 */ if (ip->base != 1) goto badop; break; case RMB: /* R/M field with byte register (/r)*/ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; ip->osize = 'B'; break; case RM: /* R/M field with register (/r) */ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; break; case RMOPB: /* R/M field with op code (/digit) */ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; c = ip->reg; /* secondary op code */ obase = (Optable*)op->proto; ip->osize = 'B'; goto newop; case RMOP: /* R/M field with op code (/digit) */ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; obase = (Optable*)op->proto; if(ip->amd64 && obase == optab0F01 && c == 0xF8) return optab0F01F8; c = ip->reg; goto newop; case FRMOP: /* FP R/M field with op code (/digit) */ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; if ((c&0xc0) == 0xc0) c = ip->reg+8; /* 16 entry table */ else c = ip->reg; obase = (Optable*)op->proto; goto newop; case FRMEX: /* Extended FP R/M field with op code (/digit) */ if (igetc(map, ip, &c) < 0) return 0; if (modrm(map, ip, c) < 0) return 0; if ((c&0xc0) == 0xc0) c = (c&0x3f)+8; /* 64-entry table */ else c = ip->reg; obase = (Optable*)op->proto; goto newop; case RMR: /* R/M register only (mod = 11) */ if (igetc(map, ip, &c) < 0) return 0; if ((c&0xc0) != 0xc0) { werrstr("invalid R/M register: %x", c); return 0; } if (modrm(map, ip, c) < 0) return 0; break; case RMM: /* R/M register only (mod = 11) */ if (igetc(map, ip, &c) < 0) return 0; if ((c&0xc0) == 0xc0) { werrstr("invalid R/M memory mode: %x", c); return 0; } if (modrm(map, ip, c) < 0) return 0; break; case PTR: /* Seg:Displacement addr (ptr16:16 or ptr16:32) */ if (ip->osize == 'L') { if (igetl(map, ip, &ip->disp) < 0) return 0; } else { if (igets(map, ip, &s)< 0) return 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -