View previous topic :: View next topic |
Author |
Message |
zxuiji Advanced Cheater
Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Mon Oct 29, 2018 9:38 am Post subject: Need example of using synchronize() |
|
|
Trying to verify some patch codes are being reached in a thread, tried to call print for it but I think it's causing an access violation. Might be something else but until I know how to use synchronize() I won't be able to verify.
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel. |
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25778 Location: The netherlands
|
Posted: Mon Oct 29, 2018 9:43 am Post subject: |
|
|
print is thread-safe(synchronized itself) so that shouldn't cause an issue
But if you're inside a thread (inMainThread() returns false ) then you can call synchronize(function()) or synchronize(function(...),...) to run the given code inside the main thread. Only the main thread can access things that affect the gui, like addresslist, memoryrecords, button states, etc... (that includes both writes AND reads)
e.g:
Code: |
synchronize(function(p1,p2)
print('hello')
print('p1='..p1)
print('p2='..p2)
end, 1,'parameter 2')
|
or to show it more clearly:
Code: |
createThread(function(t)
print('before inMainThread='..tostring(inMainThread()))
synchronize(function(p1,p2)
print('inMainThread='..tostring(inMainThread()))
print('p1='..p1)
print('p2='..p2)
end, 1,'parameter 2')
print('after inMainThread='..tostring(inMainThread()))
end)
|
returns
Code: |
before inMainThread=false
inMainThread=true
p1=1
p2=parameter 2
after inMainThread=false
|
_________________
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 |
|
Back to top |
|
 |
zxuiji Advanced Cheater
Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Mon Oct 29, 2018 10:29 am Post subject: |
|
|
Judging from that I should be creating an anonymous to call what I want then?
Anyway dunno what I did but the access violation went away, now trying to find an example the compare code types to make sure my own are correct, (e.g. I got a D type before a 4 type when possibly I need a e type instead)
https://gamehacking.org/wiki/Code_Types_%28Playstation_2%29
and
http://macrox.gshi.org/The%20Hacking%20Text.htm#ps2_code_types
are currently all I found and they don't give examples :(
And btw thanks :)
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel. |
|
Back to top |
|
 |
predprey Master Cheater
Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
|
Back to top |
|
 |
zxuiji Advanced Cheater
Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Mon Oct 29, 2018 12:10 pm Post subject: |
|
|
Thanks, wound up doing that while waiting for your reply. Also thanks for the code-master link, been trying to remember the name of that site XD
_________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel. |
|
Back to top |
|
 |
|