ReadVirtual: XXXXXXXX not properly sign extended

In my KD extension dll when I call DataSpace->ReadVirtual on an x86 target, I get the warning: address not properly sign extended warning

However, the result is always valid. Should every ULONG64 be sign-extended on 32 bit systems? Is there standard operator to do this?

The documentation says that 32 bit addresses, when read back from a 32 bit target, are sign-extended to 64 bit. I suppose the engine expects to get similar sign-extended 32 bit addresses in the call arguments.

I wonder if ReadTypedDataVirtual will properly convert 32 bit pointers read from the target to 64 bit wide format. When you need to convert an arbitrary pointer, use your own macro.

Please point me to this page:
that 32 bit addresses, when read back from a 32 bit target, are sign-extended to 64 bit.

IDebugDataSpaces::ReadPointersVirtual method

On 01-Aug-2014 20:15, xxxxx@yahoo.com wrote:

Please point me to this page:
that 32 bit addresses, when read back from a 32 bit target, are sign-extended to 64 bit.

The debugger engine uses 64-bit values for both 32-bit and 64-bit
pointers. This is to avoid duplication for 32-bit and 64-bit
targets, so that either 32-bit or 64-bit debugger could work
on any target.

When the debugger truncates 64-bit pointer value for
32-bit target, it probably uses something like Int64ToIntPtr [1]
So to avoid these warnings, when converting 32-bit pointer to 64-bit,
sign extend it properly.
What this means? Look up CWDE instruction in the Intel manual.

In intsafe.h this conversion is ULongPtrToLong64
(which is not intuitive IMHO - should be LongPtrToLong64, because
for sign extension we want to interpret input and output values as signed).

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776706(v=vs.85).aspx

– pa

1 Like

Correction:
Int64ToInt32 instead if Int64ToIntPtr

– pa

On 02-Aug-2014 05:54, Pavel A. wrote:

On 01-Aug-2014 20:15, xxxxx@yahoo.com wrote:
> Please point me to this page:
> that 32 bit addresses, when read back from a 32 bit target, are
> sign-extended to 64 bit.
>

The debugger engine uses 64-bit values for both 32-bit and 64-bit
pointers. This is to avoid duplication for 32-bit and 64-bit
targets, so that either 32-bit or 64-bit debugger could work
on any target.

When the debugger truncates 64-bit pointer value for
32-bit target, it probably uses something like Int64ToIntPtr [1]
So to avoid these warnings, when converting 32-bit pointer to 64-bit,
sign extend it properly.
What this means? Look up CWDE instruction in the Intel manual.

In intsafe.h this conversion is ULongPtrToLong64
(which is not intuitive IMHO - should be LongPtrToLong64, because
for sign extension we want to interpret input and output values as signed).

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776706(v=vs.85).aspx

– pa