Merge pull request #16691 from MarrasFederico/feat/npsignaling-memory-info-validation
feat(libSceNpSignaling): validate memory-info queries
This commit is contained in:
5 files changed
+19
-11
No files matched your search
@@ -286,7 +286,10 @@ int APS5_VABI sceNpSignalingGetConnectionStatistics(NpSignalingConnectionStatist
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
int APS5_VABI sceNpSignalingGetMemoryInfo() {
|
||||
int APS5_VABI sceNpSignalingGetMemoryInfo(NpSignalingMemoryInfo* info) {
|
||||
std::lock_guard lock(signalingMutex);
|
||||
if (!initialized) return SCE_NP_SIGNALING_ERROR_NOT_INITIALIZED;
|
||||
if (!info) return SCE_NP_SIGNALING_ERROR_INVALID_ARGUMENT;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,13 @@ struct NpSignalingConnectionStatistics {
|
||||
};
|
||||
static_assert(sizeof(NpSignalingConnectionStatistics) == 0x10);
|
||||
|
||||
struct NpSignalingMemoryInfo {
|
||||
std::uint64_t currentInUse;
|
||||
std::uint64_t peakInUse;
|
||||
std::uint64_t maxSystemSize;
|
||||
};
|
||||
static_assert(sizeof(NpSignalingMemoryInfo) == 0x18);
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceNpSignalingActivateConnection(int ctxId, const void* peerNpId, int* outConnId);
|
||||
@@ -52,5 +59,6 @@ int APS5_VABI sceNpSignalingGetPeerNetInfoA(int ctxId, const void* peerAccount,
|
||||
int APS5_VABI sceNpSignalingCancelPeerNetInfo(int ctxId, int reqId);
|
||||
int APS5_VABI sceNpSignalingGetPeerNetInfoResult(int ctxId, int connId, NpSignalingNetInfo* peerNetInfo);
|
||||
int APS5_VABI sceNpSignalingGetConnectionStatistics(NpSignalingConnectionStatistics* stats);
|
||||
int APS5_VABI sceNpSignalingGetMemoryInfo(NpSignalingMemoryInfo* info);
|
||||
|
||||
}
|
||||
@@ -4,6 +4,4 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
int APS5_VABI sceNpSignalingGetMemoryInfo();
|
||||
|
||||
}
|
||||
@@ -80,6 +80,7 @@ int main() {
|
||||
NpSignalingAccountPlatformPair account{0x1234, 1, 0};
|
||||
NpSignalingNetInfo netInfo{};
|
||||
netInfo.size = sizeof(netInfo);
|
||||
NpSignalingMemoryInfo memoryInfo{0x1234, 0x5678, 0x9ABC};
|
||||
int option = -7;
|
||||
Require(sceNpSignalingCreateContextA(-1, nullptr, nullptr, nullptr) == NotInitialized, "sceNpSignalingCreateContextA", "a call before initialization did not return NOT_INITIALIZED first");
|
||||
Require(sceNpSignalingActivateConnectionA(1, nullptr, nullptr) == NotInitialized, "sceNpSignalingActivateConnectionA", "a call before initialization did not return NOT_INITIALIZED first");
|
||||
@@ -89,6 +90,8 @@ int main() {
|
||||
Require(sceNpSignalingGetContextOption(1, 1, nullptr) == NotInitialized, "sceNpSignalingGetContextOption", "a call before initialization did not return NOT_INITIALIZED first");
|
||||
Require(sceNpSignalingCancelPeerNetInfo(1, 1) == NotInitialized, "sceNpSignalingCancelPeerNetInfo", "a call before initialization did not return NOT_INITIALIZED");
|
||||
Require(sceNpSignalingGetPeerNetInfoResult(1, 1, nullptr) == NotInitialized, "sceNpSignalingGetPeerNetInfoResult", "a call before initialization did not return NOT_INITIALIZED first");
|
||||
Require(sceNpSignalingGetMemoryInfo(nullptr) == NotInitialized, "sceNpSignalingGetMemoryInfo", "initialization was not checked before the output");
|
||||
Require(sceNpSignalingGetMemoryInfo(&memoryInfo) == NotInitialized && memoryInfo.currentInUse == 0x1234 && memoryInfo.peakInUse == 0x5678 && memoryInfo.maxSystemSize == 0x9ABC, "sceNpSignalingGetMemoryInfo", "a call before initialization did not return NOT_INITIALIZED");
|
||||
std::uint32_t reqId = 0;
|
||||
Require(sceNpSignalingGetPeerNetInfo(1, nullptr, &reqId) == NotInitialized, "sceNpSignalingGetPeerNetInfo", "a call before initialization did not return NOT_INITIALIZED");
|
||||
|
||||
@@ -220,6 +223,7 @@ int main() {
|
||||
Require(sceNpSignalingGetPeerNetInfoResult(context, 1, &netInfo) == InvalidArgument, "sceNpSignalingGetPeerNetInfoResult", "size 0 was taken");
|
||||
netInfo.size = sizeof(netInfo);
|
||||
Require(sceNpSignalingGetPeerNetInfoResult(context, 1, &netInfo) == ResultNotFound && netInfo.localAddr == 0, "sceNpSignalingGetPeerNetInfoResult", "a result that was never staged was found");
|
||||
Require(sceNpSignalingGetMemoryInfo(nullptr) == InvalidArgument, "sceNpSignalingGetMemoryInfo", "a null output was taken");
|
||||
|
||||
Require(sceNpSignalingDeleteContext(99) == 0, "sceNpSignalingDeleteContext", "deleting an unknown context failed");
|
||||
Require(sceNpSignalingDeleteContext(context) == 0, "sceNpSignalingDeleteContext", "deleting a context failed");
|
||||
@@ -244,6 +248,7 @@ int main() {
|
||||
Require(localInfo.localAddr == 0xA5A5A5A5u && localInfo.mappedAddr == 0xA5A5A5A5u &&
|
||||
localInfo.natStatus == static_cast<std::int32_t>(0xA5A5A5A5u) && localInfo.reserved == 0xA5A5A5A5u,
|
||||
"sceNpSignalingGetLocalNetInfo", "output was modified post-termination");
|
||||
Require(sceNpSignalingGetMemoryInfo(&memoryInfo) == NotInitialized, "sceNpSignalingGetMemoryInfo", "getting memory info post-termination did not return NOT_INITIALIZED");
|
||||
Require(sceNpSignalingGetPeerNetInfo(1, nullptr, &reqId) == NotInitialized, "sceNpSignalingGetPeerNetInfo", "a call after termination did not return NOT_INITIALIZED");
|
||||
|
||||
if (failures != 0) return 1;
|
||||
|
||||
@@ -12,12 +12,6 @@
|
||||
|
||||
- [Unsettled connection and peer queries](../../../core/libs/prx/libSceNpSignaling/Export.cpp) (libSceNpSignaling) - `sceNpSignalingGetConnectionStatus`, `sceNpSignalingGetConnectionStatistics`, `sceNpSignalingGetConnectionFromPeerAddressA` and `sceNpSignalingGetPeerNetInfoA` have no established console contract for the offline case. Their typed declarations follow the pinned shadPS4 source, but the inactive result, zero counts, context-kind error and validation order are unverified. All four throw through `NotImplemented_nid_no_patch` before examining arguments or state and leave outputs untouched. Closes when: the return values, output writes and check order are established from the firmware module or console measurements.
|
||||
|
||||
- [sceNpSignalingGetMemoryInfo](../../../core/libs/prx/libSceNpSignaling/Export.cpp) (libSceNpSignaling) - a call that passes the checks throws: the pool statistics are not modelled. Initialization and a null output (`INVALID_ARGUMENT`) are checked as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/98ef621decb6a35dba62e367a8a89186f5d49dcc/src/core/libraries/np/np_signaling/np_signaling.cpp#L793-L804), whose returned sizes are not reproduced. The three 64-bit fields follow its [memory-info layout](https://github.com/shadps4-emu/shadPS4/blob/98ef621decb6a35dba62e367a8a89186f5d49dcc/src/core/libraries/np/np_types2.h#L1102-L1107); no PS5 layout or behavior measurement was made.
|
||||
|
||||
- [sceNpSignalingGetPeerNetInfo](../../../core/libs/prx/libSceNpSignaling/Export.cpp) (libSceNpSignaling) - a request that passes the checks throws: no peer information request is staged offline. Initialization, null pointers, an invalid NpId (`INVALID_ARGUMENT`) and then the context (`CTX_NOT_FOUND`) are checked in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/98ef621decb6a35dba62e367a8a89186f5d49dcc/src/core/libraries/np/np_signaling/np_signaling.cpp#L688-L717)'s order. Not measured on a PS5.
|
||||
|
||||
### Additional callable export inventory
|
||||
|
||||
- [Additional callable exports](../../../core/libs/prx/libSceNpSignaling/Export.cpp) - 1 entry has import-resolution declarations only. Parameter lists, return types and behavior are unverified; parameterless `int` declarations are placeholders, not verified ABI contracts. Every entry throws through `NotImplemented_nid_no_patch`. No runtime support, implemented-function increase or title unblock is claimed.
|
||||
|
||||
| Name | NID |
|
||||
| --- | --- |
|
||||
| `sceNpSignalingGetMemoryInfo` | `tOpqyDyMje4` |
|
||||
Reference in new issue
Block a user