Posted: Wed Jun 14, 2023 2:29 am Post subject: asm call vs lua call functions
when i call functions from lua(executeCodeEx, executeMethod), it will crash after many calls of the func at the same time, and i didn't saw how it will behave when i will call it from asm script
Joined: 09 May 2003 Posts: 25807 Location: The netherlands
Posted: Wed Jun 14, 2023 3:24 am Post subject:
maybe the function you're calling isn't thread safe and can cause a conflict when the main thread of the game accesses something related to that function
e.g: (games don't code like this these days but see it as an example)
you have a 2 byte value and 2 threads
t1: decreases the value with 1
valuepart1 = valuepart1 - 1
if valuepart1 == 255 then valuepart2=valuepart2-1
t2: increases the value with 1
valuepart1 = valuepart1 + 1
if valuepart1=0 then valuepart2=valuepart2+1
now let's run:
the value is 255 (ff 00)
t1 runs:
valuepart1=valuepart1-1 : value is now fe 00 (254)
t2 runs:
valuepart2=valuepart1+1 : value is now ff 00 (255)
t1 runs:
if valuepart1 == 255 then valuepart2=valuepart2-1: value is now ff ff (-1)
....
As you can see having multiple threads execute code at the same time can cause issues
Best way around it is execute the code from the original thread using code injection _________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping
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