Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show progress while running IDA script #791

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Il2CppDumper/ida_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,35 @@ def make_function(start, end):
ida_funcs.del_func(start)
ida_funcs.add_func(start, end)

def show_progress(field, current, total):
if current % 100 == 0:
msg = f"Processing {field} {current}/{total} {current * 100 / total:.2f}%"
idaapi.replace_wait_box(msg)

path = idaapi.ask_file(False, '*.json', 'script.json from Il2cppdumper')
data = json.loads(open(path, 'rb').read().decode('utf-8'))

if "Addresses" in data and "Addresses" in processFields:
addresses = data["Addresses"]
for index in range(len(addresses) - 1):
show_progress("Addresses", index, len(addresses))
start = get_addr(addresses[index])
end = get_addr(addresses[index + 1])
make_function(start, end)

if "ScriptMethod" in data and "ScriptMethod" in processFields:
scriptMethods = data["ScriptMethod"]
for scriptMethod in scriptMethods:
for (index, scriptMethod) in enumerate(scriptMethods):
show_progress("ScriptMethod", index, len(scriptMethods))
addr = get_addr(scriptMethod["Address"])
name = scriptMethod["Name"]
set_name(addr, name)

if "ScriptString" in data and "ScriptString" in processFields:
index = 1
scriptStrings = data["ScriptString"]
for scriptString in scriptStrings:
for (index, scriptString) in enumerate(scriptStrings):
show_progress("ScriptString", index, len(scriptStrings))
addr = get_addr(scriptString["Address"])
value = scriptString["Value"]
name = "StringLiteral_" + str(index)
Expand All @@ -58,15 +66,17 @@ def make_function(start, end):

if "ScriptMetadata" in data and "ScriptMetadata" in processFields:
scriptMetadatas = data["ScriptMetadata"]
for scriptMetadata in scriptMetadatas:
for (index, scriptMetadata) in enumerate(scriptMetadatas):
show_progress("ScriptMetadata", index, len(scriptMetadatas))
addr = get_addr(scriptMetadata["Address"])
name = scriptMetadata["Name"]
set_name(addr, name)
idc.set_cmt(addr, name, 1)

if "ScriptMetadataMethod" in data and "ScriptMetadataMethod" in processFields:
scriptMetadataMethods = data["ScriptMetadataMethod"]
for scriptMetadataMethod in scriptMetadataMethods:
for (index, scriptMetadataMethod) in enumerate(scriptMetadataMethods):
show_progress("ScriptMetadataMethod", index, len(scriptMetadataMethods))
addr = get_addr(scriptMetadataMethod["Address"])
name = scriptMetadataMethod["Name"]
methodAddr = get_addr(scriptMetadataMethod["MethodAddress"])
Expand Down
18 changes: 14 additions & 4 deletions Il2CppDumper/ida_with_struct_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def make_function(start, end):
ida_funcs.del_func(start)
ida_funcs.add_func(start, end)

def show_progress(field, current, total):
if current % 100 == 0:
msg = f"Processing {field} {current}/{total} {current * 100 / total:.2f}%"
idaapi.replace_wait_box(msg)

path = idaapi.ask_file(False, '*.json', 'script.json from Il2cppdumper')
hpath = idaapi.ask_file(False, '*.h', 'il2cpp.h from Il2cppdumper')
parse_decls(open(hpath, 'r').read(), 0)
Expand All @@ -36,13 +41,15 @@ def make_function(start, end):
if "Addresses" in data and "Addresses" in processFields:
addresses = data["Addresses"]
for index in range(len(addresses) - 1):
show_progress("Addresses", index, len(addresses))
start = get_addr(addresses[index])
end = get_addr(addresses[index + 1])
make_function(start, end)

if "ScriptMethod" in data and "ScriptMethod" in processFields:
scriptMethods = data["ScriptMethod"]
for scriptMethod in scriptMethods:
for (index, scriptMethod) in enumerate(scriptMethods):
show_progress("ScriptMethod", index, len(scriptMethods))
addr = get_addr(scriptMethod["Address"])
name = scriptMethod["Name"]
set_name(addr, name)
Expand All @@ -53,7 +60,8 @@ def make_function(start, end):
if "ScriptString" in data and "ScriptString" in processFields:
index = 1
scriptStrings = data["ScriptString"]
for scriptString in scriptStrings:
for (index, scriptString) in enumerate(scriptStrings):
show_progress("ScriptString", index, len(scriptStrings))
addr = get_addr(scriptString["Address"])
value = scriptString["Value"]
name = "StringLiteral_" + str(index)
Expand All @@ -63,7 +71,8 @@ def make_function(start, end):

if "ScriptMetadata" in data and "ScriptMetadata" in processFields:
scriptMetadatas = data["ScriptMetadata"]
for scriptMetadata in scriptMetadatas:
for (index, scriptMetadata) in enumerate(scriptMetadatas):
show_progress("ScriptMetadata", index, len(scriptMetadatas))
addr = get_addr(scriptMetadata["Address"])
name = scriptMetadata["Name"]
set_name(addr, name)
Expand All @@ -75,7 +84,8 @@ def make_function(start, end):

if "ScriptMetadataMethod" in data and "ScriptMetadataMethod" in processFields:
scriptMetadataMethods = data["ScriptMetadataMethod"]
for scriptMetadataMethod in scriptMetadataMethods:
for (index, scriptMetadataMethod) in enumerate(scriptMetadataMethods):
show_progress("ScriptMetadataMethod", index, len(scriptMetadataMethods))
addr = get_addr(scriptMetadataMethod["Address"])
name = scriptMetadataMethod["Name"]
methodAddr = get_addr(scriptMetadataMethod["MethodAddress"])
Expand Down