Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Lea into label, Cant be compiled WHY! -- SOLVED THX GUYS

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sat Jan 09, 2016 6:02 pm    Post subject: Lea into label, Cant be compiled WHY! -- SOLVED THX GUYS Reply with quote

So im trying to get items id, so i can replace junk with something else.

why does it not allow me to compile lea [label],ecx?

Code:
[ENABLE]

aobscan(_ic,89 48 18 C7 46 18 00 00 00 00) // should be unique
alloc(newmem,$1000,3AF25C4F)
globalalloc(itemid,32)

label(code)
label(return)


newmem:

code:
  mov [rax+18],ecx
         push ecx
         lea ecx,[rax+10+20]
         lea [itemid],ecx <----------- this line cant be compiled.
         pop ecx
  mov [rsi+18],00000000
  jmp return

_ic:
  jmp code
  nop
  nop
  nop
  nop
  nop
return:
registersymbol(_ic)
[DISABLE]

_ic:
  db 89 48 18 C7 46 18 00 00 00 00

unregistersymbol(itemid)
unregistersymbol(_ic)
dealloc(itemid)
dealloc(newmem)


Last edited by NanoByte on Sun Jan 10, 2016 8:58 am; edited 1 time in total
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sat Jan 09, 2016 6:13 pm    Post subject: Reply with quote

Do you want to assign the address currently stored in ecx to your variable "itemid"?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Jan 09, 2016 6:20 pm    Post subject: Reply with quote

Code:
push rcx
lea rcx,[rax+10+20]
mov qword ptr [itemid],rcx
pop rcx
Back to top
View user's profile Send private message
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sun Jan 10, 2016 6:35 am    Post subject: Replay Reply with quote

Yeah i want the address currently stored in [rax+10] and assign the address to itemid so i can see what, id for certains items are so i dont have dissect datastructure for every item.

Code:
push rcx
lea rcx,[rax+10+20]
mov qword ptr [itemid],rcx  <--- this is compileable but gives out wrong data - what does it do? been so long since i last played with cheat engine :D
pop rcx
Back to top
View user's profile Send private message
mgostIH
Expert Cheater
Reputation: 3

Joined: 01 Jan 2016
Posts: 159

PostPosted: Sun Jan 10, 2016 6:40 am    Post subject: Reply with quote

If you want the address of ecx into the label "itemID", you'll have to rever the lea as the following:
Code:
lea itemid,[ecx]


Which is the exact same as:
Code:
mov itemid,ecx

_________________
Do you need to ask me something? Feel free to join my discord server at: https://discord.gg/At4VZXA or ask me something in my YouTube channel: https://www.youtube.com/c/mgostIH
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sun Jan 10, 2016 6:53 am    Post subject: Reply with quote

Right. With mov [itemid],rcx (as Zanzer suggested) you'd have a level 1 pointer ...
Back to top
View user's profile Send private message
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sun Jan 10, 2016 7:21 am    Post subject: Screenshot Reply with quote

Cant compile

Code:
Lea itemid,[ecx]

or

mov [itemid],rcx  <----  THIS WORKS WOOHOO, but mov used to move value not address why does it work?


but if i mov it, it will only give me value of the ecx and not the address?

a label has to be inside > [here] i think


How would you guys approch this?



Capture.PNG
 Description:
 Filesize:  78.22 KB
 Viewed:  9999 Time(s)

Capture.PNG




Last edited by NanoByte on Sun Jan 10, 2016 7:58 am; edited 1 time in total
Back to top
View user's profile Send private message
mgostIH
Expert Cheater
Reputation: 3

Joined: 01 Jan 2016
Posts: 159

PostPosted: Sun Jan 10, 2016 7:44 am    Post subject: Reply with quote

If the address is stored in [rax+10] (basing on your screenshot, 0x4B8A1C78), then use:
Code:
mov ecx,[rax+10]

_________________
Do you need to ask me something? Feel free to join my discord server at: https://discord.gg/At4VZXA or ask me something in my YouTube channel: https://www.youtube.com/c/mgostIH
Back to top
View user's profile Send private message
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sun Jan 10, 2016 8:00 am    Post subject: Reply with quote

it works Very Happy!!!!

but can u explain why it works??
because mov, moves value of the rax not the address, i dont get it
Code:
mov ecx,[rax+10]
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Jan 10, 2016 8:04 am    Post subject: Reply with quote

Cheat Engine addresses can be turned into pointers.
It looks like the code you want is simply:
Code:
code:
  mov [rax+18],ecx
  mov qword ptr [itemid],rax
  mov [rsi+18],00000000
  jmp return

Now manually create an address
Check "pointer" and assign the bottom value as "itemid"
Above that, assign the offset value of 10
Click the Add Offset button and give that a value of 20
Back to top
View user's profile Send private message
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sun Jan 10, 2016 8:17 am    Post subject: Reply with quote

It Works guys thx alot Very Happy

would be great if someone explained why the mov instead of lea works would be great
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Sun Jan 10, 2016 8:24 am    Post subject: Reply with quote

I think your problem is the interpretation of "value".
Code:
mov ecx,esi

for example moves the VALUE of esi into ecx. In this case the value may be a value like 1 or 1576.234 but an address also is a value in the original sence.

So the code
Code:
mov ecx,[rax+10]

also moves a VALUE, although you as a human being interpret the value as a pointer, which of course resembles an address, but for the memory instruction, it makes no difference ...

I hope you understand my thought Wink
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Jan 10, 2016 8:27 am    Post subject: This post has 2 review(s) Reply with quote

If we go off of your screenshot, RAX currently contains the value "8FB4B140"
So you want to move that value into the value of "itemid"
Now the CE address you defined starts with a base of "itemid" and the value 8FB4B140 is retrieved
The first offset is 10, so it will add hex 10 to 8FB4B140, giving 8FB4B150
It then takes the value at that address, which is 4B8A1C78 in your screenshot
Now it adds the next offset of hex 20 to 4B8A1C78, giving 4B8A1C98, which is the address containing your item id value

So lets go over the differences between MOV and LEA.
Code:
mov rcx,[rax+10]

Above, the VALUE at [rax+10] is loaded into RCX (4B8A1C78).
Code:
lea rcx,[rax+10]

Above, the ADDRESS at [rax+10] is loaded into RCX (8FB4B150).
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Jan 10, 2016 8:37 am    Post subject: Reply with quote

mov rcx,[rax+10] is the same as (pseudocode)
RCX:=readQword(RAX+0x10)



lea rcx,[rax+10] is the same as
RCX:=RAX+0x10


LEA - Load Effective Address

_________________
Back to top
View user's profile Send private message MSN Messenger
NanoByte
Expert Cheater
Reputation: 1

Joined: 13 Sep 2013
Posts: 222

PostPosted: Sun Jan 10, 2016 8:56 am    Post subject: Reply with quote

Thanks alot guys, i understand it now Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites