mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
dbc6a80e39
commit
72e5278e61
|
@ -275,6 +275,11 @@ begin
|
||||||
if (a>b) then Result:=a else Result:=b;
|
if (a>b) then Result:=a else Result:=b;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function Max(a,b:QWORD):QWORD; inline;
|
||||||
|
begin
|
||||||
|
if (a>b) then Result:=a else Result:=b;
|
||||||
|
end;
|
||||||
|
|
||||||
function Min(a,b:QWORD):QWORD; inline;
|
function Min(a,b:QWORD):QWORD; inline;
|
||||||
begin
|
begin
|
||||||
if (a<b) then Result:=a else Result:=b;
|
if (a<b) then Result:=a else Result:=b;
|
||||||
|
@ -637,6 +642,8 @@ var
|
||||||
key:TVirtualAdrNode;
|
key:TVirtualAdrNode;
|
||||||
Offset:Pointer;
|
Offset:Pointer;
|
||||||
|
|
||||||
|
galign:QWORD;
|
||||||
|
|
||||||
err:Integer;
|
err:Integer;
|
||||||
|
|
||||||
_qaddr:Pointer;
|
_qaddr:Pointer;
|
||||||
|
@ -649,6 +656,8 @@ label
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
|
|
||||||
|
galign:=Max(Align,GRANULAR_PAGE_SIZE);
|
||||||
|
|
||||||
_qaddr:=nil;
|
_qaddr:=nil;
|
||||||
_qsize:=0;
|
_qsize:=0;
|
||||||
_qflag:=0;
|
_qflag:=0;
|
||||||
|
@ -665,7 +674,15 @@ begin
|
||||||
key:=It.Item^;
|
key:=It.Item^;
|
||||||
if (key.F.mapped=0) then
|
if (key.F.mapped=0) then
|
||||||
begin
|
begin
|
||||||
Offset:=AlignUp(Max(key.Offset,ss),Align);
|
|
||||||
|
if (key.block=nil) then
|
||||||
|
begin
|
||||||
|
Offset:=AlignUp(Max(key.Offset,ss),galign);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Offset:=AlignUp(Max(key.Offset,ss),Align);
|
||||||
|
end;
|
||||||
|
|
||||||
if (Offset+Size)<=(key.Offset+key.Size) then
|
if (Offset+Size)<=(key.Offset+key.Size) then
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
@ -1134,7 +1151,7 @@ begin
|
||||||
if (Size=0) then Exit(EINVAL);
|
if (Size=0) then Exit(EINVAL);
|
||||||
if (Offset>Fhi) then Exit(EINVAL);
|
if (Offset>Fhi) then Exit(EINVAL);
|
||||||
|
|
||||||
if (Align<PHYSICAL_PAGE_SIZE) then Align:=PHYSICAL_PAGE_SIZE;
|
Align:=Max(Align,PHYSICAL_PAGE_SIZE);
|
||||||
|
|
||||||
ASize:=AlignUp(Size,PHYSICAL_PAGE_SIZE);
|
ASize:=AlignUp(Size,PHYSICAL_PAGE_SIZE);
|
||||||
|
|
||||||
|
@ -1145,9 +1162,9 @@ begin
|
||||||
begin
|
begin
|
||||||
Offset:=Max(Offset,Flo);
|
Offset:=Max(Offset,Flo);
|
||||||
|
|
||||||
if (_mapped<>0) or (Size>=GRANULAR_PAGE_SIZE) then
|
if (_mapped<>0) then
|
||||||
begin
|
begin
|
||||||
if (Align<GRANULAR_PAGE_SIZE) then Align:=GRANULAR_PAGE_SIZE;
|
Align:=Max(Align,GRANULAR_PAGE_SIZE);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result:=_FindFreeOffset(Offset,ASize,Align,Offset);
|
Result:=_FindFreeOffset(Offset,ASize,Align,Offset);
|
||||||
|
|
|
@ -1132,6 +1132,7 @@ begin
|
||||||
lib:=Result._add_lib('libkernel_unity');
|
lib:=Result._add_lib('libkernel_unity');
|
||||||
|
|
||||||
lib^.set_proc($5A4C0477737BC346,@ps4_sceKernelInstallExceptionHandler);
|
lib^.set_proc($5A4C0477737BC346,@ps4_sceKernelInstallExceptionHandler);
|
||||||
|
lib^.set_proc($421BF90110283847,@ps4_sceKernelRemoveExceptionHandler);
|
||||||
lib^.set_proc($8A5D379E5B8A7CC9,@ps4_sceKernelRaiseException);
|
lib^.set_proc($8A5D379E5B8A7CC9,@ps4_sceKernelRaiseException);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,6 +18,7 @@ type
|
||||||
TsceKernelExceptionHandler=procedure(signum:Integer;context:Pointer); SysV_ABI_CDecl;
|
TsceKernelExceptionHandler=procedure(signum:Integer;context:Pointer); SysV_ABI_CDecl;
|
||||||
|
|
||||||
function ps4_sceKernelInstallExceptionHandler(signum:Integer;callback:TsceKernelExceptionHandler):Integer; SysV_ABI_CDecl;
|
function ps4_sceKernelInstallExceptionHandler(signum:Integer;callback:TsceKernelExceptionHandler):Integer; SysV_ABI_CDecl;
|
||||||
|
function ps4_sceKernelRemoveExceptionHandler(signum:Integer):Integer; SysV_ABI_CDecl;
|
||||||
function ps4_sceKernelRaiseException(_pthread:Pointer;sig:Integer):Integer; SysV_ABI_CDecl;
|
function ps4_sceKernelRaiseException(_pthread:Pointer;sig:Integer):Integer; SysV_ABI_CDecl;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
@ -126,6 +127,26 @@ begin
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ps4_sceKernelRemoveExceptionHandler(signum:Integer):Integer; SysV_ABI_CDecl;
|
||||||
|
var
|
||||||
|
act:sigaction_t;
|
||||||
|
begin
|
||||||
|
if not _SIG_VALID_32(signum) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||||
|
|
||||||
|
if CAS(Pointer(EX_HANDLERS[_SIG_IDX(signum)]),EX_HANDLERS[_SIG_IDX(signum)],nil) then
|
||||||
|
begin
|
||||||
|
|
||||||
|
act:=Default(sigaction_t);
|
||||||
|
act.sa_flags:=SA_RESETHAND;
|
||||||
|
|
||||||
|
Result:=px2sce(__sigaction(signum,@act,nil));
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
Result:=SCE_KERNEL_ERROR_EAGAIN;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
function ps4_sceKernelRaiseException(_pthread:Pointer;sig:Integer):Integer; SysV_ABI_CDecl;
|
function ps4_sceKernelRaiseException(_pthread:Pointer;sig:Integer):Integer; SysV_ABI_CDecl;
|
||||||
begin
|
begin
|
||||||
Result:=EINVAL;
|
Result:=EINVAL;
|
||||||
|
|
37
ps4_elf.pas
37
ps4_elf.pas
|
@ -2209,6 +2209,19 @@ end;
|
||||||
// 0 1 2 3 4 5 6 7 8
|
// 0 1 2 3 4 5 6 7 8
|
||||||
//[64] [48] [8b] [04] 25 [00 00 00 00] :0x0
|
//[64] [48] [8b] [04] 25 [00 00 00 00] :0x0
|
||||||
|
|
||||||
|
|
||||||
|
//MOV RAX,qword ptr FS:[0x0]
|
||||||
|
|
||||||
|
// 0 1 2
|
||||||
|
//[66] [66] [66]
|
||||||
|
|
||||||
|
// 3 4 5 6 7 8 9 10 11
|
||||||
|
//[64] [48] [8b] [04] 25 [00 00 00 00]
|
||||||
|
|
||||||
|
//[66] [66] [66]
|
||||||
|
//64488b042500000000 //data16 data16 data16 mov %fs:0x0,%rax
|
||||||
|
|
||||||
|
|
||||||
// v this adr - base adr
|
// v this adr - base adr
|
||||||
//[e8] [9e be b3 00] relative
|
//[e8] [9e be b3 00] relative
|
||||||
//^ call
|
//^ call
|
||||||
|
@ -2255,11 +2268,17 @@ end;
|
||||||
procedure Telf_file._PatchTls(Proc:Pointer;Addr:PByte;Size:QWORD);
|
procedure Telf_file._PatchTls(Proc:Pointer;Addr:PByte;Size:QWORD);
|
||||||
Const
|
Const
|
||||||
prefix1:DWORD=$048b4864;
|
prefix1:DWORD=$048b4864;
|
||||||
//prefix2:DWORD=$00000025;
|
|
||||||
//prefix3:Byte =$00;
|
prefix2:Byte =$25;
|
||||||
|
prefix3:DWORD=$00000000;
|
||||||
|
|
||||||
//prefix3:DWORD=$05034800;
|
//prefix3:DWORD=$05034800;
|
||||||
|
|
||||||
prefix4:QWORD=$0503480000000025;
|
//prefix4:QWORD=$0503480000000025;
|
||||||
|
|
||||||
|
prefix5:DWORD=$666666;
|
||||||
|
|
||||||
|
prefixm:DWORD=$FFFFFF;
|
||||||
|
|
||||||
var
|
var
|
||||||
Stub:Pointer;
|
Stub:Pointer;
|
||||||
|
@ -2279,6 +2298,15 @@ var
|
||||||
begin
|
begin
|
||||||
_call._ofs:=Integer(PtrInt(Stub)-PtrInt(P)-PtrInt(@Tpatch_fs(nil^).{_pop_rcx}_nop));
|
_call._ofs:=Integer(PtrInt(Stub)-PtrInt(P)-PtrInt(@Tpatch_fs(nil^).{_pop_rcx}_nop));
|
||||||
Ppatch_fs(p)^:=_call;
|
Ppatch_fs(p)^:=_call;
|
||||||
|
|
||||||
|
p:=p-3;
|
||||||
|
if ((PDWORD(p)^ and prefixm)=prefix5) then
|
||||||
|
begin
|
||||||
|
p[0]:=$90; //nop
|
||||||
|
p[1]:=$90; //nop
|
||||||
|
p[2]:=$90; //nop
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure do_find(p:PByte;s:SizeInt);
|
procedure do_find(p:PByte;s:SizeInt);
|
||||||
|
@ -2291,7 +2319,8 @@ var
|
||||||
if (i=-1) then Break;
|
if (i=-1) then Break;
|
||||||
A:=@P[i];
|
A:=@P[i];
|
||||||
|
|
||||||
if (PQWORD(@A[4])^=prefix4) then
|
if (A[4]=prefix2) and (PDWORD(@A[5])^=prefix3) then
|
||||||
|
//if (PQWORD(@A[4])^=prefix4) then
|
||||||
if not _ro_seg_adr_in(A,12) then
|
if not _ro_seg_adr_in(A,12) then
|
||||||
begin
|
begin
|
||||||
Inc(c);
|
Inc(c);
|
||||||
|
|
Loading…
Reference in New Issue