mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
59b4fbd8c5
commit
2e2bf69fa3
|
@ -160,10 +160,13 @@ uses
|
|||
kern_thr,
|
||||
kern_sx,
|
||||
time,
|
||||
elf64,
|
||||
subr_dynlib,
|
||||
kern_authinfo,
|
||||
md_arc4random,
|
||||
kern_proc,
|
||||
md_proc;
|
||||
md_proc,
|
||||
trap;
|
||||
|
||||
var
|
||||
sysctllock :t_sx;
|
||||
|
@ -393,6 +396,71 @@ begin
|
|||
Result:=SYSCTL_OUT(req,@p_proc.p_ptc,SizeOf(Int64));
|
||||
end;
|
||||
|
||||
function _copy_libkernel_addr(req:p_sysctl_req):Integer;
|
||||
var
|
||||
addr_out:array[0..1] of Pointer;
|
||||
begin
|
||||
addr_out[0]:=p_proc.libkernel_start_addr;
|
||||
addr_out[1]:=p_proc.libkernel___end_addr;
|
||||
|
||||
Result:=SYSCTL_OUT(req,@addr_out,SizeOf(addr_out));
|
||||
end;
|
||||
|
||||
function sysctl_kern_text_segment(oidp:p_sysctl_oid;arg1:Pointer;arg2:ptrint;req:p_sysctl_req):Integer;
|
||||
var
|
||||
addr_out:array[0..1] of Pointer;
|
||||
libc_param:TSceLibcParam;
|
||||
sceLibcHeapDebugFlags:Integer;
|
||||
begin
|
||||
Result:=0;
|
||||
|
||||
addr_out[0]:=nil;
|
||||
addr_out[1]:=nil;
|
||||
|
||||
if false then //sceSblACMgrIsShellcoreProces
|
||||
//sceSblACMgrIsSystemUcred && sceRegMgrSrvGetQAFforReg && sceRegMgrGetInt(sys_heap_trace)
|
||||
//sceSblACMgrIsWebcoreProcess && sceKernelIsDevelopmentMode
|
||||
//sceRegMgrSrvGetQAFforReg && sceRegMgrGetInt(game_heap_trace)
|
||||
//sceKernelIsDevelopmentMode && sceKernelIsAssistMode && sceRegMgrGetInt(game_intmem_dbg)
|
||||
begin
|
||||
Exit(_copy_libkernel_addr(req));
|
||||
end;
|
||||
|
||||
Result:=copy_libc_param(@libc_param);
|
||||
|
||||
if (Result=0) then
|
||||
if (libc_param.entry_count>8) then
|
||||
begin
|
||||
|
||||
if (libc_param.SceLibcInternalHeap=1) then
|
||||
begin
|
||||
Result:=copyin(libc_param.sceLibcHeapDebugFlags,@sceLibcHeapDebugFlags,4);
|
||||
if (Result=0) and ((sceLibcHeapDebugFlags and 8)<>0) then
|
||||
begin
|
||||
Exit(_copy_libkernel_addr(req));
|
||||
end else
|
||||
begin
|
||||
Result:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (libc_param.entry_count > 11) and (libc_param.SceLibcInternalHeap=1) then
|
||||
begin
|
||||
Result:=copyin(libc_param.sceKernelInternalMemoryDebugFlags,@sceLibcHeapDebugFlags,4);
|
||||
if (Result=0) and ((sceLibcHeapDebugFlags and 8)<>0) then
|
||||
begin
|
||||
Exit(_copy_libkernel_addr(req));
|
||||
end else
|
||||
begin
|
||||
Result:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
SYSCTL_OUT(req,@addr_out,SizeOf(addr_out));
|
||||
end;
|
||||
|
||||
function sysctl_handle_int(oidp:p_sysctl_oid;arg1:Pointer;arg2:ptrint;req:p_sysctl_req):Integer;
|
||||
var
|
||||
tmpout:Integer;
|
||||
|
@ -488,6 +556,7 @@ begin
|
|||
end;
|
||||
|
||||
else
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled name2oid:',name);
|
||||
Assert(False);
|
||||
Result:=ENOENT;
|
||||
|
@ -523,11 +592,13 @@ begin
|
|||
Result:=ENOENT;
|
||||
|
||||
case name[0] of
|
||||
KERN_PROC_APPINFO :Result:=SYSCTL_HANDLE(noid,name,$C0040001,@sysctl_kern_proc_appinfo);
|
||||
KERN_PROC_SANITIZER:Result:=SYSCTL_HANDLE(noid,name,$80040001,@sysctl_kern_proc_sanitizer);
|
||||
KERN_PROC_PTC :Result:=SYSCTL_HANDLE(noid,name,$90040009,@sysctl_kern_proc_ptc);
|
||||
KERN_PROC_APPINFO :Result:=SYSCTL_HANDLE(noid,name,$C0040001,@sysctl_kern_proc_appinfo);
|
||||
KERN_PROC_SANITIZER :Result:=SYSCTL_HANDLE(noid,name,$80040001,@sysctl_kern_proc_sanitizer);
|
||||
KERN_PROC_PTC :Result:=SYSCTL_HANDLE(noid,name,$90040009,@sysctl_kern_proc_ptc);
|
||||
KERN_PROC_TEXT_SEGMENT:Result:=SYSCTL_HANDLE(noid,name,$80040001,@sysctl_kern_text_segment);
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_kern_proc:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -546,6 +617,7 @@ begin
|
|||
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_kern_smp:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -562,6 +634,7 @@ begin
|
|||
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_kern_sched:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -586,6 +659,7 @@ begin
|
|||
KERN_SCHED :Result:=sysctl_kern_sched(name+1,namelen-1,noid,req);
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_kern:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -602,6 +676,7 @@ begin
|
|||
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_sysctl:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -618,6 +693,7 @@ begin
|
|||
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_hw:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -648,6 +724,7 @@ begin
|
|||
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_machdep:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
@ -669,6 +746,7 @@ begin
|
|||
CTL_MACHDEP:Result:=sysctl_machdep(name+1,namelen-1,noid,req);
|
||||
else
|
||||
begin
|
||||
print_backtrace_td(stderr);
|
||||
Writeln(StdErr,'Unhandled sysctl_root:',name[0]);
|
||||
Assert(False);
|
||||
end;
|
||||
|
|
|
@ -344,6 +344,9 @@ function find_obj_by_name (name:pchar):p_lib_info;
|
|||
|
||||
function dynlib_load_needed_shared_objects():Integer;
|
||||
|
||||
function copy_proc_param(pout:pSceProcParam):Integer;
|
||||
function copy_libc_param(pout:pSceLibcParam):Integer;
|
||||
|
||||
var
|
||||
dynlibs_info:t_dynlibs_info;
|
||||
|
||||
|
@ -3182,6 +3185,62 @@ begin
|
|||
Result:=0;
|
||||
end;
|
||||
|
||||
//
|
||||
|
||||
function copy_proc_param(pout:pSceProcParam):Integer;
|
||||
var
|
||||
proc_param_addr:pSceProcParam;
|
||||
proc_param_size:QWORD;
|
||||
begin
|
||||
proc_param_addr:=dynlibs_info.proc_param_addr;
|
||||
proc_param_size:=dynlibs_info.proc_param_size;
|
||||
|
||||
if (proc_param_addr=nil) then Exit(ENOENT);
|
||||
|
||||
pout^:=Default(TSceProcParam);
|
||||
|
||||
if (proc_param_size>SizeOf(TSceProcParam)) then
|
||||
begin
|
||||
proc_param_size:=SizeOf(TSceProcParam);
|
||||
end;
|
||||
|
||||
Result:=copyin(proc_param_addr,pout,proc_param_size);
|
||||
|
||||
if (Result=0) then
|
||||
begin
|
||||
if (pout^.Magic<>$4942524f) then Result:=ENOEXEC;
|
||||
end;
|
||||
end;
|
||||
|
||||
function copy_libc_param(pout:pSceLibcParam):Integer;
|
||||
var
|
||||
proc_param:TSceProcParam;
|
||||
libc_param_addr:pSceLibcParam;
|
||||
libc_param_size:QWORD;
|
||||
begin
|
||||
Result:=copy_proc_param(@proc_param);
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
if (proc_param.Entry_count=0) or
|
||||
(proc_param.Size <= 63) or
|
||||
(proc_param._sceLibcParam=nil) then
|
||||
begin
|
||||
Exit(ENOEXEC);
|
||||
end;
|
||||
|
||||
libc_param_addr:=proc_param._sceLibcParam;
|
||||
|
||||
Result:=copyin(libc_param_addr,@libc_param_size,8);
|
||||
if (Result<>0) then Exit;
|
||||
|
||||
if (libc_param_size >= 169) then Exit(EINVAL);
|
||||
|
||||
pout^:=Default(TSceLibcParam);
|
||||
|
||||
Result:=copyin(proc_param._sceLibcParam,pout,libc_param_size);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -787,6 +787,10 @@
|
|||
<Filename Value="..\vm\sys_vm_object.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="..\elf64.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
|
|
Loading…
Reference in New Issue