mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
ee590973fc
commit
cc3f7a17bf
|
@ -16,6 +16,9 @@ procedure _thr_stack_free(attr:p_pthread_attr);
|
|||
|
||||
implementation
|
||||
|
||||
uses
|
||||
sys_mmap;
|
||||
|
||||
type
|
||||
//Spare thread stack.
|
||||
p_stack=^t_stack;
|
||||
|
@ -40,12 +43,15 @@ begin
|
|||
Result:=size;
|
||||
end;
|
||||
|
||||
const
|
||||
_rtld_get_stack_prot=PROT_READ or PROT_WRITE;
|
||||
|
||||
procedure _thr_stack_fix_protection(td:p_pthread);
|
||||
begin
|
||||
//mprotect(td^.attr.stackaddr_attr+
|
||||
// round_up(td^.attr.guardsize_attr),
|
||||
// round_up(td^.attr.stacksize_attr),
|
||||
// _rtld_get_stack_prot);
|
||||
mprotect(td^.attr.stackaddr_attr+
|
||||
round_up(td^.attr.guardsize_attr),
|
||||
round_up(td^.attr.stacksize_attr),
|
||||
_rtld_get_stack_prot);
|
||||
end;
|
||||
|
||||
function _thr_stack_alloc(attr:p_pthread_attr):Integer;
|
||||
|
@ -109,28 +115,28 @@ begin
|
|||
|
||||
THREAD_LIST_UNLOCK(curthread);
|
||||
|
||||
//stackaddr:=mmap(stackaddr,
|
||||
// stacksize+guardsize,
|
||||
// _rtld_get_stack_prot,
|
||||
// MAP_STACK,-1,0
|
||||
// );
|
||||
stackaddr:=mmap(stackaddr,
|
||||
stacksize+guardsize,
|
||||
_rtld_get_stack_prot,
|
||||
MAP_STACK,-1,0
|
||||
);
|
||||
|
||||
r:=0;
|
||||
if (stackaddr<>Pointer(-1)) then //MAP_FAILED
|
||||
if (stackaddr<>MAP_FAILED) then
|
||||
begin
|
||||
//r:=mprotect(stackaddr,guardsize,PROT_NONE);
|
||||
r:=mprotect(stackaddr,guardsize,PROT_NONE);
|
||||
end;
|
||||
|
||||
if (stackaddr<>Pointer(-1)) and //MAP_FAILED
|
||||
if (stackaddr<>MAP_FAILED) and
|
||||
((guardsize=0) or (r=0)) then
|
||||
begin
|
||||
//sceKernelSetVirtualRangeName(addr,guardsize,'stack guard');
|
||||
sceKernelSetVirtualRangeName(stackaddr,guardsize,'stack guard');
|
||||
stackaddr:=stackaddr+guardsize;
|
||||
end else
|
||||
begin
|
||||
if (stackaddr<>Pointer(-1)) then //MAP_FAILED
|
||||
if (stackaddr<>MAP_FAILED) then
|
||||
begin
|
||||
//munmap(stackaddr,stacksize+guardsize);
|
||||
munmap(stackaddr,stacksize+guardsize);
|
||||
end;
|
||||
stackaddr:=nil;
|
||||
end;
|
||||
|
|
|
@ -8,9 +8,10 @@ interface
|
|||
{$I sce_errno.inc}
|
||||
{$I errno.inc}
|
||||
|
||||
function px2sce(e:Integer):Integer;
|
||||
function sce2px(e:Integer):Integer;
|
||||
function px2sce(e:Integer):Integer; inline;
|
||||
function sce2px(e:Integer):Integer; inline;
|
||||
|
||||
function _get_errno:Integer; inline;
|
||||
function _set_errno(r:Integer):Integer;
|
||||
function _set_sce_errno(r:Integer):Integer;
|
||||
|
||||
|
@ -19,7 +20,7 @@ implementation
|
|||
uses
|
||||
thr_error;
|
||||
|
||||
function px2sce(e:Integer):Integer;
|
||||
function px2sce(e:Integer):Integer; inline;
|
||||
begin
|
||||
if (e=0) then
|
||||
Result:=0
|
||||
|
@ -27,7 +28,7 @@ begin
|
|||
Result:=e-$7ffe0000;
|
||||
end;
|
||||
|
||||
function sce2px(e:Integer):Integer;
|
||||
function sce2px(e:Integer):Integer; inline;
|
||||
begin
|
||||
if (e=0) then
|
||||
Result:=0
|
||||
|
@ -35,6 +36,11 @@ begin
|
|||
Result:=e+$7ffe0000;
|
||||
end;
|
||||
|
||||
function _get_errno:Integer; inline;
|
||||
begin
|
||||
Result:=__error^;
|
||||
end;
|
||||
|
||||
function _set_errno(r:Integer):Integer;
|
||||
begin
|
||||
Result:=0;
|
||||
|
|
|
@ -91,11 +91,16 @@ function madvise(addr:Pointer;len:QWORD;behav:Integer):Integer;
|
|||
function mname(addr:Pointer;len:QWORD;name:PChar):Integer;
|
||||
function query_memory_protection(addr:Pointer;len:QWORD;info:p_query_memory_prot):Integer;
|
||||
|
||||
//sce
|
||||
|
||||
function sceKernelSetVirtualRangeName(addr:Pointer;len:QWORD;name:PChar):Integer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
trap,
|
||||
thr_error;
|
||||
thr_error,
|
||||
errno;
|
||||
|
||||
function mmap(_addr :Pointer;
|
||||
_len :QWORD;
|
||||
|
@ -144,6 +149,17 @@ asm
|
|||
call cerror
|
||||
end;
|
||||
|
||||
//sce
|
||||
|
||||
function sceKernelSetVirtualRangeName(addr:Pointer;len:QWORD;name:PChar):Integer;
|
||||
begin
|
||||
Result:=mname(addr,len,name);
|
||||
if (Result=-1) then
|
||||
begin
|
||||
Result:=px2sce(_get_errno);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ begin
|
|||
Result:=query_memory_protection(Pointer($700000000),16*1024,@qr);
|
||||
Writeln(Result);
|
||||
|
||||
sceKernelSetVirtualRangeName(Pointer($700000000),16*1024,'test');
|
||||
|
||||
p:=mmap(Pointer($700000000+16*1024),16*1024,PROT_CPU_ALL,MAP_ANON {or MAP_VOID} or MAP_FIXED,-1,0);
|
||||
Writeln(HexStr(p));
|
||||
|
||||
|
|
Loading…
Reference in New Issue