3
0
mirror of synced 2024-11-28 01:10:59 +01:00

update ida_find_addrs (thanks to drmext)

This commit is contained in:
CrazyRedMachine 2023-07-25 00:02:27 +02:00
parent c79ff1856f
commit 72b1e4894a
2 changed files with 26 additions and 8 deletions

View File

@ -14,6 +14,10 @@ OFFSET_BLACKLIST = [
0x100be154, 0x100be154,
0x100be346, 0x100be346,
0x100bed91, 0x100bed91,
0x100e56ec,
0x100e56f5,
0x100e5a55,
0x100e5a5e,
0x100fa4e2, 0x100fa4e2,
] ]
@ -80,7 +84,11 @@ def get_table_size_by_xref(ea, entry_size):
return (ea - orig_ea) // entry_size return (ea - orig_ea) // entry_size
def find_weird_update_patches(): def find_weird_update_patches(music_limit):
new = True if music_limit > 2040 else False
if new:
ea = find_binary("83 C4 04 89 44 24 14 C7", 0, 0)
else:
ea = find_binary("83 C4 04 3B C5 74 09", 0, 0) ea = find_binary("83 C4 04 3B C5 74 09", 0, 0)
orig_ea = ea orig_ea = ea
@ -110,17 +118,25 @@ def find_weird_update_patches():
ea = idc.FindFuncEnd(call_ea) ea = idc.FindFuncEnd(call_ea)
lea_values = [] lea_values = []
if new:
lea_orders = [11, 11, 10, 10, 9, 9]
else:
lea_orders = [11, 10, 9] lea_orders = [11, 10, 9]
while ea >= call_ea: while ea >= call_ea:
if idc.GetMnem(ea) == "lea" and idc.GetOpnd(ea, 1).startswith('[ebx+'): if idc.GetMnem(ea) == "lea" and idc.GetOpnd(ea, 1).startswith('[ebx+'):
lea_values.append([MUSIC_IDX, lea_orders[len(lea_values)], idc.GetOperandValue(ea, 1), ea]) lea_values.append([MUSIC_IDX, lea_orders[len(lea_values)], idc.GetOperandValue(ea, 1), ea])
# It is probably possible to pull a lot more from here # It is probably possible to pull a lot more from here
if len(lea_values) == 3: if new and len(lea_values) == 6:
break
elif not new and len(lea_values) == 3:
break break
ea = idc.PrevHead(ea) ea = idc.PrevHead(ea)
if new:
return lea_values[-1::-2] + values
else:
return lea_values[::-1] + values return lea_values[::-1] + values
@ -179,7 +195,6 @@ update_patches = [
[FLAVOR_IDX, 8, limit_info_list[FLAVOR_IDX][1] * 0x0c], [FLAVOR_IDX, 8, limit_info_list[FLAVOR_IDX][1] * 0x0c],
[FLAVOR_IDX, 8, limit_info_list[FLAVOR_IDX][1] * 0x0c + 4], [FLAVOR_IDX, 8, limit_info_list[FLAVOR_IDX][1] * 0x0c + 4],
] ]
update_patches_weird = find_weird_update_patches()
hook_addrs = [ hook_addrs = [
[0, find_binary("8B C6 E8 ?? ?? ?? ?? 83 F8 ?? 7D ?? 56 8A C3 E8 ?? ?? ?? ?? 83 C4 04 3D ?? ?? ?? ?? 7D ??", 0, 0)], [0, find_binary("8B C6 E8 ?? ?? ?? ?? 83 F8 ?? 7D ?? 56 8A C3 E8 ?? ?? ?? ?? 83 C4 04 3D ?? ?? ?? ?? 7D ??", 0, 0)],
@ -200,6 +215,8 @@ print("<patches>")
print("\t<limits>") print("\t<limits>")
for limit_info in limit_info_list: for limit_info in limit_info_list:
patch_target, limit_value = limit_info patch_target, limit_value = limit_info
if TARGETS[patch_target] == "music":
music_limit = limit_value
print('\t\t<%s __type="u32">%d</%s>' % (TARGETS[patch_target], limit_value, TARGETS[patch_target])) print('\t\t<%s __type="u32">%d</%s>' % (TARGETS[patch_target], limit_value, TARGETS[patch_target]))
print("\t</limits>") print("\t</limits>")
@ -284,6 +301,7 @@ for patch_info in update_patches:
print('\t\t<%s __type="str" method="%d" expected="0x%x">0x%x</%s>' % (TARGETS[patch_target], patch_type, search_value, ea + raw_bytes.index(raw_search_value), TARGETS[patch_target])) print('\t\t<%s __type="str" method="%d" expected="0x%x">0x%x</%s>' % (TARGETS[patch_target], patch_type, search_value, ea + raw_bytes.index(raw_search_value), TARGETS[patch_target]))
print "" print ""
update_patches_weird = find_weird_update_patches(music_limit)
for patch_info in update_patches_weird: for patch_info in update_patches_weird:
patch_target, patch_type, search_value, ea = patch_info patch_target, patch_type, search_value, ea = patch_info
raw_search_value = bytearray(struct.pack("<I", search_value)) raw_search_value = bytearray(struct.pack("<I", search_value))

View File

@ -2,8 +2,8 @@
## Database structure ## Database structure
Use this url to avoid songid collisions with other chart makers Check the [community spreadsheet](https://docs.google.com/spreadsheets/d/18qPEH5OZH67Blq6ySlHRnxxfmojFmgG7GQ80Wyd21zY/edit?usp=sharing)
[community spreadsheet](https://docs.google.com/spreadsheets/d/18qPEH5OZH67Blq6ySlHRnxxfmojFmgG7GQ80Wyd21zY/edit?usp=sharing) and **reserve a songid range** to avoid songid collisions with other chart makers
- do not use hiragana or kanji in the `fw_genre`/`fw_title`/`fw_artist` fields, they are used to sort the songlist. Only use full-width S-JIS characters. - do not use hiragana or kanji in the `fw_genre`/`fw_title`/`fw_artist` fields, they are used to sort the songlist. Only use full-width S-JIS characters.
- use only lowercase filenames both inside your .ifs and for the .ifs themselves - use only lowercase filenames both inside your .ifs and for the .ifs themselves