Added initial notes and save parser code

This commit is contained in:
Benjamyn Love 2024-07-26 01:40:44 +10:00
parent d76c6e8ba9
commit 95bca9799a
5 changed files with 94 additions and 1 deletions

16
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src"
}
]
}

View File

@ -8,4 +8,13 @@ Current Ideas
- Unlocker?
Gonna start with the Add X Keys
Gonna start with the Add X Keys
Structure
Code lives in src/
keyadd.py <Script to add keys to save file>
ccsaveparser.py <Save parser lib>

19
notes
View File

@ -6,7 +6,26 @@ SaveSlot.sav
save appears to be seralised as
## This was an incorrect assumption
PropertyName (Fixed size) Property Type (Fixed size) Property (Dynamic based on type?)
## These are my current findings
Propertyname:
- Not fixed size
- Appears to be NULL terminated strings
- Appears to be fit into 16 byte chunks
- IE: 'Keys' is stored in 16 bytes and 'AccountLevel' is stored in 32 bytes
- After keys there is an `0x0C` that I am not sure what that is yet, its after the NULL byte for a few strings
- There is always a value after the NULL byte I've seen `0x0C` and `0x0D` so far (Might indicate the size of the data or the data is always a fixed size)
PropertyType
- Not fixed size
- Appears to be fit into 16 byte chunks
- IE: 'IntProperty' is stored in 32 bytes
- Value is directly after padding
- Value stored in MAYBE 16 bytes ( HIGHLY DOUBT IT)
- 16 bytes contain `19 00 00 00 0B 00 00 00`
- 19 being the current keys I have
Property/Type/Offset
Keys/Int/0x12f9

49
src/ccsaveparser.py Normal file
View File

@ -0,0 +1,49 @@
import struct
def load_save(save_file_name):
try:
with open(save_file_name, "rb") as f:
data = f.read()
return data
except Exception as e:
print(f"Failed to read save file: {e}")
def verify_save(save):
try:
struct.pack("bbbb", *save[:4]) == b"GVAS"
# This I think just means we have an unreal engine save but for now it should suffice
return True
except struct.error:
return False
def read_token_at_offset(save, offset):
# Load the first 16 bytes from the offset
try:
data = struct.pack("b" * 9, *save[offset : offset + 9])
if data[-1] == 0x00:
return str(data.split(b"\x00")[0].decode())
else:
data = struct.pack("b" * 16, *save[offset : offset + 16])
if data[-1] == 0x00:
return str(data.split(b"\x00")[0].decode())
else:
return None
except struct.error as e:
print(f"Failed to parse data: {e}")
save = load_save("./test.sav")
if verify_save(save):
print("Save appears to be a save file of some kind")
else:
print("The fuck is this shit mate")
# Should be fine to do shit here
# print(read_token_at_offset(save, 0x12DB)) # Keys
# print(read_token_at_offset(save, 0x12AD)) # AccountLevel
print(read_token_at_offset(save, 0x1329)) # AccountLevel

0
src/keyadd.py Normal file
View File