From d5b83b663f21c943fa42b6bd3b9d46353e2e7c66 Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Fri, 10 Jun 2022 10:00:15 +0300 Subject: [PATCH] + --- fpPS4.lpr | 10 ++- ps4_elf.pas | 16 ++-- ps4_libkernel/ps4_libkernel.pas | 25 +++++- ps4_libkernel/ps4_pthread.pas | 1 + ps4_libscediscmap.pas | 9 +++ ps4_libscevideoout.pas | 135 ++++++++++++++++++++++++++++++++ ps4_program.pas | 49 +++++++----- 7 files changed, 215 insertions(+), 30 deletions(-) diff --git a/fpPS4.lpr b/fpPS4.lpr index 0a373bd..a95dda8 100644 --- a/fpPS4.lpr +++ b/fpPS4.lpr @@ -467,6 +467,15 @@ begin //ps4_app.app_path:='C:\Users\User\Desktop\Games\Super Meat Boy\'; //ps4_app.app_file:='C:\Users\User\Desktop\Games\Super Meat Boy\eboot.bin'; + //ps4_app.app_path:='G:\Games\Limbo\CUSA01369\'; + //ps4_app.app_file:='G:\Games\Limbo\CUSA01369\eboot.bin'; + + //ps4_app.app_path:='G:\Games\Hue\CUSA05065\'; + //ps4_app.app_file:='G:\Games\Hue\CUSA05065\eboot.bin'; + + //ps4_app.app_path:='C:\Users\User\Desktop\Games\Hue\CUSA05065\'; + //ps4_app.app_file:='C:\Users\User\Desktop\Games\Hue\CUSA05065\eboot.bin'; + //elf:=Telf_file(LoadPs4ElfFromFile('libSceLibcInternal.sprx')); //elf.Prepare; //elf.SavePs4ElfToFile('libSceLibcInternal.prx'); @@ -488,7 +497,6 @@ begin Stub.FinStub; ps4_app.InitProt; - ps4_app.InitThread(1); _pthread_run_entry(@main); diff --git a/ps4_elf.pas b/ps4_elf.pas index c8f0675..ccb4b6f 100644 --- a/ps4_elf.pas +++ b/ps4_elf.pas @@ -2495,10 +2495,10 @@ end; procedure Telf_file.mapCodeInit; var Prog:Telf_file; - i,c:SizeInt; - StartupParams:TPS4StartupParams; - base:Pointer; - P:PPointer; + //i,c:SizeInt; + //StartupParams:TPS4StartupParams; + //base:Pointer; + //P:PPointer; begin if (Self=nil) then Exit; Prog:=Telf_file(ps4_app.prog); @@ -2506,11 +2506,11 @@ begin Writeln('mapCodeInit:',pFileName); - StartupParams:=Default(TPS4StartupParams); - StartupParams.argc:=1; - StartupParams.argv[0]:=PChar(Prog.pFileName); + //StartupParams:=Default(TPS4StartupParams); + //StartupParams.argc:=1; + //StartupParams.argv[0]:=PChar(Prog.pFileName); - base:=mMap.pAddr; + //base:=mMap.pAddr; if (Prog<>Self) then begin diff --git a/ps4_libkernel/ps4_libkernel.pas b/ps4_libkernel/ps4_libkernel.pas index 3443de3..2d4dbe8 100644 --- a/ps4_libkernel/ps4_libkernel.pas +++ b/ps4_libkernel/ps4_libkernel.pas @@ -256,6 +256,7 @@ begin node:=LoadPs4ElfFromFile(fn); if (node<>nil) then begin + node.IsStatic:=False; node.Acqure; node.Prepare; @@ -266,9 +267,13 @@ begin ps4_app.InitProt; ps4_app.InitThread(0); - Result:=node.Handle; + node.IsInit:=True; //mark exclude + + ps4_app.InitCode; i:=node.module_start(argc,argp); + + Result:=node.Handle; node.Release; if (pRes<>nil) then pRes^:=i; @@ -348,6 +353,22 @@ begin Writeln('sceKernelGetModuleList:',HexStr(list),' ',numArray,' ',i); end; +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; + function ps4_memset(ptr:Pointer;value:Integer;num:size_t):Pointer; SysV_ABI_CDecl; begin FillByte(ptr^,num,Byte(value)); @@ -680,6 +701,8 @@ begin lib^.set_proc($22EC6752E5E4E818,@ps4_sceKernelGetModuleList); lib^.set_proc($2F01BC8379E2AB00,@ps4_sceKernelDlsym); + lib^.set_proc($54EC7C3469875D3B,@ps4_sceKernelGetCpumode); + //mutex lib^.set_proc($7501D612C26DA04E,@ps4_pthread_mutexattr_init); diff --git a/ps4_libkernel/ps4_pthread.pas b/ps4_libkernel/ps4_pthread.pas index e0911c7..de603e9 100644 --- a/ps4_libkernel/ps4_pthread.pas +++ b/ps4_libkernel/ps4_pthread.pas @@ -324,6 +324,7 @@ end; function on_ps4_run_entry(arg:Pointer):Pointer; SysV_ABI_CDecl; begin Result:=nil; + ps4_app.InitThread(1); ps4_app.InitCode; Telf_file(ps4_app.prog).mapCodeEntry; end; diff --git a/ps4_libscediscmap.pas b/ps4_libscediscmap.pas index 4d0b485..75413f3 100644 --- a/ps4_libscediscmap.pas +++ b/ps4_libscediscmap.pas @@ -29,6 +29,14 @@ begin Result:=0; end; +function ps4_7C980FFB0AA27E7A(param1:PChar;param2,param3:Int64;param4,param5,param6:PInt64):Integer; SysV_ABI_CDecl; +begin + param4^:=0; + param5^:=0; + param6^:=0; + Result:=0; +end; + function Load_libSceDiscMap(Const name:RawByteString):TElf_node; var lib:PLIBRARY; @@ -39,6 +47,7 @@ begin lib:=Result._add_lib('libSceDiscMap'); lib^.set_proc($95B40AAAC11186D1,@ps4_sceDiscMapIsRequestOnHDD); lib^.set_proc($8A828CAEE7EDD5E9,@ps4_8A828CAEE7EDD5E9); + lib^.set_proc($7C980FFB0AA27E7A,@ps4_7C980FFB0AA27E7A); end; initialization diff --git a/ps4_libscevideoout.pas b/ps4_libscevideoout.pas index 1308d3f..0cfe685 100644 --- a/ps4_libscevideoout.pas +++ b/ps4_libscevideoout.pas @@ -1414,6 +1414,139 @@ begin Result:=0; end; +const +//SceVideoOutDeviceCapability + SCE_VIDEO_OUT_DEVICE_CAPABILITY_YUV = 1; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_XVYCC = 1 shl 1; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_S3D_FRAME_PACKING_59_94HZ = 1 shl 2; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_VR_VIEW_59_94HZ = 1 shl 4; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_VR_VIEW_119_88HZ = 1 shl 5; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_VR_VIEW_89_91HZ = 1 shl 6; + SCE_VIDEO_OUT_DEVICE_CAPABILITY_BT2020_PQ = 1 shl 7; + +//SceVideoOutSignalEncoding + SCE_VIDEO_OUT_SIGNAL_ENCODING_UNKNOWN = 0; + SCE_VIDEO_OUT_SIGNAL_ENCODING_RGB444 = 1; + SCE_VIDEO_OUT_SIGNAL_ENCODING_YUV444 = 2; + SCE_VIDEO_OUT_SIGNAL_ENCODING_YUV422 = 3; + + SCE_VIDEO_OUT_SIGNAL_ENCODING_ANY = $FF; + + +//SceVideoOutSignalRange + SCE_VIDEO_OUT_SIGNAL_RANGE_UNKNOWN = 0; + SCE_VIDEO_OUT_SIGNAL_RANGE_LIMITED = 1; + SCE_VIDEO_OUT_SIGNAL_RANGE_FULL = 2; + + SCE_VIDEO_OUT_SIGNAL_RANGE_ANY = $FF; + +//SceVideoOutColorimetry + SCE_VIDEO_OUT_COLORIMETRY_UNKNOWN = 0; + SCE_VIDEO_OUT_COLORIMETRY_SRGB = 1; + SCE_VIDEO_OUT_COLORIMETRY_CERGB = 2; + SCE_VIDEO_OUT_COLORIMETRY_YCBCR = 3; + SCE_VIDEO_OUT_COLORIMETRY_YCBCR601 = 4; + SCE_VIDEO_OUT_COLORIMETRY_YCBCR709 = 5; + SCE_VIDEO_OUT_COLORIMETRY_XVYCC = 6; + SCE_VIDEO_OUT_COLORIMETRY_XVYCC601 = 7; + SCE_VIDEO_OUT_COLORIMETRY_XVYCC709 = 8; + + SCE_VIDEO_OUT_COLORIMETRY_BT2020 = 9 ; // RGB or YCbCr + SCE_VIDEO_OUT_COLORIMETRY_RGB2020 = 10; + SCE_VIDEO_OUT_COLORIMETRY_YCBCR2020 = 11; + + SCE_VIDEO_OUT_COLORIMETRY_BT2020_PQ = 12; // RGB or YCbCr + SCE_VIDEO_OUT_COLORIMETRY_RGB2020_PQ = 13; + SCE_VIDEO_OUT_COLORIMETRY_YCBCR2020_PQ = 14; + + SCE_VIDEO_OUT_COLORIMETRY_ANY = $FF; + +//SceVideoOutColorDepth + SCE_VIDEO_OUT_COLOR_DEPTH_UNKNOWN = 0 ; + SCE_VIDEO_OUT_COLOR_DEPTH_24BPP = 24; + SCE_VIDEO_OUT_COLOR_DEPTH_30BPP = 30; + SCE_VIDEO_OUT_COLOR_DEPTH_36BPP = 36; + + SCE_VIDEO_OUT_COLOR_DEPTH_ANY = $FF; + + +//SceVideoOutResolution + SCE_VIDEO_OUT_RESOLUTION_UNKNOWN = 0; + + SCE_VIDEO_OUT_RESOLUTION_480I = 1; + SCE_VIDEO_OUT_RESOLUTION_480I_WIDESCREEN = 2; + SCE_VIDEO_OUT_RESOLUTION_576I = 3; + SCE_VIDEO_OUT_RESOLUTION_576I_WIDESCREEN = 4; + + SCE_VIDEO_OUT_RESOLUTION_480P = 5; + SCE_VIDEO_OUT_RESOLUTION_480P_WIDESCREEN = 6; + SCE_VIDEO_OUT_RESOLUTION_576P = 7; + SCE_VIDEO_OUT_RESOLUTION_576P_WIDESCREEN = 8; + + SCE_VIDEO_OUT_RESOLUTION_720P = 9; + SCE_VIDEO_OUT_RESOLUTION_1080I = 10; + SCE_VIDEO_OUT_RESOLUTION_1080P = 11; + + SCE_VIDEO_OUT_RESOLUTION_720P_S3D_FRAME_PACKING = $A0; + + SCE_VIDEO_OUT_RESOLUTION_1080P_VR_VIEW = $E1; + + SCE_VIDEO_OUT_RESOLUTION_ANY_S3D = $FFFFFFFF81FFFFFF; + SCE_VIDEO_OUT_RESOLUTION_ANY_VR_VIEW = $FFFFFFFFC1FFFFFF; + SCE_VIDEO_OUT_RESOLUTION_ANY = $FFFFFFFFFFFFFFFF; + +//SceVideoOutContentType + SCE_VIDEO_OUT_CONTENT_TYPE_UNKNOWN = 0; + SCE_VIDEO_OUT_CONTENT_TYPE_GRAPHICS = 1; + SCE_VIDEO_OUT_CONTENT_TYPE_PHOTO = 2; + SCE_VIDEO_OUT_CONTENT_TYPE_CINEMA = 3; + SCE_VIDEO_OUT_CONTENT_TYPE_GAME = 4; + SCE_VIDEO_OUT_CONTENT_TYPE_ANY = $FF; + + +type + pSceVideoOutMode=^SceVideoOutMode; + SceVideoOutMode=packed record + size:DWORD; // sizeof(SceVideoOutMode) + signalEncoding:Byte; // SceVideoOutSignalEncoding + signalRange:Byte; // SceVideoOutSignalRange + colorimetry:Byte; // SceVideoOutColorimetry + depth:Byte; // SceVideoOutColorDepth + refreshRate:QWORD; // SceVideoOutRefreshRate + resolution:QWORD; // SceVideoOutResolution + contentType:Byte; // SceVideoOutContentType + _reserved0:array[0..2] of Byte; + _reserved:DWORD; + end; + +function ps4_sceVideoOutModeSetAny_(pMode:pSceVideoOutMode;sizeOfMode:DWORD):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + +type + SceVideoOutVrViewCropAdjustment=packed record + verticalOffset:Word; + reserved0:Word; + reserved1:array[0..2] of DWORD; + end; + + SceVideoOutConfigureOptions=packed record + vrViewCropAdjustment:SceVideoOutVrViewCropAdjustment; + end; + pSceVideoOutConfigureOptions=^SceVideoOutConfigureOptions; + + +function ps4_sceVideoOutConfigureOutputMode_(handle:Integer; + reserved:DWORD; + pMode:pSceVideoOutMode; + pOptions:pSceVideoOutConfigureOptions; + sizeOfMode:DWORD; + sizeOfOptions:DWORD):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + // function Load_libSceVideoOut(Const name:RawByteString):TElf_node; @@ -1444,6 +1577,8 @@ begin lib^.set_proc($1E26CEB5ECF34FA3,@ps4_sceVideoOutCursorIsUpdatePending); lib^.set_proc($D456412B2F0778D5,@ps4_sceVideoOutGetVblankStatus); lib^.set_proc($313C71ACE09E4A28,@ps4_sceVideoOutSetWindowModeMargins); + lib^.set_proc($A63903B20C658BA7,@ps4_sceVideoOutModeSetAny_); + lib^.set_proc($3756C4A09E12470E,@ps4_sceVideoOutConfigureOutputMode_); end; initialization diff --git a/ps4_program.pas b/ps4_program.pas index 23f1247..5675d41 100644 --- a/ps4_program.pas +++ b/ps4_program.pas @@ -48,6 +48,7 @@ type pPrev,pNext:TElf_node; protected FHandle:Integer; + FStatic:Boolean; FPrepared:Boolean; FLoadImport:Boolean; FInitProt:Boolean; @@ -66,26 +67,29 @@ type function _get_lib(id:Word):PLIBRARY; inline; public pFileName:RawByteString; - property Handle:Integer read FHandle; - property Next:TElf_node read pNext; - function _add_lib(const strName:RawByteString):PLIBRARY; - function ModuleNameFromId(id:WORD):RawByteString; - function LibraryNameFromId(id:WORD):RawByteString; - destructor Destroy; override; - Procedure Clean; virtual; - function Prepare:Boolean; virtual; - Procedure LoadSymbolImport(cbs,data:Pointer); virtual; - Procedure ReLoadSymbolImport(cbs,data:Pointer); virtual; - Procedure InitThread(is_static:QWORD); virtual; - Procedure FreeThread; virtual; - Procedure InitProt; virtual; - Procedure InitCode; virtual; - function module_start(argc:size_t;argp:PPointer):Integer; virtual; - function GetCodeFrame:TMemChunk; virtual; - function GetEntryPoint:Pointer; virtual; - Function GetModuleInfo:TKernelModuleInfo; virtual; - Function get_proc(nid:QWORD):Pointer; - Function get_proc_by_name(const name:RawByteString):Pointer; + property IsStatic:Boolean read FStatic write FStatic; + property IsInit:Boolean read FInitCode write FInitCode; + property Handle:Integer read FHandle; + property Next:TElf_node read pNext; + function _add_lib(const strName:RawByteString):PLIBRARY; + function ModuleNameFromId(id:WORD):RawByteString; + function LibraryNameFromId(id:WORD):RawByteString; + Constructor Create; + destructor Destroy; override; + Procedure Clean; virtual; + function Prepare:Boolean; virtual; + Procedure LoadSymbolImport(cbs,data:Pointer); virtual; + Procedure ReLoadSymbolImport(cbs,data:Pointer); virtual; + Procedure InitThread(is_static:QWORD); virtual; + Procedure FreeThread; virtual; + Procedure InitProt; virtual; + Procedure InitCode; virtual; + function module_start(argc:size_t;argp:PPointer):Integer; virtual; + function GetCodeFrame:TMemChunk; virtual; + function GetEntryPoint:Pointer; virtual; + Function GetModuleInfo:TKernelModuleInfo; virtual; + Function get_proc(nid:QWORD):Pointer; + Function get_proc_by_name(const name:RawByteString):Pointer; end; TOnElfLoadCb=function(Const name:RawByteString):TElf_node; @@ -802,6 +806,11 @@ begin SetLength(aLibs,0); end; +Constructor TElf_node.Create; +begin + FStatic:=True; +end; + destructor TElf_node.Destroy; begin Clean;