Updated loadexec imported & exported function names, and addresses

Added an utility to generate a diff file of different versions of a PRX
This commit is contained in:
artart78 2011-11-02 17:07:33 +00:00
parent 9f83f83125
commit 41d619e4c6
5 changed files with 1646 additions and 1551 deletions

View File

@ -175,6 +175,7 @@ SET_REG(K1, _k1)
#define UUNCACHED(ptr) (void*)(0x40000000 | ((u32)(void*)(ptr) & 0x1FFFFFFF))
#define RESET_VECTOR(info, outAddr, func) \
{
if (*(int*)(info + 4) > 0x2000000) \
AT_SW((*(int*)(0xBC100040) & 0xFFFFFFFC) | 2, 0xBC100040); \
else \
@ -183,7 +184,8 @@ memset(0xBFC00000, 0, 0x1000); \
memcpy(0xBFC00000, &func, &func + sizeof(func)); \
*(int*)outAddr = 0xBFC00000; \
int (*_resetVector)(int, int) = 0xBFC00000; \
_resetVector(*(int*)(info + 0), *(int*)(info + 4));
_resetVector(*(int*)(info + 0), *(int*)(info + 4)); \
}
#endif

View File

@ -1,3 +1,8 @@
#include "../global.h"
#include "interruptman.h"
#include <pspmoduleinfo.h>
extern int sub_0038();
extern int sub_091C();
extern int sub_0A74();
@ -11,11 +16,6 @@ extern int sub_3160();
void *my_memset(void *dst, char c, int n);
void sub_2A40(int intrNum);
#include "../global.h"
#include "interruptman.h"
#include <pspmoduleinfo.h>
extern int sub_0CC0();
extern int sub_0864();
extern int sub_0ECC();

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +0,0 @@
int KDebugForKernel_61B6A1CE(void);
typedef struct
{
int size;
int opt1;
int opt2;
char *typeName; /* vsh, umdemu.. */
int opt4;
int opt5;
int opt6;
int opt7;
int loadPspbtcnf; // Always set to 0x10000
int opt9;
int opt10;
int opt11;
} RebootArgs2;
typedef struct
{
int opt0;
int opt1;
char *fileName;
RebootArgs2 *args2;
int opt4;
void *opt5;
int opt6;
int opt7;
} RebootArgs;
int func_282C(RebootArgs2 *arg);
int LoadExecForKernel_0DBC783B(int arg0, int arg1);
int LoadExecForKernel_3D805DE6(int arg0, int arg1);
int LoadExecForKernel_4A9446E7(int arg0, int arg1);
int LoadExecForKernel_5AA1A6D2(RebootArgs2 *opt);
int LoadExecForKernel_6C00E642(int arg0, int arg1);
int LoadExecForKernel_7A206082(int arg0, int arg1);
int LoadExecForKernel_7C0ADE1F();
int LoadExecForKernel_8CE2AB36();
int LoadExecForKernel_8EF38192(int arg0, int arg1);
int LoadExecForKernel_9D39758A();
int LoadExecForKernel_10E94E41(int arg0, int arg1);
int LoadExecForKernel_45C6125B(int arg0, int arg1);
int LoadExecForKernel_59A2F67F(int arg0, int arg1);
int LoadExecForKernel_106ABDB8(int arg0, int arg1, int arg2);
int LoadExecForKernel_179D905A(int arg0, int arg1);
int LoadExecForKernel_778E333F(int arg0, int arg1);
int LoadExecForKernel_818E14A4(int arg0, int arg1, int arg2);
int LoadExecForKernel_905FDDB6(int arg0, int arg1, int arg2);
int LoadExecForKernel_2752CD13(int arg0, int arg1);
int LoadExecForKernel_7286CF0B(int arg0, int arg1);
int LoadExecForKernel_9212E475(int arg0, int arg1);
int LoadExecForKernel_9828D1D9(int arg0, int arg1);
int LoadExecForKernel_54303E86(RebootArgs2 *opt, int arg1);
int LoadExecForKernel_78912B54(int arg0, int arg1);
int LoadExecForKernel_BAEB4B89(int arg0, int arg1);
int LoadExecForKernel_C42F65FA(int arg0, int arg1);
int LoadExecForKernel_CA86DDD9(int arg0, int arg1);
int LoadExecForKernel_CEFE1100(int arg0, int arg1);
int LoadExecForKernel_D35D6403(int arg0, int arg1);
int LoadExecForKernel_DDED4433(int arg0, int arg1);
int LoadExecForKernel_DEA6A7FC(int arg0, int arg1);
int LoadExecForUser_4AC57943(int arg);
int LoadExecForKernel_E35220AC(int arg0, int arg1, int arg2);
SceUID LoadExecForKernel_EF9C9627();
int LoadExecForKernel_FCD765C9(RebootArgs2 *arg);
int LoadExecForKernel_FE8E1A30(int arg0, int arg1, int arg2);
int LoadExecForUser_2AC9954B();
int LoadExecForKernel_E9B45481(int arg);
int LoadExecForUser_8ADA38D3(char *fileName, int arg1);
int LoadExecForUser_362A956B();
int LoadExecForUser_05572A5F();
int LoadExecForUser_BD2F1094(char *arg0, int arg1);
int module_bootstart();
void decodeKL4E(char *dst, int size, char *src, int arg3);
void sub_0BBC(int *arg0);
void sub_2A4C(RebootArgs *opt);
void sub_09D8(int *struct1, int *struct2);
int runExec(RebootArgs *args); // 20E4
int sub_21C8(char *name, int devcmd, int iocmd);
int sub_22F0(RebootArgs2 *opt);
void sub_32E4();
int sub_236C(int arg0, int arg1, int arg2, int arg3);
int runExecFromThread(int unk, RebootArgs *opt); // 284C
void sub_298C(int *dst, int arg1, int *src);
int sub_2568(int arg0, int arg1, int arg2, int arg3, int arg4);
int sub_2698(int arg0, RebootArgs2 *opt);
int LoadExecForUser_D1FB50DC(int arg);

