implemented sceNetInetNtop in RE

This commit is contained in:
georgemoralis 2025-05-28 13:02:12 +03:00
parent d124f40503
commit 9cb31aa625

View File

@ -28,6 +28,22 @@ static thread_local int32_t net_errno = 0;
static bool g_isNetInitialized = true; // TODO init it properly static bool g_isNetInitialized = true; // TODO init it properly
u64 FUN_01007040(const char* str, u64 maxlen) {
if (!str || maxlen == 0)
return 0;
size_t i = 0;
maxlen += 1; // Extended scan limit
while (i < maxlen) {
if (str[i] == '\0')
return i;
i++;
}
return maxlen;
}
int PS4_SYSV_ABI in6addr_any() { int PS4_SYSV_ABI in6addr_any() {
LOG_ERROR(Lib_Net, "(STUBBED) called"); LOG_ERROR(Lib_Net, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;
@ -956,6 +972,11 @@ u16 PS4_SYSV_ABI sceNetHtons(u16 host16) {
} }
const char* PS4_SYSV_ABI sceNetInetNtop(int af, const void* src, char* dst, u32 size) { const char* PS4_SYSV_ABI sceNetInetNtop(int af, const void* src, char* dst, u32 size) {
char temp[16];
u32 len;
if (af == 0x1C) { // AF_INET6
// return FUN_010063d0(src, dst, size, 0);//TODO
#ifdef WIN32 #ifdef WIN32
const char* res = InetNtopA(af, src, dst, size); const char* res = InetNtopA(af, src, dst, size);
#else #else
@ -964,9 +985,32 @@ const char* PS4_SYSV_ABI sceNetInetNtop(int af, const void* src, char* dst, u32
if (res == nullptr) { if (res == nullptr) {
UNREACHABLE(); UNREACHABLE();
} }
return res;
}
if (af == 2) { // AF_INET
if (src && dst) {
const u8* bytes = (const u8*)src;
len =
snprintf(temp, sizeof(temp), "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]);
if (len > 0 && len < size) {
size_t copy_len = FUN_01007040(temp, sizeof(temp));
memcpy(dst, temp, copy_len + 1); // Include null terminator
return dst; return dst;
} }
*sceNetErrnoLoc() = ORBIS_NET_ENOSPC;
} else {
*sceNetErrnoLoc() = ORBIS_NET_ENOSPC;
}
} else {
*sceNetErrnoLoc() = ORBIS_NET_EAFNOSUPPORT;
}
return nullptr;
}
int PS4_SYSV_ABI sceNetInetNtopWithScopeId() { int PS4_SYSV_ABI sceNetInetNtopWithScopeId() {
LOG_ERROR(Lib_Net, "(STUBBED) called"); LOG_ERROR(Lib_Net, "(STUBBED) called");
return ORBIS_OK; return ORBIS_OK;