|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
zxuiji Advanced Cheater Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Mon Oct 29, 2018 6:51 pm Post subject: Lua problem? Comparison Problems. |
|
|
I've tried everything I can think of and I still end up not getting past the comparison point, anyone who feels like downloading my CT and trying to solve this problem the link is in this thread:
https://forum.cheatengine.org/viewtopic.php?p=5743511
The codes are for pcsx2.exe[ff12(uk)], the place to start is DoPatch() and the only other place I can think of is the point where the comparison is defined in Patch() (look for a "elseif obj.skipn" condition). Just start a new game (or load an untainted save with reks) and try the max gil to understand what the problem is in detail.
I'm going to bed now so probably will forget this till later in the week, if you manage to fix it please let me know what I was doing wrong so that I'm less likely to make the same mistake again.
_________________
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 |
|
|
zxuiji Advanced Cheater Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Tue Oct 30, 2018 2:05 am Post subject: |
|
|
Yeah I was tired last night and couldn't think of way to explain it then, wasn't holding the expectation that someone actually would, just the hope that someone who could fix iti might actuall do so before I could produce a proper explanation. The problem is that while the code that handles writing bytes works fine (tested it with individual memory records) the code that handles comparisons and which lines to execute is somehow not reaching it afterwards despite the condition being true. This is the only code I can think of that would be faulty:
Code: | elseif obj.skipn then
obj.skipn = tonum(obj.skipn,16)
obj.desc = "Run " ..
obj.skipn .. " lines"
obj.bytes = tonum(obj.bytes,16)
if obj.stype == '0' then
obj.desc = obj.desc .. " if bytes == %X"
obj.cmp = function(value)
return (value == obj.bytes)
end
elseif obj.stype == '1' then
obj.desc = obj.desc .. " if bytes ~= %X"
obj.cmp = function(value)
return (value ~= obj.bytes)
end
elseif obj.stype == '2' then
obj.desc = obj.desc .. " if bytes < %X"
obj.cmp = function(value)
return (value < obj.bytes)
end
elseif obj.stype == '3' then
obj.desc = obj.desc .. " if bytes > %X"
obj.cmp = function(value)
return (value > obj.bytes)
end
else
print("Invalid Comparison: " .. obj.stype)
obj.desc = obj.desc .. "; bytes = %X"
obj.cmp = function()
return false
end
end
obj.desc = obj.desc:format(obj.bytes)
obj.vsize = 2
obj.getval = function()
return RdValue(obj.addr,2)
end
obj.handle = function(value)
if obj.cmp(value) == true then
return 0
end
return obj.skipn
end |
Code: | function DoPatch(chk,o)
local next,n = 0,0
local line,l,value
if o.m ~= nil and o.e == true then
for l,line in pairs(o.c) do
if chk() then
return false
end
n = n + line.lines
if n >= next then
value = line.getval()
if value == nil then
next = -1
o.e = nil
print(o.desc)
print(line.desc)
return false
else
--[[
if value ~= 0 then
next = -2
o.e = nil
print(o.desc)
print(line.desc)
end
--]]
--value = tonumber(value,16)
next = line.handle(value)
end
n = 0
end
if next == -1 then
return false
elseif next == -2 then
break
end
o.c[l] = line
end
end
return o
end
|
_________________
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 |
|
|
zxuiji Advanced Cheater Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Tue Oct 30, 2018 3:50 am Post subject: |
|
|
For starters I can't use #o.c, the line count is not related to the number of nodes, an example is this:
Code: | 30T0YYYY 0XXXXXXX
30T00000 0XXXXXXX
YYYYYYYY 00000000
|
The same code can consist of either one line or multiple lines hence the paramter "lines", in the event of false coming from a comparison n foollowing lines are supposed to be skipped, the "lines" parameter is supposed to accomidate that purpose, the "next" variable is supposed to hold n until the value "n" catches up at which point code execution is supposed to resume and the values are constently reset until the next comparison code or there is no more codes in that group. In the event the comparison returns true n lines that would normally be skipped should instead be executed, it is this situation that is not occuring.
As for the "value == nil" & "next == -1" scenarios they are merely there for error handling of unexpected read/write failures allowing for the thread to exit instead of causing unnecessary hangs or unwanted behavior in either CE or the hooked app (in this case pcsx2.exe).
I'm not sure I mentioned it properly but the value "n" is not supposed to maintain it's value unless it is less than the number of lines to skip, hence why next is normally 0.
Edit: The only other potential problem I can think of is this:
Code: |
function RdValue(addr,bytes)
--print(('%X(%d bytes)'):format(addr,bytes))
if bytes == 1 then
return (readBytes(addr,1,true))[1]
elseif bytes == 2 then
return readSmallInteger(addr)
elseif bytes == 4 then
return readInteger(addr)
elseif bytes == 8 then
return readQword(addr)
end
return nil
end
|
Edit 2: It occured to me that my naming choice for variables in DoPatch() was poor, I've now edited it:
Code: | function DoPatch(chk,o)
local skip,on = 0,0
local code,i,value
if o.m ~= nil and o.e == true then
for i,code in pairs(o.c) do
if chk() then
return false
end
on = on + code.lines
if on > skip then
on = 0
value = code.getval()
if value == nil then
skip = -1
else
--[[
if value ~= 0 then
skip = -2
o.e = nil
print(o.desc)
print(code.desc)
end
--]]
--value = tonumber(value,16)
skip = code.handle(value)
end
end
if skip == -1 then
o.e = nil
print(o.desc)
print(code.desc)
return false
elseif skip == -2 then
break
elseif skip == -3 then
return true
end
o.c[i] = code
end
end
return o
end
|
_________________
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 |
|
|
zxuiji Advanced Cheater Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Tue Oct 30, 2018 5:26 am Post subject: |
|
|
'K tried that, seems I AM getting to the write code but for some reason it's not going through or CE is not updating. Incidently this is what printed:
Code: | asm attempt
==(4.1) Max Gil; Count = 0
Run 1 lines if bytes > 0 @209E8A04
==(4.1) Max Gil; Count = 1
Write Always: 05F5E0FF @2054C008
==(4.1) Max Gil
Write Always: 05F5E0FF
writeByted attempt
==(4.1) Max Gil; Count = 0
Run 1 lines if bytes > 0 @209E8A04
==(4.1) Max Gil; Count = 1
Write Always: 05F5E0FF @2054C008 |
The function I'm using is this:
Code: | function WrBytes(addr,bytes,value)
-- print("WrBytes( " .. addr .. ", " .. bytes .. " )")
-- Provides fallback scenario
if addr == 0xDEADC0DE then
print("DEADC0DE, will not write")
return nil
end
-- Prevents accidental usage of timers & seed changes
if addr == 0xDEAFC0DE or
addr == 0xDEADFACE then
return addr
end
addr = addr + BaseAddress
if type(bytes) == 'number' then
if not value then
if bytes > 0xFFFF then
value = ('%08X'):format(bytes)
elseif bytes > 0xFF then
value = ('%04X'):format(bytes)
else
value = ('%02X'):format(bytes)
end
else
value = ('%0' ..
(('%dX'):format(bytes))):format(value)
end
bytes = SeperateBytes(value)
end
addr = tonum(addr,16)
--
bytes = Split(bytes,"%S+")
for i,v in pairs(bytes) do
bytes[i] = tonumber(v,16)
end
if writeBytes(addr,bytes) then
--]]
--[[
local asm = [[registersymbol(WrBytesTmp,%X)
WrBytesTmp:
db %s
unregistersymbol(WrBytesTmp)]]
--[[
asm = asm:format(addr,bytes)
asm = autoAssemble(asm)
if asm and asm ~= nil then
--]]
return addr
end
return nil
end |
_________________
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 |
|
|
zxuiji Advanced Cheater Reputation: 1
Joined: 26 Sep 2016 Posts: 70
|
Posted: Tue Oct 30, 2018 5:57 am Post subject: |
|
|
Finally found it, forgot to remove the "addr = addr + BaseAddress" line from WrBytes() after setting it properly in PatchCode(), you're point about not being able to replicate it got me thinking so re-tried the individual records and then continued to look at WrBytes() itself eventually noticing the forgotten temporary line, everything is behaving as I expect it to now :)
_________________
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 |
|
|
|
|
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
|
|