From f6d88d3561a5e47e6b6d45bc908ae4359102cb03 Mon Sep 17 00:00:00 2001 From: red-prig Date: Tue, 25 Oct 2022 22:43:08 +0300 Subject: [PATCH] + --- fpPS4.lpr | 6 ++--- kernel/mm_adr_virtual.pas | 13 +++++++--- src/ajm/ps4_libsceajm.pas | 45 ++++++++++++++++++++++++++++++++ src/np/ps4_libscenpmanager.pas | 47 ++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 6 deletions(-) diff --git a/fpPS4.lpr b/fpPS4.lpr index 73fe93f..5ec906b 100644 --- a/fpPS4.lpr +++ b/fpPS4.lpr @@ -312,7 +312,7 @@ begin end; { - if (Result<>nil) and (Info^.sType=STT_FUN) then //trace + if (Result<>nil) and ((Info^.sType=STT_FUN) or (Info^.sType=STT_SCE)) then //trace begin Case Info^.lib^.strName of @@ -406,11 +406,11 @@ begin if (Result=nil) then begin - if (Info^.sType=STT_FUN) then + if (Info^.sType=STT_FUN) or (Info^.sType=STT_SCE) then begin Result:=Stub.NewNopStub(Info^.Nid,Info^.lib,@print_stub); - //Writeln('Warn^:',Info^.lib^.strName,':',ps4libdoc.GetFunctName(Info^.Nid),':',HexStr(Info^.Nid,16)); end else + if (Info^.sBind<>STB_WEAK) then begin Writeln(StdErr,'Warn^:',Info^.lib^.strName,':',ps4libdoc.GetFunctName(Info^.Nid),':',HexStr(Info^.Nid,16)); end; diff --git a/kernel/mm_adr_virtual.pas b/kernel/mm_adr_virtual.pas index 327caaf..a2f8226 100644 --- a/kernel/mm_adr_virtual.pas +++ b/kernel/mm_adr_virtual.pas @@ -221,7 +221,8 @@ begin BT_PRIV, BT_GPUM: begin - err:=_VirtualReserve(Pointer(FOffset),ASize,prot); + //err:=_VirtualReserve(Pointer(FOffset),ASize,prot); + err:=_VirtualAlloc(Pointer(FOffset),ASize,prot); if (err<>0) then begin Writeln(StdErr,'_VirtualReserve(',HexStr(FOffset),',',HexStr(ASize,16),'):',err); @@ -394,7 +395,8 @@ begin BT_PRIV, BT_GPUM: begin - Result:=_VirtualCommit(Pointer(key^.Offset),key^.Size,prot); + //Result:=_VirtualCommit(Pointer(key^.Offset),key^.Size,prot); + Result:=0; if (Result=0) then begin key^.F.prot:=prot; @@ -452,7 +454,8 @@ begin Rsrv:=Rsrv+key^.Size; //+ end; - Result:=_VirtualDecommit(Pointer(key^.Offset),key^.Size); + //Result:=_VirtualDecommit(Pointer(key^.Offset),key^.Size); + Result:=0; end; function TVirtualAdrBlock.Protect(key:PVirtualAdrNode;prot:Integer):Integer; @@ -1980,6 +1983,10 @@ begin begin Result:='FREE'; end else + if (key.block=nil) then + begin + Result:='SYST'; + end else if (key.F.reserv<>0) then begin Result:='RSRV'; diff --git a/src/ajm/ps4_libsceajm.pas b/src/ajm/ps4_libsceajm.pas index add86bb..df25bef 100644 --- a/src/ajm/ps4_libsceajm.pas +++ b/src/ajm/ps4_libsceajm.pas @@ -23,6 +23,10 @@ const SCE_AJM_CODEC_CELP_DEC =12; SCE_AJM_CODEC_CELP_ENC =13; + SCE_AJM_FLAG_SIDEBAND_STREAM =(1 shl 47); + SCE_AJM_FLAG_SIDEBAND_FORMAT =(1 shl 46); + SCE_AJM_FLAG_SIDEBAND_GAPLESS_DECODE=(1 shl 45); + var FAjmMap:TIntegerHandles; @@ -41,6 +45,25 @@ type iInternalResult:SceAjmResult; end; + SceAjmSidebandStream=packed record + iSizeConsumed:Integer; + iSizeProduced:Integer; + uiTotalDecodedSamples:QWORD; + end; + + SceAjmSidebandDecAt9CodecInfo=packed record + uiSuperFrameSize:DWORD; + uiFramesInSuperFrame:DWORD; + uiNextFrameSize:DWORD; + uiFrameSamples:DWORD; + end; + + pSceAjmDecAt9GetCodecInfoResult=^SceAjmDecAt9GetCodecInfoResult; + SceAjmDecAt9GetCodecInfoResult=packed record + sResult:SceAjmSidebandResult; + sCodecInfo:SceAjmSidebandDecAt9CodecInfo; + end; + pSceAjmBuffer=^SceAjmBuffer; SceAjmBuffer=packed record pAddress:Pointer; @@ -332,6 +355,23 @@ begin H.Release; end; +type + pSceAjmSidebandStreamResult=^SceAjmSidebandStreamResult; + SceAjmSidebandStreamResult=packed record + sResult:SceAjmSidebandResult; + sStream:SceAjmSidebandStream; + end; + +procedure FixSideband(uiFlags:qword;pSidebandOutput:Pointer;szSidebandOutputSize:qword); +begin + if ((uiFlags and SCE_AJM_FLAG_SIDEBAND_STREAM)<>0) then + begin + pSceAjmSidebandStreamResult(pSidebandOutput)^.sStream.iSizeConsumed:=1; + pSceAjmSidebandStreamResult(pSidebandOutput)^.sStream.iSizeProduced:=1; + pSceAjmSidebandStreamResult(pSidebandOutput)^.sStream.uiTotalDecodedSamples:=1; //loop or div to zero + end; +end; + function ps4_sceAjmBatchJobControlBufferRa( pBatchPosition:Pointer; uiInstance:SceAjmInstanceId; @@ -346,7 +386,9 @@ begin if (pSidebandOutput<>nil) then begin FillChar(pSidebandOutput^,szSidebandOutputSize,0); + FixSideband(uiFlags,pSidebandOutput,szSidebandOutputSize); end; + end; function ps4_sceAjmBatchJobRunBufferRa( @@ -362,9 +404,11 @@ function ps4_sceAjmBatchJobRunBufferRa( pReturnAddress:PPointer):Pointer; SysV_ABI_CDecl; begin Result:=nil; + if (pSidebandOutput<>nil) then begin FillChar(pSidebandOutput^,szSidebandOutputSize,0); + FixSideband(uiFlags,pSidebandOutput,szSidebandOutputSize); end; FillChar(pDataOutput^,szDataOutputSize,0); @@ -388,6 +432,7 @@ begin if (pSidebandOutput<>nil) then begin FillChar(pSidebandOutput^,szSidebandOutputSize,0); + FixSideband(uiFlags,pSidebandOutput,szSidebandOutputSize); end; if (pDataOutputBuffers<>nil) and (szNumDataOutputBuffers<>0) then diff --git a/src/np/ps4_libscenpmanager.pas b/src/np/ps4_libscenpmanager.pas index 4c0a0d5..06a1655 100644 --- a/src/np/ps4_libscenpmanager.pas +++ b/src/np/ps4_libscenpmanager.pas @@ -5,6 +5,7 @@ unit ps4_libSceNpManager; interface uses + windows, ps4_program, Classes, SysUtils; @@ -14,6 +15,7 @@ Const type // Np country code (ISO 3166-1 two-letter system) + pSceNpCountryCode=^SceNpCountryCode; SceNpCountryCode=packed record data:array[0..SCE_NP_COUNTRY_CODE_LENGTH-1] of AnsiChar; term:AnsiChar; @@ -130,6 +132,50 @@ begin Result:=0; end; +const + GEOCLASS_NATION = 16; + + GEO_ISO2 = $0004; + +type + GEOID = LONG; + GEOTYPE = DWORD; + GEOCLASS = DWORD; + +function GetUserGeoID(GeoClass: GEOCLASS):GEOID; stdcall external kernel32; + +function GetGeoInfoA(Location: GEOID; GeoType: GEOTYPE; lpGeoData: LPSTR; + cchData: Integer; LangId: LANGID): Integer; stdcall external kernel32; + +function ps4_sceNpGetAccountCountry(onlineId:pSceNpOnlineId;pCountryCode:pSceNpCountryCode):Integer; SysV_ABI_CDecl; +var + g:GEOID; + s:integer; + b:RawByteString; +begin + if (onlineId=nil) then Exit(SCE_NP_ERROR_INVALID_ARGUMENT); + if (pCountryCode=nil) then Exit(SCE_NP_ERROR_INVALID_ARGUMENT); + + g:=GetUserGeoID(GEOCLASS_NATION); + s:=GetGeoInfoA(g,GEO_ISO2,nil,0,0); + SetLength(b,s); + GetGeoInfoA(g,GEO_ISO2,PChar(b),s,0); + + if (s>=2) then + begin + pCountryCode^:=Default(SceNpCountryCode); + pCountryCode^.data[0]:=LowerCase(b[1]); + pCountryCode^.data[1]:=LowerCase(b[2]); + end else + begin + pCountryCode^:=Default(SceNpCountryCode); + pCountryCode^.data[0]:='u'; + pCountryCode^.data[1]:='s'; + end; + + Result:=0; +end; + function ps4_sceNpGetNpId(userId:Integer;npId:PSceNpId):Integer; SysV_ABI_CDecl; begin npId^:=Default(SceNpId); @@ -365,6 +411,7 @@ begin lib:=Result._add_lib('libSceNpManager'); lib^.set_proc($036090DE4812A294,@ps4_sceNpSetContentRestriction); lib^.set_proc($ADB9276948E9A96A,@ps4_sceNpGetAccountIdA); + lib^.set_proc($1A1CFD8960D4B42E,@ps4_sceNpGetAccountCountry); lib^.set_proc($A7FA3BE029E83736,@ps4_sceNpGetNpId); lib^.set_proc($5C39DC5D02095129,@ps4_sceNpGetOnlineId); lib^.set_proc($7901FB9D63DC0207,@ps4_sceNpGetState);