📄 disio.cpp
字号:
}
}
else
{ outargs(inst,DSMITEM_ARG1(inst));
if(DSMITEM_ARG2(inst)!=ARG_NONE)
{ LastPrintBuff(", ");
outargs(inst,DSMITEM_ARG2(inst));
}
if(DSMITEM_ARG3(inst)!=ARG_NONE)
{ LastPrintBuff(", ");
outargs(inst,DSMITEM_ARG3(inst));
}
}
break;
default:
break;
}
}
/************************************************************************
* outdb *
* - this is similar to outinst, but when there is no disassembly for a *
* loc we call this to output a db xxh or a db ? if its uninitdata *
************************************************************************/
void disio::outdb(lptr *lp,bool printaddrs)
{ dsegitem *dblock;
dword aaddr;
byte *mcode;
printlineheader(*lp,printaddrs);
dblock=dta.findseg(*lp); // find segment item.
if(dblock==NULL)
{ if(printaddrs)
LastPrintBuff("??");
}
else if(dblock->typ==uninitdata)
{ if(printaddrs)
LastPrintBuff("??");
}
else
{ aaddr=(*lp-dblock->addr);
mcode=dblock->data+aaddr;
if(printaddrs)
LastPrintBuff("%02x",mcode[0]);
}
if(options.mode32)
LastPrintBuffEpos(ASMPOS+4);
else
LastPrintBuffEpos(ASMPOS);
LastPrintBuff("db");
if(options.mode32)
LastPrintBuffEpos(ARGPOS+4);
else
LastPrintBuffEpos(ARGPOS);
// changed to single ? - 2.25
if(dblock==NULL)
LastPrintBuff("?");
else if(dblock->typ==uninitdata)
{ LastPrintBuff("?");
}
else
{ LastPrintBuffHexValue(mcode[0]);
if(isprint(mcode[0]))
{ LastPrintBuffEpos(COMMENTPOS);
LastPrintBuff(";\'%c\'",mcode[0]);
}
}
}
/************************************************************************
* issegprefix *
* - returns true if byte is a segment prefix valid value *
************************************************************************/
bool disio::issegprefix(byte byt)
{ if((byt==0x2e)||(byt==0x36)||(byt==0x3e)||(byt==0x26)||(byt==0x64)||(byt==0x65))
return true;
return false;
}
/************************************************************************
* isprefix *
* - returns true if byte is a prefix valid value (rep/repne/lock) *
************************************************************************/
bool disio::isprefix(byte byt)
{ if((byt==0xf0)||(byt==0xf2)||(byt==0xf3))
return true;
return false;
}
/************************************************************************
* outprefix *
* - here we output a prefix segment override *
************************************************************************/
void disio::outprefix(byte prefixbyte)
{ switch(prefixbyte)
{ case 0x2e:
LastPrintBuff("cs:");
break;
case 0x36:
LastPrintBuff("ss:");
break;
case 0x3e:
LastPrintBuff("ds:");
break;
case 0x26:
LastPrintBuff("es:");
break;
case 0x64:
LastPrintBuff("fs:");
break;
case 0x65:
LastPrintBuff("gs:");
break;
case 0xf0:
LastPrintBuff("lock ");
break;
case 0xf2:
LastPrintBuff("repne ");
break;
case 0xf3:
LastPrintBuff("rep ");
break;
default:
LastPrintBuff("err:");
break;
}
}
/************************************************************************
* jumpback *
* - when the user presses ESC, or selects jump back we get the last *
* address from the top of the address stack and call setcuraddr and *
* update the window and so the disassembly listing flicks back *
************************************************************************/
void disio::jumpback(void)
{ lptr outhere;
outhere=retstack.pop();
if(outhere.segm)
setcuraddr(outhere);
updatewindow();
}
/************************************************************************
* jumpto *
* - more complex than the jumpback is the jumpto. The complexity lies *
* in deciding where we are jumping to and what the arguments value is *
* and if the location exists. Actually making the jump consists of *
* saving the current location to the address stack and then changing *
* the curraddr for output, and updating the window *
* - most of this routine is a complex decipherment of a modrm address *
* to jump to *
* NB I need to stick this in a function of its own at some point, as it *
* would be quite useful to just get an argument address in several *
* places in the code *
************************************************************************/
void disio::jumpto(bool arg1)
{ dsmitem *tblock;
lptr outhere;
byte *data;
bool madejump;
byte modrm,sib;
word rm;
tblock=findcurrentline();
outhere.assign(0,0);
if(tblock!=NULL)
if(tblock->type!=dsmcode)
return;
madejump=false;
if(tblock!=NULL)
{ if(arg1)
{ switch(DSMITEM_ARG1(tblock))
{ case ARG_FADDR:
data=tblock->data+tblock->length;
if(tblock->mode32)
{ data-=6;
outhere.assign(((word *)(&data[4]))[0],((dword *)(&data[0]))[0]);
}
else
{ data-=4;
outhere.assign(((word *)(&data[2]))[0],((word *)(&data[0]))[0]);
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
case ARG_IMM32:
if(tblock->override!=over_dsoffset)
break;
data=tblock->data+tblock->length;
data-=4;
outhere.assign(options.dseg,((dword *)(&data[0]))[0]);
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
case ARG_MEMLOC:
data=tblock->data+tblock->length;
if(options.mode32)
{ data-=4;
outhere.assign(tblock->addr.segm,((dword *)data)[0]);
}
else
{ data-=2;
outhere.assign(tblock->addr.segm,((word *)data)[0]);
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
case ARG_IMM:
if(tblock->override!=over_dsoffset)
break;
if(options.mode32)
{ data=tblock->data+tblock->length;
data-=4;
outhere.assign(options.dseg,((dword *)(&data[0]))[0]);
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
}
break;
case ARG_RELIMM:
data=tblock->data+tblock->length;
outhere=tblock->addr;
if(tblock->mode32)
{ data-=4;
outhere+=((dword *)data)[0]+tblock->length;
}
else
{ data-=2;
outhere+=(word)(((word *)data)[0]+tblock->length);
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
case ARG_RELIMM8:
data=tblock->data+tblock->length-1;
outhere=tblock->addr;
if(tblock->mode32)
{ if(data[0]&0x80)
outhere+=(dword)(data[0]+0xffffff00+tblock->length);
else
outhere+=(dword)(data[0]+tblock->length);
}
else
{ if(data[0]&0x80)
outhere+=(word)(data[0]+0xff00+tblock->length);
else
outhere+=(word)(data[0]+tblock->length);
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
case ARG_MMXMODRM:
case ARG_XMMMODRM:
case ARG_MODRM_S:
case ARG_MODRMM512:
case ARG_MODRMQ:
case ARG_MODRM_SREAL:
case ARG_MODRM_PTR:
case ARG_MODRM_WORD:
case ARG_MODRM_SINT:
case ARG_MODRM_EREAL:
case ARG_MODRM_DREAL:
case ARG_MODRM_WINT:
case ARG_MODRM_LINT:
case ARG_MODRM_BCD:
case ARG_MODRM_FPTR:
case ARG_MODRM:
data=tblock->data+tblock->modrm;
rm=(byte)((data[0]&0xc0)>>6);
modrm=(byte)(data[0]&0x07);
switch(rm)
{ case 0:
if(options.mode32)
{ if(modrm==5)
{ outhere.assign(tblock->addr.segm,((dword *)(&data[1]))[0]);
}
else if(modrm==4) // case 4=sib
{ sib=data[1];
if((sib&0x07)==5) // disp32
{ outhere.assign(tblock->addr.segm,((dword *)(&data[2]))[0]);
}
}
}
else
{ if(modrm==6)
{ outhere.assign(tblock->addr.segm,((word *)(&data[1]))[0]);
}
}
break;
case 1:
break;
case 2:
if(options.mode32)
{ outhere.assign(tblock->addr.segm,((dword *)(&data[1]))[0]);
if(modrm==4) // case 4=sib
{ outhere.assign(tblock->addr.segm,((dword *)(&data[2]))[0]);
}
}
else
{ outhere.assign(tblock->addr.segm,((word *)(&data[1]))[0]);
}
break;
case 3:
break;
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
madejump=true;
}
break;
default:
break;
}
}
if(!madejump)
{ switch(DSMITEM_ARG2(tblock))
{ case ARG_IMM32:
if(tblock->override!=over_dsoffset)
break;
data=tblock->data+tblock->length;
data-=4;
outhere.assign(options.dseg,((dword *)(&data[0]))[0]);
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
}
break;
case ARG_IMM:
if(tblock->override!=over_dsoffset)
break;
if(options.mode32)
{ data=tblock->data+tblock->length;
data-=4;
outhere.assign(options.dseg,((dword *)(&data[0]))[0]);
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
}
}
break;
case ARG_MEMLOC:
data=tblock->data+tblock->length;
if(options.mode32)
{ data-=4;
outhere.assign(tblock->addr.segm,((dword *)data)[0]);
}
else
{ data-=2;
outhere.assign(tblock->addr.segm,((word *)data)[0]);
}
if(dta.findseg(outhere)!=NULL)
{ retstack.push(curraddr);
setcuraddr(outhere);
updatewindow();
}
break;
case ARG_MMXMODRM:
case ARG_XMMMODRM:
case ARG_MODRM_S:
case ARG_MODRMM512:
case ARG_MODRMQ:
case ARG_MODRM_SREAL:
case ARG_MODRM_PTR:
case ARG_MODRM_WORD:
case ARG_MODRM_SINT:
case ARG_MODRM_EREAL:
case ARG_MODRM_DREAL:
case ARG_MODRM_WINT:
case ARG_MODRM_LINT:
case ARG_MODRM_BCD:
case ARG_MODRM_FPTR:
case ARG_MODRM:
data=tblock->data+tblock->modrm;
rm=(byte)((data[0]&0xc0)>>6);
modrm=(byte)(data[0]&0x07);
switch(rm)
{ case 0:
if(options.mode32)
{ if(modrm==5)
{ outhere.assign(tblock->addr.segm,((dword *)(&data[1]))[0]);
}
else if(modrm==4) // case 4=sib
{ sib=data[1];
if((sib&0x07)==5) // disp32
{ outhere.assign(tblock->addr.segm,((dword *)(&data[2]))[0]);
}
}
}
else
{ if(modrm==6)
{ outhere.assign(tblock->addr.segm,((word *)(&data[1]))[0]);
}
}
break;
case 1:
break;
case 2:
if(options.mode32)
{ outhere.assign(tblock->addr.segm,((dword *)(&data[1]))[0]);
if(modrm==4) // case 4=sib
{ outhere.assign(tblock->addr.segm,((dword *)(&data[2]))[0]);
}
}
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -