fpPS4/kernel/ps4_libkernel.pas

1218 lines
37 KiB
ObjectPascal
Raw Normal View History

2021-12-08 20:04:07 +00:00
unit ps4_libkernel;
{$mode objfpc}{$H+}
interface
uses
Windows,
RWLock,
2022-05-31 07:20:10 +00:00
sys_types,
ps4_map_mm,
2022-11-26 14:39:03 +00:00
ps4_mspace,
2021-12-08 20:04:07 +00:00
ps4_pthread,
2022-05-31 07:20:10 +00:00
ps4_signal,
2021-12-08 20:04:07 +00:00
ps4_mutex,
ps4_cond,
ps4_sema,
ps4_rwlock,
2022-09-06 12:53:07 +00:00
ps4_barrier,
2021-12-08 20:04:07 +00:00
ps4_time,
ps4_kernel_file,
ps4_queue,
2022-05-31 07:20:10 +00:00
ps4_event_flag,
2021-12-08 20:04:07 +00:00
ps4_elf,
ps4_program,
2022-05-31 07:20:10 +00:00
//trace_manager,
2021-12-08 20:04:07 +00:00
2022-05-31 07:20:10 +00:00
Classes,
SysUtils;
2021-12-08 20:04:07 +00:00
2022-09-15 14:41:58 +00:00
function ps4___error:Pointer; SysV_ABI_CDecl;
function ps4_sceKernelError(i:Integer):Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
function ps4_sceKernelIsNeoMode:Integer; SysV_ABI_CDecl;
2022-09-14 14:11:20 +00:00
function ps4_sceKernelGetCompiledSdkVersion(sdkVersion:PDWORD):Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
implementation
2022-05-31 07:20:10 +00:00
uses
2022-10-20 14:29:28 +00:00
sys_path,
2022-05-31 07:20:10 +00:00
sys_kernel,
sys_pthread,
2022-11-12 21:59:35 +00:00
sys_signal,
sys_dev;
2021-12-08 20:04:07 +00:00
2022-10-03 20:06:13 +00:00
type
pSceKernelUuid=^SceKernelUuid;
SceKernelUuid=TGuid;
function ps4_sceKernelUuidCreate(outUuid:pSceKernelUuid):Integer; SysV_ABI_CDecl;
begin
if (outUuid=nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
CreateGUID(outUuid^);
2022-10-03 21:17:18 +00:00
_set_errno(0);
2022-10-03 20:06:13 +00:00
Result:=0;
end;
2022-05-31 07:20:10 +00:00
function ps4___error:Pointer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
2022-05-31 07:20:10 +00:00
Result:=_error;
2021-12-08 20:04:07 +00:00
end;
2022-05-31 07:20:10 +00:00
function ps4_sceKernelError(i:Integer):Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
2022-05-31 07:20:10 +00:00
if (i=0) then
Result:=0
else
Result:=i-$7ffe0000;
2021-12-08 20:04:07 +00:00
end;
Const
_stack_chk_guard:QWORD=$deadbeefa55a857;
ps4_stack_chk_guard:Pointer=@_stack_chk_guard;
procedure ps4_stack_chk_fail; SysV_ABI_CDecl;
begin
2022-10-26 19:25:02 +00:00
Writeln(StdErr,GetCurrentThreadId,':Stack overflow detected! Aborting program.');
2022-05-31 07:20:10 +00:00
DebugBreak;
2021-12-08 20:04:07 +00:00
end;
{$I StopNotificationReason.inc}
// eStopNotificationReason
procedure ps4_sceKernelDebugRaiseException(dwStopReason,dwStopId:DWORD); SysV_ABI_CDecl;
begin
Writeln(StdErr,'RaiseException:',HexStr(dwStopReason,8),':',HexStr(dwStopId,8),':',GetStopReasonInfo(dwStopReason));
2022-05-31 07:20:10 +00:00
DebugBreak;
2021-12-08 20:04:07 +00:00
end;
2022-05-31 07:20:10 +00:00
procedure ps4_sceKernelDebugRaiseExceptionOnReleaseMode(dwStopReason,dwStopId:DWORD); SysV_ABI_CDecl;
begin
2022-10-27 10:30:39 +00:00
//skip
2021-12-08 20:04:07 +00:00
end;
2022-10-10 13:02:04 +00:00
procedure ps4_sceKernelDebugOutText(dbg_id:Integer;text:Pchar); SysV_ABI_CDecl;
begin
Writeln(text);
end;
2021-12-08 20:04:07 +00:00
//ps4 neo mode is support? (Ps4 Pro)
function ps4_sceKernelIsNeoMode:Integer; SysV_ABI_CDecl;
begin
Result:=0; //no
//Result:=1; //yes
end;
2022-09-05 16:44:19 +00:00
//ps5? no
function ps4_sceKernelIsProspero:Integer; SysV_ABI_CDecl;
begin
Result:=0; //no
end;
2022-10-05 14:05:17 +00:00
function ps4_sceKernelGetModuleInfoFromAddr(Addr:Pointer;flags:DWORD;info:pSceKernelModuleInfoEx):Integer; SysV_ABI_CDecl;
2022-05-31 07:20:10 +00:00
var
node:TElf_node;
2021-12-08 20:04:07 +00:00
begin
2022-05-31 07:20:10 +00:00
if (info=nil) then Exit(SCE_KERNEL_ERROR_EFAULT);
2022-10-05 14:05:17 +00:00
if (flags - 1 < 2) then
2022-05-31 07:20:10 +00:00
begin
2022-10-05 14:05:17 +00:00
if (info=nil) then
begin
2022-10-24 11:17:28 +00:00
Result:=SCE_KERNEL_ERROR_EFAULT;
2022-10-05 14:05:17 +00:00
end else
begin
_sig_lock;
Writeln('GetModuleInfoFromAddr:',HexStr(Addr),':',flags,':',HexStr(info));
node:=ps4_app.AcqureFileByCodeAdr(Addr);
if (node=nil) then
begin
_sig_unlock;
info^:=Default(SceKernelModuleInfoEx);
2022-10-24 11:17:28 +00:00
Exit(SCE_KERNEL_ERROR_ESRCH);
2022-10-05 14:05:17 +00:00
end;
2022-10-05 19:16:42 +00:00
info^:=node.GetModuleInfoEx;
2022-10-05 14:05:17 +00:00
node.Release;
_sig_unlock;
Result:=0;
2022-10-05 19:16:42 +00:00
2022-10-05 14:05:17 +00:00
end;
end else
begin
2022-10-24 11:17:28 +00:00
Result:=SCE_KERNEL_ERROR_EINVAL;
2022-10-05 14:05:17 +00:00
info^:=Default(SceKernelModuleInfoEx);
2022-05-31 07:20:10 +00:00
end;
2021-12-08 20:04:07 +00:00
end;
2022-10-05 19:16:42 +00:00
function ps4_sceKernelGetModuleInfo(handle:Integer;info:pSceKernelModuleInfo):Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
var
node:TElf_node;
begin
2022-05-31 07:20:10 +00:00
if (info=nil) then Exit(SCE_KERNEL_ERROR_EFAULT);
_sig_lock;
Writeln('sceKernelGetModuleInfo:',handle,':',HexStr(info));
node:=ps4_app.AcqureFileByHandle(handle);
if (node=nil) then
2021-12-08 20:04:07 +00:00
begin
2022-05-31 07:20:10 +00:00
_sig_unlock;
Exit(SCE_KERNEL_ERROR_EINVAL);
2021-12-08 20:04:07 +00:00
end;
2022-05-31 07:20:10 +00:00
info^:=node.GetModuleInfo;
node.Release;
_sig_unlock;
2021-12-08 20:04:07 +00:00
Result:=0;
end;
2022-10-05 19:16:42 +00:00
function ps4_sceKernelGetModuleInfoForUnwind(addr:Pointer;flags:DWORD;info:pSceModuleInfoForUnwind):Integer; SysV_ABI_CDecl;
var
node:TElf_node;
info_ex:SceKernelModuleInfoEx;
2022-10-05 14:05:17 +00:00
begin
if (info=nil) then Exit(SCE_KERNEL_ERROR_EFAULT);
if (flags - 1 < 2) then
begin
if (info=nil) then
begin
2022-10-24 11:17:28 +00:00
Result:=SCE_KERNEL_ERROR_EFAULT;
2022-10-05 14:05:17 +00:00
end else
begin
2022-10-24 11:17:28 +00:00
Result:=SCE_KERNEL_ERROR_EINVAL;
2022-10-05 14:05:17 +00:00
if (info^.st_size > 303) then
begin
2022-10-05 19:16:42 +00:00
_sig_lock;
Writeln('sceKernelGetModuleInfoForUnwind:',HexStr(Addr),':',flags,':',HexStr(info));
node:=ps4_app.AcqureFileByCodeAdr(Addr);
if (node=nil) then
begin
_sig_unlock;
info^:=Default(SceModuleInfoForUnwind);
2022-10-24 11:17:28 +00:00
Exit(SCE_KERNEL_ERROR_ESRCH);
2022-10-05 19:16:42 +00:00
end;
info_ex:=node.GetModuleInfoEx;
node.Release;
_sig_unlock;
info^.name :=info_ex.name;
info^.eh_frame_hdr_addr:=info_ex.eh_frame_hdr_addr;
info^.eh_frame_addr :=info_ex.eh_frame_addr;
info^.eh_frame_size :=info_ex.eh_frame_size;
info^.seg0_addr :=info_ex.segments[0].address;
info^.seg0_size :=info_ex.segments[0].size;
Result:=0;
2022-10-05 14:05:17 +00:00
end;
end;
end else
begin
2022-10-24 11:17:28 +00:00
Result:=SCE_KERNEL_ERROR_EINVAL;
2022-10-05 14:05:17 +00:00
info^:=Default(SceModuleInfoForUnwind);
end;
end;
2022-10-06 19:58:35 +00:00
function ps4_sceSysmoduleGetModuleInfoForUnwind(addr:Pointer;flags:DWORD;info:pSceModuleInfoForUnwind):Integer; SysV_ABI_CDecl;
begin
Result:=ps4_sceKernelGetModuleInfoForUnwind(addr,flags,info);
end;
2022-11-28 17:05:52 +00:00
function ps4_sceKernelGetLibkernelTextLocation(address:PPointer;size:PQWORD):Integer; SysV_ABI_CDecl;
var
elf:Telf_file;
begin
Result:=0;
elf:=Telf_file(ps4_program.ps4_app.prog);
if (elf=nil) then Exit(-1);
address^:=elf.ModuleInfo.segmentInfo[0].address;
size ^:=elf.ModuleInfo.segmentInfo[0].size;
end;
2021-12-08 20:04:07 +00:00
type
PInternalSegmentInfo=^TInternalSegmentInfo;
TInternalSegmentInfo=packed record
address:Pointer;
2022-11-28 17:05:52 +00:00
size:QWORD;
2021-12-08 20:04:07 +00:00
end;
function ps4_sceKernelInternalMemoryGetModuleSegmentInfo(pOut:PInternalSegmentInfo):Integer; SysV_ABI_CDecl;
begin
2022-11-28 17:05:52 +00:00
//pOut^.address:=nil;
//pOut^.size:=0;
//Result:=0;
Result:=ps4_sceKernelGetLibkernelTextLocation(@pOut^.address,@pOut^.size)
2021-12-08 20:04:07 +00:00
end;
2022-10-22 21:09:28 +00:00
function ps4_sceKernelGetProcParam:PSceProcParam; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
Writeln('KernelGetProcParam');
2022-09-28 20:02:27 +00:00
Result:=GetSceProcParam;
2021-12-08 20:04:07 +00:00
end;
type
PAppHeapAPI=^TAppHeapAPI;
TAppHeapAPI=packed record
2022-11-22 10:40:17 +00:00
malloc:Pointer;
free :Pointer;
unknow:array[0..3] of Pointer;
posix_memalign:Pointer;
2021-12-08 20:04:07 +00:00
end;
2022-10-21 08:15:40 +00:00
procedure ps4__sceKernelRtldSetApplicationHeapAPI(heap_api:PAppHeapAPI); SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
Writeln('SetApplicationHeapAPI:',HexStr(heap_api));
2022-11-22 10:40:17 +00:00
Writeln(' malloc:',HexStr(heap_api^.malloc));
Writeln(' free:',HexStr(heap_api^.free));
Writeln(' posix_memalign:',HexStr(heap_api^.posix_memalign));
2021-12-08 20:04:07 +00:00
end;
2022-09-12 14:13:01 +00:00
//cb used in pthread_exit
2021-12-08 20:04:07 +00:00
function ps4_sceKernelSetThreadDtors(Proc:TProcedure):Integer; SysV_ABI_CDecl;
begin
2022-09-12 19:37:16 +00:00
sceKernelThreadDtors:=Proc;
2021-12-08 20:04:07 +00:00
Writeln('sceKernelSetThreadDtors:',HexStr(proc));
Result:=0;
end;
2022-09-12 14:13:01 +00:00
//cb used in sceKernelStopUnloadModule
function ps4_sceKernelSetThreadAtexitCount(proc:TKernelAtexitFuncCount):Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
Writeln('sceKernelSetThreadAtexitCount:',HexStr(proc));
Result:=0;
end;
2022-09-12 14:13:01 +00:00
//cb used in sceKernelStopUnloadModule
2021-12-08 20:04:07 +00:00
function ps4_sceKernelSetThreadAtexitReport(proc:TKernelAtexitReportFunc):Integer; SysV_ABI_CDecl;
begin
Writeln('sceKernelSetThreadAtexitReport:',HexStr(proc));
Result:=0;
end;
//extern "C" {
//int user_malloc_init(void);
//int user_malloc_finalize(void);
//void *user_malloc(size_t size);
//void user_free(void *ptr);
//void *user_calloc(size_t nelem, size_t size);
//void *user_realloc(void *ptr, size_t size);
//void *user_memalign(size_t boundary, size_t size);
//int user_posix_memalign(void **ptr, size_t boundary, size_t size);
//void *user_reallocalign(void *ptr, size_t size, size_t boundary);
//int user_malloc_stats(SceLibcMallocManagedSize *mmsize);
//int user_malloc_stats_fast(SceLibcMallocManagedSize *mmsize);
//size_t user_malloc_usable_size(void *ptr);
//}
2022-10-21 08:15:40 +00:00
function ps4_sceKernelGetSanitizerMallocReplaceExternal:Pointer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
2022-10-21 08:15:40 +00:00
//sceKernelDlsym: libSceDbgAddressSanitizer.prx->__asan_malloc_replace_external
2021-12-08 20:04:07 +00:00
Result:=nil;
end;
2022-10-21 08:15:40 +00:00
function ps4_sceKernelGetSanitizerNewReplaceExternal:Pointer; SysV_ABI_CDecl;
begin
//sceKernelDlsym: libSceDbgAddressSanitizer.prx->__asan_new_replace_external
Result:=nil;
end;
function ps4_sceKernelGetSanitizerMallocReplace:Pointer; SysV_ABI_CDecl;
begin
//sceKernelDlsym: libSceDbgAddressSanitizer.prx->__asan_malloc_replace
Result:=nil;
end;
function ps4_sceKernelGetSanitizerNewReplace:Pointer; SysV_ABI_CDecl;
begin
//sceKernelDlsym: libSceDbgAddressSanitizer.prx->__asan_new_replace
Result:=nil;
end;
function ps4_sceKernelIsAddressSanitizerEnabled:Integer; SysV_ABI_CDecl;
2021-12-08 20:04:07 +00:00
begin
Result:=0;
end;
2022-10-21 08:15:40 +00:00
function ps4_sceKernelMapSanitizerShadowMemory(addr:Pointer;len:qword;flags:DWORD;name:Pchar):Integer; SysV_ABI_CDecl;
begin
Result:=SCE_KERNEL_ERROR_EINVAL;
end;
2022-05-31 07:20:10 +00:00
function ps4_sceKernelGetCompiledSdkVersion(sdkVersion:PDWORD):Integer; SysV_ABI_CDecl;
2022-09-10 17:10:46 +00:00
var
P:PSceProcParam;
2022-05-31 07:20:10 +00:00
begin
2022-09-10 17:10:46 +00:00
Result:=SCE_KERNEL_ERROR_EINVAL;
if (sdkVersion=nil) then Exit;
2022-09-28 20:02:27 +00:00
P:=GetSceProcParam;
2022-09-10 17:10:46 +00:00
if (P<>nil) then
if (P^.Header.Size>$13) then
if (P^.Header.Magic=$4942524f) then
if (P^.Header.Entry_count<>0) then
begin
sdkVersion^:=P^.Header.SDK_version;
Result:=0;
end;
2022-05-31 07:20:10 +00:00
end;
2021-12-08 20:04:07 +00:00
2022-09-30 21:25:10 +00:00
const
//eLoadOptions
LOAD_OPTIONS_DEFAULT =$0000;
LOAD_OPTIONS_LOAD_SUSPENDED =$0001;
LOAD_OPTIONS_USE_SYSTEM_LIBRARY_VERIFICATION =$0002;
LOAD_OPTIONS_SLV_MODE_WARN =$0004;
LOAD_OPTIONS_ARG_STACK_SIZE =$0008;
LOAD_OPTIONS_FULL_DEBUG_REQUIRED =$0010;
type
PSCE_APP_ENV=^TSCE_APP_ENV;
TSCE_APP_ENV=packed record
unk1:array[0..15] of Byte; //16
ustr:array[0.. 9] of char; //10
unk2:array[0..37] of Byte; //38
flags:Byte; //1 eLoadOptions
unk3:array[0.. 6] of Byte; //7
end;
//sysctl to KERN_PROC_ENV
function ps4_sceKernelGetAppInfo(pid:Integer;env:PSCE_APP_ENV):Integer; SysV_ABI_CDecl;
begin
//ignore pid
Result:=0;
if (env=nil) then
begin
_set_errno(EINVAL);
Exit(SCE_KERNEL_ERROR_EINVAL);
end;
env^:=Default(TSCE_APP_ENV);
end;
2022-09-12 14:13:01 +00:00
//dynlib_get_obj_member(handle,8,&ptr); module param
//dynlib_get_obj_member(handle,1,&ptr); init
//dynlib_get_obj_member(handle,2,&ptr); fini
2022-10-24 11:17:28 +00:00
function _sceKernelLoadStartModule(moduleFileName:Pchar;
argc:size_t;
argp:PPointer;
flags:DWORD;
pOpt:PSceKernelLoadModuleOpt;
pRes:PInteger):SceKernelModule;
2022-05-31 07:20:10 +00:00
var
node:TElf_node;
fn:RawByteString;
i:Integer;
2021-12-08 20:04:07 +00:00
begin
2022-05-31 07:20:10 +00:00
Result:=0;
2022-10-24 11:17:28 +00:00
if (pOpt<>nil) then Exit(SCE_KERNEL_ERROR_EINVAL);
2022-06-28 14:21:49 +00:00
2021-12-08 20:04:07 +00:00
Writeln('Load Lib:',moduleFileName);
2022-05-31 07:20:10 +00:00
2022-10-20 14:29:28 +00:00
Result:=parse_filename(moduleFileName,fn);
2022-11-09 13:46:13 +00:00
Case Result of
PT_FILE:;
else
Exit(_set_sce_errno(SCE_KERNEL_ERROR_EACCES));
2022-10-20 14:29:28 +00:00
end;
2022-05-31 07:20:10 +00:00
2022-06-28 14:21:49 +00:00
node:=ps4_app.AcqureFileByName(ExtractFileName(fn));
if (node<>nil) then
begin
Writeln('File Loaded:',ExtractFileName(fn));
Result:=node.Handle;
node.Release;
if (pRes<>nil) then pRes^:=0;
Exit;
end;
2022-05-31 07:20:10 +00:00
Writeln('Load File:',fn);
node:=LoadPs4ElfFromFile(fn);
if (node<>nil) then
begin
2022-06-10 07:00:15 +00:00
node.IsStatic:=False;
2022-05-31 07:20:10 +00:00
node.Acqure;
node.Prepare;
2022-10-24 11:17:28 +00:00
if not ps4_app.RegistredElf(node) then Assert(false,'RegistredElf');
2022-05-31 07:20:10 +00:00
ps4_app.ResolveDepended(node);
ps4_app.LoadSymbolImport(nil);
ps4_app.ReLoadSymbolImport(Pointer(node));
ps4_app.InitProt;
ps4_app.InitThread(0);
2022-06-10 07:00:15 +00:00
node.IsInit:=True; //mark exclude
ps4_app.InitCode;
2022-05-31 07:20:10 +00:00
2022-09-12 19:37:16 +00:00
i:=node.module_start(argc,argp,nil);
2022-06-10 07:00:15 +00:00
Result:=node.Handle;
2022-05-31 07:20:10 +00:00
node.Release;
if (pRes<>nil) then pRes^:=i;
if (i<0) then Result:=SCE_KERNEL_ERROR_EINVAL;
end else
begin
Result:=SCE_KERNEL_ERROR_ENOENT;
end;
2022-11-09 13:46:13 +00:00
_set_sce_errno(Result);
2022-10-24 11:17:28 +00:00
end;
function ps4_sceKernelLoadStartModule(moduleFileName:Pchar;
argc:size_t;
argp:PPointer;
flags:DWORD;
pOpt:PSceKernelLoadModuleOpt;
pRes:PInteger):SceKernelModule; SysV_ABI_CDecl;
begin
if (flags<>0) then Exit(SCE_KERNEL_ERROR_EINVAL);
_sig_lock;
Result:=_sceKernelLoadStartModule(moduleFileName,
argc,
argp,
0,
pOpt,
pRes);
2022-05-31 07:20:10 +00:00
_sig_unlock;
end;
Function ps4_sceKernelDlsym(handle:Integer;symbol:PChar;addrp:PPointer):Integer; SysV_ABI_CDecl;
var
node:TElf_node;
p:Pointer;
begin
Result:=0;
if (addrp=nil) then Exit(SCE_KERNEL_ERROR_EFAULT);
_sig_lock;
Writeln('sceKernelDlsym:',symbol);
node:=ps4_app.AcqureFileByHandle(handle);
if (node=nil) then
begin
_sig_unlock;
Exit(SCE_KERNEL_ERROR_ESRCH);
end;
p:=node.get_proc_by_name(symbol);
if (p<>nil) then
begin
addrp^:=p;
end else
begin
Result:=SCE_KERNEL_ERROR_EFAULT;
end;
node.Release;
_sig_unlock;
2021-12-08 20:04:07 +00:00
end;
2022-05-31 07:20:10 +00:00
Function ps4_sceKernelGetModuleList(list:PInteger;numArray:QWORD;actualNum:PQWORD):Integer; SysV_ABI_CDecl;
var
i:QWORD;
node:TElf_node;
begin
Result:=0;
if (list=nil) or (actualNum=nil) then Exit(SCE_KERNEL_ERROR_EFAULT);
_sig_lock;
ps4_app.LockRd;
i:=0;
node:=ps4_app.FirstFile;
While (node<>nil) do
begin
if (i<numArray) then
begin
list[i]:=node.Handle;
end;
Inc(i);
node:=node.Next;
end;
ps4_app.Unlock;
_sig_unlock;
actualNum^:=i;
if (i>numArray) then Result:=SCE_KERNEL_ERROR_ENOMEM;
Writeln('sceKernelGetModuleList:',HexStr(list),' ',numArray,' ',i);
end;
2022-06-10 07:00:15 +00:00
const
//
//For CPU mode
// bit 0: 7/6 CPU mode flag 1: 7 CPU mode 0: 6 CPU mode
// bit 1: Reserved
// bit 2: CPU #6 flag 1: normal 0: low
//
SCE_KERNEL_CPUMODE_6CPU =0;
SCE_KERNEL_CPUMODE_7CPU_LOW =1;
SCE_KERNEL_CPUMODE_7CPU_NORMAL=5;
function ps4_sceKernelGetCpumode():Integer; SysV_ABI_CDecl;
begin
Result:=SCE_KERNEL_CPUMODE_7CPU_NORMAL;
end;
2022-11-29 14:27:48 +00:00
//wtf it mean?
function ps4_sceKernelSetFsstParam(prio:Integer;
mask:QWORD //SceKernelCpumask
):Integer; SysV_ABI_CDecl;
begin
Result:=0;
end;
2022-12-07 12:36:21 +00:00
const
RUSAGE_SELF = 0;
RUSAGE_CHILDREN=-1;
RUSAGE_THREAD = 1;
type
p_rusage=^rusage;
rusage=packed record
ru_utime :timeval; // user time used
ru_stime :timeval; // system time used
ru_maxrss :DWORD; // max resident set size
ru_ixrss :DWORD; // integral shared memory size *
ru_idrss :DWORD; // integral unshared data
ru_isrss :DWORD; // integral unshared stack
ru_minflt :DWORD; // page reclaims
ru_majflt :DWORD; // page faults
ru_nswap :DWORD; // swaps
ru_inblock :DWORD; // block input operations
ru_oublock :DWORD; // block output operations
ru_msgsnd :DWORD; // messages sent
ru_msgrcv :DWORD; // messages received
ru_nsignals:DWORD; // signals received
ru_nvcsw :DWORD; // voluntary context switches
ru_nivcsw :DWORD; // involuntary
end;
function ps4_getrusage(who:Integer;usage:p_rusage):Integer; SysV_ABI_CDecl;
var
ct,et,kt,ut:TFileTime;
pmc:_PROCESS_MEMORY_COUNTERS;
pio:_IO_COUNTERS;
function _timeval(f:TFileTime):timeval; inline;
begin
Result.tv_sec :=(QWORD(f) div 10000000);
Result.tv_usec:=(QWORD(f) mod 10000000) div 10
end;
begin
Result:=0;
if (usage=nil) then Exit(_set_errno(EFAULT));
usage^:=Default(rusage);
QWORD(ct):=0;
QWORD(et):=0;
QWORD(kt):=0;
QWORD(ut):=0;
pmc:=Default(_PROCESS_MEMORY_COUNTERS);
pmc.cb:=sizeof(pmc);
pio:=Default(_IO_COUNTERS);
Case who of
RUSAGE_SELF:
begin
_sig_lock;
GetProcessTimes(GetCurrentProcess,ct,et,kt,ut);
GetProcessMemoryInfo(GetCurrentProcess,@pmc,sizeof(pmc));
GetProcessIoCounters(GetCurrentProcess,@pio);
_sig_unlock;
end;
RUSAGE_THREAD:
begin
_sig_lock;
GetThreadTimes(GetCurrentThread,ct,et,kt,ut);
_sig_unlock;
end;
else;
Exit(_set_errno(EINVAL));
end;
usage^.ru_utime:=_timeval(ut);
usage^.ru_stime:=_timeval(kt);
usage^.ru_maxrss:=pmc.PeakWorkingSetSize div 1024;
//ru_ixrss
//ru_idrss
//ru_isrss
//ru_minflt
usage^.ru_majflt:=pmc.PageFaultCount;
//ru_nswap
usage^.ru_inblock:=pio.ReadOperationCount;
usage^.ru_oublock:=pio.WriteOperationCount;
//ru_msgsnd
//ru_msgrcv
//ru_nsignals
//ru_nvcsw >NtQuerySystemInformation
//ru_nivcsw
end;
2022-06-26 20:50:32 +00:00
{$I libsysmodule.inc}
2021-12-08 20:04:07 +00:00
function ps4_sceSysmoduleLoadModule(id:Word):Integer; SysV_ABI_CDecl;
begin
2022-07-14 11:59:03 +00:00
Writeln('sceSysmoduleLoadModule:',GetSysmoduleName(id));
2021-12-08 20:04:07 +00:00
Result:=0;
end;
function ps4_sceSysmoduleUnloadModule(id:Word):Integer; SysV_ABI_CDecl;
begin
2022-07-14 11:59:03 +00:00
Writeln('sceSysmoduleUnloadModule:',GetSysmoduleName(id));
2021-12-08 20:04:07 +00:00
Result:=0;
end;
function ps4_sceSysmoduleIsLoaded(id:Word):Integer; SysV_ABI_CDecl;
begin
2022-07-14 11:59:03 +00:00
Writeln('sceSysmoduleIsLoaded:',GetSysmoduleName(id));
2021-12-08 20:04:07 +00:00
Result:=0;
end;
2022-09-05 20:08:52 +00:00
//
function ps4_sceSysmoduleLoadModuleInternalWithArg(id:Word;
argc:size_t;
argp:PPointer;
flags:DWORD;
pRes:PInteger):Integer; SysV_ABI_CDecl;
begin
Writeln('sceSysmoduleLoadModuleInternalWithArg:',GetSysmoduleName(id));
if (pRes<>nil) then pRes^:=0;
Result:=0;
end;
2021-12-08 20:04:07 +00:00
const
2022-05-31 07:20:10 +00:00
__progname:PChar='eboot.bin'; //argv[0]
2021-12-08 20:04:07 +00:00
function Load_libSceSysmodule(Const name:RawByteString):TElf_node;
var
lib:PLIBRARY;
begin
Result:=TElf_node.Create;
Result.pFileName:=name;
lib:=Result._add_lib('libSceSysmodule');
lib^.set_proc($83C70CDFD11467AA,@ps4_sceSysmoduleLoadModule);
lib^.set_proc($791D9B6450005344,@ps4_sceSysmoduleUnloadModule);
lib^.set_proc($7CC3F934750E68C9,@ps4_sceSysmoduleIsLoaded);
2022-09-05 20:08:52 +00:00
lib^.set_proc($847AC6A06A0D7FEB,@ps4_sceSysmoduleLoadModuleInternalWithArg);
2022-10-06 19:58:35 +00:00
lib^.set_proc($E1F539CAF3A4546E,@ps4_sceSysmoduleGetModuleInfoForUnwind);
2021-12-08 20:04:07 +00:00
end;
2022-11-12 21:59:35 +00:00
procedure _kernel_init;
begin
2022-11-26 14:39:03 +00:00
ps4_sceKernelGetCompiledSdkVersion(@SDK_VERSION);
2022-11-12 21:59:35 +00:00
_mem_init;
_sys_dev_init;
2022-11-26 14:39:03 +00:00
ps4_malloc_init;
2022-11-12 21:59:35 +00:00
end;
2021-12-08 20:04:07 +00:00
function Load_libkernel(Const name:RawByteString):TElf_node;
var
lib,px:PLIBRARY;
begin
Result:=TElf_node.Create;
Result.pFileName:=name;
lib:=Result._add_lib('libkernel');
lib^.set_proc($BCD7B5C387622C2B,@_dynamic_tls_get_addr);
lib^.set_proc($763C713A65BAFDAC,@__progname);
lib^.set_proc($F41703CA43E6A352,@ps4___error);
2022-05-31 07:20:10 +00:00
lib^.set_proc($0F8CA56B7BF1E2D6,@ps4_sceKernelError);
2021-12-08 20:04:07 +00:00
lib^.set_proc($7FBB8EC58F663355,@ps4_stack_chk_guard);
lib^.set_proc($3AEDE22F569BBE78,@ps4_stack_chk_fail);
lib^.set_proc($91BC385071D2632D,@ps4_pthread_cxa_finalize);
2022-05-31 07:20:10 +00:00
2022-10-03 20:06:13 +00:00
lib^.set_proc($5E3A28B22C3E5CF2,@ps4_sceKernelUuidCreate);
2022-12-07 12:36:21 +00:00
lib^.set_proc($8479594149E5C523,@ps4_getrusage);
2022-05-31 07:20:10 +00:00
//signal
2021-12-08 20:04:07 +00:00
lib^.set_proc($5644C0B2B643709D,@ps4_sigfillset);
2022-10-09 23:32:01 +00:00
lib^.set_proc($2548A616D29ED0A7,@ps4_sigaddset);
2022-10-26 19:25:02 +00:00
lib^.set_proc($68F732A6D6CE899B,@ps4_sigprocmask); //sigprocmask
lib^.set_proc($EB1569CB415DABE2,@ps4_sigprocmask); //_sigprocmask
2022-10-09 23:32:01 +00:00
lib^.set_proc($2592B0E7E5AB9DAC,@ps4_pthread_sigmask);
2021-12-08 20:04:07 +00:00
lib^.set_proc($72B6F98FB9A49357,@ps4_is_signal_return);
2022-10-09 23:32:01 +00:00
lib^.set_proc($2A22443C4591C946,@ps4_sigaction);
lib^.set_proc($5400DCDCC350DDC3,@ps4_signal_);
lib^.set_proc($38C0D128A019F08E,@ps4_sceKernelDebugRaiseException);
lib^.set_proc($CC4FF05C86632E83,@ps4_sceKernelDebugRaiseExceptionOnReleaseMode);
2022-10-10 13:02:04 +00:00
lib^.set_proc($F4960DA8DEA300A2,@ps4_sceKernelDebugOutText);
2021-12-08 20:04:07 +00:00
2022-05-31 07:20:10 +00:00
//signal
2022-11-28 17:05:52 +00:00
lib^.set_proc($0262749A7DA5E253,@ps4_sceKernelGetLibkernelTextLocation);
2021-12-08 20:04:07 +00:00
lib^.set_proc($FD84D6FAA5DCDC24,@ps4_sceKernelInternalMemoryGetModuleSegmentInfo);
lib^.set_proc($7FB28139A7F2B17A,@ps4_sceKernelGetModuleInfoFromAddr);
2022-05-31 07:20:10 +00:00
lib^.set_proc($914A60AD722BCFB4,@ps4_sceKernelGetModuleInfo);
2022-10-05 19:16:42 +00:00
lib^.set_proc($4694092552938853,@ps4_sceKernelGetModuleInfoForUnwind);
2021-12-08 20:04:07 +00:00
lib^.set_proc($F79F6AADACCF22B8,@ps4_sceKernelGetProcParam);
2022-10-21 08:15:40 +00:00
lib^.set_proc($A7911C41E11E2401,@ps4__sceKernelRtldSetApplicationHeapAPI);
2021-12-08 20:04:07 +00:00
lib^.set_proc($ACD856CFE96F38C5,@ps4_sceKernelSetThreadDtors);
lib^.set_proc($A41FF2199DA743DA,@ps4_sceKernelSetThreadAtexitCount);
lib^.set_proc($5A109CD70DC48522,@ps4_sceKernelSetThreadAtexitReport);
2022-10-21 08:15:40 +00:00
lib^.set_proc($A72E8BF2389500DF,@ps4_sceKernelGetSanitizerMallocReplaceExternal);
2021-12-08 20:04:07 +00:00
lib^.set_proc($6E7671620005780D,@ps4_sceKernelGetSanitizerNewReplaceExternal);
2022-10-21 08:15:40 +00:00
lib^.set_proc($6EDD0F38451975D1,@ps4_sceKernelGetSanitizerMallocReplace);
lib^.set_proc($1782A26F731BD302,@ps4_sceKernelGetSanitizerNewReplace);
2021-12-08 20:04:07 +00:00
lib^.set_proc($8E1FBC5E22B82DE1,@ps4_sceKernelIsAddressSanitizerEnabled);
2022-10-21 08:15:40 +00:00
lib^.set_proc($F1C0250B3A0E8A27,@ps4_sceKernelMapSanitizerShadowMemory);
2022-05-31 07:20:10 +00:00
lib^.set_proc($581EBA7AFBBC6EC5,@ps4_sceKernelGetCompiledSdkVersion);
2022-09-30 21:25:10 +00:00
lib^.set_proc($1BF318BF97AB5DA5,@ps4_sceKernelGetAppInfo);
2021-12-08 20:04:07 +00:00
lib^.set_proc($C33BEA4F852A297F,@ps4_sceKernelLoadStartModule);
2022-05-31 07:20:10 +00:00
lib^.set_proc($22EC6752E5E4E818,@ps4_sceKernelGetModuleList);
lib^.set_proc($2F01BC8379E2AB00,@ps4_sceKernelDlsym);
2021-12-08 20:04:07 +00:00
2022-06-10 07:00:15 +00:00
lib^.set_proc($54EC7C3469875D3B,@ps4_sceKernelGetCpumode);
2022-11-29 14:27:48 +00:00
lib^.set_proc($56306D83906D97DE,@ps4_sceKernelSetFsstParam);
2022-06-10 07:00:15 +00:00
2021-12-08 20:04:07 +00:00
//mutex
lib^.set_proc($7501D612C26DA04E,@ps4_pthread_mutexattr_init);
lib^.set_proc($1C5EE52B8EB1CE36,@ps4_pthread_mutexattr_destroy);
lib^.set_proc($19916523B461B90A,@ps4_pthread_mutexattr_gettype);
lib^.set_proc($9839A030E19552A8,@ps4_pthread_mutexattr_settype);
lib^.set_proc($3E62FF4F0294CD72,@ps4_pthread_mutexattr_getpshared);
lib^.set_proc($117BF7CED1AAB433,@ps4_pthread_mutexattr_setpshared);
lib^.set_proc($C83696C54139D2CD,@ps4_pthread_mutexattr_getprotocol);
lib^.set_proc($E6DC4A7DC3140289,@ps4_pthread_mutexattr_setprotocol);
lib^.set_proc($FA6F3EAAEA8EC213,@ps4_pthread_mutexattr_getprioceiling);
lib^.set_proc($64BBDFEA55407383,@ps4_pthread_mutexattr_setprioceiling);
lib^.set_proc($B6D1CD7D4FAA0C15,@ps4_pthread_mutex_init);
lib^.set_proc($96D09F686AF62461,@ps4_pthread_mutex_destroy);
lib^.set_proc($EC7D224CE7224CBA,@ps4_pthread_mutex_lock);
lib^.set_proc($D99F8FA58E826898,@ps4_pthread_mutex_unlock);
lib^.set_proc($228F7E9D329766D0,@ps4_pthread_mutex_timedlock);
lib^.set_proc($2BF8D785BB76827E,@ps4_pthread_mutex_trylock);
lib^.set_proc($17C6D41F0006DBCE,@ps4_scePthreadMutexattrInit);
lib^.set_proc($B2658492D8B2C86D,@ps4_scePthreadMutexattrDestroy);
lib^.set_proc($82AB84841AD2DA2C,@ps4_scePthreadMutexattrGettype);
lib^.set_proc($88CA7C42913E5CEE,@ps4_scePthreadMutexattrSettype);
lib^.set_proc($1A84E615EBA2FA14,@ps4_scePthreadMutexattrGetprotocol);
lib^.set_proc($D451AF5348BDB1A4,@ps4_scePthreadMutexattrSetprotocol);
lib^.set_proc($4A08CCA721FD67D2,@ps4_scePthreadMutexattrGetprioceiling);
lib^.set_proc($E77D8869082EC0C8,@ps4_scePthreadMutexattrSetprioceiling);
lib^.set_proc($726A3544862F6BDA,@ps4_scePthreadMutexInit);
lib^.set_proc($D8E7F47FEDE68611,@ps4_scePthreadMutexDestroy);
lib^.set_proc($F542B5BCB6507EDE,@ps4_scePthreadMutexLock);
lib^.set_proc($21A7C8D8FC5C3E74,@ps4_scePthreadMutexTimedlock);
lib^.set_proc($B67DD5943D211BAD,@ps4_scePthreadMutexUnlock);
lib^.set_proc($BA9A15AF330715E1,@ps4_scePthreadMutexTrylock);
//mutex
//rwlock
lib^.set_proc($C4579BB00E18B052,@ps4_pthread_rwlockattr_init);
lib^.set_proc($AAC7668178EA4A09,@ps4_pthread_rwlockattr_destroy);
lib^.set_proc($97E6C6E5FB189218,@ps4_pthread_rwlockattr_gettype_np);
lib^.set_proc($F0DB8E1E24EBD55C,@ps4_pthread_rwlockattr_settype_np);
lib^.set_proc($56A10CB82BFFA876,@ps4_pthread_rwlockattr_getpshared);
lib^.set_proc($3AE2A0FA44430FB5,@ps4_pthread_rwlockattr_setpshared);
lib^.set_proc($CAD4142CDFE784BE,@ps4_pthread_rwlock_init);
lib^.set_proc($D78EF56A33F3C61D,@ps4_pthread_rwlock_destroy);
lib^.set_proc($8868ECAF5580B48D,@ps4_pthread_rwlock_rdlock);
lib^.set_proc($B08951BD0AAC3766,@ps4_pthread_rwlock_wrlock);
lib^.set_proc($485C5330E7EE0A41,@ps4_pthread_rwlock_tryrdlock);
lib^.set_proc($5E15879FA3F947B5,@ps4_pthread_rwlock_trywrlock);
lib^.set_proc($12098BA3A11682CA,@ps4_pthread_rwlock_unlock);
2022-10-11 14:51:41 +00:00
lib^.set_proc($C8E7C683F2356482,@ps4_scePthreadRwlockattrInit);
lib^.set_proc($8B689F6777D2D9FA,@ps4_scePthreadRwlockattrDestroy);
lib^.set_proc($2B296CD42845CAB7,@ps4_scePthreadRwlockattrGettype);
lib^.set_proc($87F3A27E2A2E05DF,@ps4_scePthreadRwlockattrSettype);
2021-12-08 20:04:07 +00:00
lib^.set_proc($E942C06B47EAE230,@ps4_scePthreadRwlockInit);
lib^.set_proc($041FA46F4F1397D0,@ps4_scePthreadRwlockDestroy);
lib^.set_proc($3B1F62D1CECBE70D,@ps4_scePthreadRwlockRdlock);
lib^.set_proc($9AA74DA2BAC1FA02,@ps4_scePthreadRwlockWrlock);
lib^.set_proc($5C3DE60DEC9B0A79,@ps4_scePthreadRwlockTryrdlock);
lib^.set_proc($6C81E86424E89AC2,@ps4_scePthreadRwlockTrywrlock);
lib^.set_proc($F8BF7C3C86C6B6D9,@ps4_scePthreadRwlockUnlock);
//rwlock
//Sema
lib^.set_proc($A43B8F11FDE6E1F2,@ps4_sem_init);
lib^.set_proc($7035B6DF7440C16A,@ps4_sem_destroy);
lib^.set_proc($06AF8B455FCDE879,@ps4_sem_getvalue);
lib^.set_proc($20A3FCB72A744149,@ps4_sem_post);
lib^.set_proc($C39207CAF6A183FA,@ps4_sem_timedwait);
lib^.set_proc($5815B3B1189F0840,@ps4_sem_trywait);
lib^.set_proc($602579746181702A,@ps4_sem_wait);
lib^.set_proc($D7CF31E7B258A748,@ps4_sceKernelCreateSema);
lib^.set_proc($47526F9FC6D2096F,@ps4_sceKernelDeleteSema);
lib^.set_proc($6716B45614154EC9,@ps4_sceKernelWaitSema);
lib^.set_proc($E1CCE9A47062AE2C,@ps4_sceKernelSignalSema);
lib^.set_proc($D76C0E1E4F32C1BD,@ps4_sceKernelPollSema);
lib^.set_proc($E03334E94D813446,@ps4_sceKernelCancelSema);
//Sema
//cond
2022-05-31 07:20:10 +00:00
lib^.set_proc($98AA13C74DC74560,@ps4_pthread_condattr_init);
lib^.set_proc($74972E4159FAFC8C,@ps4_pthread_condattr_destroy);
lib^.set_proc($7130D8C5350D3E13,@ps4_pthread_condattr_getclock);
lib^.set_proc($123965680A803D9A,@ps4_pthread_condattr_setclock);
lib^.set_proc($874A94A92B8E982F,@ps4_pthread_condattr_getpshared);
lib^.set_proc($DC1A4FF39D21053E,@ps4_pthread_condattr_setpshared);
2021-12-08 20:04:07 +00:00
lib^.set_proc($D13C959383122EDD,@ps4_pthread_cond_init);
2022-06-10 23:48:17 +00:00
lib^.set_proc($4575EA8B80AD17CC,@ps4_pthread_cond_destroy);
2021-12-08 20:04:07 +00:00
2022-05-31 07:20:10 +00:00
lib^.set_proc($D8C3B2FAB51FBA14,@ps4_pthread_cond_signal);
lib^.set_proc($9A4C767D584D32C8,@ps4_pthread_cond_broadcast);
lib^.set_proc($3A9F130466392878,@ps4_pthread_cond_wait);
lib^.set_proc($DBB6C08222663A1D,@ps4_pthread_cond_timedwait);
2021-12-08 20:04:07 +00:00
lib^.set_proc($9B9FF66EC35FBFBB,@ps4_scePthreadCondattrInit);
lib^.set_proc($C1A3DCC58891DD60,@ps4_scePthreadCondattrDestroy);
lib^.set_proc($D936FDDAABA9AE5D,@ps4_scePthreadCondInit);
lib^.set_proc($83E3D977686269C8,@ps4_scePthreadCondDestroy);
2022-05-31 07:20:10 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($90387F35FC6032D1,@ps4_scePthreadCondSignal);
lib^.set_proc($58A0172785C13D0E,@ps4_scePthreadCondWait);
lib^.set_proc($06632363199EC35C,@ps4_scePthreadCondTimedwait);
lib^.set_proc($246823ED4BEB97E0,@ps4_scePthreadCondBroadcast);
//cond
2022-09-06 12:53:07 +00:00
//barrier
lib^.set_proc($66C5CB16D7768EA4,@ps4_pthread_barrier_init);
lib^.set_proc($F8FAAE6FD1D908FA,@ps4_pthread_barrier_destroy);
lib^.set_proc($09AC1980262A5D69,@ps4_pthread_barrier_wait);
//barrier
2021-12-08 20:04:07 +00:00
//thread
lib^.set_proc($9EC628351CB0C0D8,@ps4_scePthreadAttrInit);
lib^.set_proc($EB6282C04326CDC3,@ps4_scePthreadAttrDestroy);
2022-05-31 07:20:10 +00:00
lib^.set_proc($C2D92DFED791D6CA,@ps4_pthread_attr_init);
lib^.set_proc($CC772163C7EDE699,@ps4_pthread_attr_destroy);
2021-12-08 20:04:07 +00:00
lib^.set_proc($5135F325B5A18531,@ps4_scePthreadAttrSetstacksize);
2022-05-31 07:20:10 +00:00
lib^.set_proc($D90D33EAB9C1AD31,@ps4_pthread_attr_setstacksize);
2021-12-08 20:04:07 +00:00
lib^.set_proc($FD6ADEA6BB6ED10B,@ps4_scePthreadAttrSetdetachstate);
2022-07-14 11:59:03 +00:00
lib^.set_proc($13EB72A37969E4BC,@ps4_pthread_attr_setdetachstate);
2021-12-08 20:04:07 +00:00
lib^.set_proc($E3E87D133C0A1782,@ps4_scePthreadAttrSetschedpolicy);
lib^.set_proc($0F3112F61405E1FE,@ps4_scePthreadAttrSetschedparam);
2022-07-14 11:59:03 +00:00
lib^.set_proc($1573D61CD93C39FD,@ps4_scePthreadAttrGetschedparam);
lib^.set_proc($7AE291826D159F63,@ps4_pthread_attr_setschedparam);
lib^.set_proc($AA593DA522EC5263,@ps4_pthread_attr_getschedparam);
2021-12-08 20:04:07 +00:00
lib^.set_proc($DEAC603387B31130,@ps4_scePthreadAttrSetaffinity);
2022-05-31 07:20:10 +00:00
lib^.set_proc($F3EB39073663C528,@ps4_scePthreadAttrGetaffinity);
2021-12-08 20:04:07 +00:00
lib^.set_proc($7976D44A911A4EC0,@ps4_scePthreadAttrSetinheritsched);
2022-06-01 14:05:23 +00:00
lib^.set_proc($B711ED9E027E7B27,@ps4_scePthreadAttrGetguardsize);
2022-05-31 07:20:10 +00:00
lib^.set_proc($46EDFA7E24ED2730,@ps4_scePthreadAttrGetstackaddr);
lib^.set_proc($FDF03EED99460D0B,@ps4_scePthreadAttrGetstacksize);
lib^.set_proc($FEAB8F6B8484254C,@ps4_scePthreadAttrGetstack);
lib^.set_proc($25A44CCBE41CA5E5,@ps4_scePthreadAttrGetdetachstate);
lib^.set_proc($5544F5652AC74F42,@ps4_pthread_attr_getdetachstate);
2021-12-08 20:04:07 +00:00
2022-05-31 07:20:10 +00:00
lib^.set_proc($C755FBE9AAD83315,@ps4_scePthreadAttrGet);
2022-10-26 13:26:02 +00:00
lib^.set_proc($2668BEF70F6ED04E,@ps4_pthread_create_name_np);
2022-05-31 07:20:10 +00:00
lib^.set_proc($3B184807C2C1FCF4,@ps4_pthread_create);
2022-10-26 13:26:02 +00:00
lib^.set_proc($E9482DC15FB4CDBE,@ps4_scePthreadCreate);
2022-06-28 09:05:15 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($E2A1AB47A7A83FD6,@ps4_scePthreadDetach);
2022-05-31 07:20:10 +00:00
lib^.set_proc($F94D51E16B57BE87,@ps4_pthread_detach);
2022-06-28 09:05:15 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($A27358F41CA7FD6F,@ps4_scePthreadJoin);
2022-06-28 09:05:15 +00:00
lib^.set_proc($87D09C3F7274A153,@ps4_pthread_join);
2022-05-31 07:20:10 +00:00
lib^.set_proc($678428B15B80B00D,@ps4_pthread_once);
lib^.set_proc($D786CE00200D4C1A,@ps4_scePthreadOnce);
lib^.set_proc($DCFB55EA9DD0357E,@ps4_scePthreadEqual);
lib^.set_proc($ED7976E7B33854D2,@ps4_pthread_equal);
2021-12-08 20:04:07 +00:00
lib^.set_proc($DE483BAD3D0D408B,@ps4_scePthreadExit);
2022-05-31 07:20:10 +00:00
lib^.set_proc($149AD3E4BB940405,@ps4_pthread_exit);
2021-12-08 20:04:07 +00:00
2022-10-04 17:27:29 +00:00
lib^.set_proc($959CC5792C4F974F,@ps4_pthread_setcancelstate);
2021-12-08 20:04:07 +00:00
lib^.set_proc($128B51F1ADC049FE,@ps4_pthread_self);
lib^.set_proc($688F8E782CFCC6B4,@ps4_scePthreadSelf);
2022-05-31 07:20:10 +00:00
lib^.set_proc($1E82D558D6A70417,@ps4_getpid);
2022-06-30 21:31:33 +00:00
lib^.set_proc($108FF9FE396AD9D1,@ps4_scePthreadGetthreadid);
2022-05-31 07:20:10 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($1E8C3B07C39EB7A9,@ps4_scePthreadGetname);
lib^.set_proc($181518EF2C1D50B1,@ps4_scePthreadRename);
2022-05-31 07:20:10 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($6EDDC24C12A61B22,@ps4_scePthreadSetaffinity);
2022-05-31 07:20:10 +00:00
lib^.set_proc($ADCAD5149B105916,@ps4_scePthreadGetaffinity);
2022-10-26 13:11:37 +00:00
lib^.set_proc($8345530717C9CAED,@ps4_sceKernelGetCurrentCpu);
2022-05-31 07:20:10 +00:00
2021-12-08 20:04:07 +00:00
lib^.set_proc($D6D2B21BB465309A,@ps4_scePthreadGetprio);
lib^.set_proc($5B41E99B65F4B8F1,@ps4_scePthreadSetprio);
2022-05-31 07:20:10 +00:00
lib^.set_proc($3F8D644D6512DC42,@ps4_scePthreadGetschedparam);
lib^.set_proc($A084454E3A082DB8,@ps4_scePthreadSetschedparam);
lib^.set_proc($08136D5CEA1E7FF1,@ps4_sched_get_priority_max);
lib^.set_proc($9B4892EA336C5DDB,@ps4_sched_get_priority_min);
2021-12-08 20:04:07 +00:00
lib^.set_proc($4FBDA1CFA7DFAB4F,@ps4_scePthreadYield);
2022-05-31 07:20:10 +00:00
lib^.set_proc($0791A65432B0A67D,@ps4_pthread_yield);
2022-10-20 11:34:55 +00:00
lib^.set_proc($E971B8077DCDD3D8,@ps4_sched_yield);
2022-05-31 07:20:10 +00:00
lib^.set_proc($E1979959C32C015D,@ps4_pthread_cleanup_push);
lib^.set_proc($455C5BD12B1AE6DD,@ps4_pthread_cleanup_pop);
lib^.set_proc($D71BED515C75FD28,@ps4___pthread_cleanup_push_imp);
lib^.set_proc($896B0595831FDCAC,@ps4___pthread_cleanup_pop_imp);
lib^.set_proc($9AA50B35D8A64E7D,@ps4_pthread_key_create);
lib^.set_proc($E81A4466E0D3ED82,@ps4_pthread_key_delete);
lib^.set_proc($D3F297692EF4C72E,@ps4_pthread_getspecific);
lib^.set_proc($5AB38BBC7534C903,@ps4_pthread_setspecific);
2021-12-08 20:04:07 +00:00
//thread
lib^.set_proc($5AC95C2B51507062,@ps4_sceKernelIsNeoMode);
2022-09-05 16:44:19 +00:00
lib^.set_proc($9A9C4076A5BB74A6,@ps4_sceKernelIsProspero);
2021-12-08 20:04:07 +00:00
2022-06-01 14:05:23 +00:00
//mmap
2022-10-02 21:52:51 +00:00
lib^.set_proc($93E017AAEDBF7817,@ps4_getpagesize);
2021-12-08 20:04:07 +00:00
lib^.set_proc($A4EF7A4F0CCE9B91,@ps4_sceKernelGetDirectMemorySize);
2022-10-11 14:51:41 +00:00
lib^.set_proc($68DCF5D5F9E7CE2E,@ps4_sceKernelAvailableFlexibleMemorySize);
2022-12-03 17:09:56 +00:00
lib^.set_proc($9F5FEFE85814ECC4,@ps4_sceKernelConfiguredFlexibleMemorySize);
2022-10-02 21:52:51 +00:00
2022-09-29 14:17:37 +00:00
lib^.set_proc($AD35F0EB9C662C80,@ps4_sceKernelAllocateDirectMemory);
lib^.set_proc($07EBDCD803B666B7,@ps4_sceKernelAllocateMainDirectMemory);
2022-06-02 13:25:38 +00:00
lib^.set_proc($0B47FB4C971B7DA7,@ps4_sceKernelAvailableDirectMemorySize);
2022-06-01 14:05:23 +00:00
lib^.set_proc($047A2E2D0CE1D17D,@ps4_sceKernelDirectMemoryQuery);
2022-09-29 14:17:37 +00:00
lib^.set_proc($042F8E1B99BDF9BC,@ps4_sceKernelGetDirectMemoryType);
lib^.set_proc($8705523C29A9E6D3,@ps4_sceKernelCheckedReleaseDirectMemory);
lib^.set_proc($301B88B6F6DAEB3F,@ps4_sceKernelReleaseDirectMemory);
2022-10-02 21:52:51 +00:00
lib^.set_proc($04F13DB3DBD0417A,@ps4_mmap);
lib^.set_proc($3C68501DDFDDCEFF,@ps4_sceKernelMmap);
lib^.set_proc($52A0C68D7039C943,@ps4_munmap);
2021-12-08 20:04:07 +00:00
lib^.set_proc($71091EF54B8140E9,@ps4_sceKernelMunmap);
2022-10-02 21:52:51 +00:00
lib^.set_proc($B5E888B4BD9BA05C,@ps4_sceKernelReleaseFlexibleMemory);
lib^.set_proc($61039FC4BE107DE5,@ps4_mprotect);
lib^.set_proc($BD23009B77316136,@ps4_sceKernelMprotect);
lib^.set_proc($F5B7DD2C8CAEC026,@ps4_sceKernelMtypeprotect);
2021-12-08 20:04:07 +00:00
lib^.set_proc($58571F2F697389DA,@ps4_sceKernelQueryMemoryProtection);
2022-07-13 20:27:56 +00:00
lib^.set_proc($AD58D1BC72745FA7,@ps4_sceKernelVirtualQuery);
lib^.set_proc($0C6306DC9B21AD95,@ps4_sceKernelSetVirtualRangeName);
2022-10-02 21:52:51 +00:00
lib^.set_proc($21620105D4C78ADE,@ps4_sceKernelMapFlexibleMemory);
lib^.set_proc($98BF0D0C7F3A8902,@ps4_sceKernelMapNamedFlexibleMemory);
2022-11-25 12:36:19 +00:00
lib^.set_proc($91CF8B1042186A47,@ps4_sceKernelMapNamedSystemFlexibleMemory);
2022-10-02 21:52:51 +00:00
lib^.set_proc($EE8C6FDCF3C2BA6A,@ps4_sceKernelReserveVirtualRange);
lib^.set_proc($0504278A8963F6D4,@ps4_sceKernelMapDirectMemory2);
lib^.set_proc($2FF4372C48C86E00,@ps4_sceKernelMapDirectMemory);
lib^.set_proc($35C6965317CC3484,@ps4_sceKernelMapNamedDirectMemory);
lib^.set_proc($B59638F9264D1610,@ps4_msync);
lib^.set_proc($0E435E6F1989C952,@ps4_sceKernelMsync);
2021-12-08 20:04:07 +00:00
2022-06-01 14:05:23 +00:00
//mmap
2021-12-08 20:04:07 +00:00
//queue
lib^.set_proc($0F439D14C8E9E3A2,@ps4_sceKernelCreateEqueue);
lib^.set_proc($7F3C8C2ACF648A6D,@ps4_sceKernelWaitEqueue);
lib^.set_proc($BF3FA9836CDDA292,@ps4_sceKernelGetEventUserData);
2022-10-05 09:38:38 +00:00
lib^.set_proc($E11EBF3AF2367040,@ps4_sceKernelAddUserEvent);
lib^.set_proc($583B339926D6B839,@ps4_sceKernelAddUserEventEdge);
2022-11-30 13:16:13 +00:00
lib^.set_proc($2C90F07523539C38,@ps4_sceKernelDeleteUserEvent);
2022-10-05 09:38:38 +00:00
lib^.set_proc($17A7B4930A387279,@ps4_sceKernelTriggerUserEvent);
2021-12-08 20:04:07 +00:00
//queue
2022-05-31 07:20:10 +00:00
//event_flag
lib^.set_proc($0691686E8509A195,@ps4_sceKernelCreateEventFlag);
lib^.set_proc($253BC17E58586B34,@ps4_sceKernelWaitEventFlag);
lib^.set_proc($20E9D2BC7CEABBA0,@ps4_sceKernelSetEventFlag);
lib^.set_proc($EEE8411564404BAD,@ps4_sceKernelClearEventFlag);
2022-06-06 08:48:13 +00:00
lib^.set_proc($F26AA5F4E7109DDE,@ps4_sceKernelDeleteEventFlag);
2022-10-06 14:15:00 +00:00
lib^.set_proc($3D992EE19AD726A8,@ps4_sceKernelCancelEventFlag);
2022-05-31 07:20:10 +00:00
//event_flag
2021-12-08 20:04:07 +00:00
//time
lib^.set_proc($9FCF2FC770B99D6F,@ps4_gettimeofday);
2022-05-31 07:20:10 +00:00
lib^.set_proc($B26223EDEAB3644F,@ps4_clock_getres);
2021-12-08 20:04:07 +00:00
lib^.set_proc($94B313F6F240724D,@ps4_clock_gettime);
2022-05-31 07:20:10 +00:00
lib^.set_proc($7A37A471A35036AD,@ps4_sceKernelGettimeofday);
2022-10-23 13:33:47 +00:00
lib^.set_proc($90E7277ABCA99D00,@ps4_sceKernelGettimezone);
2022-09-15 14:41:58 +00:00
lib^.set_proc($77B9D48F52CE7435,@ps4_clock_settime);
lib^.set_proc($55D5C80C06C9DED4,@ps4_settimeofday);
lib^.set_proc($0A108E0A13D4FD83,@ps4_sceKernelSettimeofday);
2021-12-08 20:04:07 +00:00
lib^.set_proc($D63DD2DE7FED4D6E,@ps4_sceKernelGetTscFrequency);
lib^.set_proc($FF62115023BFFCF3,@ps4_sceKernelReadTsc);
lib^.set_proc($4018BB1C22B4DE1C,@ps4_sceKernelClockGettime);
lib^.set_proc($E09DAC5099AE1D94,@ps4_sceKernelGetProcessTime);
2022-07-13 20:27:56 +00:00
lib^.set_proc($04DA30C76979F3C1,@ps4_sceKernelGetProcessTimeCounterFrequency);
lib^.set_proc($7E0C6731E4CD52D6,@ps4_sceKernelGetProcessTimeCounter);
2021-12-08 20:04:07 +00:00
lib^.set_proc($C92F14D931827B50,@ps4_nanosleep);
2022-10-31 08:41:23 +00:00
lib^.set_proc($42FB19C689AF507B,@ps4_sceKernelNanosleep);
2021-12-08 20:04:07 +00:00
lib^.set_proc($41CB5E4706EC9D5D,@ps4_usleep);
lib^.set_proc($D637D72D15738AC7,@ps4_sceKernelUsleep);
2022-10-31 08:41:23 +00:00
lib^.set_proc($D30BB7DE1BA735D1,@ps4_sleep);
2022-10-08 21:16:44 +00:00
lib^.set_proc($FD947E846EDA0C7C,@ps4_sceKernelSleep);
2021-12-08 20:04:07 +00:00
2022-07-14 11:59:03 +00:00
lib^.set_proc($FE8E6E103A4DFA86,@ps4_sceKernelConvertUtcToLocaltime);
lib^.set_proc($D0D4C737534A38D2,@ps4_sceKernelConvertLocaltimeToUtc);
2021-12-08 20:04:07 +00:00
//time
//file
lib^.set_proc($D46DE51751A0D64F,@ps4_sceKernelOpen);
2022-10-23 16:59:01 +00:00
lib^.set_proc($50AD939760D6527B,@ps4_sceKernelClose);
2021-12-08 20:04:07 +00:00
lib^.set_proc($A226FBE85FF5D9F9,@ps4_sceKernelLseek);
lib^.set_proc($0A0E2CAD9E9329B5,@ps4_sceKernelRead);
lib^.set_proc($FABDEB305C08B55E,@ps4_sceKernelPread);
2022-10-25 20:10:07 +00:00
lib^.set_proc($E304B37BDD8184B2,@ps4_sceKernelWrite);
2022-10-26 09:16:00 +00:00
lib^.set_proc($9CA5A2FCDD87055E,@ps4_sceKernelPwrite);
2022-11-29 07:42:53 +00:00
lib^.set_proc($556DD355988CE3F1,@ps4_sceKernelFtruncate);
2022-10-26 09:16:00 +00:00
lib^.set_proc($901C023EC617FE6E,@ps4_sceKernelFstat);
2021-12-08 20:04:07 +00:00
2022-11-12 21:59:35 +00:00
lib^.set_proc($B5A4568532454E01,@ps4_sceKernelGetdirentries);
lib^.set_proc($8F6008A92A893F4C,@ps4_sceKernelGetdents);
2022-12-06 20:56:38 +00:00
lib^.set_proc($7D3C7AEA5E625880,@ps4_sceKernelFsync);
2022-11-12 21:59:35 +00:00
2022-10-14 13:00:58 +00:00
lib^.set_proc($C2E0ABA081A3B768,@ps4_open); //open
lib^.set_proc($E9CDEB09513F7D35,@ps4_open); //_open
2022-10-23 16:59:01 +00:00
lib^.set_proc($3B2E88A7082D60E9,@ps4_lseek); //lseek
2022-10-14 13:00:58 +00:00
lib^.set_proc($6D8FCF3BA261CE14,@ps4_close); //close
lib^.set_proc($34DB4568A25B3EDD,@ps4_close); //_close
2022-10-23 16:59:01 +00:00
2022-10-03 20:06:13 +00:00
lib^.set_proc($0D1B81B76A6F2029,@ps4_read); //_read
lib^.set_proc($02A062A02DAF1772,@ps4_read); //read
2022-10-23 16:59:01 +00:00
2022-10-26 09:16:00 +00:00
lib^.set_proc($7B3BFF45204D2AA2,@ps4_pread); //pread
2022-10-14 13:00:58 +00:00
lib^.set_proc($F9646590A8D9BDA8,@ps4_readv); //_readv
lib^.set_proc($23B22670B76CFEE5,@ps4_readv); //readv
2022-10-25 20:10:07 +00:00
lib^.set_proc($171559A81000EE4B,@ps4_write); //_write
lib^.set_proc($14DE2068F9AE155F,@ps4_write); //write
2022-10-26 09:16:00 +00:00
lib^.set_proc($0B6909FDBC92E6B3,@ps4_pwrite); //pwrite
2022-05-31 07:20:10 +00:00
2022-11-29 07:42:53 +00:00
lib^.set_proc($8A1E020FDFE08213,@ps4_ftruncate);
2022-05-31 07:20:10 +00:00
lib^.set_proc($9AA40C875CCF3D3F,@ps4_fstat);
2022-11-12 21:59:35 +00:00
lib^.set_proc($7F4F4ABC83F2FD06,@ps4_getdirentries);
lib^.set_proc($D86EA2EA13085146,@ps4_getdents);
2022-12-06 20:56:38 +00:00
lib^.set_proc($8EE59B4CD33EF21C,@ps4_fsync);
2022-11-12 21:59:35 +00:00
2022-10-26 09:16:00 +00:00
lib^.set_proc($13A6A8DF8C0FC3E5,@ps4_stat);
lib^.set_proc($795F70003DAB8880,@ps4_sceKernelStat);
2021-12-08 20:04:07 +00:00
lib^.set_proc($246322A3EDB52F87,@ps4_mkdir);
2022-10-26 09:16:00 +00:00
lib^.set_proc($D7F2C52E6445C713,@ps4_sceKernelMkdir);
2021-12-08 20:04:07 +00:00
2022-11-28 21:09:07 +00:00
lib^.set_proc($540CECC2F4CE0B32,@ps4_unlink);
lib^.set_proc($0145D5C5678953F0,@ps4_sceKernelUnlink);
2022-11-30 16:19:06 +00:00
lib^.set_proc($73B6674FB57507DF,@ps4_rmdir);
lib^.set_proc($9DA22752362DDECA,@ps4_sceKernelRmdir);
2022-07-15 10:12:45 +00:00
lib^.set_proc($B96C96DEFF7CB14E,@ps4_sceKernelCheckReachability);
2021-12-08 20:04:07 +00:00
//file
px:=Result._add_lib('libScePosix');
px^.MapSymbol:=lib^.MapSymbol;
2022-09-05 16:44:19 +00:00
px:=Result._add_lib('libkernel_cpumode_platform');
px^.MapSymbol:=lib^.MapSymbol;
2022-05-31 07:20:10 +00:00
lib:=Result._add_lib('libkernel_unity');
lib^.set_proc($5A4C0477737BC346,@ps4_sceKernelInstallExceptionHandler);
2022-10-04 13:44:45 +00:00
lib^.set_proc($421BF90110283847,@ps4_sceKernelRemoveExceptionHandler);
2022-05-31 07:20:10 +00:00
lib^.set_proc($8A5D379E5B8A7CC9,@ps4_sceKernelRaiseException);
2022-09-30 21:25:10 +00:00
//
2022-11-12 21:59:35 +00:00
_kernel_init;
2021-12-08 20:04:07 +00:00
end;
initialization
ps4_app.RegistredPreLoad('libSceSysmodule.prx',@Load_libSceSysmodule);
ps4_app.RegistredPreLoad('libkernel.prx',@Load_libkernel);
end.