Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Made by Deepseek AI
- import os
- import time
- from datetime import datetime
- def monitor_save_file(file_path, check_interval=1.0, log_file="changes.txt"):
- if not os.path.exists(file_path):
- print(f"Error: File not found - {file_path}")
- print("Tip: Press Win+R, type '%appdata%', and check the Sekiro folder.")
- return
- print(f"Monitoring: {file_path}")
- print(f"Logging to: {log_file}")
- print("Ignoring offsets 0x0300-0x030F (playtime counters).")
- print("Press Ctrl+C to stop.\n")
- previous_data = open(file_path, 'rb').read()
- try:
- with open(log_file, 'a') as log:
- while True:
- time.sleep(check_interval)
- try:
- current_data = open(file_path, 'rb').read()
- except PermissionError:
- print("Error: Could not read the file. Close Sekiro and retry.")
- break
- if current_data != previous_data:
- changes = []
- min_len = min(len(previous_data), len(current_data))
- # Detect all changes (except 0x0300-0x030F)
- for offset in range(min_len):
- if 0x0300 <= offset <= 0x030F: # Skip playtime/data
- continue
- if previous_data[offset] != current_data[offset]:
- changes.append((offset, previous_data[offset], current_data[offset]))
- timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- log_msg = f"\n--- Change at {timestamp} ---\n"
- log_msg += f"Total bytes changed: {len(changes)}\n"
- # Log ALL changes to file
- for offset, old_byte, new_byte in changes[:100]: # Limit to 100 changes per log
- log_msg += f"Offset: 0x{offset:06X} | Old: 0x{old_byte:02X} | New: 0x{new_byte:02X}\n"
- log.write(log_msg)
- log.flush()
- # Print to console + highlight potential flags
- print(f"\n--- Change at {timestamp} ---")
- print(f"Total changes: {len(changes)} (Full log in {log_file})")
- for offset, old_byte, new_byte in changes[:20]: # Show first 20 changes
- # Skip playtime/data (redundant check for console output)
- if 0x0300 <= offset <= 0x030F:
- continue
- # Highlight potential flags
- if old_byte == 0x00 and new_byte in (0x01, 0x02, 0x80):
- print(f">>> FLAG CANDIDATE (DECISION?) | Offset: 0x{offset:06X} | Old: 0x{old_byte:02X} → New: 0x{new_byte:02X}")
- elif (old_byte ^ new_byte) in (0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80):
- print(f">>> BITFLAG TOGGLE | Offset: 0x{offset:06X} | Old: 0x{old_byte:02X} | New: 0x{new_byte:02X}")
- else:
- print(f"Offset: 0x{offset:06X} | Old: 0x{old_byte:02X} | New: 0x{new_byte:02X}")
- previous_data = current_data
- except KeyboardInterrupt:
- print("\nStopped monitoring.")
- except Exception as e:
- print(f"Error: {e}")
- # EDIT THIS PATH TO YOUR ACTUAL SAVE FILE!
- save_file_path = r"C:\Users\windows11\AppData\Roaming\Sekiro\76561197960267366\S0000.sl2"
- monitor_save_file(save_file_path)
- input("\nPress Enter to exit...") # Keeps window open
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement