-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
functionManager = currentProgram.getFunctionManager() | ||
baseAddress = currentProgram.getImageBase() | ||
USER_DEFINED = ghidra.program.model.symbol.SourceType.USER_DEFINED | ||
|
||
def get_addr(addr): | ||
return baseAddress.add(addr) | ||
|
||
def set_name(addr, name): | ||
name = name.replace(' ', '-') | ||
createLabel(addr, name, True, USER_DEFINED) | ||
|
||
def make_function(start): | ||
func = getFunctionAt(start) | ||
if func is None: | ||
createFunction(start, None) | ||
|
||
f = askFile("script.json from UE4Dumper", "Open") | ||
json_data = json.loads(open(f.absolutePath, 'rb').read().decode('utf-8')) | ||
|
||
monitor.initialize(len(json_data['Functions'])) | ||
monitor.setMessage("Methods") | ||
for func_entry in json_data['Functions']: | ||
addr = get_addr(func_entry["Address"]) | ||
name = func_entry["Name"].encode("utf-8") | ||
set_name(addr, name) | ||
monitor.incrementProgress(1) | ||
|
||
print('Script finished!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
imageBase = idaapi.get_imagebase() | ||
|
||
def get_addr(addr): | ||
return imageBase + addr | ||
|
||
def set_name(addr, name): | ||
ret = idc.set_name(addr, name, SN_NOWARN | SN_NOCHECK) | ||
if ret == 0: | ||
new_name = name + '_' + str(addr) | ||
ret = idc.set_name(addr, new_name, SN_NOWARN | SN_NOCHECK) | ||
|
||
def make_function(start, end): | ||
next_func = idc.get_next_func(start) | ||
if next_func < end: | ||
end = next_func | ||
if idc.get_func_attr(start, FUNCATTR_START) == start: | ||
ida_funcs.del_func(start) | ||
ida_funcs.add_func(start, end) | ||
|
||
path = idaapi.ask_file(False, '*.json', 'script.json') | ||
json_data = json.loads(open(path, 'rb').read().decode('utf-8')) | ||
|
||
for func_entry in json_data['Functions']: | ||
addr = get_addr(func_entry["Address"]) | ||
name = func_entry["Name"].encode("utf-8") | ||
set_name(addr, name) | ||
|
||
print('Script finished!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
import json | ||
|
||
imageBase = idaapi.get_imagebase() | ||
|
||
def get_addr(addr): | ||
return imageBase + addr | ||
|
||
def set_name(addr, name): | ||
ret = idc.set_name(addr, name, SN_NOWARN | SN_NOCHECK) | ||
if ret == 0: | ||
new_name = name + '_' + str(addr) | ||
ret = idc.set_name(addr, new_name, SN_NOWARN | SN_NOCHECK) | ||
|
||
def make_function(start, end): | ||
next_func = idc.get_next_func(start) | ||
if next_func < end: | ||
end = next_func | ||
if idc.get_func_attr(start, FUNCATTR_START) == start: | ||
ida_funcs.del_func(start) | ||
ida_funcs.add_func(start, end) | ||
|
||
path = idaapi.ask_file(False, '*.json', 'script.json') | ||
json_data = json.loads(open(path, 'rb').read().decode('utf-8')) | ||
|
||
for func_entry in json_data['Functions']: | ||
addr = get_addr(func_entry["Address"]) | ||
name = func_entry["Name"] | ||
set_name(addr, name) | ||
|
||
print('Script finished!') |