This commit is contained in:
red-prig 2022-09-28 23:02:27 +03:00
parent 8aac9d5e9c
commit 831b5218ea
4 changed files with 82 additions and 22 deletions

View File

@ -167,7 +167,7 @@ end;
function ps4_sceKernelGetProcParam:Pointer; SysV_ABI_CDecl;
begin
Writeln('KernelGetProcParam');
Result:=GetProcParam;
Result:=GetSceProcParam;
end;
type
@ -245,7 +245,7 @@ var
begin
Result:=SCE_KERNEL_ERROR_EINVAL;
if (sdkVersion=nil) then Exit;
P:=GetProcParam;
P:=GetSceProcParam;
if (P<>nil) then
if (P^.Header.Size>$13) then

View File

@ -89,7 +89,7 @@ function ps4_pthread_key_delete(Key:pthread_key_t):Integer; SysV_ABI_CDecl;
function ps4_pthread_getspecific(Key:pthread_key_t):Pointer; SysV_ABI_CDecl;
function ps4_pthread_setspecific(Key:pthread_key_t;value:Pointer):Integer; SysV_ABI_CDecl;
function _pthread_run_entry(pthread:p_pthread):Integer;
function _pthread_run_entry(pthread:p_pthread;name:Pchar;stack:PDWORD):Integer;
implementation
@ -400,14 +400,28 @@ end;
const
default_name:Pchar='main';
default_stack:Integer=DefaultStackSize;
function _pthread_run_entry(pthread:p_pthread):Integer;
function _pthread_run_entry(pthread:p_pthread;name:Pchar;stack:PDWORD):Integer;
var
attr:pthread_attr_t;
begin
if (name=nil) then
begin
name:=default_name;
end;
if (stack=nil) then
begin
stack:=@default_stack;
end else
if (stack^<PTHREAD_STACK_MIN) then
begin
stack:=@default_stack;
end;
ps4_pthread_attr_init(@attr);
ps4_pthread_attr_setstacksize(@attr,DefaultStackSize);
Result:=ps4_scePthreadCreate(pthread,@attr,@on_ps4_run_entry,nil,default_name);
ps4_pthread_attr_setstacksize(@attr,stack^);
Result:=ps4_scePthreadCreate(pthread,@attr,@on_ps4_run_entry,nil,name);
ps4_pthread_attr_destroy(@attr);
end;

View File

@ -67,25 +67,25 @@ type
TSceLibcParam=packed record
Size:QWORD;
Unknown1:QWORD; //10000000c
sceLibcHeapSize:PQWORD;
sceLibcHeapDelayedAlloc:PQWORD;
sceLibcHeapExtendedAlloc:PQWORD;
sceLibcHeapInitialSize:PQWORD;
sceLibcHeapSize:PDWORD;
sceLibcHeapDelayedAlloc:PDWORD;
sceLibcHeapExtendedAlloc:PDWORD;
sceLibcHeapInitialSize:PDWORD;
_sceLibcMallocReplace:PsceLibcMallocReplace;
_sceLibcNewReplace:PsceLibcNewReplace;
sceLibcHeapHighAddressAlloc:PQWORD;
Need_sceLibc:PQWORD;
Need_sceLibc:PDWORD;
sceLibcHeapMemoryLock:PQWORD;
sceKernelInternalMemorySize:PQWORD;
_sceLibcMallocReplaceForTls:PsceLibcMallocReplaceForTls;
Unknown2:QWORD;
sceLibcHeapDebugFlags:PQWORD;
sceLibcStdThreadStackSize:PQWORD;
sceLibcStdThreadStackSize:PDWORD;
Unknown3:QWORD;
sceKernelInternalMemoryDebugFlags:PQWORD;
sceLibcWorkerThreadNum:PQWORD;
sceLibcWorkerThreadPriority:PQWORD;
sceLibcThreadUnnamedObjects:PQWORD;
sceKernelInternalMemoryDebugFlags:PDWORD;
sceLibcWorkerThreadNum:PDWORD;
sceLibcWorkerThreadPriority:PDWORD;
sceLibcThreadUnnamedObjects:PDWORD;
end;
PSceKernelMemParam=^TSceKernelMemParam;
@ -110,17 +110,17 @@ type
Header:packed record
Size:QWORD; //0x50
Magic:DWORD; //"ORBI" //0x4942524F
Entry_count:DWORD;
Entry_count:DWORD; //>=1
SDK_version:QWORD; //0x4508101
end;
sceProcessName:PChar;
sceUserMainThreadName:PChar;
sceUserMainThreadPriority:PQWORD;
sceUserMainThreadStackSize:PQWORD;
sceUserMainThreadPriority:PDWORD;
sceUserMainThreadStackSize:PDWORD;
_sceLibcParam :PSceLibcParam;
_sceKernelMemParam:PSceKernelMemParam;
_sceKernelFsParam :PSceKernelFsParam;
sceProcessPreloadEnabled:PQWORD;
sceProcessPreloadEnabled:PDWORD;
end;
Telf_file=class;

View File

@ -173,7 +173,11 @@ Function UnMountPath(path:PChar):Integer;
function _parse_filename(filename:PChar):RawByteString;
function GetProcParam:Pointer;
function GetSceProcParam:Pointer;
function GetSceUserMainThreadName:PChar;
function GetSceUserMainThreadPriority:PDWORD;
function GetSceUserMainThreadStackSize:PDWORD;
Function get_dev_progname:RawByteString;
implementation
@ -1501,7 +1505,7 @@ begin
rwlock_unlock(lock);
end;
function GetProcParam:Pointer;
function GetSceProcParam:Pointer;
var
elf:Telf_file;
begin
@ -1512,6 +1516,48 @@ begin
Result:=elf.mMap.pAddr+elf.pProcParam;
end;
function GetSceUserMainThreadName:PChar;
var
p:PSceProcParam;
begin
Result:=nil;
p:=GetSceProcParam;
if (p=nil) then Exit;
if (P^.Header.Size>=qword(@PSceProcParam(nil)^.sceUserMainThreadName)+SizeOf(Pointer)) then
begin
Result:=p^.sceUserMainThreadName;
end;
end;
function GetSceUserMainThreadPriority:PDWORD;
var
p:PSceProcParam;
begin
Result:=nil;
p:=GetSceProcParam;
if (p=nil) then Exit;
if (P^.Header.Size>=qword(@PSceProcParam(nil)^.SceUserMainThreadPriority)+SizeOf(Pointer)) then
begin
Result:=p^.SceUserMainThreadPriority;
end;
end;
function GetSceUserMainThreadStackSize:PDWORD;
var
p:PSceProcParam;
begin
Result:=nil;
p:=GetSceProcParam;
if (p=nil) then Exit;
if (P^.Header.Size>=qword(@PSceProcParam(nil)^.SceUserMainThreadStackSize)+SizeOf(Pointer)) then
begin
Result:=p^.SceUserMainThreadStackSize;
end;
end;
Function get_dev_progname:RawByteString;
begin
Result:='';