简体   繁体   中英

ASSEMBLY Offset to C++ Code question

I've been trying to convert this code to C++ without any inlining and I cannot figure it out..

Say you got this line

sub     edx, (offset loc_42C1F5+5)

My hex-rays gives me

edx -= (uint)((char*)loc_42C1F5 + 5))

But how would it really look like without the loc_42C1F5 .

I would think it would be

edx -= 0x42C1FA;

But is that correct? (can't really step this code in any assembler-level debugger.. as it's damaged well protected)

loc_42C1F5 is a label actually..

seg000:0042C1F5 loc_42C1F5:                             ; DATA XREF: sub_4464A0+2B5o
seg000:0042C1F5                 mov     edx, [esi+4D98h]
seg000:0042C1FB                 lea     ebx, [esi+4D78h]
seg000:0042C201                 xor     eax, eax
seg000:0042C203                 xor     ecx, ecx
seg000:0042C205                 mov     [ebx], eax

loc_42C1F5 is a symbol. Given the information you've provided, I cannot say what its offset is. It may be 0x42C1F5 or it may be something else entirely.

If it is 0x42C1F5, then your translation should be correct.

IDA has incorrectly identified 0x42C1FA as an offset, and Hex-Rays used that interpretation. Just convert it to plain number (press O) and all will be well. That's why it's called Interactive Disassembler :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM