"this instruction cannot be assembled because the distance..."

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
User avatar
LIOBOSS
Table Makers
Table Makers
Posts: 342
Joined: Mon Dec 11, 2023 11:21 pm
Reputation: 999

"this instruction cannot be assembled because the distance..."

Post by LIOBOSS »

hi friends....

i'm facing a problem that require your help and knowledge i'm lacking of...

sometime when i write some scripts like infinite health or whatever, the script syntax is ok but when i want to execute it by ticking the box in cheat engine, it does not activate and i got the following warning message....

"This instruction cannot be assembled because the distance between the current adress and adressed adress is too big.
Try placing the adress in a register first and use that"


Can someone show me how to bypass this problem...what code should i use instead ?

thanx you all...

here is the script that pops this message up...

[ENABLE]

aobscan(INJECT,89 87 FC 00 00 00 48 8B 47 68)
alloc(newmem,$1000,INJECT)

label(code infhp)
label(return)

newmem:
cmp [basepl],rdi // ---> Line that is source of the problem
je infhp

code:
mov [rdi+000000FC],eax
jmp return

infhp:
mov eax,#999
mov [rdi+000000FC],eax
jmp return

INJECT:
jmp newmem
nop

return:
registersymbol(INJECT)

[DISABLE]

INJECT:
db 89 87 FC 00 00 00

unregistersymbol(INJECT)
dealloc(newmem)

User avatar
Rhark
Expert Cheater
Expert Cheater
Posts: 3463
Joined: Tue Apr 16, 2019 1:27 am
Reputation: 1392

Re: "this instruction cannot be assembled because the distance..."

Post by Rhark »

If "basepl" is not in the same script where it is registered as a symbol it can be too far away in memory to use this way.

To resolve this you can do this:

Code: Select all

[ENABLE]

aobscan(INJECT,89 87 FC 00 00 00 48 8B 47 68)
alloc(newmem,$1000,INJECT)

label(code)
label(return)

newmem:
push r15
mov r15,basepl
mov r15,[r15]
test r15,r15
je @f
cmp rdi,r15
jne @f
mov eax,#999

@@:
pop r15

code:
mov [rdi+000000FC],eax
jmp return

INJECT:
jmp newmem
nop

return:
registersymbol(INJECT)

[DISABLE]

INJECT:
db 89 87 FC 00 00 00

unregistersymbol(INJECT)
dealloc(newmem)

User avatar
LIOBOSS
Table Makers
Table Makers
Posts: 342
Joined: Mon Dec 11, 2023 11:21 pm
Reputation: 999

Re: "this instruction cannot be assembled because the distance..."

Post by LIOBOSS »

Thanx a lot for your answer ...i 'm gonna try to proceed this way from now.....Big thx!!

Post Reply

Who is online

Users browsing this forum: No registered users