 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
7aniki How do I cheat?
Reputation: 0
Joined: 14 Aug 2023 Posts: 4
|
Posted: Mon Aug 14, 2023 7:06 pm Post subject: How to split value into multiple input |
|
|
Hi guys!
I want to ask how to split a 4byte value into multiple input like this?
i.ibb.co/W306rm3/time.jpg
the formula is kinda like this (from game Story of season a wonderful life)
i.ibb.co/RSr7jJv/sosawl.png
I read here and there that I should make a custom value (right click in value type dropdown)
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Mon Aug 14, 2023 8:12 pm Post subject: |
|
|
I guess you could make custom value types that only access part of the 4-byte value. The general algorithm would look something like this:
Code: | int convertroutine(unsigned char *input, int div, int mod) {
int v = *(int *)input;
return (v / div) % mod;
}
void convertbackroutine(int i, unsigned char *output, int div, int mod) {
int v = *(int *)output;
int high = v / (div * mod);
int low = v % (div);
*(int *)output = high * (div * mod) + (i * div) + low;
} | These aren't the exact signatures of convertroutine and convertbackroutine, but these could be used as helper functions on their own. e.g. autoAssemble targetself {$c} block might work
`div` is how many base units are in the current unit, and `mod` is how many current units are in the next unit. e.g. for an "hour" custom type, `div` would be 60*60 (3600 seconds in an hour) and `mod` would be 24 (24 hours in a day).
In convertbackroutine, CE stores the current value in output, so that's used to not modify the other parts of the value (e.g. setting hours won't affect years or minutes).
I have no idea how you'd handle months. Hopefully the game has a constant "4 weeks per month" or something.
If the game tracks dates according to the Gregorian calendar... well, good luck.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
7aniki How do I cheat?
Reputation: 0
Joined: 14 Aug 2023 Posts: 4
|
Posted: Mon Aug 14, 2023 10:41 pm Post subject: |
|
|
Wow, ParkourPenguin!
It surprised me to see you are the first one to reply, because every thread I read I encountered your name.
About month, thankfully the game time format is very simple, 1 month consist of 10 days (no week), which I already included in my previous excel formula. And 1 year consist of 4 month.
Please bear with me because I only have the knowledge of basic Pascal,
i.ibb.co/2S1K2vW/time3.jpg
1. The previous table already located time as 4 byte in that address and it is always updating every second
2. As of now if I want to do a time jump, I could just input the year/month/day to excel, and it convert to the 4byte total value for me to be put into CE's Time Editor Value
3. If I split Time Editor value into 5 input variable A B C D E, and change only the value of variable C, will CE look at all those 5 variable's value first before convert them back to 4 byte value?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Mon Aug 14, 2023 11:46 pm Post subject: |
|
|
Honestly the way you're doing it now is probably fine.
You could make 5 different custom types that each modify the respective part of that 4-byte integer, but is that worth the effort if your excel solution is working fine?
I thought it was interesting (haven't used {$c} much) and got this Lua script working:
Code: | assert(cheatEngineIs64Bit(), 'These custom types not implemented for 32-bit CE')
local success,err = autoAssemble([[
{$c}
int time_convertroutine_helper(unsigned char *input, int div, int mod) {
int v = *(int *)input;
return (v / div) % mod;
}
void time_convertbackroutine_helper(int i, unsigned char *output, int div, int mod) {
int v = *(int *)output;
int high = v / (div * mod);
int low = v % (div);
*(int *)output = high * (div * mod) + (i * div) + low;
}
{$asm}
]], true)
if not success then
-- string concat must be lazily evaluated
error('Failed to compile custom type helper functions: ' .. err)
end
-- array of tables {
-- name = string (e.g. "Hour")
-- base = base units (3600 seconds = 1 hour),
-- mod = modulus; # to next unit (24 hours = 1 day);
-- }
local time_units = {
{
name = "Minutes",
base = 60,
mod = 60
},
{
name = "Hours",
base = 60*60,
mod = 24
},
{
name = "Days",
base = 60*60*24,
mod = 10
},
{
name = "Months",
base = 60*60*24*10,
mod = 4
},
{
name = "Years",
base = 60*60*24*10*4,
mod = 0x7FFFFFFF -- no next unit, so use something big
},
}
for _,t in ipairs(time_units) do
local ct, err = registerCustomTypeAutoAssembler(([[
alloc(ConvertRoutine,1024)
alloc(ConvertBackRoutine,1024)
alloc(TypeName,256)
alloc(ByteSize,4)
alloc(UsesFloat,1)
alloc(UsesString,1)
alloc(MaxStringSize,2)
alloc(CallMethod,1)
TypeName:
db '%s',0
ByteSize:
dd 4
UsesFloat:
db 0
UsesString:
db 0
MaxStringSize:
dw #100
CallMethod:
db 1
ConvertRoutine:
mov edx,%X
mov r8d,%X
jmp time_convertroutine_helper
ConvertBackRoutine:
mov rdx,r8
mov r8d,%X
mov r9d,%X
jmp time_convertbackroutine_helper
]]):format('CT_' .. t.name, t.base, t.mod, t.base, t.mod))
if not ct then
error('Failed to add AA custom type: ' .. err)
end
end |
As for that description for years / months, right click the memory record in the address list and select "Set/change dropdown selection options".
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
7aniki How do I cheat?
Reputation: 0
Joined: 14 Aug 2023 Posts: 4
|
Posted: Tue Aug 15, 2023 3:12 am Post subject: |
|
|
Wow, it works flawlessly!
And to think you made the script works from scratch without playing the game, it's mindblowing!!
i.ibb.co/74zKKqd/timemachine.jpg
Thank you very much!
Can you give me some tips how to search the address for journal entries?
It goes like this:
1.the journal entry is empty at the beginning
2. cook 1 herbal soup
3. Journal entry got 1 new entry: herbal soup. First made: Year 1, Spring 1.
I tried to new search-first search 0 (4 byte) it gives hundred of million address, my potato PC crashed.
Oh and I already have all the Item ID list (herbal soup ID 1365), if that can help narrow down the search.
I thought if I can get the address for 2-3 item and found the offset, maybe I can do something like,"from address range A to B, insert Year1,Spring 1" to unlock all the journal entries
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4697
|
Posted: Tue Aug 15, 2023 10:39 am Post subject: |
|
|
That would be quite difficult. You'd have to be able to figure out what kind of container stores those journal entries. By your description, there's at least 2 points of information: whether or not an item is unlocked, and when it was unlocked. Maybe it's something as simple as an array of non-zero time points (encoded as a 4-byte integer; 0 means locked), or maybe it's something more complicated like a hash map from item IDs to time points.
Randomly scanning for values probably won't get you very far. Maybe you could look at the set difference between the results of two scans for some value: one made before the journal entry related to the item is made, and the other made after. Of course, there's no guarantee this works either, as you have no idea what values a journal entry is comprised of.
If you're pretty familiar with assembly and know some basic reverse engineering knowledge (e.g. calling conventions, data structures), you might be able to trace an access from some related information and get what you want. e.g. look at what accesses the current time, cook something, hopefully a new instruction accesses it when the journal entry is made, trace it from there. Even for people who know what they're doing, this is typically easier said than done.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
7aniki How do I cheat?
Reputation: 0
Joined: 14 Aug 2023 Posts: 4
|
Posted: Tue Aug 15, 2023 5:58 pm Post subject: |
|
|
yep, that is way beyond my knowledge I think I will pass on those journal entry cheat request. Thanks again Parkourpenguin for all of your help, you ended up doing my howework.
*insert keanureeve's you're breathtaking meme.
|
|
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
|
|