forked from foxox/nzconfigtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind_m_settings.py
More file actions
57 lines (49 loc) · 1.5 KB
/
find_m_settings.py
File metadata and controls
57 lines (49 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import struct
def find_sequence(data, sequence):
matches = []
stride = 4
seq_len_bytes = len(sequence) * stride
for i in range(0, len(data) - seq_len_bytes, 4):
match = True
for j, val in enumerate(sequence):
if val is not None:
if data[i + j*stride] != val:
match = False
break
if match:
matches.append(i)
return matches
def main():
filename = "NCSET016_downloaded_20251125.BIN"
try:
with open(filename, "rb") as f:
data = f.read()
except FileNotFoundError:
print(f"File {filename} not found.")
return
# User M Sequence:
# 31 (Set Picture Control)
# 21 (Image Quality)
# 22 (Image Size)
# 24 (Iso sensitivity)
# 1 (AF-area)
# 15 (Focus mode)
# Search for just [31, 21, 22]
seq = [31, 21, 22]
print(f"Searching for {seq}...")
matches = find_sequence(data, seq)
for m in matches:
print(f"Found match at {m} (0x{m:x})")
# Print context (12 items)
vals = []
for k in range(12):
pos = m + k*4
if pos < len(data):
vals.append(data[pos])
print(f" Context: {vals}")
# Check if this could be the start of i-menu
# If so, section start is m - 924
section_start = m - 924
print(f" Potential Section Start: {section_start} (0x{section_start:x})")
if __name__ == "__main__":
main()