-
Notifications
You must be signed in to change notification settings - Fork 396
Created script for automatically generating function boundaries #98
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
base: main
Are you sure you want to change the base?
Conversation
…ring that, rename file
…nning of the line, this accounts for some weird HTML formatting
|
did you try to run it as an idapython script? cause if so i think you're suppose to run it as a regular python script outside of idapro. you're suppose to take the log from runnning xenonrecomp and put it in a text file and then use idapro to make an html of default.xex and then run python directory/name of xex file directory/name of log file for xenonrecomp output name of file.toml Edit: i was correct, it worked for the most part, it only missed 2 function boundaries for destroy all humans path of the furon which was easy for me to find 1 of, the others been a bit wonky so i wasnt surprised it couldnt find it. |
|
I got hit by these error when I'm trying to run it |
I didn't test the script in Windows, can you try replacing every instance of \. with . and see if that works? EDIT: I think your issue might be related to this, https://stackoverflow.com/questions/52335970/how-to-fix-syntaxwarning-invalid-escape-sequence-in-python I tested my script with Python 3.11, try using an older version of Python without changing the script. EDIT2: I pushed an update of the script tested to work with Python 3.12, let me know if this worked |
That did a trick, runs without errors now |
|
Edit 1: was using an older version of the parser script without noticing, Current version from 11 hours ago as of me typing this seems to be working, though I'm currently waiting for this to be done with the html file since that for whatever reason is 1gb in size. Edit 2: For whatever reason it came out as this. I honestly don't know why it didn't even find the needed functions given they were pretty much in the IDA HTML, especially with them also being listed in the XenonRecomp log. Tried doing this with the Open Season Video Game as an example, I'm stuck on this error with it pointing to line 122 in the error. |
compare_xref_addr isn't a function in the newest version of the script, nor is it referred to on line 122. Try deleting your version and downloading it from https://raw.githubusercontent.com/hedge-dev/XenonRecomp/8fc280bed99903d7bfaf1003e18cfec0c627141d/Auto_Function_Parser.py |
|
Would it be possible to integrate your detection here to XenonAnalyse in some way? |
Tried this, but had the same result. Though I did update to a different fork of XenonRecomp to try and deal with other issues, though not much had changed tbh. This is the result as before.
The fork is from this #22 |
Yeah... although parsing IDA output is a bit easier than plain decompilation though because most subroutine headers will tell you what references it rather than having to look through every line for references and saving it. I went through the path of least resistance so I could quickly churn this out (hence using Python)
I used this script with Ninja Gaiden 2 using a combination of the simde, Bakugan, and NG2 forks and it found 155 functions, so I don't think that's the issue. Are you using IDA Pro 9.0SP1 to create the HTML? If so, can you try adding "print(switch_addrs)" to line 49 and "print(functs)" to line 203 to see if either of those lists are empty? |
i feel a lot of peoples issues are an expectation for using idapro 9.0 sp1 which most people arent aware of how to get without paying an absurd amount for it |
Yes, I do realize the issue with that, but on the other hand, I don't think anyone can make substantial progress on a recomp port if they don't have it. |
or at least not in a short time. i wonder if it can work with ghidra |
|
The only IDAPro 9.0 I have is a leaked build from August 2024, though it should be working relatively the same, so I don't know what's going on here tbh. I can try to work on this a little further if I can. |
Ghidra has the big problem that it lacks a lot of the special instructions used on the Xenon processor, making reverse engineering very difficult. |
This is fair. I wish it had a better plugin for xex files like idapro does |
|
Sorry,could you clarify what the CLI output file is that you are refering to. |
In a Linux terminal when you run XenonRecomp, append " > out.txt" to the command so it outputs all the stuff it would print to the terminal to a file instead |
|
Ok, so this script won't work in windows?
…On Thu 3 Apr 2025, 17:50 Jillian To, ***@***.***> wrote:
Sorry,could you clarify what the CLI output file is that you are refering
to.
In a Linux terminal when you run XenonRecomp, append " > out.txt" to the
command so it outputs all the stuff it would print to the terminal to a
file instead
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMKBGYH2C6C6IOY2MQD2XVRGNAVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZWGQYDANZWG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: JillianTo]*JillianTo* left a comment (hedge-dev/XenonRecomp#98)
<#98 (comment)>
Sorry,could you clarify what the CLI output file is that you are refering
to.
In a Linux terminal when you run XenonRecomp, append " > out.txt" to the
command so it outputs all the stuff it would print to the terminal to a
file instead
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMKBGYH2C6C6IOY2MQD2XVRGNAVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZWGQYDANZWG4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
the tool managed to find 50% of the functions that xenonrecomp considers to be wrong, but for some reason it couldn't find the others, and when I run the tool again this time using the new log with the rest of the missing functions it gives me half of the ones that that had already been found before |
You can try copy pasting the output of XenonRecomp from the Windows prompt into a text file but I haven't verified that
That's because the leftover 50% are functions nested in the ones found by the script, and the script doesn't handle that |
|
What should Xenon recomp be outputting?
…On Fri 4 Apr 2025, 00:22 Jillian To, ***@***.***> wrote:
Ok, so this script won't work in windows?
You can try copy pasting the output of XenonRecomp from the Windows prompt
into a text file but I haven't verified that
the tool managed to find 50% of the functions that xenonrecomp considers
to be wrong, but for some reason it couldn't find the others, and when I
run the tool again this time using the new log with the rest of the missing
functions it gives me half of the ones that that had already been found
before
That's because the leftover 50% are functions nested in the ones found by
the script, and the script doesn't handle that
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMPQGEGHQISERUYHYWT2XW7E3AVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZXGE4TMOJQGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: JillianTo]*JillianTo* left a comment (hedge-dev/XenonRecomp#98)
<#98 (comment)>
Ok, so this script won't work in windows?
You can try copy pasting the output of XenonRecomp from the Windows prompt
into a text file but I haven't verified that
the tool managed to find 50% of the functions that xenonrecomp considers
to be wrong, but for some reason it couldn't find the others, and when I
run the tool again this time using the new log with the rest of the missing
functions it gives me half of the ones that that had already been found
before
That's because the leftover 50% are functions nested in the ones found by
the script, and the script doesn't handle that
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMPQGEGHQISERUYHYWT2XW7E3AVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZXGE4TMOJQGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
When you look at the command window it should just say what percentage has been recompiled, if it says that an address is going out of bounds from another address or something it means you need to add function boundaries to your config (what this script should do) if it says it found a jump table at an address but the switch table file you made with xenonanalyse doesn't exist it means you need to go to that address and find it's jump table. And if it says something about an unrecognized instruction you have to edit recompiler.cpp and add those instructions with the right c++ code and rebuild xenonrecomp |
|
Ok, I'm not getting any of that when run the recomp. I also only get part
of the jump table, it won't give me any computed or offset values. I have
changed the instructions in main.cpp but it doesn't detect anything else.
There are some instructions present that aren't in unleashed recompiled.
Does something else need to be done to make them work? The instructions are
subi and ori.
…On Fri 4 Apr 2025, 01:21 MadLadMikael, ***@***.***> wrote:
What should Xenon recomp be outputting?
When you look at the command window it should just say what percentage has
been recompiled, if it says that an address is going out of bounds from
another address or something it means you need to add function boundaries
to your config (what this script should do) if it says it found a jump
table at an address but the switch table file you made with xenonanalyse
doesn't exist it means you need to go to that address and find it's jump
table. And if it says something about an unrecognized instruction you have
to edit recompiler.cpp and add those instructions with the right c++ code
and rebuild xenonrecomp
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMNQSHHI5OJLYO3ZBXD2XXGBHAVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZXGI3DCOJVGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: masterspike52]*masterspike52* left a comment
(hedge-dev/XenonRecomp#98)
<#98 (comment)>
What should Xenon recomp be outputting?
When you look at the command window it should just say what percentage has
been recompiled, if it says that an address is going out of bounds from
another address or something it means you need to add function boundaries
to your config (what this script should do) if it says it found a jump
table at an address but the switch table file you made with xenonanalyse
doesn't exist it means you need to go to that address and find it's jump
table. And if it says something about an unrecognized instruction you have
to edit recompiler.cpp and add those instructions with the right c++ code
and rebuild xenonrecomp
—
Reply to this email directly, view it on GitHub
<#98 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BEIJWMNQSHHI5OJLYO3ZBXD2XXGBHAVCNFSM6AAAAABYUY5F4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONZXGI3DCOJVGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
I think Im nearly there, but Im getting this error. How can I fix it? |
|
Tested TGM ACE TU1 with IDA Pro 9.1, ran without issue and found 41/42 functions. Script output: Missed function: |
|
Hi, after parsing the .html i've got 0 functions on my log. Only: "functions = ]" |

Using the decompiled code exported from IDA as a HTML and the switch addresses that cause errors when using XenonRecomp (I deleted every line in SWA.toml after 'setjmp_address', (although I had to keep the invalid address block, else XenonRecomp wouldn't run), then ran XenonRecomp and saved the CLI output to a file), I wrote a script that reproduces 39/42 of the function boundaries in UnleashedRecomp. Below is the output of the script:
I verified these functions were correct using sort and diff in the Linux terminal. The only difference is the order, and that it is missing the following three functions: