This commit is contained in:
Pavel 2023-12-22 17:05:47 +03:00
parent 63bf83a067
commit 833437a591
8 changed files with 121 additions and 38 deletions

View File

@ -1400,8 +1400,7 @@ begin
Exit(error);
end;
if (fp=nil) then
Exit(error);
if (fp=nil) then Exit(error);
if (fp^.f_ops=@badfileops) then
begin

View File

@ -14,7 +14,7 @@ uses
var
print_asm:Boolean=False;
procedure pick(var ctx:t_jit_context2);
procedure pick(var ctx:t_jit_context2;preload:Pointer);
procedure pick_locked(var ctx:t_jit_context2);
implementation
@ -1012,15 +1012,27 @@ begin
proc.Free;
end;
procedure pick(var ctx:t_jit_context2); [public, alias:'kern_jit_pick'];
procedure pick(var ctx:t_jit_context2;preload:Pointer); [public, alias:'kern_jit_pick'];
var
map:vm_map_t;
node:p_jit_entry_point;
begin
map:=p_proc.p_vmspace;
vm_map_lock(map);
pick_locked(ctx);
if (preload<>nil) then
begin
node:=preload_entry(preload);
if (node<>nil) then
begin
node^.dec_ref;
vm_map_unlock(map);
Exit;
end;
end;
pick_locked(ctx);
vm_map_unlock(map);
end;

View File

@ -154,7 +154,7 @@ uses
//
procedure pick(var ctx:t_jit_context2); external name 'kern_jit_pick';
procedure pick(var ctx:t_jit_context2;preload:Pointer); external name 'kern_jit_pick';
//
@ -214,7 +214,7 @@ begin
ctx.add_forward_point(fpCall,addr);
pick(ctx);
pick(ctx,addr);
end else
begin
node^.dec_ref;

View File

@ -17,7 +17,7 @@ type
p_authinfo=^t_authinfo;
t_authinfo=packed record
app_type :QWORD;
app_caps :array[0..3] of QWORD; //62 bit IsSystemProcess;61 bit IsGameProcess1;60 bit IsGameProcess2;
app_caps :array[0..3] of QWORD; //62 bit IsSystem;61 bit IsGame;60 bit IsNongame;
app_attrs:array[0..3] of QWORD;
unknow :array[0..7] of QWORD;
end;
@ -127,11 +127,17 @@ var
g_authinfo:t_authinfo;
g_appinfo :t_appinfo;
function sceSblACMgrHasMmapSelfCapability(info:p_authinfo):Boolean;
function sceSblACMgrHasUseHp3dPipeCapability(info:p_authinfo):Boolean;
function sceSblACMgrIsVideoplayerProcess(info:p_authinfo):Boolean;
function sceSblACMgrHasUseVideoServiceCapability(info:p_authinfo):Boolean;
function sceSblACMgrIsNongameUcred(info:p_authinfo):Boolean;
function sceSblACMgrIsSystemUcred(info:p_authinfo):Boolean;
function sceSblACMgrHasSceProgramAttribute(info:p_authinfo):Boolean;
function is_sce_prog_attr_080000(info:p_authinfo):Boolean;
function sceSblACMgrIsAllowedToMmapSelf(icurr,ifile:p_authinfo):Boolean;
function is_sce_prog_attr_20_800000(info:p_authinfo):Boolean;
function is_sce_prog_attr_40_800000(info:p_authinfo):Boolean;
function is_sce_prog_attr_40_400000(info:p_authinfo):Boolean;
function sys_get_proc_type_info(dst:Pointer):Integer;
function sys_get_authinfo(pid:Integer;info:Pointer):Integer;
@ -144,6 +150,11 @@ uses
kern_proc,
md_proc;
function sceSblACMgrHasMmapSelfCapability(info:p_authinfo):Boolean;
begin
Result:=(info^.app_caps[1] and $400000000000000)<>0;
end;
function sceSblACMgrHasUseHp3dPipeCapability(info:p_authinfo):Boolean;
var
app_type:QWORD;
@ -163,7 +174,17 @@ end;
function sceSblACMgrHasUseVideoServiceCapability(info:p_authinfo):Boolean;
begin
Result:=((info^.app_caps[1] shr $39) and 1)<>0;
Result:=(info^.app_caps[1] and $200000000000000)<>0;
end;
function sceSblACMgrIsNongameUcred(info:p_authinfo):Boolean;
begin
Result:=(info^.app_caps[0] and $1000000000000000)<>0;
end;
function sceSblACMgrIsSystemUcred(info:p_authinfo):Boolean;
begin
Result:=(info^.app_caps[0] and $4000000000000000)<>0;
end;
function sceSblACMgrHasSceProgramAttribute(info:p_authinfo):Boolean;
@ -183,7 +204,17 @@ begin
Exit(false);
end;
function is_sce_prog_attr_080000(info:p_authinfo):Boolean;
function sceSblACMgrIsAllowedToMmapSelf(icurr,ifile:p_authinfo):Boolean;
begin
Result:=True;
if ((icurr^.app_caps[1] and $400000000000000)=0) or
((ifile^.app_attrs[0] and $8000000)=0) then
begin
Result:=False;
end;
end;
function is_sce_prog_attr_20_800000(info:p_authinfo):Boolean;
begin
Result:=True;
if ((info^.app_caps[1] and $2000000000000000)=0) or
@ -193,6 +224,26 @@ begin
end;
end;
function is_sce_prog_attr_40_800000(info:p_authinfo):Boolean;
begin
Result:=True;
if ((info^.app_caps[1] and $4000000000000000)=0) or
((info^.app_attrs[0] and $800000)=0) then
begin
Result:=False;
end;
end;
function is_sce_prog_attr_40_400000(info:p_authinfo):Boolean;
begin
Result:=True;
if ((info^.app_caps[1] and $4000000000000000)=0) or
((info^.app_attrs[0] and $400000)=0) then
begin
Result:=False;
end;
end;
function sys_get_proc_type_info(dst:Pointer):Integer;
var
info:t_proc_type_info;

