mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
ae44cd497a
commit
7882b646ea
|
@ -19,9 +19,36 @@ const
|
|||
STATUS_PENDING =$00000103;
|
||||
STATUS_NO_YIELD_PERFORMED=$40000024;
|
||||
STATUS_ACCESS_VIOLATION =$C0000005;
|
||||
STATUS_INVALID_HANDLE =$C0000008;
|
||||
STATUS_INVALID_PARAMETER =$C000000D;
|
||||
STATUS_END_OF_FILE =$C0000011;
|
||||
STATUS_ACCESS_DENIED =$C0000022;
|
||||
STATUS_DISK_FULL =$C000007F;
|
||||
|
||||
NT_INFINITE=$8000000000000000;
|
||||
|
||||
FileStandardInformation = 5;
|
||||
FilePositionInformation =14;
|
||||
FileAllocationInformation=19;
|
||||
FileEndOfFileInformation =20;
|
||||
|
||||
type
|
||||
PIO_STATUS_BLOCK=^IO_STATUS_BLOCK;
|
||||
IO_STATUS_BLOCK=packed record
|
||||
Status:DWORD;
|
||||
_Align:DWORD;
|
||||
Information:PTRUINT;
|
||||
end;
|
||||
|
||||
PFILE_STANDARD_INFORMATION=^FILE_STANDARD_INFORMATION;
|
||||
FILE_STANDARD_INFORMATION=packed record
|
||||
AllocationSize:LARGE_INTEGER;
|
||||
EndOfFile :LARGE_INTEGER;
|
||||
NumberOfLinks :ULONG;
|
||||
DeletePending :WORD;
|
||||
Directory :WORD;
|
||||
end;
|
||||
|
||||
function NtAlertThread(hThread:THandle):DWORD; stdcall; external 'ntdll';
|
||||
function NtTestAlert():DWORD; stdcall; external 'ntdll';
|
||||
|
||||
|
@ -93,6 +120,46 @@ function NtSetTimerResolution(
|
|||
CurrentResolution:PULONG
|
||||
):DWORD; stdcall; external 'ntdll';
|
||||
|
||||
function NtReadFile(
|
||||
FileHandle :THandle;
|
||||
Event :THandle;
|
||||
ApcRoutine :Pointer;
|
||||
ApcContext :Pointer;
|
||||
IoStatusBlock:PIO_STATUS_BLOCK;
|
||||
Buffer :Pointer;
|
||||
Length :ULONG;
|
||||
ByteOffset :PLARGE_INTEGER;
|
||||
Key :PULONG
|
||||
):DWORD; stdcall; external 'ntdll';
|
||||
|
||||
function NtWriteFile(
|
||||
FileHandle :THandle;
|
||||
Event :THandle;
|
||||
ApcRoutine :Pointer;
|
||||
ApcContext :Pointer;
|
||||
IoStatusBlock:PIO_STATUS_BLOCK;
|
||||
Buffer :Pointer;
|
||||
Length :ULONG;
|
||||
ByteOffset :PLARGE_INTEGER;
|
||||
Key :PULONG
|
||||
):DWORD; stdcall; external 'ntdll';
|
||||
|
||||
function NtSetInformationFile(
|
||||
FileHandle :THandle;
|
||||
IoStatusBlock :PIO_STATUS_BLOCK;
|
||||
FileInformation :Pointer;
|
||||
Length :ULONG;
|
||||
FileInformationClass:DWORD
|
||||
):DWORD; stdcall; external 'ntdll';
|
||||
|
||||
function NtQueryInformationFile(
|
||||
FileHandle :THandle;
|
||||
IoStatusBlock :PIO_STATUS_BLOCK;
|
||||
FileInformation :Pointer;
|
||||
Length :ULONG;
|
||||
FileInformationClass:DWORD
|
||||
):DWORD; stdcall; external 'ntdll';
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
||||
|
|
|
@ -128,6 +128,7 @@ end;
|
|||
|
||||
function TDevRandom.read (data:Pointer;size:Int64):Int64;
|
||||
begin
|
||||
if (data=nil) or (size=0) then Exit(0);
|
||||
Assert(size<High(DWORD));
|
||||
|
||||
BCryptGenRandom(nil,data,size,BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
|
@ -188,6 +189,7 @@ function TDevStd.read (data:Pointer;size:Int64):Int64;
|
|||
var
|
||||
S:RawByteString;
|
||||
begin
|
||||
if (data=nil) or (size=0) then Exit(0);
|
||||
rwlock_wrlock(lock);
|
||||
if (Length(cache)<>0) then
|
||||
begin
|
||||
|
|
|
@ -381,7 +381,7 @@ var
|
|||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
|
||||
if (size=0) then //zero check
|
||||
if (data=nil) or (size=0) then //zero check
|
||||
begin
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
@ -389,7 +389,6 @@ begin
|
|||
Exit(0);
|
||||
end;
|
||||
|
||||
if (data=nil) then Exit(-EFAULT);
|
||||
if (size<=0) then Exit(-EINVAL);
|
||||
|
||||
f:=_sys_acqure_fd(fd);
|
||||
|
@ -406,7 +405,7 @@ var
|
|||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
|
||||
if (size=0) then //zero check
|
||||
if (data=nil) or (size=0) then //zero check
|
||||
begin
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
@ -414,7 +413,6 @@ begin
|
|||
Exit(0);
|
||||
end;
|
||||
|
||||
if (data=nil) then Exit(-EFAULT);
|
||||
if (size<=0) then Exit(-EINVAL);
|
||||
if (offset<0) then Exit(-EINVAL);
|
||||
|
||||
|
@ -432,15 +430,17 @@ var
|
|||
i:Integer;
|
||||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
if (vector=nil) then Exit(-EFAULT);
|
||||
if (count<=0) then Exit(-EINVAL);
|
||||
|
||||
For i:=0 to count-1 do
|
||||
if (vector=nil) or (count=0) then //zero check
|
||||
begin
|
||||
if (vector[i].iov_base=nil) then Exit(-EFAULT);
|
||||
if (vector[i].iov_len<=0) then Exit(-EINVAL);
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
f.Release;
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
if (count<=0) or (count>IOV_MAX) then Exit(-EINVAL);
|
||||
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
||||
|
@ -455,15 +455,17 @@ var
|
|||
i:Integer;
|
||||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
if (vector=nil) then Exit(-EFAULT);
|
||||
if (count<=0) then Exit(-EINVAL);
|
||||
|
||||
For i:=0 to count-1 do
|
||||
if (vector=nil) or (count=0) then //zero check
|
||||
begin
|
||||
if (vector[i].iov_base=nil) then Exit(-EFAULT);
|
||||
if (vector[i].iov_len<=0) then Exit(-EINVAL);
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
f.Release;
|
||||
Exit(0);
|
||||
end;
|
||||
|
||||
if (count<=0) or (count>IOV_MAX) then Exit(-EINVAL);
|
||||
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
||||
|
@ -478,7 +480,7 @@ var
|
|||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
|
||||
if (size=0) then //zero check
|
||||
if (data=nil) or (size=0) then //zero check
|
||||
begin
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
@ -486,7 +488,6 @@ begin
|
|||
Exit(0);
|
||||
end;
|
||||
|
||||
if (data=nil) then Exit(-EFAULT);
|
||||
if (size<=0) then Exit(-EINVAL);
|
||||
|
||||
f:=_sys_acqure_fd(fd);
|
||||
|
@ -503,7 +504,7 @@ var
|
|||
begin
|
||||
if (fd<0) then Exit(-EINVAL);
|
||||
|
||||
if (size=0) then //zero check
|
||||
if (data=nil) or (size=0) then //zero check
|
||||
begin
|
||||
f:=_sys_acqure_fd(fd);
|
||||
if (f=nil) then Exit(-EBADF);
|
||||
|
@ -511,7 +512,6 @@ begin
|
|||
Exit(0);
|
||||
end;
|
||||
|
||||
if (data=nil) then Exit(-EFAULT);
|
||||
if (size<=0) then Exit(-EINVAL);
|
||||
if (offset<0) then Exit(-EINVAL);
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ type
|
|||
Function get_DesiredAccess(flags:Integer):DWORD;
|
||||
begin
|
||||
Result:=0;
|
||||
if (flags and SCE_KERNEL_O_RDWR)<>0 then
|
||||
if (flags and O_RDWR)<>0 then
|
||||
begin
|
||||
Result:=GENERIC_READ or GENERIC_WRITE;
|
||||
end else
|
||||
if (flags and SCE_KERNEL_O_WRONLY)<>0 then
|
||||
if (flags and O_WRONLY)<>0 then
|
||||
begin
|
||||
Result:=GENERIC_WRITE;
|
||||
end else
|
||||
|
@ -52,26 +52,27 @@ begin
|
|||
Result:=GENERIC_READ;
|
||||
end;
|
||||
|
||||
if (flags and SCE_KERNEL_O_APPEND)<>0 then
|
||||
if (flags and O_APPEND)<>0 then
|
||||
begin
|
||||
Result:=Result and (not GENERIC_WRITE);
|
||||
Result:=Result or FILE_APPEND_DATA;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function get_CreationDisposition(flags:Integer):DWORD;
|
||||
const
|
||||
CREAT_EXCL=SCE_KERNEL_O_CREAT or SCE_KERNEL_O_EXCL;
|
||||
CREAT_EXCL=O_CREAT or O_EXCL;
|
||||
begin
|
||||
Result:=0;
|
||||
if (flags and CREAT_EXCL)=CREAT_EXCL then
|
||||
begin
|
||||
Result:=CREATE_NEW;
|
||||
end else
|
||||
if (flags and SCE_KERNEL_O_CREAT)<>0 then
|
||||
if (flags and O_CREAT)<>0 then
|
||||
begin
|
||||
Result:=CREATE_ALWAYS;
|
||||
end else
|
||||
if (flags and SCE_KERNEL_O_TRUNC)<>0 then
|
||||
if (flags and O_TRUNC)<>0 then
|
||||
begin
|
||||
Result:=TRUNCATE_EXISTING;
|
||||
end else
|
||||
|
@ -278,6 +279,7 @@ begin
|
|||
rwlock_wrlock(lock);
|
||||
|
||||
For i:=0 to count-1 do
|
||||
if (vector[i].iov_base<>nil) and (vector[i].iov_len<>0) then
|
||||
begin
|
||||
Assert(vector[i].iov_len<High(DWORD));
|
||||
|
||||
|
@ -320,6 +322,7 @@ begin
|
|||
if not _set_pos(Handle,offset) then Assert(False);
|
||||
|
||||
For i:=0 to count-1 do
|
||||
if (vector[i].iov_base<>nil) and (vector[i].iov_len<>0) then
|
||||
begin
|
||||
Assert(vector[i].iov_len<High(DWORD));
|
||||
|
||||
|
|
Loading…
Reference in New Issue