195
utils/diff.sh Executable file
View File

@ -0,0 +1,195 @@
#!/bin/sh
###
# This program generates a diff file from different PRX versions, comparing functions with each other.
# It's very slow, especially for big modules (it can take up to an hour for huge modules, probably)
# It creates a lot of files in the <PRX file>-diff directory. The most useful created file is "mod.diff", it contains all the differences, including the ones from data.
####
# Generates a list of functions
function genlist
{
local file=$1
local i=1
for f in `cat $file|grep "; Subroutine"|sed -e "s/.*outine //" -e "s/ .*//"`; do
echo $i $f
i=$(( $i + 1 ))
done
}
# Add two matching functions (from old & new PRX) in the matching list
function match
{
list1=`echo "$list1"|grep -v "^$1 "`
list2=`echo "$list2"|grep -v "^$2 "`
matchlist[$1]=$2
echo "$1 <=> $2"
}
# Get a function content
function getfunc
{
file=$1
func=$2
start=`cat -n $file|grep "Subroutine.*$func"|sed -e "s/^[^0-9]*//" -e "s/[^0-9].*//"`
start=`expr $start + 3`
content=`cat $file|sed -n -e "$start,/; ====/p"`
echo "$content"|head -n $(( `echo "$content"|wc -l` - 2 ))|sed -e "s/; Refs.*//" -e "s/loc_......../loc/" -e "s/Subroutine sub_......../Subroutine sub/" -e "s/0x........: //" -e "s/Address.*//" -e "s/Data ref.*/Data ref/"
}
# Get data sections from a PRX file
function getdata
{
startaddr=`cat $1|grep ".rodata"|sed -e "s/.*Address //" -e "s/ .*//"`
startaddr=`printf "%d\n" $startaddr`
for i in `cat $1|sed -n -e "5,$ p"|sed -n -e "/Section/,$ p"|grep "^0x........ "|sed -e "s/ - ................$//" -e "s/ - /_/" -e "s/ | /|/g" -e "s/ /,/g"`; do
addr=`echo $i|sed -e "s/_.*//"`
intv=`printf "%d\n" $addr`
offset=`expr $intv - $startaddr`
offset=`printf "0x%08X\n" $offset`
echo $i|sed -e "s/^0x........_/$offset /" -e "s/,/ /g" -e "s/|/ | /g"
done
}
if [ $# -ne 2 ]; then
echo "Usage: ./diff.sh <old> <new>"
fi
echo "diff $1 $2"
prxtmp1="re1"
prxtmp2="re2"
difftmp1="diff1"
difftmp2="diff2"
difftmp="diff"
dir=`echo $1|sed -e "s/.*\///"`
dir="$dir-diff"
if [ ! -e $dir ]; then
mkdir $dir
fi
cd $dir
if [ ! -f $prxtmp1 ]; then
prxtool -w ../$1 > $prxtmp1
fi
if [ ! -f $prxtmp2 ]; then
prxtool -w ../$2 > $prxtmp2
fi
list1=`genlist $prxtmp1`
numlist1=`echo "$list1"|wc -l`
list2=`genlist $prxtmp2`
numlist2=`echo "$list2"|wc -l`
list1back=$list1
list2back=$list2
echo "list 1:"
echo "$list1"
echo "list 2"
echo "$list2"
# regroup functions by name
for num1 in `seq $numlist1`; do
name=`echo "$list1"|grep "^$num1 "|sed -e "s/[^ ]* //"`
num2=`echo "$list2"|grep "$name"|sed -e "s/ .*//"`
if [ -n "$num2" ]; then
match $num1 $num2
fi
done
# put each function in a file
a1=`echo func-1-*`
a2=`echo func-2-*`
if [ "$a1" = "func-1-*" ] || [ "$a2" = "func-2-*" ]; then
for name in `echo "$list1back"|sed -e "s/.* //"`; do
num=`echo "$list1back"|grep $name|sed -e "s/ .*//"`
getfunc $prxtmp1 $name > "func-1-$num"
done
for name in `echo "$list2back"|sed -e "s/.* //"`; do
num=`echo "$list2back"|grep $name|sed -e "s/ .*//"`
getfunc $prxtmp2 $name > "func-2-$num"
done
fi
# put each diff in a file
a=`echo diff-*`
if [ "$a" = "diff-*" ]; then
for f1 in func-1-*; do
for f2 in func-2-*; do
diff $f1 $f2 > diff-`echo $f1|sed -e "s/func-1-//"`-`echo $f2|sed -e "s/func-2-//"`
done
done
fi
# regroup functions by number of differences
for l1 in `echo "$list1"|sed -e "s/ .*//"`; do
min=9999999
found=0
for l2 in `echo "$list2"|sed -e "s/ .*//"`; do
numdiff=`wc -l diff-$l1-$l2|sed -e "s/ .*//"`
numl1=`wc -l func-1-$l1|sed -e "s/ .*//"`
numl2=`wc -l func-2-$l2|sed -e "s/ .*//"`
if [ $numdiff -lt `expr \( $numl1 + $numl2 \) \* 9 / 10` ] && [ $numdiff -lt $min ]; then
min=$numdiff
min2=$l2
found=1
fi
done
if [ $found -eq 1 ]; then
match $l1 $min2
fi
done
# generate mod.diff
rm -f mod.diff
touch mod.diff
for num1 in `seq $numlist1`; do
num2=${matchlist[$num1]}
if [ ! "$num2" = "" ]; then
name1=`echo "$list1back"|grep "^$num1 "|sed -e "s/.* //"`
name2=`echo "$list2back"|grep "^$num2 "|sed -e "s/.* //"`
echo "$name1 <=> $name2"
if [ "$name1" = "$name2" ]; then
if [ `cat diff-$num1-$num2|wc -l` -ne 0 ]; then
echo "; ================================" >> mod.diff
echo "; $name1" >> mod.diff
fi
else
echo "; ================================" >> mod.diff
echo "; $name1 renamed to $name2" >> mod.diff
fi
cat diff-$num1-$num2 >> mod.diff
fi
done
for removed in `echo "$list1"|sed -e "s/ .*//"`; do
echo "; ================================" >> mod.diff
name1=`echo "$list1back"|grep "^$removed "|sed -e "s/.* //"`
echo "; $name1 has been removed" >> mod.diff
done
for added in `echo "$list2"|sed -e "s/ .*//"`; do
echo "; ================================" >> mod.diff
name2=`echo "$list2back"|grep "^$added "|sed -e "s/.* //"`
echo "; $name2 has been added" >> mod.diff
cat func-2-$added >> mod.diff
done
# diff data
echo "; ================================" >> mod.diff
echo "; data" >> mod.diff
getdata $prxtmp1 > data1
getdata $prxtmp2 > data2
diff data1 data2 >> mod.diff
cd ..