View File

@ -128,7 +128,7 @@ var
vmap:vm_map_t;
begin
dobj:=vm_object_allocate(OBJT_PHYSHM,OFF_TO_IDX(SCE_KERNEL_MAIN_DMEM_SIZE));
dobj^.flags:=dobj^.flags or OBJ_DMEM_EXT;
dobj^.flags:=dobj^.flags or OBJ_DMEM_EXT or OBJ_NOSPLIT;
dmem_map_init(@dmem,0,SCE_KERNEL_MAIN_DMEM_SIZE);
rmem_map_init(@rmap,0,SCE_KERNEL_MAIN_DMEM_SIZE);
@ -242,7 +242,7 @@ begin
//
if (not boolean(err)) or //not found
(is_sce_prog_attr_080000(@g_authinfo)) or
(is_sce_prog_attr_20_800000(@g_authinfo)) or
((p_proc.p_dmem_aliasing and 1)<>0) then //aliasing
begin
_rmap_insert:
@ -465,7 +465,7 @@ end;
function get_obj_mtype(obj:vm_map_object):Byte;
begin
Result:=QWORD(obj^.handle);
Result:=QWORD(obj^.un_pager.vnp.vnp_size);
end;
procedure dmem_vmo_get_type(map:vm_map_t;

View File

@ -2796,7 +2796,7 @@ begin
lib_entry:=TAILQ_NEXT(lib_entry,@lib_entry^.link)
end;
kern_jit.pick(ctx);
kern_jit.pick(ctx,nil);
end;
function preload_prx_modules(path:pchar;flags:DWORD;var err:Integer):p_lib_info;

View File

@ -65,26 +65,26 @@ const
KERN_NOT_RECEIVER =7;
KERN_NO_ACCESS =8;
MAP_SHARED =$00001; // share changes
MAP_PRIVATE =$00002; // changes are private
MAP_FIXED =$00010; // map addr must be exactly as requested
MAP_NO_OVERWRITE =$00080; // don't overwrite memory with MAP_FIXED
MAP_VOID =$00100; // reserve addr
MAP_HASSEMAPHORE =$00200; // region may contain semaphores
MAP_STACK =$00400; // region grows down, like a stack
MAP_NOSYNC =$00800; // page to but do not sync underlying file
MAP_FILE =$00000; // map from file (default)
MAP_ANON =$01000; // allocated from memory, swap space
MAP_ANONYMOUS =MAP_ANON; // For compatibility.
MAP_SYSTEM =$02000;
MAP_ALLAVAILABLE =$04000;
MAP_NOCORE =$20000; // dont include these pages in a coredump
MAP_PREFAULT_READ=$40000; // prefault mapping for reading
MAP_SELF =$80000; // map decryped SELF file
MAP_SHARED =$00001; // share changes
MAP_PRIVATE =$00002; // changes are private
MAP_FIXED =$00010; // map addr must be exactly as requested
MAP_NO_OVERWRITE =$00080; // don't overwrite memory with MAP_FIXED
MAP_VOID =$00100; // reserve addr
MAP_HASSEMAPHORE =$00200; // region may contain semaphores
MAP_STACK =$00400; // region grows down, like a stack
MAP_NOSYNC =$00800; // page to but do not sync underlying file
MAP_FILE =$00000; // map from file (default)
MAP_ANON =$01000; // allocated from memory, swap space
MAP_ANONYMOUS =MAP_ANON; // For compatibility.
MAP_SYSTEM =$02000;
MAP_ALLAVAILABLE =$04000;
MAP_NOCORE =$20000; // dont include these pages in a coredump
MAP_PREFAULT_READ =$40000; // prefault mapping for reading
MAP_SELF =$80000; // map decryped SELF file
MAP_SANITIZER =$200000; // devkit only
MAP_NO_COALESCE =$400000; // do not merge nearby areas
//0x800000
MAP_SANITIZER =$200000; // devkit only
MAP_NO_COALESCE =$400000; // do not merge nearby areas
MAP_WRITABLE_WB_GARLIC=$800000;
MAP_ALIGNMENT_BIT =24;
MAP_ALIGNMENT_SHIFT=24;

View File

@ -303,13 +303,34 @@ begin
Exit(error);
end;
function IDX_TO_OFF(x:DWORD):QWORD; inline;
begin
Result:=QWORD(x) shl PAGE_SHIFT;
end;
function vm_mmap_dmem(handle :Pointer;
objsize :vm_size_t;
foff :p_vm_ooffset_t;
foff :vm_ooffset_t;
objp :p_vm_object_t):Integer;
var
obj:vm_object_t;
len:vm_size_t;
begin
//todo
Exit(EOPNOTSUPP);
obj:=handle; //t_physhmfd *
len:=IDX_TO_OFF(obj^.size);
if (foff<0) or
(len<foff) or
((len-foff)<objsize) then
begin
Exit(EINVAL);
end;
vm_object_reference(obj);
objp^:=obj;
Result:=0;
end;
function vm_mmap_to_errno(rv:Integer):Integer; inline;
@ -394,7 +415,7 @@ begin
if ((prot and (VM_PROT_WRITE or VM_PROT_GPU_WRITE))=0) or
((maxprot and VM_PROT_WRITE)<>0) then
begin
error:=vm_mmap_dmem(handle,size,@foff,@obj);
error:=vm_mmap_dmem(handle,size,foff,@obj);
end;
end;