This commit is contained in:
Pavel 2022-11-17 15:34:30 +03:00
parent 1e7e2c7247
commit b52bd0861f
3 changed files with 62 additions and 17 deletions

View File

@ -92,21 +92,64 @@ type
base:Pointer; base:Pointer;
capacity:size_t; capacity:size_t;
count:size_t; count:size_t;
alloc:Integer;
flag:Integer;
lock:TRWLock; lock:TRWLock;
end; end;
function ps4_sceLibcMspaceCreate(name:PChar;base:Pointer;capacity:size_t;flag:Integer):SceLibcMspace; SysV_ABI_CDecl; function ps4_sceLibcMspaceCreate(name:PChar;base:Pointer;capacity:size_t;flag:Integer):SceLibcMspace; SysV_ABI_CDecl;
var
addr:Pointer;
max_size:Integer;
unk_flag:Integer;
alloc:Integer;
r:Integer;
begin begin
Result:=nil; Result:=nil;
if ((QWORD(base) and $F)<>0) or ((capacity and $F)<>0) then Exit; max_size:=1440;
if (capacity<=1440) then Exit; if (SDK_VERSION<>0) and (SDK_VERSION<=$34fffff) then
begin
max_size:=1408;
end;
unk_flag:=flag and 2;
if ((unk_flag=0) or (base<>nil)) and
(
(ptruint(base)<$400000) or
(capacity>$fbffc00000) or
((ptruint(base)+capacity)>$fbffffffff)
) then Exit;
if (flag>15) then Exit;
if (SDK_VERSION<>0) and (SDK_VERSION<=$34fffff) then
begin
if (capacity<=max_size) or (((ptruint(base) or capacity) and 7)<>0) then Exit;
end else
begin
if (capacity<=max_size) then Exit;
end;
Writeln('sceLibcMspaceCreate:',name,':',HexStr(base),'..',HexStr(base+capacity)); Writeln('sceLibcMspaceCreate:',name,':',HexStr(base),'..',HexStr(base+capacity));
alloc:=0;
if (base=nil) then
begin
r:=ps4_sceKernelMapNamedFlexibleMemory(@base,Align(capacity,64*1024),3,0,name);
if (r<>0) then Exit;
alloc:=1;
end;
Result:=SwAllocMem(SizeOf(TSceLibcMspace)); Result:=SwAllocMem(SizeOf(TSceLibcMspace));
Result^.base:=base; if (Result=nil) then Exit;
Result^.base :=base;
Result^.capacity:=capacity; Result^.capacity:=capacity;
Result^.count:=1440; Result^.count :=max_size;
Result^.alloc :=alloc;
Result^.flag :=flag;
_sig_lock; _sig_lock;
rwlock_init(Result^.lock); rwlock_init(Result^.lock);
@ -119,11 +162,11 @@ begin
if (msp=nil) then Exit; if (msp=nil) then Exit;
_sig_lock; _sig_lock;
rwlock_wrlock(msp^.lock); rwlock_wrlock(msp^.lock);
if ((msp^.count+size)<=msp^.capacity) then if ((msp^.count+size)<=msp^.capacity) then
begin begin
Result:=msp^.base+msp^.count; Result:=msp^.base+msp^.count;
msp^.count:=msp^.count+size; msp^.count:=msp^.count+size;
end; end;
rwlock_unlock(msp^.lock); rwlock_unlock(msp^.lock);
_sig_unlock; _sig_unlock;
end; end;

View File

@ -21,8 +21,8 @@ end;
function ps4_sceNpWebApiCreateContextA(libCtxId,userId:Integer):Integer; SysV_ABI_CDecl; function ps4_sceNpWebApiCreateContextA(libCtxId,userId:Integer):Integer; SysV_ABI_CDecl;
begin begin
Writeln('sceNpWebApiCreateContextA:',libCtxId,':',userId); Writeln('sceNpWebApiCreateContextA:',libCtxId,':',userId);
//Result:=Integer($80552907); Result:=Integer($80552907);
Result:=0; //Result:=0;
end; end;
//nop nid:libSceNpWebApi:ADD82CE59D4CC85C:sceNpWebApiCreateRequest //nop nid:libSceNpWebApi:ADD82CE59D4CC85C:sceNpWebApiCreateRequest

View File

@ -50,15 +50,17 @@ type
implementation implementation
var uses
SDK_VERSION:DWORD; sys_kernel;
function SDK_VERSION:DWORD;
begin
Result:=sys_kernel.SDK_VERSION;
if (Result=0) then Result:=$5050031;
end;
function ps4_module_start(args:QWORD;argp:Pointer):Integer; SysV_ABI_CDecl; //BaOKcng8g88 function ps4_module_start(args:QWORD;argp:Pointer):Integer; SysV_ABI_CDecl; //BaOKcng8g88
begin begin
if (ps4_sceKernelGetCompiledSdkVersion(@SDK_VERSION)<0) then
begin
SDK_VERSION:=$5050031;
end;
Result:=0; Result:=0;
end; end;