From d52ef7a382c815bd7ff276dc4d44c64769522c6f Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:59:06 +0300 Subject: [PATCH] + --- kernel/ps4_time.pas | 34 +--------- src/np/ps4_libscenpmanager.pas | 2 +- src/ps4_libscedialogs.pas | 13 +++- src/ps4_libscehttp.pas | 112 ++++++++++++++++++++++++++++++++- src/ps4_libscenet.pas | 6 ++ sys/sys_time.pas | 34 +++++++++- 6 files changed, 163 insertions(+), 38 deletions(-) diff --git a/kernel/ps4_time.pas b/kernel/ps4_time.pas index baf14fc..9096ef6 100644 --- a/kernel/ps4_time.pas +++ b/kernel/ps4_time.pas @@ -118,32 +118,6 @@ begin Result:=t1-t2; end; -function SwGetProcessTime(var ut:QWORD):Boolean; -var - ct,et,kt:TFileTime; -begin - QWORD(ct):=0; - QWORD(et):=0; - QWORD(kt):=0; - ut:=0; - _sig_lock; - Result:=GetProcessTimes(GetCurrentProcess,ct,et,kt,TFileTime(ut)); - _sig_unlock; -end; - -function SwGetThreadTime(var ut:QWORD):Boolean; -var - ct,et,kt:TFileTime; -begin - QWORD(ct):=0; - QWORD(et):=0; - QWORD(kt):=0; - ut:=0; - _sig_lock; - Result:=GetThreadTimes(GetCurrentProcess,ct,et,kt,TFileTime(ut)); - _sig_unlock; -end; - function ps4_gettimeofday(tv:Ptimeval;tz:Ptimezone):Integer; SysV_ABI_CDecl; Var tp:timespec; @@ -247,9 +221,7 @@ begin case clock_id of CLOCK_SECOND: begin - _sig_lock; - GetSystemTimeAsFileTime(TFILETIME(pc)); - _sig_unlock; + SwGetSystemTimeAsFileTime(TFILETIME(pc)); pc:=pc-DELTA_EPOCH_IN_100NS; tp^.tv_sec :=pc div POW10_7; //tp^.tv_nsec:=(QWORD(pc) mod POW10_7)*100; @@ -260,9 +232,7 @@ begin CLOCK_REALTIME_PRECISE, CLOCK_REALTIME_FAST: begin - _sig_lock; - GetSystemTimeAsFileTime(TFILETIME(pc)); - _sig_unlock; + SwGetSystemTimeAsFileTime(TFILETIME(pc)); pc:=pc-DELTA_EPOCH_IN_100NS; tp^.tv_sec :=(pc div POW10_7); tp^.tv_nsec:=(pc mod POW10_7)*100; diff --git a/src/np/ps4_libscenpmanager.pas b/src/np/ps4_libscenpmanager.pas index 1d11b4f..78e32e5 100644 --- a/src/np/ps4_libscenpmanager.pas +++ b/src/np/ps4_libscenpmanager.pas @@ -266,7 +266,7 @@ function ps4_sceNpCheckCallbackForLib():Integer; SysV_ABI_CDecl; begin if (Cb4Toolkit.callback<>nil) then begin - //Cb4Toolkit.callback(0,SCE_NP_STATE_SIGNED_OUT,Cb4Toolkit.userdata); + //Cb4Toolkit.callback(0,SCE_NP_STATE_SIGNED_OUT,nil,Cb4Toolkit.userdata); end; Result:=0; end; diff --git a/src/ps4_libscedialogs.pas b/src/ps4_libscedialogs.pas index 77f5466..4a2b5c0 100644 --- a/src/ps4_libscedialogs.pas +++ b/src/ps4_libscedialogs.pas @@ -99,6 +99,7 @@ end; function ps4_sceErrorDialogTerminate():Integer; SysV_ABI_CDecl; begin + Writeln('sceErrorDialogTerminate'); status_err_dialog:=0; //SCE_ERROR_DIALOG_STATUS_NONE Result:=0; end; @@ -121,7 +122,6 @@ end; function ps4_sceSaveDataDialogUpdateStatus():Integer; SysV_ABI_CDecl; begin - //Writeln('sceSaveDataDialogUpdateStatus'); Result:=SCE_COMMON_DIALOG_STATUS_NONE; end; @@ -161,6 +161,7 @@ const function ps4_sceSaveDataDialogGetResult(_result:pSceSaveDataDialogResult):Integer; SysV_ABI_CDecl; begin + Writeln('sceSaveDataDialogGetResult'); Result:=SCE_COMMON_DIALOG_ERROR_NOT_FINISHED; end; @@ -173,6 +174,7 @@ type function ps4_sceSaveDataDialogClose(closeParam:pSceSaveDataDialogCloseParam):Integer; SysV_ABI_CDecl; begin + Writeln('sceSaveDataDialogClose'); Result:=0; end; @@ -246,6 +248,8 @@ function ps4_sceMsgDialogOpen(param:pSceMsgDialogParam):Integer; SysV_ABI_CDecl; begin if (param=nil) then Exit(SCE_COMMON_DIALOG_ERROR_ARG_NULL); + Writeln('sceMsgDialogOpen'); + Case param^.mode of SCE_MSG_DIALOG_MODE_USER_MSG: begin @@ -266,6 +270,7 @@ end; function ps4_sceMsgDialogClose():Integer; SysV_ABI_CDecl; begin + Writeln('sceMsgDialogClose'); status_msg_dialog:=SCE_COMMON_DIALOG_STATUS_FINISHED; Result:=0; end; @@ -291,6 +296,7 @@ type function ps4_sceMsgDialogGetResult(pResult:pSceMsgDialogResult):Integer; SysV_ABI_CDecl; begin + Writeln('sceMsgDialogGetResult'); if (pResult<>nil) then begin pResult^.result:=0; @@ -301,6 +307,7 @@ end; function ps4_sceMsgDialogTerminate():Integer; SysV_ABI_CDecl; begin + Writeln('sceMsgDialogTerminate'); status_msg_dialog:=SCE_COMMON_DIALOG_STATUS_NONE; Result:=0; end; @@ -334,6 +341,7 @@ type function ps4_sceNpCommerceDialogOpen(param:pSceNpCommerceDialogParam):Integer; SysV_ABI_CDecl; begin + Writeln('sceNpCommerceDialogOpen'); status_commerce_dialog:=SCE_COMMON_DIALOG_STATUS_FINISHED; Result:=0; end; @@ -356,6 +364,7 @@ type function ps4_sceNpCommerceDialogGetResult(pResult:pSceNpCommerceDialogResult):Integer; SysV_ABI_CDecl; begin + Writeln('sceNpCommerceDialogGetResult'); if (pResult<>nil) then begin pResult^.result:=1; //SCE_COMMON_DIALOG_RESULT_USER_CANCELED @@ -366,6 +375,7 @@ end; function ps4_sceNpCommerceDialogTerminate():Integer; SysV_ABI_CDecl; begin + Writeln('sceNpCommerceDialogTerminate'); status_commerce_dialog:=SCE_COMMON_DIALOG_STATUS_NONE; Result:=0; end; @@ -418,6 +428,7 @@ const function ps4_sceSigninDialogOpen(param:pSceSigninDialogParam):Integer; SysV_ABI_CDecl; begin + Writeln('sceSigninDialogOpen'); Result:=0; end; diff --git a/src/ps4_libscehttp.pas b/src/ps4_libscehttp.pas index 318b96d..0679dbf 100644 --- a/src/ps4_libscehttp.pas +++ b/src/ps4_libscehttp.pas @@ -6,7 +6,8 @@ interface uses ps4_program, - Classes, SysUtils; + Classes, + SysUtils; implementation @@ -29,6 +30,11 @@ function ps4_sceHttpCreateTemplate( autoProxyConf:Integer):Integer; SysV_ABI_CDecl; begin Writeln('userAgent:',userAgent); + Result:=1; +end; + +function ps4_sceHttpDeleteTemplate(templateId:Integer):Integer; SysV_ABI_CDecl; +begin Result:=0; end; @@ -47,6 +53,23 @@ begin eh^:=Pointer($BADF); end; +function ps4_sceHttpDestroyEpoll(libhttpCtxId:Integer;eh:SceHttpEpollHandle):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + +function ps4_sceHttpSetEpoll(id:Integer;eh:SceHttpEpollHandle;userArg:Pointer):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpSetEpoll'); + Result:=0; +end; + +function ps4_sceHttpUnsetEpoll(id:Integer):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpUnsetEpoll'); + Result:=0; +end; + function ps4_sceHttpAddRequestHeader(id:Integer;name:PChar;value:PChar;mode:Integer):Integer; SysV_ABI_CDecl; begin Result:=0; @@ -66,6 +89,80 @@ begin Result:=0; end; +function ps4_sceHttpCreateConnectionWithURL(tmplId:Integer; + url:PChar; + enableKeepalive:Boolean):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpCreateConnectionWithURL:',url); + Result:=2; +end; + +function ps4_sceHttpDeleteConnection(connId:Integer):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + +function ps4_sceHttpCreateRequestWithURL2(connId:Integer; + method:PChar; + url:PChar; + contentLength:QWORD):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpCreateRequestWithURL2:',url); + Result:=3; +end; + +function ps4_sceHttpDeleteRequest(reqId:Integer):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpDeleteRequest'); + Result:=0; +end; + +function ps4_sceHttpSendRequest(reqId:Integer; + postData:Pointer; + size:QWORD):Integer; SysV_ABI_CDecl; +begin + Writeln('sceHttpSendRequest'); + Result:=0; +end; + +function ps4_sceHttpGetStatusCode(reqId:Integer; + statusCode:PInteger):Integer; SysV_ABI_CDecl; +begin + if (statusCode<>nil) then + begin + statusCode^:=404; + end; + Result:=0; +end; + +const + nullp:Pchar=''; + +function ps4_sceHttpGetAllResponseHeaders(reqId:Integer; + header:PPchar; + headerSize:PQWORD):Integer; SysV_ABI_CDecl; +begin + header^:=@nullp; + headerSize^:=0; + Result:=0; +end; + +function ps4_sceHttpGetResponseContentLength(reqId:Integer; + presult:PInteger; + contentLength:PQWORD):Integer; SysV_ABI_CDecl; +begin + presult^:=0; + contentLength^:=0; + Result:=0; +end; + +function ps4_sceHttpReadData(reqId:Integer; + data:Pointer; + size:QWORD):Integer; SysV_ABI_CDecl; +begin + Result:=0; +end; + function Load_libSceHttp(Const name:RawByteString):TElf_node; var lib:PLIBRARY; @@ -76,10 +173,23 @@ begin lib^.set_proc($03D715314B44A786,@ps4_sceHttpInit); lib^.set_proc($224FCAA4B4E57FB4,@ps4_sceHttpTerm); lib^.set_proc($D206233D347FE9C6,@ps4_sceHttpCreateTemplate); + lib^.set_proc($E08F2F129B84859F,@ps4_sceHttpDeleteTemplate); lib^.set_proc($B36FCD3C8BF3FA20,@ps4_sceHttpSetNonblock); lib^.set_proc($EB7F3575617EC6C4,@ps4_sceHttpCreateEpoll); + lib^.set_proc($C1885755F4B612DE,@ps4_sceHttpDestroyEpoll); + lib^.set_proc($FF19BB91940DA472,@ps4_sceHttpSetEpoll); + lib^.set_proc($E7DB4BD404016FC5,@ps4_sceHttpUnsetEpoll); lib^.set_proc($118DBC4F66E437B9,@ps4_sceHttpAddRequestHeader); lib^.set_proc($86DC813A859E4B9F,@ps4_sceHttpsSetSslCallback); + lib^.set_proc($AA0C43063A2B531B,@ps4_sceHttpCreateConnectionWithURL); + lib^.set_proc($3FA037CADA6C8987,@ps4_sceHttpDeleteConnection); + lib^.set_proc($0A7A7BEE9A1D9025,@ps4_sceHttpCreateRequestWithURL2); + lib^.set_proc($A9EEE867EBF83D60,@ps4_sceHttpDeleteRequest); + lib^.set_proc($D5ED8137023F5F31,@ps4_sceHttpSendRequest); + lib^.set_proc($D1AD9304D7C4DC15,@ps4_sceHttpGetStatusCode); + lib^.set_proc($68260F31250868FF,@ps4_sceHttpGetAllResponseHeaders); + lib^.set_proc($CAE3B61F652F9E8B,@ps4_sceHttpGetResponseContentLength); + lib^.set_proc($3F9A5DA3290F6139,@ps4_sceHttpReadData); end; initialization diff --git a/src/ps4_libscenet.pas b/src/ps4_libscenet.pas index 9b4bce1..ce42d5c 100644 --- a/src/ps4_libscenet.pas +++ b/src/ps4_libscenet.pas @@ -117,6 +117,11 @@ begin Result:=0; end; +procedure ps4_sceNetCtlTerm; SysV_ABI_CDecl; +begin + // +end; + const SCE_NET_CTL_ERROR_NOT_INITIALIZED =-2143215359; // 0x80412101 SCE_NET_CTL_ERROR_CALLBACK_MAX =-2143215357; // 0x80412103 @@ -375,6 +380,7 @@ begin Result.pFileName:=name; lib:=Result._add_lib('libSceNetCtl'); lib^.set_proc($824CB4FA868D3389,@ps4_sceNetCtlInit); + lib^.set_proc($678C3008588110B4,@ps4_sceNetCtlTerm); lib^.set_proc($B813E5AF495BBA22,@ps4_sceNetCtlGetState); lib^.set_proc($509F99ED0FB8724D,@ps4_sceNetCtlRegisterCallback); lib^.set_proc($890C378903E1BD44,@ps4_sceNetCtlCheckCallback); diff --git a/sys/sys_time.pas b/sys/sys_time.pas index a7ee8a8..6dec8fc 100644 --- a/sys/sys_time.pas +++ b/sys/sys_time.pas @@ -7,8 +7,7 @@ interface uses windows, ntapi, - sys_types, - sys_kernel; + sys_types; function _usec2msec(usec:QWORD):QWORD; //Microsecond to Milisecond function _msec2usec(msec:QWORD):QWORD; //Milisecond to Microsecond @@ -29,6 +28,9 @@ procedure SwSaveTime(var pc:QWORD); function SwTimePassedUnits(ot:QWORD):QWORD; function SwGetTimeUnits:Int64; +function SwGetProcessTime(var ut:QWORD):Boolean; +function SwGetThreadTime(var ut:QWORD):Boolean; + procedure SwGetSystemTimeAsFileTime(var lpSystemTimeAsFileTime:TFILETIME); procedure Swgettimezone(z:Ptimezone); function Swgetntptimeofday(tp:Ptimespec;z:Ptimezone):Integer; @@ -166,6 +168,32 @@ begin Result:=sec*POW10_7{POW10_11}+uec; end; +function SwGetProcessTime(var ut:QWORD):Boolean; +var + ct,et,kt:TFileTime; +begin + QWORD(ct):=0; + QWORD(et):=0; + QWORD(kt):=0; + ut:=0; + _sig_lock; + Result:=GetProcessTimes(GetCurrentProcess,ct,et,kt,TFileTime(ut)); + _sig_unlock; +end; + +function SwGetThreadTime(var ut:QWORD):Boolean; +var + ct,et,kt:TFileTime; +begin + QWORD(ct):=0; + QWORD(et):=0; + QWORD(kt):=0; + ut:=0; + _sig_lock; + Result:=GetThreadTimes(GetCurrentProcess,ct,et,kt,TFileTime(ut)); + _sig_unlock; +end; + type TGetSystemTimeAsFileTime=procedure(var lpSystemTimeAsFileTime:TFILETIME); stdcall; @@ -222,7 +250,7 @@ begin Swgettimezone(z); if (tp<>nil) then begin - GetSystemTimeAsFileTime(_now); + SwGetSystemTimeAsFileTime(_now); QWORD(_now):=filetime_to_hnsec(_now); tp^.tv_sec :=QWORD(_now) div HECTONANOSEC_PER_SEC; tp^.tv_nsec:=(QWORD(_now) mod HECTONANOSEC_PER_SEC)*100;