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_PENDING =$00000103;
|
||||||
STATUS_NO_YIELD_PERFORMED=$40000024;
|
STATUS_NO_YIELD_PERFORMED=$40000024;
|
||||||
STATUS_ACCESS_VIOLATION =$C0000005;
|
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;
|
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 NtAlertThread(hThread:THandle):DWORD; stdcall; external 'ntdll';
|
||||||
function NtTestAlert():DWORD; stdcall; external 'ntdll';
|
function NtTestAlert():DWORD; stdcall; external 'ntdll';
|
||||||
|
|
||||||
|
@ -93,6 +120,46 @@ function NtSetTimerResolution(
|
||||||
CurrentResolution:PULONG
|
CurrentResolution:PULONG
|
||||||
):DWORD; stdcall; external 'ntdll';
|
):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
|
implementation
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -128,6 +128,7 @@ end;
|
||||||
|
|
||||||
function TDevRandom.read (data:Pointer;size:Int64):Int64;
|
function TDevRandom.read (data:Pointer;size:Int64):Int64;
|
||||||
begin
|
begin
|
||||||
|
if (data=nil) or (size=0) then Exit(0);
|
||||||
Assert(size<High(DWORD));
|
Assert(size<High(DWORD));
|
||||||
|
|
||||||
BCryptGenRandom(nil,data,size,BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
BCryptGenRandom(nil,data,size,BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||||
|
@ -188,6 +189,7 @@ function TDevStd.read (data:Pointer;size:Int64):Int64;
|
||||||
var
|
var
|
||||||
S:RawByteString;
|
S:RawByteString;
|
||||||
begin
|
begin
|
||||||
|
if (data=nil) or (size=0) then Exit(0);
|
||||||
rwlock_wrlock(lock);
|
rwlock_wrlock(lock);
|
||||||
if (Length(cache)<>0) then
|
if (Length(cache)<>0) then
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -381,7 +381,7 @@ var
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
if (fd<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
if (size=0) then //zero check
|
if (data=nil) or (size=0) then //zero check
|
||||||
begin
|
begin
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
@ -389,7 +389,6 @@ begin
|
||||||
Exit(0);
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (data=nil) then Exit(-EFAULT);
|
|
||||||
if (size<=0) then Exit(-EINVAL);
|
if (size<=0) then Exit(-EINVAL);
|
||||||
|
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
|
@ -406,7 +405,7 @@ var
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
if (fd<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
if (size=0) then //zero check
|
if (data=nil) or (size=0) then //zero check
|
||||||
begin
|
begin
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
@ -414,7 +413,6 @@ begin
|
||||||
Exit(0);
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (data=nil) then Exit(-EFAULT);
|
|
||||||
if (size<=0) then Exit(-EINVAL);
|
if (size<=0) then Exit(-EINVAL);
|
||||||
if (offset<0) then Exit(-EINVAL);
|
if (offset<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
|
@ -432,15 +430,17 @@ var
|
||||||
i:Integer;
|
i:Integer;
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
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
|
begin
|
||||||
if (vector[i].iov_base=nil) then Exit(-EFAULT);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (vector[i].iov_len<=0) then Exit(-EINVAL);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
f.Release;
|
||||||
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (count<=0) or (count>IOV_MAX) then Exit(-EINVAL);
|
||||||
|
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
|
||||||
|
@ -455,15 +455,17 @@ var
|
||||||
i:Integer;
|
i:Integer;
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
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
|
begin
|
||||||
if (vector[i].iov_base=nil) then Exit(-EFAULT);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (vector[i].iov_len<=0) then Exit(-EINVAL);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
f.Release;
|
||||||
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (count<=0) or (count>IOV_MAX) then Exit(-EINVAL);
|
||||||
|
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
|
||||||
|
@ -478,7 +480,7 @@ var
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
if (fd<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
if (size=0) then //zero check
|
if (data=nil) or (size=0) then //zero check
|
||||||
begin
|
begin
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
@ -486,7 +488,6 @@ begin
|
||||||
Exit(0);
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (data=nil) then Exit(-EFAULT);
|
|
||||||
if (size<=0) then Exit(-EINVAL);
|
if (size<=0) then Exit(-EINVAL);
|
||||||
|
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
|
@ -503,7 +504,7 @@ var
|
||||||
begin
|
begin
|
||||||
if (fd<0) then Exit(-EINVAL);
|
if (fd<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
if (size=0) then //zero check
|
if (data=nil) or (size=0) then //zero check
|
||||||
begin
|
begin
|
||||||
f:=_sys_acqure_fd(fd);
|
f:=_sys_acqure_fd(fd);
|
||||||
if (f=nil) then Exit(-EBADF);
|
if (f=nil) then Exit(-EBADF);
|
||||||
|
@ -511,7 +512,6 @@ begin
|
||||||
Exit(0);
|
Exit(0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (data=nil) then Exit(-EFAULT);
|
|
||||||
if (size<=0) then Exit(-EINVAL);
|
if (size<=0) then Exit(-EINVAL);
|
||||||
if (offset<0) then Exit(-EINVAL);
|
if (offset<0) then Exit(-EINVAL);
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,11 @@ type
|
||||||
Function get_DesiredAccess(flags:Integer):DWORD;
|
Function get_DesiredAccess(flags:Integer):DWORD;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
if (flags and SCE_KERNEL_O_RDWR)<>0 then
|
if (flags and O_RDWR)<>0 then
|
||||||
begin
|
begin
|
||||||
Result:=GENERIC_READ or GENERIC_WRITE;
|
Result:=GENERIC_READ or GENERIC_WRITE;
|
||||||
end else
|
end else
|
||||||
if (flags and SCE_KERNEL_O_WRONLY)<>0 then
|
if (flags and O_WRONLY)<>0 then
|
||||||
begin
|
begin
|
||||||
Result:=GENERIC_WRITE;
|
Result:=GENERIC_WRITE;
|
||||||
end else
|
end else
|
||||||
|
@ -52,26 +52,27 @@ begin
|
||||||
Result:=GENERIC_READ;
|
Result:=GENERIC_READ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (flags and SCE_KERNEL_O_APPEND)<>0 then
|
if (flags and O_APPEND)<>0 then
|
||||||
begin
|
begin
|
||||||
|
Result:=Result and (not GENERIC_WRITE);
|
||||||
Result:=Result or FILE_APPEND_DATA;
|
Result:=Result or FILE_APPEND_DATA;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function get_CreationDisposition(flags:Integer):DWORD;
|
Function get_CreationDisposition(flags:Integer):DWORD;
|
||||||
const
|
const
|
||||||
CREAT_EXCL=SCE_KERNEL_O_CREAT or SCE_KERNEL_O_EXCL;
|
CREAT_EXCL=O_CREAT or O_EXCL;
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
if (flags and CREAT_EXCL)=CREAT_EXCL then
|
if (flags and CREAT_EXCL)=CREAT_EXCL then
|
||||||
begin
|
begin
|
||||||
Result:=CREATE_NEW;
|
Result:=CREATE_NEW;
|
||||||
end else
|
end else
|
||||||
if (flags and SCE_KERNEL_O_CREAT)<>0 then
|
if (flags and O_CREAT)<>0 then
|
||||||
begin
|
begin
|
||||||
Result:=CREATE_ALWAYS;
|
Result:=CREATE_ALWAYS;
|
||||||
end else
|
end else
|
||||||
if (flags and SCE_KERNEL_O_TRUNC)<>0 then
|
if (flags and O_TRUNC)<>0 then
|
||||||
begin
|
begin
|
||||||
Result:=TRUNCATE_EXISTING;
|
Result:=TRUNCATE_EXISTING;
|
||||||
end else
|
end else
|
||||||
|
@ -278,6 +279,7 @@ begin
|
||||||
rwlock_wrlock(lock);
|
rwlock_wrlock(lock);
|
||||||
|
|
||||||
For i:=0 to count-1 do
|
For i:=0 to count-1 do
|
||||||
|
if (vector[i].iov_base<>nil) and (vector[i].iov_len<>0) then
|
||||||
begin
|
begin
|
||||||
Assert(vector[i].iov_len<High(DWORD));
|
Assert(vector[i].iov_len<High(DWORD));
|
||||||
|
|
||||||
|
@ -320,6 +322,7 @@ begin
|
||||||
if not _set_pos(Handle,offset) then Assert(False);
|
if not _set_pos(Handle,offset) then Assert(False);
|
||||||
|
|
||||||
For i:=0 to count-1 do
|
For i:=0 to count-1 do
|
||||||
|
if (vector[i].iov_base<>nil) and (vector[i].iov_len<>0) then
|
||||||
begin
|
begin
|
||||||
Assert(vector[i].iov_len<High(DWORD));
|
Assert(vector[i].iov_len<High(DWORD));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue