Assembler instruction lea rax,[rip]

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
AlexS
Expert Cheater
Expert Cheater
Posts: 359
Joined: Sun Apr 08, 2018 3:46 pm
Reputation: 215

Assembler instruction lea rax,[rip]

Post by AlexS »

(Google translation)

How to use instructions lea rax,[rip] in Cheat Engine?
I need to get the RIP register value. The Cheat Engine program does not allow me to save the AA script with such an instruction and issues a warning about the error "Not All Code Is Injectable".
However, when I instead
lea rax,[rip]
I post a byte code of this instruction in the script script
db 48 8D 05 00 00 00 00
then the Cheat Engine program accepts it and instruction lea rax,[rip] works fine.
What am I doing wrong? What are the reasons for this phenomenon and how can I use the instruction lea rax,[rip] without transformation into bytes?

User avatar
NocturnallySad
What is cheating?
What is cheating?
Posts: 1
Joined: Sat Mar 22, 2025 1:15 pm
Reputation: 1

Re: Assembler instruction lea rax,[rip]

Post by NocturnallySad »

AlexS wrote:
Sun Apr 06, 2025 1:53 pm
(Google translation)

How to use instructions lea rax,[rip] in Cheat Engine?
I need to get the RIP register value. The Cheat Engine program does not allow me to save the AA script with such an instruction and issues a warning about the error "Not All Code Is Injectable".
However, when I instead
lea rax,[rip]
I post a byte code of this instruction in the script script
db 48 8D 05 00 00 00 00
then the Cheat Engine program accepts it and instruction lea rax,[rip] works fine.
What am I doing wrong? What are the reasons for this phenomenon and how can I use the instruction lea rax,[rip] without transformation into bytes?

Theres no special phenomenon you are just a misunderstanding how the legendary rip register works.

This "48 8D 05 00 00 00 00" does mean "lea rax, [rip + 0]" but not in that form. It would look like this:

0D3B0000 - 48 8D 05 00000000 - lea rax,[0D3B0007] ; rip+ 0
0D3B0007 - C3 - ret

This is how rip relative addressing works it's always relative as the name suggests. Any assembler that lets you do something like mov rax,[rip+10] isnt actually accessing rip adding 10 and then grabbing whatever is at that location. When assembled it generates 'Position Independent Code' the assembler calculates the offset from the current instruction location and encodes it directly. Like in the example above its not dynamically reading rip its just using a precomputed offset.

Take a look at these below they may help you:

call @f
@@:
pop rax

or

lea rax,[@f]
@@:

Your not meant to be able to touch rip because its not a generel purpose register its hidden away in cave somewhere in the cpu its a special register that isnt designed to be exposed to general purpose data manipulation.

AlexS
Expert Cheater
Expert Cheater
Posts: 359
Joined: Sun Apr 08, 2018 3:46 pm
Reputation: 215

Re: Assembler instruction lea rax,[rip]

Post by AlexS »

NocturnallySad wrote:
Sun Apr 06, 2025 6:49 pm
Take a look at these below they may help you
(Google translation)

Thank you very much for your explanations, you helped me a lot. :)

Paul44
RCE Fanatics
RCE Fanatics
Posts: 988
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 683

Re: Assembler instruction lea rax,[rip]

Post by Paul44 »

^ #ParkourPenguin wrote up a VERY good article on the subject: google "cheat engine RIP-Relative Addressing and Jmp Oddities (64-bit)" <= this is kinda 'MUST READ' for any tablemaker...
(yep, including me :))

=> whether this responds to your question and/or gives a solution, i can't really tell. I never had the need - nor tendency - to collect EIP/RIP... sofar.

AlexS
Expert Cheater
Expert Cheater
Posts: 359
Joined: Sun Apr 08, 2018 3:46 pm
Reputation: 215

Re: Assembler instruction lea rax,[rip]

Post by AlexS »

Paul44 wrote:
Mon Apr 07, 2025 4:52 pm
ParkourPenguin wrote up a VERY good article on the subject
(Google translation)

Thank you, Paul, I used to read this article. Useful.
I know that RIP is a “difficult” register, so I asked experts how to access the contents of this register using Cheat Engine.
Thanks for the help. :)

Post Reply

Who is online

Users browsing this forum: AmazonBot