Moonloader memory.setint8

innoj

Новичок
Автор темы
10
30
so, in my script there is memory.setint8 and it works for me but it crashes for other people.
local memory = require"memory"
local TurnAddress = 7003425
local NOP = 144
for i = 1,6 do
memory.setint8(TurnAddress +i, NOP)
end

Why does some people get error for this but I dont?
[ML] (error) CounterSteerFix.lua: cannot resume non-suspended coroutine stack traceback: [C]: in function 'setint8' ...heft Auto San Andreas 037\moonloader\CounterSteerFix.lua:61: in function <...heft Auto San Andreas 037\moonloader\CounterSteerFix.lua:56> [ML] (error) CounterSteerFix.lua: Script died due to an error. (08DDB844)

It has nothing to do with coroutines lol
 

innoj

Новичок
Автор темы
10
30
Tried different CLEO version and it crashed, need 4.3 for it to work
different game version might break it too
 
Последнее редактирование:

san0

Известный
Друг
411
267
An address you're trying to modify is located in the read-only code segment.
Fortunately for some of your users, Cleo 4.3 does unprotecting of these memory regions 'till a game shuts down.
As for cleo 4.3, "cleo.log" usually contains these lines:
Код:
...
Unprotecting memory region '.text': ...
Unprotecting memory region '.rdata': ...
Unprotecting memory region '.text': ...
...

Anyway, both types of your users are able to run this code without such problems
as long as you take a look at the memory module documentation
https://blast.hk/wiki/lua:memory
and find out that every function that modifies game memory in fact takes optional last argument which indicated to Moonloader that memory might be protected so it has to do something with that
memory.setint8(int address, int byte, [bool unprotect=false])

Moreover, there's still available pair of functions to be used:
memory.protect / memory.unprotect

Accordingly, you would've got the following if you hadn't missed DEV_WIKI:
memory.fill(0x6ADD21, 0x90, 6, true)
 
  • Нравится
Реакции: AnWu, innoj и imring