mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
e860742b5e
commit
183cd16771
|
@ -193,12 +193,16 @@ type
|
|||
|
||||
function ps4_open(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelOpen(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_close(fd:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelClose(fd:Integer):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_lseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelLseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_sceKernelWrite(fd:Integer;buf:Pointer;nbytes:Int64):Int64; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelRead(fd:Integer;buf:Pointer;nbytes:Int64):Int64; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelPread(fd:Integer;buf:Pointer;nbytes,offset:Int64):Int64; SysV_ABI_CDecl;
|
||||
function ps4_close(fd:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelClose(fd:Integer):Integer; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_stat(path:PChar;stat:PSceKernelStat):Integer; SysV_ABI_CDecl;
|
||||
function ps4_sceKernelStat(path:PChar;stat:PSceKernelStat):Integer; SysV_ABI_CDecl;
|
||||
|
@ -211,8 +215,6 @@ function ps4_read(fd:Integer;data:Pointer;size:QWORD):Int64; SysV_ABI_CDecl;
|
|||
|
||||
function ps4_readv(fd:Integer;vector:p_iovec;count:Integer):Int64; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_lseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
|
||||
function ps4_sceKernelMkdir(path:PChar;mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
function ps4_mkdir(path:PChar):Integer; SysV_ABI_CDecl;
|
||||
|
||||
|
@ -272,7 +274,7 @@ var
|
|||
dev_random_nm:array[0..1] of PChar=('/dev/random','/dev/urandom');
|
||||
dev_random_fd:Integer=-1;
|
||||
|
||||
function _sys_open(path:PChar;flags,mode:Integer;var fd:Integer):Integer;
|
||||
function _sys_open(path:PChar;flags,mode:Integer):Integer;
|
||||
const
|
||||
WR_RDWR=O_WRONLY or O_RDWR;
|
||||
O_OFS=O_RDONLY or O_WRONLY or O_RDWR or O_APPEND;
|
||||
|
@ -288,7 +290,7 @@ var
|
|||
wp:WideString;
|
||||
begin
|
||||
Result:=0;
|
||||
if (path=nil) then Exit(EINVAL);
|
||||
if (path=nil) then Exit(-EINVAL);
|
||||
|
||||
Writeln('open:',path,' ',flags,' (',OctStr(mode,3),')');
|
||||
|
||||
|
@ -296,12 +298,12 @@ begin
|
|||
|
||||
if ((flags and WR_RDWR)=WR_RDWR) then
|
||||
begin
|
||||
Exit(EINVAL);
|
||||
Exit(-EINVAL);
|
||||
end;
|
||||
|
||||
if (path[0]=#0) then
|
||||
begin
|
||||
Exit(ENOENT);
|
||||
Exit(-ENOENT);
|
||||
end;
|
||||
|
||||
if (CompareChar0(path^,dev_random_nm[0]^,Length(dev_random_nm[0]))=0) or
|
||||
|
@ -318,7 +320,7 @@ begin
|
|||
|
||||
if (Result<>0) then
|
||||
begin
|
||||
Exit(EMFILE);
|
||||
Exit(-EMFILE);
|
||||
end else
|
||||
begin
|
||||
dev_random_fd:=Result;
|
||||
|
@ -332,7 +334,7 @@ begin
|
|||
|
||||
if (Result<>0) then
|
||||
begin
|
||||
Exit(EACCES);
|
||||
Exit(-EACCES);
|
||||
end;
|
||||
|
||||
wp:=UTF8Decode(rp);
|
||||
|
@ -357,62 +359,51 @@ begin
|
|||
Case err of
|
||||
ERROR_INVALID_DRIVE,
|
||||
ERROR_PATH_NOT_FOUND,
|
||||
ERROR_FILE_NOT_FOUND :Exit(ENOENT);
|
||||
ERROR_ACCESS_DENIED :Exit(EACCES);
|
||||
ERROR_BUFFER_OVERFLOW :Exit(ENAMETOOLONG);
|
||||
ERROR_NOT_ENOUGH_MEMORY:Exit(ENOMEM);
|
||||
ERROR_ALREADY_EXISTS :Exit(EEXIST);
|
||||
ERROR_FILE_EXISTS :Exit(EEXIST);
|
||||
ERROR_DISK_FULL: Exit(ENOSPC);
|
||||
ERROR_FILE_NOT_FOUND :Exit(-ENOENT);
|
||||
ERROR_ACCESS_DENIED :Exit(-EACCES);
|
||||
ERROR_BUFFER_OVERFLOW :Exit(-ENAMETOOLONG);
|
||||
ERROR_NOT_ENOUGH_MEMORY:Exit(-ENOMEM);
|
||||
ERROR_ALREADY_EXISTS :Exit(-EEXIST);
|
||||
ERROR_FILE_EXISTS :Exit(-EEXIST);
|
||||
ERROR_DISK_FULL: Exit(-ENOSPC);
|
||||
else
|
||||
Exit(EIO);
|
||||
Exit(-EIO);
|
||||
end;
|
||||
end;
|
||||
|
||||
fd:=_open_osfhandle(h,flags and O_OFS);
|
||||
Result:=_open_osfhandle(h,flags and O_OFS);
|
||||
|
||||
if (fd<0) then
|
||||
if (Result<0) then
|
||||
begin
|
||||
CloseHandle(h);
|
||||
Exit(EMFILE);
|
||||
Exit(-EMFILE);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function ps4_open(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
var
|
||||
fd:Integer;
|
||||
begin
|
||||
fd:=0;
|
||||
_sig_lock;
|
||||
Result:=_sys_open(path,flags,mode,fd);
|
||||
Result:=_sys_open(path,flags,mode);
|
||||
_sig_unlock;
|
||||
|
||||
if (Result<>0) then
|
||||
if (Result<0) then
|
||||
begin
|
||||
Result:=_set_errno(Result);
|
||||
end else
|
||||
begin
|
||||
Result:=fd;
|
||||
Result:=_set_errno(-Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_sceKernelOpen(path:PChar;flags,mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
var
|
||||
fd:Integer;
|
||||
begin
|
||||
fd:=0;
|
||||
_sig_lock;
|
||||
Result:=_sys_open(path,flags,mode,fd);
|
||||
Result:=_sys_open(path,flags,mode);
|
||||
_sig_unlock;
|
||||
|
||||
if (Result<>0) then
|
||||
if (Result<0) then
|
||||
begin
|
||||
Result:=-Result;
|
||||
_set_errno(Result);
|
||||
Result:=px2sce(Result);
|
||||
end else
|
||||
begin
|
||||
Result:=fd;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -447,37 +438,71 @@ begin
|
|||
Result:=px2sce(Result);
|
||||
end;
|
||||
|
||||
function ps4_sceKernelLseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
function SetFilePointerEx(hFile:HANDLE;
|
||||
lDistanceToMove:LARGE_INTEGER;
|
||||
lpDistanceToMoveHigh:PLARGE_INTEGER;
|
||||
dwMoveMethod:DWORD):BOOL; external 'kernel32';
|
||||
|
||||
function _sys_lseek(fd:Integer;offset:Int64;whence:Integer):Int64;
|
||||
var
|
||||
h:THandle;
|
||||
err:DWORD;
|
||||
begin
|
||||
if (dev_random_fd=fd) then Exit(SCE_KERNEL_ERROR_EINVAL);
|
||||
Result:=0;
|
||||
if (dev_random_fd=fd) then Exit(-ESPIPE);
|
||||
|
||||
_sig_lock;
|
||||
h:=_get_osfhandle(fd);
|
||||
_sig_unlock;
|
||||
|
||||
if (h=INVALID_HANDLE_VALUE) then
|
||||
begin
|
||||
Exit(_set_sce_errno(SCE_KERNEL_ERROR_EBADF));
|
||||
Exit(-EBADF);
|
||||
end;
|
||||
|
||||
_sig_lock;
|
||||
case whence of
|
||||
SCE_KERNEL_SEEK_SET:Result:=FileSeek(h,offset,fsFromBeginning);
|
||||
SCE_KERNEL_SEEK_CUR:Result:=FileSeek(h,offset,fsFromCurrent);
|
||||
SCE_KERNEL_SEEK_END:Result:=FileSeek(h,offset,fsFromEnd);
|
||||
SEEK_SET,
|
||||
SEEK_CUR,
|
||||
SEEK_END:
|
||||
begin
|
||||
if not SetFilePointerEx(h,LARGE_INTEGER(offset),@Result,whence) then
|
||||
begin
|
||||
err:=GetLastError;
|
||||
Case err of
|
||||
ERROR_HANDLE_EOF :Exit(-EOVERFLOW);
|
||||
ERROR_INVALID_PARAMETER:Exit(-EINVAL);
|
||||
else
|
||||
Exit(-EOVERFLOW);
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
else
|
||||
Result:=_set_sce_errno(SCE_KERNEL_ERROR_EINVAL);
|
||||
Exit(-EINVAL);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_lseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
begin
|
||||
_sig_lock;
|
||||
Result:=_sys_lseek(fd,offset,whence);
|
||||
_sig_unlock;
|
||||
|
||||
if (Result=-1) then
|
||||
if (Result<0) then
|
||||
begin
|
||||
Result:=_set_sce_errno(SCE_KERNEL_ERROR_EOVERFLOW);
|
||||
end else
|
||||
Result:=_set_errno(-Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_sceKernelLseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
begin
|
||||
_sig_lock;
|
||||
Result:=_sys_lseek(fd,offset,whence);
|
||||
_sig_unlock;
|
||||
|
||||
if (Result<0) then
|
||||
begin
|
||||
_set_sce_errno(0);
|
||||
Result:=-Result;
|
||||
_set_errno(Result);
|
||||
Result:=px2sce(Result);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -905,40 +930,6 @@ begin
|
|||
_sig_unlock;
|
||||
end;
|
||||
|
||||
function ps4_lseek(fd:Integer;offset:Int64;whence:Integer):Int64; SysV_ABI_CDecl;
|
||||
var
|
||||
h:THandle;
|
||||
begin
|
||||
if (dev_random_fd=fd) then Exit(_set_errno(EINVAL));
|
||||
|
||||
_sig_lock;
|
||||
h:=_get_osfhandle(fd);
|
||||
_sig_unlock;
|
||||
|
||||
if (h=INVALID_HANDLE_VALUE) then
|
||||
begin
|
||||
Exit(_set_errno(EBADF));
|
||||
end;
|
||||
|
||||
_sig_lock;
|
||||
case whence of
|
||||
SCE_KERNEL_SEEK_SET:Result:=FileSeek(h,offset,fsFromBeginning);
|
||||
SCE_KERNEL_SEEK_CUR:Result:=FileSeek(h,offset,fsFromCurrent);
|
||||
SCE_KERNEL_SEEK_END:Result:=FileSeek(h,offset,fsFromEnd);
|
||||
else
|
||||
Result:=_set_errno(EINVAL);
|
||||
end;
|
||||
_sig_unlock;
|
||||
|
||||
if (Result=-1) then
|
||||
begin
|
||||
Result:=_set_errno(EOVERFLOW);
|
||||
end else
|
||||
begin
|
||||
_set_errno(0);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ps4_sceKernelMkdir(path:PChar;mode:Integer):Integer; SysV_ABI_CDecl;
|
||||
var
|
||||
fn:RawByteString;
|
||||
|
|
|
@ -1241,26 +1241,30 @@ begin
|
|||
//file
|
||||
|
||||
lib^.set_proc($D46DE51751A0D64F,@ps4_sceKernelOpen);
|
||||
lib^.set_proc($50AD939760D6527B,@ps4_sceKernelClose);
|
||||
lib^.set_proc($A226FBE85FF5D9F9,@ps4_sceKernelLseek);
|
||||
lib^.set_proc($E304B37BDD8184B2,@ps4_sceKernelWrite);
|
||||
lib^.set_proc($0A0E2CAD9E9329B5,@ps4_sceKernelRead);
|
||||
lib^.set_proc($FABDEB305C08B55E,@ps4_sceKernelPread);
|
||||
lib^.set_proc($50AD939760D6527B,@ps4_sceKernelClose);
|
||||
|
||||
lib^.set_proc($C2E0ABA081A3B768,@ps4_open); //open
|
||||
lib^.set_proc($E9CDEB09513F7D35,@ps4_open); //_open
|
||||
lib^.set_proc($6D8FCF3BA261CE14,@ps4_close); //close
|
||||
lib^.set_proc($34DB4568A25B3EDD,@ps4_close); //_close
|
||||
lib^.set_proc($171559A81000EE4B,@ps4_write); //_write
|
||||
lib^.set_proc($14DE2068F9AE155F,@ps4_write); //write
|
||||
lib^.set_proc($0D1B81B76A6F2029,@ps4_read); //_read
|
||||
lib^.set_proc($02A062A02DAF1772,@ps4_read); //read
|
||||
lib^.set_proc($F9646590A8D9BDA8,@ps4_readv); //_readv
|
||||
lib^.set_proc($23B22670B76CFEE5,@ps4_readv); //readv
|
||||
|
||||
lib^.set_proc($97F61135C3DE998C,@ps4_lseek); //_lseek
|
||||
lib^.set_proc($3B2E88A7082D60E9,@ps4_lseek); //lseek
|
||||
|
||||
lib^.set_proc($6D8FCF3BA261CE14,@ps4_close); //close
|
||||
lib^.set_proc($34DB4568A25B3EDD,@ps4_close); //_close
|
||||
|
||||
lib^.set_proc($171559A81000EE4B,@ps4_write); //_write
|
||||
lib^.set_proc($14DE2068F9AE155F,@ps4_write); //write
|
||||
|
||||
lib^.set_proc($0D1B81B76A6F2029,@ps4_read); //_read
|
||||
lib^.set_proc($02A062A02DAF1772,@ps4_read); //read
|
||||
|
||||
lib^.set_proc($F9646590A8D9BDA8,@ps4_readv); //_readv
|
||||
lib^.set_proc($23B22670B76CFEE5,@ps4_readv); //readv
|
||||
|
||||
lib^.set_proc($795F70003DAB8880,@ps4_sceKernelStat);
|
||||
lib^.set_proc($13A6A8DF8C0FC3E5,@ps4_stat);
|
||||
|
||||
|
|
|
@ -209,9 +209,8 @@ end;
|
|||
type
|
||||
SceCommonDialogBaseParam=packed record
|
||||
size:QWORD;
|
||||
reserved:array[0..31] of Byte;
|
||||
reserved:array[0..35] of Byte;
|
||||
magic:DWORD;
|
||||
_align:Integer;
|
||||
end; //__attribute__ ((__aligned__(8)));
|
||||
|
||||
pSceMsgDialogButtonsParam=^SceMsgDialogButtonsParam;
|
||||
|
|
Loading…
Reference in New Issue