Page 1 of 1

Inline ASM Pointers

PostPosted: Fri Jun 18, 2010 11:24 pm
by tahnsk
Alright, what I need to do is write the value 4 to this pointer in c++ inline asm:
[Value of 00400000] + 0x32F8


Can you give me an example what the code should be?
I tried this and it crashed me:

Code: Select all
   _asm {

       mov    eax,0x00400000
       mov    ebx,[eax]
       add    ebx,0x32F8
       mov    eax,[ebx]
       add    dword ptr ds:[eax],0x04
}



I USE THE ADDRESS 00400000 JUST FOR EXAMPLE

Re: Inline ASM Pointers

PostPosted: Sat Jun 19, 2010 10:13 pm
by L. Spiro
Why don’t you single-step through it to see which value is wrong and why?


L. Spiro

Re: Inline ASM Pointers

PostPosted: Sat Jun 19, 2010 11:37 pm
by Felheart
if you want to write it to the address then why this:
add dword ptr ds:[eax],0x04

use mov for writing... maybe its just a typo.

Re: Inline ASM Pointers

PostPosted: Sun Jun 20, 2010 6:47 pm
by denispn
Hi!

Code: Select all
_asm {

       mov    eax,0x00400000
       mov    ebx,[eax]
       add    ebx,0x32F8
       mov    eax,[ebx]
       add    dword ptr ds:[eax],0x04
}


In line 4 you are doing this: eax = [[Value of 00400000] + 0x32F8], so eax stores the result of this expression, that is an address.
In line 5 you are adding 04h to the value eax points to, so [[[Value of 00400000] + 0x32F8]] = [[[Value of 00400000] + 0x32F8]] + 04h, like value = value + 04h.

Is this really what you want?

Cheers