1
0
mirror of https://github.com/bitdefender/bddisasm.git synced 2024-11-18 05:28:09 +00:00

Improved linear address computation in bdshemu.

This commit is contained in:
Andrei Vlad LUTAS 2020-07-24 23:11:36 +03:00
parent 6c248cc4c1
commit d11fe85599
2 changed files with 15 additions and 8 deletions

View File

@ -788,12 +788,6 @@ ShemuComputeLinearAddress(
{
uint64_t gla = 0;
// Memory operands usually have a segment.
if (Operand->Info.Memory.HasSeg)
{
gla += ShemuGetSegBase(Context, Operand->Info.Memory.Seg);
}
if (Operand->Info.Memory.HasBase)
{
gla += ShemuGetGprValue(Context, Operand->Info.Memory.Base, Operand->Info.Memory.BaseSize, false);
@ -857,11 +851,24 @@ ShemuComputeLinearAddress(
gla &= 0xFFFFFFFF;
break;
case ND_ADDR_16:
gla &= 0xFFFFF;
gla &= 0xFFFF;
default:
break;
}
// Memory operands usually have a segment. Note that we don't care about any segment checks, since we're most
// likely be provided with flat segments. If checks should be needed, dedicated callbacks should be added.
if (Operand->Info.Memory.HasSeg)
{
gla += ShemuGetSegBase(Context, Operand->Info.Memory.Seg);
if (Context->Mode != ND_CODE_64)
{
// Truncate to 32 bit outside 64 bit.
gla &= 0xFFFFFFFF;
}
}
return gla;
}

View File

@ -376,7 +376,7 @@ Determining if the instruction is a branch of any kind
if (ix.RipAccess & ND_ACCESS_ANY_WRITE) // Instruction writes RIP.
Computing the linear address of a memory operand
Computing the virtual address of a memory operand
------------------------------------------------
.. code-block:: c