Page 1 of 1

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

Posted: Mon Nov 04, 2024 9:04 am
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)

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

Posted: Mon Nov 04, 2024 10:07 am
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)

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

Posted: Mon Nov 04, 2024 2:14 pm
by LIOBOSS
Thanx a lot for your answer ...i 'm gonna try to proceed this way from now.....Big thx!!